Why does it have to be a text representation? What if I wanted to
return a generated PNG image of the file names instead as the index? I
realize that building a zip of the contents isn't exactly an "index",
but requiring a text representation just seems limiting.
The problem with returning my own instance of DirectoryResource is that
I really do want all the functionality provided by the returned
representation (such as content negotiation, etc), but the
DirectoryResource instance is created via
Engine.getInstance().createDirectoryResource(). I guess I could write
and register my own Engine, but that seems like a lot of work for this
customization.
Thierry Boileau wrote:
Hello all,
The Directory is designed to serve a single file taken from its own
directory and/or subdirectories via an instance of DirectoryResource
(see Directory#findTarget(Request, Response)), or to return a "text"
representation of the index of a given directory via the
Directory#getIndexRepresentation.
It is not designed to retrieve a whole directory content in a zip file.
If you want to inherit from Directory, you must create your own
resource class and override the Directory#findTarget in order to
create a new instance of your new resource class.
I hope this will help you,
Thierry Boileau
Kevin Conaway wrote:
Are you able to debug com.noelios.restlet.local.DirectoryResource?
That looks like where the problem might be but the code is so obscured
by URI processing logic that its tough to read through without valid
data.
No, I haven't debugged through that yet -- that was my next step.
Is isListingAllowed() true on your Directory instance?
Yep.
On Jan 14, 2008 9:46 AM, Valdis Rigdon <[EMAIL PROTECTED]> wrote:
Yep, I've tried that. In walking through the code via a debugger, I see
my APPLICATION_ZIP representation being built, but it's not the
representation being returned -- the StringRepresentation is with the
HTML contents.
Valdis
Kevin Conaway wrote:
Hi Valids,
Did you try overriding getIndexVariants() to add APPLICATION_ZIP in
addition to overriding getIndexRepresentation()?
Kevin
On Jan 14, 2008 8:34 AM, Valdis Rigdon <[EMAIL PROTECTED]> wrote:
I'm looking for a little help in trying to implement a solution with
Directory -- maybe someone on this list has done this before; I've tried
a number of ways but nothing seems to work quite right. Note that we
are using version 1.0.7, not 1.1.
My use case involves exposing the log4j logs for our running
applications over REST. This works using Directory and handing it a
LocalReference to our logs directory. I can hit it and get the
generated HTML index page, etc. Now, I'd also like to enhance the
resource to return the entire log directory zipped (ie, a snapshot of
the logs). My thoughts on this were to simply request an
APPLICATION_ZIP representation from the URL (http://localhost/api/log)
and override getIndexRepresentation() to return the zipped logs. The
zip representation is never returned however. I've tried using
http://localhost/api/log?media=zip to force it, as well as written a
REST client hitting the URL and the wrong representation is sent back.
Has anyone extended Directory in such a way?
I realize I could add a different URL to get this information, but it
seems logical that it's just a different representation of the same
resource.
Any help would be appreciated.
Valdis