After doing a bit of work on the FileManager as part of my Theme
Encapsulation proposal I have come to a point where I am thinking I
would like to add in a new WeblogResource class/interface to serve as a
layer of abstraction between an uploaded resource as used by Roller and
the physical way that resource is managed by the FileManager.
Right now the FileManager simply returns java.io.File objects which
represent the resource as it lives on the filesystem, and I think that's
not particularly ideal. There are a couple of reasons to change that
such that the FileManager returns a more abstract notion of a
WeblogResource.
1. security and proper abstraction through layers. Ideally the
presentation layer should not need to know or have access to the details
of how a resource is being stored on the filesystem. Returning
java.io.File objects gives more information than is needed.
2. there are some things that we may want to associate with a resource
that we can't do with a java.io.File object. for example, i want to
have a method which returns the relative path to a resource inside the
weblog's uploads area. it would also make sense if a WeblogResource had
a reference to the Weblog it's part of and also possibly has a method to
access the URL to the resource.
So this is what I've defined ...
public interface WeblogResource {
public WebsiteData getWeblog();
public String getName();
public String getPath();
public long getLastModified();
public long getLength();
public boolean isDirectory();
public boolean isFile();
public String getURL(boolean absolute);
public InputStream getInputStream();
}
anyone have any objections to doing this? The only class which produces
these objects will be the FileManager by calling it's getFile() or
getFiles() methods.
-- Allen