use of org.apache.cxf.resource.URIResolver in project Activiti by Activiti.
the class CxfWSDLImporter method importFrom.
public void importFrom(Import theImport, BpmnParse parse) {
this.namespace = theImport.getNamespace() == null ? "" : theImport.getNamespace() + ":";
try {
final URIResolver uriResolver = new URIResolver(parse.getSourceSystemId(), theImport.getLocation());
if (uriResolver.isResolved()) {
if (uriResolver.getURI() != null) {
this.importFrom(uriResolver.getURI().toString());
} else if (uriResolver.isFile()) {
this.importFrom(uriResolver.getFile().getAbsolutePath());
} else if (uriResolver.getURL() != null) {
this.importFrom(uriResolver.getURL().toString());
}
} else {
throw new UncheckedException(new Exception("Unresolved import against " + parse.getSourceSystemId()));
}
this.transferImportsToParse(parse);
} catch (final IOException e) {
throw new UncheckedException(e);
}
}
use of org.apache.cxf.resource.URIResolver in project ddf by codice.
the class AttributeQueryClaimsHandler method createService.
/**
* Creates a dynamic service from the provided wsdl location.
*/
protected final Service createService() {
Service service = null;
URL wsdlURL;
if (StringUtils.isNotBlank(wsdlLocation) && StringUtils.isNotBlank(serviceName)) {
try {
URIResolver uriResolver = new URIResolver();
uriResolver.resolve("", wsdlLocation, this.getClass());
wsdlURL = uriResolver.isResolved() ? uriResolver.getURL() : new URL(wsdlLocation);
service = AccessController.doPrivileged((PrivilegedAction<Service>) () -> Service.create(wsdlURL, QName.valueOf(serviceName)));
auditRemoteConnection(wsdlURL);
} catch (Exception e) {
LOGGER.info("Unable to create service from WSDL location. Set log level for \"org.codice.ddf.security.claims.attributequery.common\" to DEBUG for more information.");
LOGGER.debug("Unable to create service from WSDL location.", e);
}
}
return service;
}
use of org.apache.cxf.resource.URIResolver in project cxf by apache.
the class OASISCatalogManager method getResolver.
private static EntityResolver getResolver() {
try {
CatalogManager catalogManager = new CatalogManager();
if (DEBUG_LEVEL != null) {
catalogManager.debug.setDebug(Integer.parseInt(DEBUG_LEVEL));
}
catalogManager.setUseStaticCatalog(false);
catalogManager.setIgnoreMissingProperties(true);
return new CatalogResolver(catalogManager) {
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()) {
return r.getURL().toExternalForm();
}
} catch (IOException e) {
// ignore
}
}
return s;
}
};
} catch (Throwable t) {
// ignore
}
return null;
}
use of org.apache.cxf.resource.URIResolver in project cxf by apache.
the class CustomizationParser method getTargetNode.
public Element getTargetNode(String uri) {
if (uri == null) {
return null;
}
if (uri.equals(wsdlURL) && wsdlNode != null) {
return wsdlNode;
}
Document doc = null;
try (URIResolver resolver = new URIResolver(uri)) {
if (!resolver.isResolved()) {
return null;
}
XMLStreamReader reader = null;
try {
// NOPMD
reader = StaxUtils.createXMLStreamReader(uri, resolver.getInputStream());
doc = StaxUtils.read(reader, true);
} catch (Exception e) {
Message msg = new Message("CAN_NOT_READ_AS_ELEMENT", LOG, new Object[] { uri });
throw new ToolException(msg, e);
} finally {
try {
StaxUtils.close(reader);
} catch (XMLStreamException e) {
// ignore
}
}
} catch (IOException e1) {
return null;
}
try {
doc.setDocumentURI(uri);
} catch (Exception ex) {
// ignore - probably not DOM level 3
}
if (doc != null) {
return doc.getDocumentElement();
}
return null;
}
use of org.apache.cxf.resource.URIResolver in project cxf by apache.
the class SchemaResourceResolver method resolveResource.
public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
Message msg = new Message("RESOLVE_SCHEMA", LOG, namespaceURI, systemId, baseURI);
LOG.log(Level.FINE, msg.toString());
if (NSFILEMAP.containsKey(namespaceURI)) {
return loadLSInput(namespaceURI);
}
LSInput lsin = null;
String resURL = null;
if (systemId != null) {
String schemaLocation = "";
if (baseURI != null) {
schemaLocation = baseURI.substring(0, baseURI.lastIndexOf('/') + 1);
}
if (systemId.indexOf("http://") < 0) {
resURL = schemaLocation + systemId;
} else {
resURL = systemId;
}
} else if (namespaceURI != null) {
resURL = namespaceURI;
}
if (resURL == null) {
return null;
}
String localFile = resURL;
if (resURL.startsWith("http://")) {
String filename = NSFILEMAP.get(resURL);
if (filename != null) {
localFile = ToolConstants.CXF_SCHEMAS_DIR_INJAR + filename;
}
}
try {
msg = new Message("RESOLVE_FROM_LOCAL", LOG, localFile);
LOG.log(Level.FINE, msg.toString());
@SuppressWarnings("resource") final URIResolver resolver = new URIResolver(localFile);
if (resolver.isResolved()) {
lsin = new LSInputImpl();
lsin.setSystemId(localFile);
lsin.setByteStream(resolver.getInputStream());
}
} catch (IOException e) {
return null;
}
return lsin;
}
Aggregations