public static Properties loadProperties(String propertiesLocation, Bus bus) throws Exception { Properties props = new Properties(); try (InputStream is = getResourceStream(propertiesLocation, bus)) { props.load(is); } return props; }
public static List<UserResource> getUserResources(String loc, Bus bus) { try (InputStream is = ResourceUtils.getResourceStream(loc, bus)) { if (is == null) { return null; } return getUserResources(is); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc); } return null; }
public static UserApplication getUserApplication(String loc, Bus bus, ParseConfiguration cfg) { try { InputStream is = ResourceUtils.getResourceStream(loc, bus); if (is == null) { return null; } return getUserApplicationFromStream(is, cfg); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc); } return null; } public static UserApplication getUserApplicationFromStream(InputStream is) throws IOException {
public static List<UserResource> getUserResources(String loc, Bus bus) { try { InputStream is = ResourceUtils.getResourceStream(loc, bus); if (is == null) { return null; } return getUserResources(is); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc); } return null; }
public static UserApplication getUserApplication(String loc, Bus bus, ParseConfiguration cfg) { try { InputStream is = ResourceUtils.getResourceStream(loc, bus); if (is == null) { return null; } return getUserApplicationFromStream(is, cfg); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc); } return null; } public static UserApplication getUserApplicationFromStream(InputStream is) throws IOException {
public static UserApplication getUserApplication(String loc, Bus bus, ParseConfiguration cfg) { try { InputStream is = ResourceUtils.getResourceStream(loc, bus); if (is == null) { return null; } return getUserApplicationFromStream(is, cfg); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc); } return null; } public static UserApplication getUserApplicationFromStream(InputStream is) throws IOException {
private String transformLocally(Message m, UriInfo ui, Source source) throws Exception { InputStream is = ResourceUtils.getResourceStream(stylesheetReference, m.getExchange().getBus()); TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = transformerFactory.newTemplates(new StreamSource(is)).newTransformer(); t.setParameter("base.path", m.get("http.base.path")); StringWriter stringWriter = new StringWriter(); t.transform(source, new StreamResult(stringWriter)); return stringWriter.toString(); }
private String transformLocally(Message m, UriInfo ui, Source source) throws Exception { InputStream is = ResourceUtils.getResourceStream(stylesheetReference, m.getExchange().getBus()); TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformerFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true); Transformer t = transformerFactory.newTemplates(new StreamSource(is)).newTransformer(); t.setParameter("base.path", m.get("http.base.path")); StringWriter stringWriter = new StringWriter(); t.transform(source, new StreamResult(stringWriter)); return stringWriter.toString(); }
public static String getOpenApiFromSwaggerLoc(String loc, OpenApiConfiguration cfg, Bus bus) { try { InputStream is = ResourceUtils.getResourceStream(loc, bus); if (is == null) { return null; } return getOpenApiFromSwaggerStream(is, cfg); } catch (Exception ex) { LOG.warning("Problem with processing a user model at " + loc + ", exception: " + ExceptionUtils.getStackTrace(ex)); } return null; }
private Element readIncludedDocument(String href) { try { InputStream is = null; if (!href.startsWith("http")) { is = ResourceUtils.getResourceStream(href, bus); } if (is == null) { URL url = URI.create(href).toURL(); if (href.startsWith("https") && authentication != null) { is = SecureConnectionHelper.getStreamFromSecureConnection(url, authentication); } else { is = url.openStream(); } } return readXmlDocument(new InputStreamReader(is, StandardCharsets.UTF_8)); } catch (Exception ex) { throw new RuntimeException("Resource " + href + " can not be read"); } }
private void loadSchemasIntoCache(String loc) throws Exception { InputStream is = ResourceUtils.getResourceStream(loc, bus == null ? BusFactory.getDefaultBus() : bus); if (is == null) { return; } try (ByteArrayInputStream bis = IOUtils.loadIntoBAIS(is)) { XMLSource source = new XMLSource(bis); source.setBuffering(); String targetNs = source.getValue("/*/@targetNamespace"); Map<String, String> nsMap = Collections.singletonMap("xs", Constants.URI_2001_SCHEMA_XSD); String[] elementNames = source.getValues("/*/xs:element/@name", nsMap); externalQnamesMap.put(targetNs, Arrays.asList(elementNames)); String schemaValue = source.getNode("/xs:schema", nsMap, String.class); externalSchemasCache.add(schemaValue); } }
private void loadSchemasIntoCache(String loc) throws Exception { InputStream is = ResourceUtils.getResourceStream(loc, bus == null ? BusFactory.getDefaultBus() : bus); if (is == null) { return; } ByteArrayInputStream bis = IOUtils.loadIntoBAIS(is); XMLSource source = new XMLSource(bis); source.setBuffering(); String targetNs = source.getValue("/*/@targetNamespace"); Map<String, String> nsMap = Collections.singletonMap("xs", XmlSchemaConstants.XSD_NAMESPACE_URI); String[] elementNames = source.getValues("/*/xs:element/@name", nsMap); externalQnamesMap.put(targetNs, Arrays.asList(elementNames)); String schemaValue = source.getNode("/xs:schema", nsMap, String.class); externalSchemasCache.add(schemaValue); }
private void loadSchemasIntoCache(String loc) throws Exception { InputStream is = ResourceUtils.getResourceStream(loc, bus == null ? BusFactory.getDefaultBus() : bus); if (is == null) { return; } try (ByteArrayInputStream bis = IOUtils.loadIntoBAIS(is)) { XMLSource source = new XMLSource(bis); source.setBuffering(); String targetNs = source.getValue("/*/@targetNamespace"); Map<String, String> nsMap = Collections.singletonMap("xs", Constants.URI_2001_SCHEMA_XSD); String[] elementNames = source.getValues("/*/xs:element/@name", nsMap); externalQnamesMap.put(targetNs, Arrays.asList(elementNames)); String schemaValue = source.getNode("/xs:schema", nsMap, String.class); externalSchemasCache.add(schemaValue); } }
loc = loc.substring(0, fragmentIndex); InputStream is = ResourceUtils.getResourceStream(loc, m.getExchange().getBus()); if (is != null) { Element docEl = StaxUtils.read(is).getDocumentElement(); InputStream is = ResourceUtils.getResourceStream(href, m.getExchange().getBus()); return Response.ok().type(MediaType.APPLICATION_XML_TYPE).entity(is).build();
loc = loc.substring(0, fragmentIndex); InputStream is = ResourceUtils.getResourceStream(loc, (Bus)ep.get(Bus.class.getName())); if (is != null) { Element docEl = StaxUtils.read(is).getDocumentElement();
if (loc != null) { try { InputStream is = ResourceUtils.getResourceStream(loc, (Bus)ep.get(Bus.class.getName())); if (is != null) { Element appEl = StaxUtils.read(is).getDocumentElement();
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { try { String resolvedLocation = catalogResolver.resolveSystem(systemId); if (resolvedLocation == null) { resolvedLocation = catalogResolver.resolveURI(namespaceURI); } if (resolvedLocation == null) { resolvedLocation = catalogResolver.resolvePublic( publicId != null ? publicId : namespaceURI, systemId); } if (resolvedLocation != null) { InputStream resourceStream = ResourceUtils.getResourceStream(resolvedLocation, bus); if (resourceStream != null) { return new LSInputImpl(publicId, systemId, resourceStream); } } } catch (Exception ex) { // ignore } return null; }
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { try { String resolvedLocation = catalogResolver.resolveSystem(systemId); if (resolvedLocation == null) { resolvedLocation = catalogResolver.resolveURI(namespaceURI); } if (resolvedLocation == null) { resolvedLocation = catalogResolver.resolvePublic(publicId, systemId); } if (resolvedLocation != null) { InputStream resourceStream = ResourceUtils.getResourceStream(resolvedLocation, bus); if (resourceStream != null) { return new LSInputImpl(publicId, systemId, resourceStream); } } } catch (Exception ex) { // ignore } return null; }
if (loc != null) { try { InputStream is = ResourceUtils.getResourceStream(loc, (Bus)ep.get(Bus.class.getName())); if (is != null) { Object contextProp = m.getContextualProperty(CONVERT_WADL_RESOURCES_TO_DOM);
if (loc != null) { try { InputStream is = ResourceUtils.getResourceStream(loc, (Bus)ep.get(Bus.class.getName())); if (is != null) { Object contextProp = m.getContextualProperty(CONVERT_WADL_RESOURCES_TO_DOM);