jakarta-slide-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Lützkendorf <luetzkend...@apache.org>
Subject Re: Quota development.
Date Mon, 21 Mar 2005 16:40:13 GMT
I see, you are right.

Maybe we should introduce some new events like mkcolAfter and putAfter that
not to hard and will be usefull for others too.

Stefan

Thomas Bellembois wrote:
> Hello Stefan,
> 
> I thought about this solution but the problem is that methods of the 
> WebdavListener class are called before the job is performed, aren't they ?
> We are not sure that the request will be successfull ?
> If we are, it is nice :-)
> Thank you for your help.
> 
> Thomas
> 
> 
> Stefan Lützkendorf wrote:
> 
>> For this you can use WebdavListener-Events. WebdavAdapter implements both
>> interfaces WebdavListener and DetailedWebdavListener. If your listener is
>> deriveed from WebdavAdapter you can sould get calls to 
>> put(WebdavEvent) and
>> mkcol(WebdavEvent event) methods.
>>
>> Stefan
>>
>> Thomas Bellembois wrote:
>>
>>> Another basic question :
>>> None of the methods of the DetailedWebdavListener class are called 
>>> for a put or a mkcol method (I tried uploading a file and creating a 
>>> directory with a Web folder).
>>> So for these actions how can I update metadata when the job is 
>>> performed ?
>>> Thomas
>>>
>>> Thomas Bellembois wrote:
>>>
>>>> Hello Stefan,
>>>>
>>>> Yes, it helps me very much ! Thank you !
>>>> I have now the information I needed.
>>>> I remember that you told me about this DetailedWebdavEvent, but I 
>>>> was a bit lost... But now it is ok. :-)
>>>> Thank you.
>>>>
>>>> Thomas.
>>>>
>>>>
>>>> Stefan Lützkendorf wrote:
>>>>
>>>>> 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  --  luetzkendorf@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org


Mime
View raw message