List of usage examples for org.xml.sax InputSource setSystemId
public void setSystemId(String systemId)
From source file:org.apache.myfaces.config.impl.FacesConfigEntityResolver.java
public InputSource resolveEntity(String publicId, String systemId) throws IOException { InputStream stream;/*from ww w . j ava 2 s . com*/ if (systemId.equals(FACES_CONFIG_1_0_DTD_SYSTEM_ID)) { stream = ClassUtils.getResourceAsStream(FACES_CONFIG_1_0_DTD_RESOURCE); } else if (systemId.equals(FACES_CONFIG_1_1_DTD_SYSTEM_ID)) { stream = ClassUtils.getResourceAsStream(FACES_CONFIG_1_1_DTD_RESOURCE); } else if (systemId.startsWith("jar:")) { URL url = new URL(systemId); JarURLConnection conn = (JarURLConnection) url.openConnection(); JarEntry jarEntry = conn.getJarEntry(); if (jarEntry == null) { log.fatal("JAR entry '" + systemId + "' not found."); } //_jarFile.getInputStream(jarEntry); stream = conn.getJarFile().getInputStream(jarEntry); } else { if (_externalContext == null) { stream = ClassUtils.getResourceAsStream(systemId); } else { if (systemId.startsWith("file:")) { systemId = systemId.substring(7); // remove file:// } stream = _externalContext.getResourceAsStream(systemId); } } if (stream == null) { return null; } InputSource is = new InputSource(stream); is.setPublicId(publicId); is.setSystemId(systemId); is.setEncoding("ISO-8859-1"); return is; }
From source file:org.apache.myfaces.ov2021.config.impl.digester.DigesterFacesConfigUnmarshallerImpl.java
public FacesConfig getFacesConfig(InputStream in, String systemId) throws IOException, SAXException { InputSource is = new InputSource(in); is.setSystemId(systemId); // Fix for http://issues.apache.org/jira/browse/MYFACES-236 FacesConfig config = (FacesConfig) digester.parse(is); for (org.apache.myfaces.ov2021.config.element.Application application : config.getApplications()) { for (org.apache.myfaces.ov2021.config.element.LocaleConfig localeConfig : application .getLocaleConfig()) {// w w w. j a va 2 s.c om if (!localeConfig.getSupportedLocales().contains(localeConfig.getDefaultLocale())) { localeConfig.getSupportedLocales().add(localeConfig.getDefaultLocale()); } } } return config; }
From source file:org.apache.myfaces.shared_impl.webapp.webxml.WebXmlParser.java
private InputSource createContextInputSource(String publicId, String systemId) { InputStream inStream = _context.getResourceAsStream(systemId); if (inStream == null) { // there is no such entity return null; }// ww w . j a v a2 s.co m InputSource is = new InputSource(inStream); is.setPublicId(publicId); is.setSystemId(systemId); //the next line was removed - encoding should be determined automatically out of the inputStream //DEFAULT_ENCODING was ISO-8859-1 //is.setEncoding(DEFAULT_ENCODING); return is; }
From source file:org.apache.myfaces.shared_impl.webapp.webxml.WebXmlParser.java
private InputSource createClassloaderInputSource(String publicId, String systemId) { InputStream inStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(systemId); if (inStream == null) { // there is no such entity return null; }/*from ww w.ja va 2s. co m*/ InputSource is = new InputSource(inStream); is.setPublicId(publicId); is.setSystemId(systemId); //the next line was removed - encoding should be determined automatically out of the inputStream //encoding should be determined automatically out of the inputStream //DEFAULT_ENCODING was ISO-8859-1 //is.setEncoding(DEFAULT_ENCODING); return is; }
From source file:org.apache.ode.axis2.util.Axis2UriResolver.java
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) { if (LOG.isDebugEnabled()) { LOG.debug("resolveEntity: targetNamespace=" + targetNamespace + " schemaLocation=" + schemaLocation + " baseUri=" + baseUri); }//from w w w . j av 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.apache.ode.axis2.util.Axis2WSDLLocator.java
public InputSource getBaseInputSource() { try {//from ww w . j a v a 2 s . 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.apache.ode.axis2.util.Axis2WSDLLocator.java
public InputSource getImportInputSource(String parent, String imprt) { URI uri;/*from w w w. java 2s . c om*/ try { uri = parent == null ? _baseUri.resolve(imprt) : new URI(parent).resolve(imprt); } catch (URISyntaxException e1) { LOG.error("URI syntax error: parent=" + parent + " error=" + 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.apache.ode.bpel.compiler.BpelC.java
/** * <p>//w w w. j a va2s . c o m * Compile a BPEL process from a file. This method uses a {@link BpelObjectFactory} * to parse the XML and then calls {@link #compile(Process,String)}. * </p> * @param bpelFile the file of the BPEL process to be compiled. * @param version the version of the BPEL file. * @throws IOException if one occurs while reading the BPEL process or writing the * output. * @throws CompilationException if one occurs while compiling the process. */ public void compile(File bpelFile, long version) throws CompilationException, IOException { if (__log.isDebugEnabled()) { __log.debug("compile(URL)"); } if (bpelFile == null) { this.invalidate(); throw new IllegalArgumentException("Null bpelFile"); } _bpelFile = bpelFile; Process process; try { InputSource isrc = new InputSource(new ByteArrayInputStream(StreamUtils.read(bpelFile.toURL()))); isrc.setSystemId(bpelFile.getAbsolutePath()); process = BpelObjectFactory.getInstance().parse(isrc, _bpelFile.toURI()); } catch (Exception e) { CompilationMessage cmsg = __cmsgs.errBpelParseErr().setSource(new SourceLocationImpl(bpelFile.toURI())); this.invalidate(); throw new CompilationException(cmsg, e); } assert process != null; // Output file = bpel file with a cbp extension String bpelPath = bpelFile.getAbsolutePath(); String cbpPath = bpelPath.substring(0, bpelPath.lastIndexOf(".")) + ".cbp"; compile(process, cbpPath, version); this.invalidate(); }
From source file:org.apache.ode.bpel.compiler.WSDLLocatorImpl.java
public InputSource getBaseInputSource() { try {//from ww w .j a va 2 s. co m InputSource is = new InputSource(); is.setByteStream(_resourceFinder.openResource(_base)); is.setSystemId(_base.toString()); return is; } catch (MalformedURLException e) { return null; } catch (IOException e) { return null; } }
From source file:org.apache.ode.bpel.compiler.WSDLLocatorImpl.java
public InputSource getImportInputSource(String parent, String imprt) { URI uri;/*from ww w.j a va 2s. c o m*/ try { uri = parent == null ? _base.resolve(imprt) : new URI(parent).resolve(imprt); } catch (URISyntaxException e1) { __log.error("URI syntax error: " + parent); return null; } __log.debug("getImportInputSource: parent=" + parent + ", imprt=" + imprt + ", uri=" + uri); InputSource is = new InputSource(); try { is.setByteStream(_resourceFinder.openResource(uri)); } catch (Exception e) { return null; } is.setSystemId(uri.toString()); _latest = uri.toString(); return is; }