public String getResolvedEntity(String publicId, String systemId) { String s = super.getResolvedEntity(publicId, systemId); if (s != null && s.startsWith("classpath:")) { try { URIResolver r = new URIResolver(s); if (r.isResolved()) { r.getInputStream().close(); return r.getURL().toExternalForm(); } } catch (IOException e) { //ignore } } return s; } };
public InputSource resolve(String curUri, String baseUri) { try { currentResolver.resolve(baseUri, curUri, getClass()); if (currentResolver.isResolved()) { if (currentResolver.getURI() != null && currentResolver.getURI().isAbsolute()) { curUri = currentResolver.getURI().toString(); if (currentResolver.isFile()) { curUri = currentResolver.getFile().getAbsoluteFile().toURI().toString(); InputStream in = currentResolver.getInputStream(); resourceOpened.addElement(in); InputSource source = new InputSource(in);
private void tryArchive(String baseStr, String uriStr) throws IOException { int i = baseStr.indexOf('!'); if (i == -1) { tryFileSystem(baseStr, uriStr); } String archiveBase = baseStr.substring(0, i + 1); String archiveEntry = baseStr.substring(i + 1); try { URI u = new URI(archiveEntry).resolve(uriStr); tryArchive(archiveBase + u.toString()); if (is != null) { if (u.isAbsolute()) { url = u.toURL(); } return; } } catch (URISyntaxException e) { // do nothing } tryFileSystem("", uriStr); }
public URIResolver(String baseUriStr, String uriStr, Class<?> calling) throws IOException { this.calling = (calling != null) ? calling : getClass(); if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else if (baseUriStr != null && (baseUriStr.startsWith("jar:") || baseUriStr.startsWith("zip:") || baseUriStr.startsWith("wsjar:"))) { tryArchive(baseUriStr, uriStr); } else if (uriStr.startsWith("jar:") || uriStr.startsWith("zip:") || uriStr.startsWith("wsjar:")) { tryArchive(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } }
public URIResolver(String baseUriStr, String uriStr, Class<?> calling) throws IOException { this.calling = (calling != null) ? calling : getClass(); if (uriStr.startsWith("classpath:")) { tryClasspath(uriStr); } else if (baseUriStr != null && (baseUriStr.startsWith("jar:") || baseUriStr.startsWith("zip:") || baseUriStr.startsWith("wsjar:")) && !isAbsolute(uriStr)) { tryArchive(baseUriStr, uriStr); } else if (uriStr.startsWith("jar:") || uriStr.startsWith("zip:") || uriStr.startsWith("wsjar:")) { tryArchive(uriStr); } else { tryFileSystem(baseUriStr, uriStr); } }
HttpURLConnection huc = (HttpURLConnection)url.openConnection(); baseFile = new File(getFilePathFromUri(baseUriStr)); baseFile = new File(base.getPath().replace("%20", " ")); if (baseFile.exists()) { is = base.toURL().openStream(); uri = base; } else { tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(uriStr.startsWith("file:") ? uriStr.substring(5) : uriStr); tryClasspath(baseUriStr + uriStr); if (is == null && uri != null && "file".equals(uri.getScheme())) { url = file.toURI().toURL(); } else if (is == null) { tryClasspath(uriStr);
URL url = urls.nextElement(); if (url.toString().startsWith("jar")) { JarURLConnection jarConnection = (JarURLConnection)url.openConnection(); && ele.getName().indexOf(ToolConstants.CXF_SCHEMAS_DIR_INJAR) > -1) { URIResolver resolver = new URIResolver(ele.getName()); if (resolver.isResolved()) { InputSource is = new InputSource(resolver.getInputStream()); if (resolver.getURI() != null) { is.setSystemId(resolver.getURI().toString()); } else { is.setSystemId(ele.getName()); } else if (url.toString().startsWith("file")) { URI loc = null; try { if (files != null) { for (int i = 0; i < files.length; i++) { InputSource is = new InputSource(files[i].toURI().toURL().openStream()); is.setSystemId(files[i].toURI().toURL().toString()); xsdList.add(is);
private void fillDataBindingSchemas() { ResourceManager rr = getBus().getExtension(ResourceManager.class); List<DOMSource> schemas = new ArrayList<>(); for (String l : schemaLocations) { URL url = rr.resolveResource(l, URL.class); if (url == null) { URIResolver res; try { res = new URIResolver(l); } catch (IOException e) { throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l), e); } if (!res.isResolved()) { throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l)); } url = res.getURL(); } Document d; try { d = StaxUtils.read(url.openStream()); } catch (Exception e) { throw new ServiceConstructionException(new Message("ERROR_READING_SCHEMA", LOG, l), e); } schemas.add(new DOMSource(d, url.toString())); } ((AbstractDataBinding)getDataBinding()).setSchemas(schemas); }
URLConnection urlCon = null; try { url = new URL(resURL); urlCon = url.openConnection(); urlCon.setUseCaches(false); lsin = new LSInputImpl(); LOG.log(Level.FINE, msg.toString()); resolver = new URIResolver(localFile); if (resolver.isResolved()) { lsin = new LSInputImpl(); lsin.setSystemId(localFile); lsin.setByteStream(resolver.getInputStream());
static String mapSchemaLocation(String target, String base, OASISCatalogManager catalog) { try { String resolvedLocation = new OASISCatalogManagerHelper().resolve(catalog, target, base); if (resolvedLocation != null) { return resolvedLocation; } } catch (Exception ex) { //ignore } try { URIResolver resolver = new URIResolver(base, target); if (resolver.isResolved()) { target = resolver.getURI().toString(); } } catch (Exception ex) { //ignore } return target; } private Element removeImportElement(Element element,
XMLStreamReader xmlReader = null; try { URIResolver resolver = new URIResolver(bindingFile); xmlReader = StaxUtils.createXMLStreamReader(resolver.getURI().toString(), resolver.getInputStream()); root = StaxUtils.read(xmlReader, true).getDocumentElement(); } catch (Exception e1) {
private URL composeUrl(String s) { try { URIResolver resolver = new URIResolver(null, s, getClass()); if (resolver.isResolved()) { return resolver.getURI().toURL(); } throw new ServiceConstructionException(new Message("COULD_NOT_RESOLVE_URL", LOG, s)); } catch (IOException e) { throw new ServiceConstructionException(new Message("COULD_NOT_RESOLVE_URL", LOG, s), e); } }
URIResolver res = new URIResolver(wsdlLocation); if (!res.isResolved()) url = res.getURL();
URIResolver resolver = new URIResolver(uri); ins = resolver.getInputStream(); } catch (IOException e1) { return null;
public void validate(ToolContext env) throws ToolException { env.put("service.target", getServiceTarget()); env.put("service.superclass", getServiceSuperclass()); super.validate(env); if (env.containsKey(ToolConstants.CFG_BINDING)) { String[] bindings = (String[])env.get(ToolConstants.CFG_BINDING); URIResolver resolver = null; for (int i = 0; i < bindings.length; i++) { try { resolver = new URIResolver(bindings[i]); } catch (IOException ioe) { throw new ToolException(ioe); } if (!resolver.isResolved()) { Message msg = new Message("FILE_NOT_EXIST", LOG, bindings[i]); throw new ToolException(msg); } } env.put(ToolConstants.CFG_BINDING, bindings); } cleanArrays(env, ToolConstants.CFG_ASYNCMETHODS); cleanArrays(env, ToolConstants.CFG_BAREMETHODS); cleanArrays(env, ToolConstants.CFG_MIMEMETHODS); }
public ExtendedURIResolver() { currentResolver = new org.apache.cxf.resource.URIResolver(); }
HttpURLConnection huc = (HttpURLConnection)url.openConnection(); baseFile = new File(getFilePathFromUri(baseUriStr)); baseFile = new File(base.getPath().replace("%20", " ")); if (baseFile.exists()) { is = base.toURL().openStream(); uri = base; } else { tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(base.toString().startsWith("file:") ? base.toString().substring(5) : base.toString()); tryClasspath(uriStr.startsWith("file:") ? uriStr.substring(5) : uriStr); tryClasspath(baseUriStr + uriStr); if (is == null && uri != null && "file".equals(uri.getScheme())) { url = file.toURI().toURL(); } else if (is == null) { tryClasspath(uriStr);
URL url = urls.nextElement(); if (url.toString().startsWith("jar")) { JarURLConnection jarConnection = (JarURLConnection)url.openConnection(); && ele.getName().indexOf(ToolConstants.CXF_SCHEMAS_DIR_INJAR) > -1) { URIResolver resolver = new URIResolver(ele.getName()); if (resolver.isResolved()) { InputSource is = new InputSource(resolver.getInputStream()); if (resolver.getURI() != null) { is.setSystemId(resolver.getURI().toString()); } else { is.setSystemId(ele.getName()); } else if (url.toString().startsWith("file")) { URI loc = null; try { if (files != null) { for (int i = 0; i < files.length; i++) { InputSource is = new InputSource(files[i].toURI().toURL().openStream()); is.setSystemId(files[i].toURI().toURL().toString()); xsdList.add(is);
private void fillDataBindingSchemas() { ResourceManager rr = getBus().getExtension(ResourceManager.class); List<DOMSource> schemas = new ArrayList<>(); for (String l : schemaLocations) { URL url = rr.resolveResource(l, URL.class); if (url == null) { URIResolver res; try { res = new URIResolver(l); } catch (IOException e) { throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l), e); } if (!res.isResolved()) { throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l)); } url = res.getURL(); } Document d; try { d = StaxUtils.read(url.openStream()); } catch (Exception e) { throw new ServiceConstructionException(new Message("ERROR_READING_SCHEMA", LOG, l), e); } schemas.add(new DOMSource(d, url.toString())); } ((AbstractDataBinding)getDataBinding()).setSchemas(schemas); }