On 11/03/2016 11:53, Wilson, A. (Aidan) wrote:
> Hi,
> 
> After configuring a pre-resource for my webapp with readOnly=false
> and mapped to the root, an attempt to PUT failed with 409 "Resource
> conflict".
> 
> To get around this I wrote a servlet that extends DefaultServlet and
> implements doPut using pretty much the same code as its parent but
> with a few extra lines that try to write to each set of resources in
> turn (pre, main, post) until successful. A 409 is only returned if
> it's not possible to write the data to any of the configured
> resources.
> 
> My question is: do you think DefaultServlet should already do this
> i.e. should I submit my code change for inclusion, or is the current
> behaviour by-design ?

The current behaviour is by design and is documented in the Javadoc for
WebResourceRoot:
<quote>
Write operations (including delete) will only be applied to the main
ResourceSet. The write operation will fail if the presence of a Resource
in one of the other ResourceSets effectively makes the operation on the
main ResourceSet a NO-OP.
</quote>

That isn't to say that the design can't be changed.

The reason for this design was to avoid strange / unexpected behaviour.
For example, if the same resource is present in the Main (read-only) and
Pre (read/write) what should DELETE do?
a) Fail?
b) Delete the pre resource?

If we go with b) you get the rather unexpected result that deleting the
resource appears to perform a random edit of the resource.

Lets stick with b). If I try another DELETE that will fail. OK. But I
can overwrite it. That is slightly odd although not unfamiliar. I have
seen systems configured where delete was not permitted but you could
edit the contents. Whether that makes sense or not is a different question.

If we change this, I think it needs to be changed in the resources
implementation so the behaviour is the same for all parts of the code
rather than implementing something just for the DefaultServlet.

I'm thinking of a configuration option for WebResourceRoot that would
control the write mode. The current mode is effectively "Main Resource
Set Only". What other modes might make sense?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to