dev@jersey.java.net

Re: [Jersey] WebDAV "Depth" header and enum <was> Re: Developer role

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 12 Jan 2009 11:00:11 +0100

On Jan 10, 2009, at 3:36 PM, Markus KARG wrote:

> Paul,
>
> thank you for your comments.
>
> I wonder how to code an enum that has a value of "0"? Any idea?
>

Ah, i remember now, enum already supports this but the string parameter:
        "must match exactly an identifier used to declare an enum
constant in this type."

which is, unfortunately, not what you want. The only other way i can
think of is to create a wrapper class that takes a string constructor
and from a method on the class the enum can be obtained.


> For your last sentence, I just did not understand what you like to
> tell me. Can you rephrase that?
>

I was wondering if you could combine a request entity with WebDAV
headers. Since my knowledge of WebDAV is limited the following might
not be suitable: for example:

   @PROPFIND
   public .. . put(PropFind find) {
   }

the class PropFind encapsulates the request entity (if any) and
relevant WebDAV headers. The message body reader for the PropFind
would be responsible for reading the request entity and processing the
WebDAV headers. The above approach, if possible, might be easier for
the end user.

Paul.


> Thanks
> Markus
>
>
>
> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
> Sent: Freitag, 9. Januar 2009 14:53
> To: Markus KARG
> Cc: dev_at_jersey.dev.java.net
> Subject: [Jersey] WebDAV "Depth" header and enum <was> Re: Developer
> role
>
>
> On Dec 30, 2008, at 7:13 PM, Markus KARG wrote:
> I currently have defined header constants like "Depth", as defined
> by the WebDAV spec. I have seen that some of them are defined in the
> WebDAV spec to be actually not Strings but enums, i. e. for example,
> the WebDAV "Depth" header must only be one of the Strings "0", "1"
> or "infinity". So to prevent people from incidentially using "2",
> "3" or "infinte" as an invalid header value, it would be great to
> make that particular header not a String but an enum. Is that
> possible in JAX-RS? For example, can I use an enum in a method as a
> @HeaderParam variable?
>
> IIRC it is possible to use Enum classes, i recommend experimenting
> with a simple class.
>
>
>
> Like:
>
> @PROPFIND
> public MultiStatus propfind(@HeaderParam final DepthEnum depth)
>
> @HeaderParam("Depth")
>
>
>
>
> Will Jersey be able to parse the header value "0" to inject
> Depth.ZERO here?
>
> If "0" is the value of the enum constant then i think yes.
>
>
>
>
> If possible, then I will overhaul the code once more before
> committing it, since it is so much easier to work with enums. :-)
>
> Is Depth associated with all forms of WebDAV method or with
> particular methods.
>
> The reason i ask is that you might be able to combine the request
> entity with headers without your own special type and message body
> reader (as they are also capable of getting request header
> information).
>
> Paul.
>
>
>
>
>
>
>
>
>
>
>
>
>