use of org.exist.protocolhandler.embedded.EmbeddedInputStream 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;
}
use of org.exist.protocolhandler.embedded.EmbeddedInputStream in project exist by eXist-db.
the class ExistResolver method resolveInputSource.
/* ============== */
/* Helper methods */
/* ============== */
private InputSource resolveInputSource(BrokerPool bPool, String path) throws IOException {
LOG.debug("Resolving {}", path);
final InputSource inputsource = new InputSource();
if (path != null) {
if (path.startsWith(LOCALURI) || path.startsWith(SHORTLOCALURI)) {
final XmldbURL url = new XmldbURL(path);
final EmbeddedInputStream eis = new EmbeddedInputStream(bPool, url);
inputsource.setByteStream(eis);
inputsource.setSystemId(path);
} else {
final InputStream is = new URL(path).openStream();
inputsource.setByteStream(is);
inputsource.setSystemId(path);
}
}
return inputsource;
}
use of org.exist.protocolhandler.embedded.EmbeddedInputStream in project exist by eXist-db.
the class ExistResolver method resolveStreamSource.
private StreamSource resolveStreamSource(BrokerPool bPool, String path) throws TransformerException {
LOG.debug("Resolving {}", path);
final StreamSource streamsource = new StreamSource();
try {
if (path != null) {
if (path.startsWith(LOCALURI) || path.startsWith(SHORTLOCALURI)) {
final XmldbURL url = new XmldbURL(path);
final EmbeddedInputStream eis = new EmbeddedInputStream(bPool, url);
streamsource.setInputStream(eis);
streamsource.setSystemId(path);
} else {
final InputStream is = new URL(path).openStream();
streamsource.setInputStream(is);
streamsource.setSystemId(path);
}
}
} catch (final IOException ex) {
throw new TransformerException(ex);
}
return streamsource;
}
use of org.exist.protocolhandler.embedded.EmbeddedInputStream 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;
}
Aggregations