protected void closeQuietly( Resource resource ) { try { if (resource != null) { resource.close(); } } catch( Exception ex ) { log( "Exception during Resource.close()", ex ); } }
@Override public String[] list() { return this.delegate.list(); }
@Override public boolean exists() { return this.delegate.exists(); }
public Resource getWebInf() throws IOException { if (super.getBaseResource() == null) return null; // Iw there a WEB-INF directory? Resource web_inf= super.getBaseResource().addPath("WEB-INF/"); if (!web_inf.exists() || !web_inf.isDirectory()) return null; return web_inf; }
@Override public InputStream getInputStream() throws IOException { return this.delegate.getInputStream(); }
public void init(WebAppContext webAppContext) throws IOException { String railsRootDirName = webAppContext.getInitParameter("rails.root").replaceAll("/WEB-INF/", ""); String assetsDir = webAppContext.getWebInf().addPath(String.format("%s/public/assets/", railsRootDirName)).getName(); handler.setAssetsDir(assetsDir); }
/** * Sets the base resources for this context. * * @param baseResources The list of resources to be used as the base for all static * content of this context. */ public void setBaseResource(Resource... baseResources) { handler.setBaseResource(new ResourceCollection(baseResources)); }
@Override public File getFile() throws IOException { return this.delegate.getFile(); }
@Override public boolean isDirectory() { return this.delegate.isDirectory(); }
@Override public String getName() { return this.delegate.getName(); }
@Override public long lastModified() { return this.delegate.lastModified(); }
@Override public long length() { return this.delegate.length(); }
@Override public boolean isContainedIn(Resource resource) throws MalformedURLException { return this.delegate.isContainedIn(resource); }
@Override public ReadableByteChannel getReadableByteChannel() throws IOException { return this.delegate.getReadableByteChannel(); }
@Override public boolean delete() throws SecurityException { return this.delegate.delete(); }
@Override public boolean renameTo(Resource dest) throws SecurityException { return this.delegate.renameTo(dest); }
public void copyTo(OutputStream outputStream) throws IOException { try (InputStream in = source.getInputStream()) { IOUtils.copy(in, outputStream); } }
/** * Sets the base resources for this context. * * @param resources A list of strings representing the base resources to serve static * content for the context. Any string accepted by Resource.newResource(String) * may be passed and the call is equivalent to {@link #setBaseResource(Resource...)}} */ public void setBaseResource(String... resources) { handler.setBaseResource(new ResourceCollection(resources)); }
@Override public void close() { this.delegate.close(); }
public void copyTo(File output) throws IOException { try (InputStream in = source.getInputStream()) { FileUtils.copyToFile(in, output); } } }