List of usage examples for org.xml.sax InputSource setSystemId
public void setSystemId(String systemId)
From source file:org.walkmod.conf.providers.LanguageConfigurationProvider.java
private Document lookUpDocument() { Document doc = null;/* www . j av a2s . c om*/ URL url = null; if (configuration == null) { throw new ConfigurationException("Missing default values configuration"); } String defaults = configuration.getDefaultLanguage(); String fileName; if (defaults == null) { fileName = "default-config.xml"; } else { fileName = "META-INF/walkmod/walkmod-" + defaults + "-" + suffixFileName; } File f = new File(fileName); if (f.exists()) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new ConfigurationException("Unable to load " + fileName, e); } } if (url == null) { url = configuration.getClassLoader().getResource(fileName); } InputStream is = null; if (url == null) { if (errorIfMissing) { throw new ConfigurationException("Could not open files of the name " + fileName); } else { LOG.info("Unable to locate default values configuration of the name " + f.getName() + ", skipping"); return doc; } } try { is = url.openStream(); InputSource in = new InputSource(is); in.setSystemId(url.toString()); doc = DomHelper.parse(in, dtdMappings); } catch (Exception e) { throw new ConfigurationException("Unable to load " + fileName, e); } finally { try { is.close(); } catch (IOException e) { LOG.error("Unable to close input stream", e); } } if (doc != null) { LOG.debug("Walkmod configuration parsed"); } return doc; }
From source file:org.walkmod.conf.providers.PluginsConfigurationProvider.java
private Document lookUpDocument() { Document doc = null;/*w w w. ja v a 2 s . c o m*/ URL url = null; if (configuration == null) { throw new ConfigurationException("Missing default values configuration"); } File f = new File(fileName); if (f.exists()) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new ConfigurationException("Unable to load " + fileName, e); } } if (url == null) { url = configuration.getClassLoader().getResource(fileName); } InputStream is = null; if (url == null) { if (errorIfMissing) { throw new ConfigurationException("Could not open files of the name " + fileName); } else { LOG.info("Unable to locate default values configuration of the name " + f.getName() + ", skipping"); return doc; } } try { is = url.openStream(); InputSource in = new InputSource(is); in.setSystemId(url.toString()); doc = DomHelper.parse(in, dtdMappings); } catch (Exception e) { throw new ConfigurationException("Unable to load " + fileName, e); } finally { try { is.close(); } catch (IOException e) { LOG.error("Unable to close input stream", e); } } if (doc != null) { LOG.debug("Default Walkmod plugins configuration parsed"); } return doc; }
From source file:org.walkmod.conf.providers.XMLConfigurationProvider.java
/** * Load the XML configuration on memory as a DOM structure with SAX. * Additional information about elements location is added. Non valid DTDs * or XML structures are detected.// w w w . ja v a2 s . c o m * * @param file * XML configuration * @return XML tree */ private Document loadDocument(String file) { Document doc = null; URL url = null; File f = new File(file); if (f.exists()) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new ConfigurationException("Unable to load " + file, e); } } if (url == null) { url = ClassLoader.getSystemResource(file); } InputStream is = null; if (url == null) { if (errorIfMissing) { throw new ConfigurationException("Could not open files of the name " + file); } else { LOG.info("Unable to locate configuration files of the name " + file + ", skipping"); return doc; } } try { is = url.openStream(); InputSource in = new InputSource(is); in.setSystemId(url.toString()); doc = DomHelper.parse(in, dtdMappings); } catch (Exception e) { throw new ConfigurationException("Unable to load " + file, e); } finally { try { is.close(); } catch (IOException e) { LOG.error("Unable to close input stream", e); } } if (doc != null) { LOG.debug("Wallmod configuration parsed"); } return doc; }
From source file:org.wso2.carbon.bpel.core.ode.integration.axis2.Axis2UriResolver.java
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) { if (log.isDebugEnabled()) { log.debug("resolveEntity: targetNamespace=" + targetNamespace + " schemaLocation=" + schemaLocation + " baseUri=" + baseUri); }//from www. j a v a 2 s . c om InputStream is; try { URI base = new URI(baseUri); URI uri = base.resolve(schemaLocation); is = uri.toURL().openStream(); if (is == null) { log.error("Exception resolving entity: schemaLocation=" + schemaLocation + " baseUri=" + baseUri); return null; } InputSource source = new InputSource(is); source.setSystemId(uri.toString()); source.setPublicId(schemaLocation); return new InputSource(is); } catch (Exception e) { log.error("Exception resolving entity: schemaLocation=" + schemaLocation + " baseUri=" + baseUri, e); return null; } }
From source file:org.wso2.carbon.bpel.core.ode.integration.axis2.Axis2WSDLLocator.java
public InputSource getBaseInputSource() { try {//from w w w. ja va2s . c om InputSource is = new InputSource(); is.setByteStream(openResource(baseUri)); is.setSystemId(baseUri.toString()); return is; } catch (IOException e) { log.error("Unable to create InputSource for " + baseUri, e); return null; } }
From source file:org.wso2.carbon.bpel.core.ode.integration.axis2.Axis2WSDLLocator.java
public InputSource getImportInputSource(String parent, String imprt) { URI uri;/*from www .ja va2s .c om*/ try { uri = parent == null ? baseUri.resolve(imprt) : new URI(parent).resolve(imprt); } catch (URISyntaxException e1) { log.error("URI syntax error: parent=" + parent, e1); return null; } if (log.isDebugEnabled()) { log.debug("Get import: import=" + imprt + " parent=" + parent); } InputSource is = new InputSource(); try { is.setByteStream(openResource(uri)); } catch (Exception e) { log.error("Unable to open import resource: " + uri, e); return null; } is.setSystemId(uri.toString()); latest = uri.toString(); return is; }
From source file:org.wso2.carbon.humantask.core.deployment.HumanTaskWSDLLocator.java
public InputSource getBaseInputSource() { try {/* w ww . jav a 2s . c o m*/ InputSource is = new InputSource(); is.setByteStream(openResource(baseUri)); is.setSystemId(baseUri.toString()); return is; } catch (IOException e) { log.error("Unable to create InputSource for " + baseUri, e); return null; } }
From source file:org.wso2.carbon.humantask.core.integration.HumanTaskSchemaURIResolver.java
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) { if (log.isDebugEnabled()) { log.debug("resolveEntity: targetNamespace=" + targetNamespace + " schemaLocation=" + schemaLocation + " baseUri=" + baseUri); }//from w ww.j a v a 2 s .c om InputStream is; try { URI base = new URI("file:" + baseUri); URI uri = base.resolve(schemaLocation); is = uri.toURL().openStream(); if (is == null) { log.error("Exception resolving entity: schemaLocation=" + schemaLocation + " baseUri=" + baseUri); return null; } InputSource source = new InputSource(is); source.setSystemId(uri.toString()); source.setPublicId(schemaLocation); return new InputSource(is); } catch (Exception e) { log.error("Exception resolving entity: schemaLocation=" + schemaLocation + " baseUri=" + baseUri, e); return null; } }
From source file:org.wyona.yanel.impl.resources.usecase.UsecaseResource.java
/** * Generate jelly view./*w ww. j av a2 s. com*/ */ private InputStream getJellyInputStream(String viewID, String viewTemplate, boolean XMLoutput) throws UsecaseException { try { if (log.isDebugEnabled()) log.debug("viewTemplate: " + viewTemplate); Repository repo = this.getRealm().getRepository(); JellyContext jellyContext = new JellyContext(); jellyContext.setVariable("resource", this); jellyContext.setVariable("yanel.back2context", PathUtil.backToContext(realm, getPath())); jellyContext.setVariable("yanel.back2realm", PathUtil.backToRealm(getPath())); jellyContext.setVariable("yanel.globalHtdocsPath", PathUtil.getGlobalHtdocsPath(this)); jellyContext.setVariable("yanel.resourcesHtdocsPath", PathUtil.getResourcesHtdocsPathURLencoded(this)); jellyContext.setVariable("yanel.reservedPrefix", this.getYanel().getReservedPrefix()); //jellyContext.setVariable("request", request); ByteArrayOutputStream jellyResultStream = new ByteArrayOutputStream(); XMLOutput jellyOutput = XMLOutput.createXMLOutput(jellyResultStream, XMLoutput); InputStream templateInputStream; String templatePublicId; String templateSystemId; if (viewTemplate.startsWith("/")) { if (log.isDebugEnabled()) log.debug( "Accessing view template directly from the repo (no protocol specified). View Template: " + viewTemplate); // for backwards compatibility. when not using a protocol templateInputStream = repo.getNode(viewTemplate).getInputStream(); templatePublicId = "yanelrepo:" + viewTemplate; /*XXX HACK the following does not work: Jelly wants URLs => protocol must be registered by the JVM! templateSystemId = "yanelrepo:"+viewTemplate; */ templateSystemId = "file:///yanelrepo" + viewTemplate; } else { if (log.isDebugEnabled()) log.debug( "Accessing view template through the source-resolver (protocol specified). View Template: " + viewTemplate); SourceResolver resolver = new SourceResolver(this); Source templateSource = resolver.resolve(viewTemplate, null); templateInputStream = ((StreamSource) templateSource).getInputStream(); templatePublicId = templateSource.getSystemId(); /*XXX HACK the following does not work: Jelly wants URLs => protocol must be registered by the JVM! templateSystemId = templateSource.getSystemId(); */ templateSystemId = "file:///" + viewTemplate.replaceFirst(":", "/"); } InputSource inputSource = new InputSource(templateInputStream); inputSource.setPublicId(templatePublicId); inputSource.setSystemId(templateSystemId); jellyContext.runScript(inputSource, jellyOutput); //XXX should we close templateInputStream here?!? jellyOutput.flush(); byte[] result = jellyResultStream.toByteArray(); //System.out.println(new String(result, "utf-8")); return new ByteArrayInputStream(result); } catch (Exception e) { String errorMsg = "Error creating 'jelly' view '" + viewID + "' of usecase resource: " + getName() + ": " + e; log.error(errorMsg, e); throw new UsecaseException(errorMsg, e); } }
From source file:org.xchain.namespaces.sax.UrlSourceCommand.java
/** * The name of the parameter./* w w w.j av a2 s. c om*/ */ public boolean execute(JXPathContext context) throws Exception { InputSource inputSource = null; XMLReader xmlReader = null; DependencyTracker dependencyTracker = DependencyTracker.getInstance(); String systemId = getSystemId(context); URL url = UrlFactory.getInstance().newUrl(getLocator().getSystemId(), systemId); inputSource = new InputSource(); inputSource.setSystemId(systemId); inputSource.setByteStream(url.openStream()); // set the source in the pipeline config. PipelineCommand.getPipelineConfig().setSource(inputSource); if (xmlReader != null) { PipelineCommand.getPipelineConfig().setXmlReader(xmlReader); } return false; }