use of com.adaptris.util.URLString in project interlok by adaptris.
the class MappedResolver method retrieveAndCache.
@Override
protected InputStream retrieveAndCache(URLString url) throws Exception {
String key = url.toString();
String candidate = getMappings().getValueIgnoringKeyCase(key);
if (!isEmpty(candidate)) {
debugLog("[{}] mapped to [{}]", key, candidate);
return super.retrieveAndCache(new URLString(candidate));
}
debugLog("No mapping for [{}]; using as-is", key);
return super.retrieveAndCache(url);
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class Resolver method resolveEntity.
/**
* @see EntityResolver#resolveEntity(String, String)
*/
@Override
public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
debugLog("Resolving [{}][{}]", publicId, systemId);
InputSource result = null;
try {
InputSource ret = new InputSource(retrieveAndCache(new URLString(systemId)));
ret.setPublicId(publicId);
ret.setSystemId(systemId);
result = ret;
} catch (Exception e) {
debugLog("Couldn't handle [{}][{}], fallback to default parser behaviour", publicId, systemId);
result = null;
}
return result;
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class Resolver method resolve.
/**
* @see URIResolver#resolve(java.lang.String, java.lang.String)
*/
@Override
public Source resolve(String href, String base) throws TransformerException {
debugLog("Resolving [{}][{}]", href, base);
StreamSource result = null;
try {
URL myUrl = null;
try {
myUrl = new URL(href);
} catch (Exception ex) {
// Indicates that the URL was probably relative and therefore Malformed
int end = base.lastIndexOf('/');
String url = base.substring(0, end + 1);
myUrl = new URL(url + href);
}
result = new StreamSource(retrieveAndCache(new URLString(myUrl)), myUrl.toExternalForm());
} catch (Exception e) {
debugLog("Couldn't handle [{}][{}], fallback to default parser behaviour", href, base);
result = null;
}
return result;
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class Resolver method retrieveAndCache.
protected InputStream retrieveAndCache(URLString url) throws Exception {
String key = url.toString();
InputStream result = null;
if (!hm.containsKey(key)) {
debugLog("Nothing in cache for [{}]", key);
ByteArrayOutputStream output = new ByteArrayOutputStream();
StreamUtil.copyAndClose(URLHelper.connect(url), output);
hm.put(key, output);
result = new ByteArrayInputStream(output.toByteArray());
} else {
debugLog("Resolved from cache [{}]", key);
result = new ByteArrayInputStream(hm.get(key).toByteArray());
}
return result;
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistry method persistAdapter.
@Override
public void persistAdapter(ObjectName adapter, String url) throws CoreException, IOException {
assertNotNull(url, EXCEPTION_MSG_URL_NULL);
persistAdapter(adapter, new URLString(url));
}
Aggregations