@Override public InputStream getContent() { // todo - this needs to be more complete so the proxy information will // make it up to the higher levels. Ie, so one can pass back the response information try { return getResourceUri().toURL().openStream(); } catch (final IOException e) { throw new ExternalContentAccessException("Problems getting external content : " + e.getMessage(), e); } }
@Override public Response toResponse(final ExternalContentAccessException exception) { debugException(this, exception, LOGGER); return status(BAD_GATEWAY).entity(exception.getMessage()).type(TEXT_PLAIN_WITH_CHARSET) .build(); }
/** * Fetch the external content * @return InputStream containing the external content */ public InputStream fetchExternalContent() { final URI uri = link.getUri(); final String scheme = uri.getScheme(); LOGGER.debug("scheme is {}", scheme); if (scheme != null) { try { if (scheme.equals("file")) { return new FileInputStream(uri.getPath()); } else if (scheme.equals("http") || scheme.equals("https")) { return uri.toURL().openStream(); } } catch (final IOException e) { throw new ExternalContentAccessException("Failed to read external content from " + uri, e); } } return null; }