Hello Thomas, sounds well

but maybe you want to try the recently invented DetailedWebdavEvent.
It provides some "*After" events, that are issued after the object creation.
The event source of WebdavEvent's and DetailedWebdavEvent's are always the
method classes from org.apache.slide.webdav.method. These provide access to
the helper classes and to the request and response infos.
(this is similar to the WebdavListener, but that issues an event only once per 
method)

You can use this like the following sample:

public void copyAfterCopy(DetailedWebdavEvent event) throws VetoException {

     AbstractWebdavMethod method = (AbstractWebdavMethod)event.getSource();

     Content content = method.getContent();

     NodeRevisionDescriptors nrds = content.retrieve(
                    method.getSlideToken(), method.getRequestUri());
     NodeRevisionDescriptor nrd = content.retrieve(
                    method.getSlideToken(), nrds);

     ndr.setProperty(...);

     content.store(method.getSlideToken(), method.getRequestUri(), nrd, null);
}

If you are updateing properties at other nodes you may get problems with the 
permissions,
may be you want to update quota properties at nodes where the current user does 
not
have read or write permissions. You can work around this using a Wrapper that 
disables
security checking:

SlideToken systemToken = new SlideTokenWrapper(method.getSlideToken());
systemToken.setForceSecurity(false);
systemToken.setForceLock(false);

I think we have to complete the getErrorCode method at WebdavUtils to make
VetoExceptions into more detailed WebDAV error codes.

I hope this helps. Keep you motivation.

Cheers Stefan


Thomas Bellembois wrote:

Hello,

I have started to develop quota using Listener and Events (following your advice - thank you again), and I would like to be sure that I am on the good way.
I have built a new class that extends the ContentListener class.
I can get parameters of the current request (content length...) and access resources metadata (quota-available-bytes quota-used-bytes).
I override all of the methods of the ContentListener class, except the "retrieve" method (it does not seem to be necessary - not yet).


According to the draft, every resource on the server should contain quota properties.
So, when an event is caught by my Listener, for example in the create method :
1. getting the content lenght of the resource to be created
2. getting the quota properties (quota-available-bytes quota-used-bytes) of the parent node (ie. directory where the resource will be stored)
> if no quota properties are found, quota are supposed to be unlimited (?)
3. if (request_contentLength + quota-used-bytes > quota-available-bytes) throw new VetoException(...quota exceeded...)
4. else updating quota-available-bytes properties (quota-available-bytes = quota-available-bytes + request-contentLength) up to the root node
#Note : it does not seem to be very suitable do to that here, because the current action (create) is not performed yet - How can we do better ?


For the store method, apparently called only when the resource already exists, the calculation at the point 3 is a bit different

I wanted to use the WebDavListener interface but I could not find any way to retrieve request parameters and it looked easier to use a ContentListener (and event).

So can I follow this idea ?

Thank you very much.

Thomas (still a beginner Slide-based product developer but still motivated ! ;-) )



--
Stefan L�tzkendorf  --  [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to