Search in sources :

Example 1 with XmlrpcInputStream

use of org.exist.protocolhandler.xmlrpc.XmlrpcInputStream in project exist by eXist-db.

the class AnyUriResolver method resolveEntity.

@Override
public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException {
    if (xri.getExpandedSystemId() == null && xri.getLiteralSystemId() == null && xri.getNamespace() == null && xri.getPublicId() == null) {
        // quick fail
        return null;
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Resolving XMLResourceIdentifier: {}", getXriDetails(xri));
    }
    String resourcePath = null;
    String baseSystemId = null;
    if (firstTime) {
        // First time use constructor supplied path
        resourcePath = docPath;
        baseSystemId = parentURI;
        xri.setExpandedSystemId(docPath);
        firstTime = false;
    } else {
        resourcePath = xri.getExpandedSystemId();
    }
    xri.setBaseSystemId(docPath);
    LOG.debug("resourcePath='{}'", resourcePath);
    // prevent NPE
    if (resourcePath == null) {
        return null;
    }
    InputStream is = null;
    if (resourcePath.startsWith("xmldb:")) {
        final XmldbURL xmldbURL = new XmldbURL(resourcePath);
        if (xmldbURL.isEmbedded()) {
            is = new EmbeddedInputStream(xmldbURL);
        } else {
            is = new XmlrpcInputStream(threadGroup, xmldbURL);
        }
    } else {
        is = new URL(resourcePath).openStream();
    }
    final XMLInputSource xis = new XMLInputSource(xri.getPublicId(), resourcePath, baseSystemId, is, "UTF-8");
    if (LOG.isDebugEnabled()) {
        LOG.debug("XMLInputSource: {}", getXisDetails(xis));
    }
    return xis;
}
Also used : XmldbURL(org.exist.protocolhandler.xmldb.XmldbURL) XMLInputSource(org.apache.xerces.xni.parser.XMLInputSource) EmbeddedInputStream(org.exist.protocolhandler.embedded.EmbeddedInputStream) XmlrpcInputStream(org.exist.protocolhandler.xmlrpc.XmlrpcInputStream) InputStream(java.io.InputStream) EmbeddedInputStream(org.exist.protocolhandler.embedded.EmbeddedInputStream) XmlrpcInputStream(org.exist.protocolhandler.xmlrpc.XmlrpcInputStream) URL(java.net.URL) XmldbURL(org.exist.protocolhandler.xmldb.XmldbURL)

Example 2 with XmlrpcInputStream

use of org.exist.protocolhandler.xmlrpc.XmlrpcInputStream in project exist by eXist-db.

the class EmbeddedURLConnection method getInputStream.

@Override
public InputStream getInputStream() throws IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug(url);
    }
    final XmldbURL xmldbURL = new XmldbURL(url);
    final InputStream inputstream;
    if (xmldbURL.isEmbedded()) {
        inputstream = new EmbeddedInputStream(xmldbURL);
    } else {
        inputstream = new XmlrpcInputStream(threadGroup, xmldbURL);
    }
    return inputstream;
}
Also used : XmldbURL(org.exist.protocolhandler.xmldb.XmldbURL) EmbeddedInputStream(org.exist.protocolhandler.embedded.EmbeddedInputStream) XmlrpcInputStream(org.exist.protocolhandler.xmlrpc.XmlrpcInputStream) InputStream(java.io.InputStream) EmbeddedInputStream(org.exist.protocolhandler.embedded.EmbeddedInputStream) XmlrpcInputStream(org.exist.protocolhandler.xmlrpc.XmlrpcInputStream)

Aggregations

InputStream (java.io.InputStream)2 EmbeddedInputStream (org.exist.protocolhandler.embedded.EmbeddedInputStream)2 XmldbURL (org.exist.protocolhandler.xmldb.XmldbURL)2 XmlrpcInputStream (org.exist.protocolhandler.xmlrpc.XmlrpcInputStream)2 URL (java.net.URL)1 XMLInputSource (org.apache.xerces.xni.parser.XMLInputSource)1