Hi,

You will find enclosed UserQuotaContentInterceptor implementation.

There are 2 new files :

org.apache.slide.content.UserQuotaContentInterceptor.java
Quota Interceptor class

org.apache.slide.content.InsufficientStorageException.java
The exception it raises

And I've patched 5 others files :

org.apache.slide.webdav.method.WebdavMethod.java
Added InsufficientStorageException processing
(returns SC_INSUFFICIENT_STORAGE (507) status code)

org.apache.slide.content.ContentInterceptor.java
Made it abstract.
Added postRemoveContent method
Added some exceptions to throws clause

org.apache.slide.common.Content.java
Added InsufficientStorageExceptions to some throws clause

org.apache.slide.common.ContentImpl.java
Added postRemoveContent constant and calls.
Added some exceptions to throws clause
Added some revisionDescriptor(s) retreiving before calls
to invokeContentInterceptors()

org.apache.slide.common.XMLUnmarshaler.java
Added two InsufficientStorageException catchs


Usage guide :

Add to the <namespace><configuration> part of Domain.xml file :

<content-interceptor 
class="org.apache.slide.content.UserQuotaContentInterceptor"/>
<parameter name="allowUnknownSizeContent">false</parameter>
<parameter name="allowQuotaToBeExceeded">false</parameter>

This contentInterceptor has 2 parameters :
1) allowUnknownSizeContent :
    Allows to process requests with null contentLength header
2) allowQuotaToBeExceeded :
    If set to true : Allow users to exceed their quota with ONE file.
    If set to false : Do not allow users to exceed their quota at all.
                 This implies empty files creation when quota is exceeded
                 (See my email : UserQuota : Webfolders and PUT method).

User quota MUST be a protected property of the users's node (need to be 
done during user creation).

User should have write permission on its own node.


Improvements :

How could I add my 2 parameters to <content-interceptor> tag rather than
putting them as namespace parameters ?

Would it be possible to retreive these parameters without having to pass 
   a NamespaceConfig object as arguments to pre/post methods ?

If not, would it be possible to add this object to contentInterceptor
constructor ?

Is there a may to avoid to pass to pre/post methods the contentHelper as
argument ?

Finally, what could be done better than it is in my code ?


All remarks are welcome


JP
/*
 * $Header: 
/home/cvspublic/jakarta-slide/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java,v
 1.0 2002/01/10 16:19:32 remm Exp $
 * $Revision: 1.0 $
 * $Date: 2002/01/10 16:19:32 $
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights 
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:  
 *       "This product includes software developed by the 
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written 
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */ 

package org.apache.slide.content;

import java.util.Date;
import java.util.Enumeration;

import org.apache.slide.common.SlideToken;
import org.apache.slide.common.NamespaceConfig;
import org.apache.slide.lock.ObjectLockedException;
import org.apache.slide.common.ServiceAccessException;
import org.apache.slide.security.AccessDeniedException;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.LinkedObjectNotFoundException;


/**
 * Slide user quota content interceptor class.
 * 
 * @author <a href="mailto:[EMAIL PROTECTED]";>Jean-Philippe Courson</a>
 */
public class UserQuotaContentInterceptor extends ContentInterceptor {

    
    // --------------------------------------------------------- Public methods

    
    /**
     * That method will be called just before storing content.
     *
     * @param token Slide's token
     * @param revisionDescriptors New node revision descriptors
     * @param revisionDescriptor New node revision descriptor
     * @param revisionContent New node revision content
     * @param contentHelper Content helper
     * @param namespaceConfig Namespace configuration
     */
    public void preStoreContent(SlideToken token, 
                                NodeRevisionDescriptors revisionDescriptors,
                                NodeRevisionDescriptor revisionDescriptor,
                                NodeRevisionContent revisionContent,
                                Content contentHelper,
                                NamespaceConfig namespaceConfig)
        throws InsufficientStorageException, AccessDeniedException,
               ObjectNotFoundException, LinkedObjectNotFoundException,
               ObjectLockedException, ServiceAccessException {

        // if there is no content
        if(revisionContent == null) return;

        // retrieve user's node
        String userUri = getUserUri(token, namespaceConfig);
        NodeRevisionDescriptors userRevisionDescriptors =
            contentHelper.retrieve(token, userUri);
        NodeRevisionDescriptor userRevisionDescriptor = null;
        try {
            userRevisionDescriptor =
                contentHelper.retrieve(token,userRevisionDescriptors);
        }
        catch(RevisionDescriptorNotFoundException e) {
            // should never happen
        }

        // should requests with null contentLength headers be accepted ?
        String parameter = namespaceConfig.getParameter("allowUnknownSizeContent"); 
        boolean allowUnknownSizeContent = Boolean.valueOf(parameter).booleanValue();

        // check user's quota
        check(userRevisionDescriptors, userRevisionDescriptor,
              revisionDescriptors, revisionDescriptor, namespaceConfig);

        // if content is overwritten, substract old contentLength
        cleanBeforeOverwriting(userRevisionDescriptors, userRevisionDescriptor,
                               revisionDescriptors, token, contentHelper);
    }
    
    
    /**
     * That method will be called just after storing content.
     *
     * @param token Slide's token
     * @param revisionDescriptors New node revision descriptors
     * @param revisionDescriptor New node revision descriptor
     * @param revisionContent New node revision content
     * @param contentHelper Content helper
     * @param namespaceConfig Namespace configuration
     */
    public void postStoreContent(SlideToken token, 
                                 NodeRevisionDescriptors revisionDescriptors,
                                 NodeRevisionDescriptor revisionDescriptor,
                                 NodeRevisionContent revisionContent,
                                 Content contentHelper,
                                 NamespaceConfig namespaceConfig)
        throws InsufficientStorageException, AccessDeniedException,
               ObjectNotFoundException, LinkedObjectNotFoundException,
               ObjectLockedException, ServiceAccessException {

        // if there is no content
        if(revisionContent == null) return;

        // retrieve user's node
        String userUri = getUserUri(token, namespaceConfig);
        NodeRevisionDescriptors userRevisionDescriptors =
            contentHelper.retrieve(token, userUri);
        NodeRevisionDescriptor userRevisionDescriptor = null;
        try {
            userRevisionDescriptor =
                contentHelper.retrieve(token, userRevisionDescriptors);
        } catch(RevisionDescriptorNotFoundException e) {
            // should never happen
        }

        // check user's quota
        check(userRevisionDescriptors, userRevisionDescriptor,
              revisionDescriptors, revisionDescriptor, namespaceConfig);

        // update user's node bytesUsed properties
        update(userRevisionDescriptors, userRevisionDescriptor,
               revisionDescriptors, revisionDescriptor, true, token, contentHelper);
    }


    /**
     * That method will be called just after removing content.
     *
     * @param token Slide's token
     * @param revisionDescriptors Node revision descriptors
     * @param revisionDescriptor Node revision descriptor
     * @param revisionContent Node revision content
     * @param contentHelper Content helper
     * @param namespaceConfig Namespace configuration
     */
    protected void postRemoveContent(SlideToken token,
                                     NodeRevisionDescriptors revisionDescriptors,
                                     NodeRevisionDescriptor revisionDescriptor,
                                     Content contentHelper,
                                     NamespaceConfig namespaceConfig)
        throws InsufficientStorageException, AccessDeniedException,
               ObjectNotFoundException, LinkedObjectNotFoundException,
               ObjectLockedException, ServiceAccessException {

        // retrieve user's node
        String userUri = getUserUri(token, namespaceConfig);
        NodeRevisionDescriptors userRevisionDescriptors =
            contentHelper.retrieve(token, userUri);
        NodeRevisionDescriptor userRevisionDescriptor = null;
        try {
            userRevisionDescriptor =
                contentHelper.retrieve(token, userRevisionDescriptors);
        } catch(RevisionDescriptorNotFoundException e) {
            // should never happen
        }

        // update user's node bytesUsed properties
        update(userRevisionDescriptors, userRevisionDescriptor, revisionDescriptors,
               revisionDescriptor, false, token, contentHelper);
    }
    
   
    // -------------------------------------------------------- Private methods


    /**
     * That method used to check user's quota.
     *
     * @param userRevisionDescriptors User's node revision descriptors
     * @param userRevisionDescriptor User's node revision descriptor
     * @param revisionDescriptors New node revision descriptors
     * @param revisionDescriptor New node revision descriptor
     * @param namespaceConfig Namespace configuration
     */
    private void check(NodeRevisionDescriptors userRevisionDescriptors,
                       NodeRevisionDescriptor userRevisionDescriptor,
                       NodeRevisionDescriptors revisionDescriptors,
                       NodeRevisionDescriptor revisionDescriptor,
                       NamespaceConfig namespaceConfig)
        throws InsufficientStorageException {

        String userUri = userRevisionDescriptors.getUri();

        // retreive parameters
        // should requests with null contentLength headers be accepted ?
        String parameter = namespaceConfig.getParameter("allowUnknownSizeContent"); 
        boolean allowUnknownSizeContent = Boolean.valueOf(parameter).booleanValue();
        // could quota be exceeded ?
        parameter = namespaceConfig.getParameter("allowQuotaToBeExceeded"); 
        boolean allowQuotaToBeExceeded = Boolean.valueOf(parameter).booleanValue();
        
        // retrieve new content's length
        long contentLength = revisionDescriptor.getContentLength();
        if(contentLength < 0 && !allowUnknownSizeContent)
            throw new InsufficientStorageException("Request contentLength header is 
null",
                                                   userUri);

        // retrieve user's node quota and bytesUsed properties
        NodeProperty property = userRevisionDescriptor.getProperty("quota");
        if(property == null)
            throw new InsufficientStorageException("Quota property is null", userUri);
        long quota = Long.parseLong((String)property.getValue());
        property = userRevisionDescriptor.getProperty("bytesUsed");
        long bytesUsed = 0;
        if(property != null) bytesUsed = Long.parseLong((String)property.getValue());

        // if user's quota is exhausted throws InsufficientStorageException
        if(allowQuotaToBeExceeded) contentLength = 0;
        if(bytesUsed + contentLength > quota)
            throw new InsufficientStorageException("Quota exhausted", userUri);
    }


    /**
     * Method used to update user's node bytesUsed property.
     *
     * @param userRevisionDescriptors user's node revision descriptors
     * @param userRevisionDescriptor user's node revision descriptor
     * @param revisionDescriptors node revision descriptors
     * @param revisionDescriptor node revision descriptor
     * @param add If true we add else we substract given contentLength
     * @param token Slide's token
     * @param contentHelper Content helper
     */
    private void update(NodeRevisionDescriptors userRevisionDescriptors,
                        NodeRevisionDescriptor userRevisionDescriptor,
                        NodeRevisionDescriptors revisionDescriptors,
                        NodeRevisionDescriptor revisionDescriptor,
                        boolean add,
                        SlideToken token,
                        Content contentHelper)
        throws AccessDeniedException, ObjectNotFoundException,
               LinkedObjectNotFoundException, ObjectLockedException,
               ServiceAccessException {

        // retreive user's node uri
        String userUri = userRevisionDescriptors.getUri();

        // retrieve content's length
        long contentLength = revisionDescriptor.getContentLength();

        // retrieve user's node bytesUsed properties
        NodeProperty property = userRevisionDescriptor.getProperty("bytesUsed");
        long bytesUsed = 0;
        if(property != null) bytesUsed = Long.parseLong((String)property.getValue());

        // computes new bytesUsed value
        if(add) bytesUsed = bytesUsed + contentLength;
        else {
            bytesUsed = bytesUsed - contentLength;
            if(bytesUsed < 0) bytesUsed = 0;
        }

        // update user's node totalBytes properties
        userRevisionDescriptor.setProperty("bytesUsed", Long.toString(bytesUsed), 
true);
        try {
            contentHelper.store(token, userUri, userRevisionDescriptor, null);
        } catch(InsufficientStorageException e) {
            // should never happen
        } catch(RevisionDescriptorNotFoundException e) {
            // should never happen
        } catch(RevisionNotFoundException e) {
            // should never happen
        }
    }


    /**
     * In the case of an overwriting, this method substract the old 
     * content's contentLength from user's node bytesUsed properties.
     *
     * @param userRevisionDescriptors user's node revision descriptors
     * @param userRevisionDescriptor user's node revision descriptor
     * @param revisionDescriptors new node revision descriptors
     * @param token Slide's token
     * @param contentHelper Content helper
     */
    private void cleanBeforeOverwriting(NodeRevisionDescriptors 
userRevisionDescriptors,
                                        NodeRevisionDescriptor userRevisionDescriptor,
                                        NodeRevisionDescriptors revisionDescriptors,
                                        SlideToken token,
                                        Content contentHelper)
        throws AccessDeniedException, ObjectLockedException, ServiceAccessException {

        try {
            NodeRevisionDescriptors oldRevisionDescriptors =
                contentHelper.retrieve(token, revisionDescriptors.getUri());
            NodeRevisionDescriptor oldRevisionDescriptor =
                contentHelper.retrieve(token, oldRevisionDescriptors);
            update(userRevisionDescriptors, userRevisionDescriptor,
                   oldRevisionDescriptors, oldRevisionDescriptor, false, token, 
contentHelper);
        } catch(ObjectNotFoundException e) {
            // object was not existing, nothing to clean
        } catch(LinkedObjectNotFoundException e) {
            // object was not existing, nothing to clean
        } catch(RevisionDescriptorNotFoundException e) {
            // object was not existing, nothing to clean
        }
    }


    /**
     * Method used to build user's node uri.
     *
     * @param token Slide's token
     * @param namespaceConfig Namespace configuration
     *
     * @return user's node uri
     */
    private String getUserUri(SlideToken token, NamespaceConfig namespaceConfig) {
        StringBuffer sb = new StringBuffer(namespaceConfig.getUsersPath());
        sb.append("/");
        sb.append(token.getCredentialsToken().getPublicCredentials());
        return sb.toString();
    }


}










/*
 * $Header: 
/home/cvspublic/jakarta-slide/src/share/org/apache/slide/content/InsufficientStorageException.java,v
 1.0 2002/01/10 15:54:14 remm Exp $
 * $Revision: 1.0 $
 * $Date: 2002/01/10 15:54:14 $
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights 
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:  
 *       "This product includes software developed by the 
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written 
 *    permission, please contact [EMAIL PROTECTED]
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */ 

package org.apache.slide.content;

import org.apache.slide.util.Messages;

/**
 * User quota is exhausted.
 * 
 * @author <a href="mailto:[EMAIL PROTECTED]";>Jean-Philippe Courson</a>
 * @version $Revision: 1.0 $
 */
public class InsufficientStorageException extends ContentException {
    
    
    // ----------------------------------------------------------- Constructors
    
    
    /**
     * Constructor.
     * 
     * @param userUri Uri of the user
     */
    public InsufficientStorageException(String message, String userUri) {
        super(InsufficientStorageException.class.getName() + " : " + message + " for 
user " + userUri);
        this.userUri = userUri;
    }
    
    
    // ----------------------------------------------------- Instance Variables
    
    
    /**
     * User Uri.
     */
    private String userUri;
    
    
    // ------------------------------------------------------------- Properties
    
    
    /**
     * User Uri accessor.
     * 
     * @return String user Uri
     */
    public String getUserUri() {
        if (userUri == null) {
            return new String();
        } else {
            return userUri;
        }
    }

    
}
--- 1.0.16-origin/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java   
 Thu Nov  8 00:04:26 2001
+++ 1.0.16-modified/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java 
+ Tue Jan 15 16:01:36 2002
@@ -542,6 +542,8 @@
             return getErrorCode((ServiceAccessException)ex);
         } catch(ObjectLockedException e) {
             return WebdavStatus.SC_LOCKED;
+        } catch(InsufficientStorageException e) {
+            return WebdavStatus.SC_INSUFFICIENT_STORAGE;
         } catch(SlideException e) {
             return WebdavStatus.SC_INTERNAL_SERVER_ERROR;
         }
--- 1.0.16-origin/src/share/org/apache/slide/content/Content.java       Thu Nov  8 
00:04:26 2001
+++ 1.0.16-modified/src/share/org/apache/slide/content/Content.java     Tue Jan 15 
+15:38:15 2002
@@ -192,7 +192,8 @@
                 NodeRevisionContent revisionContent)
         throws ObjectNotFoundException, AccessDeniedException, 
         RevisionAlreadyExistException, LinkedObjectNotFoundException, 
-        ServiceAccessException, ObjectLockedException;
+        ServiceAccessException, ObjectLockedException,
+       InsufficientStorageException;
     
     
     /**
@@ -210,7 +211,7 @@
         RevisionAlreadyExistException, LinkedObjectNotFoundException, 
         ServiceAccessException, RevisionDescriptorNotFoundException, 
         ObjectLockedException, NodeNotVersionedException, 
-        BranchNotFoundException;
+        BranchNotFoundException, InsufficientStorageException;
     
     
     /**
@@ -226,7 +227,8 @@
         throws ObjectNotFoundException, AccessDeniedException, 
         LinkedObjectNotFoundException, ServiceAccessException, 
         RevisionDescriptorNotFoundException, ObjectLockedException,
-        NodeNotVersionedException, RevisionAlreadyExistException;
+        NodeNotVersionedException, RevisionAlreadyExistException,
+       InsufficientStorageException;
     
     
     /**
@@ -242,7 +244,8 @@
         throws ObjectNotFoundException, AccessDeniedException, 
         LinkedObjectNotFoundException, ServiceAccessException, 
         RevisionDescriptorNotFoundException, ObjectLockedException,
-        NodeNotVersionedException, RevisionAlreadyExistException;
+        NodeNotVersionedException, RevisionAlreadyExistException,
+       InsufficientStorageException;
     
     
     /**
@@ -263,7 +266,7 @@
         LinkedObjectNotFoundException, ServiceAccessException, 
         RevisionDescriptorNotFoundException, ObjectLockedException,
         NodeNotVersionedException, BranchNotFoundException,
-        RevisionAlreadyExistException;
+        RevisionAlreadyExistException, InsufficientStorageException;
     
     
     /**
@@ -283,7 +286,7 @@
         LinkedObjectNotFoundException, ServiceAccessException, 
         RevisionDescriptorNotFoundException, ObjectLockedException,
         NodeNotVersionedException, BranchNotFoundException,
-        RevisionAlreadyExistException;
+        RevisionAlreadyExistException, InsufficientStorageException;
     
     
     /**
@@ -299,7 +302,7 @@
         throws ObjectNotFoundException, AccessDeniedException, 
         LinkedObjectNotFoundException, ServiceAccessException, 
         RevisionDescriptorNotFoundException, ObjectLockedException, 
-        RevisionNotFoundException;
+        RevisionNotFoundException, InsufficientStorageException;
     
     
     /**
--- 1.0.16-origin/src/share/org/apache/slide/content/ContentImpl.java   Thu Nov  8 
00:04:26 2001
+++ 1.0.16-modified/src/share/org/apache/slide/content/ContentImpl.java Thu Jan 17 
+17:40:50 2002
@@ -1,5 +1,5 @@
 /*
- * $Header: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v 1.29 
2001/09/22 12:51:04 dirkv Exp $
+ * $Header: 
+/home/cvspublic/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v 
+1.29 2001/09/22 12:51:04 dirkv Exp $
  * $Revision: 1.29 $
  * $Date: 2001/09/22 12:51:04 $
  *
@@ -88,6 +88,7 @@
     protected static final int PRE_STORE = 0;
     protected static final int POST_STORE = 1;
     protected static final int POST_RETRIEVE = 2;
+    protected static final int POST_REMOVE = 3;
     
     
     // ----------------------------------------------------------- Constructors
@@ -258,8 +259,13 @@
             (objectUri, revisionNumber);
         
         // Invoke interceptors
+       try {
         invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                            null, POST_RETRIEVE);
+       }
+       catch(InsufficientStorageException e) {
+           // could not happen here
+       }
         
         return revisionDescriptor;
         
@@ -337,8 +343,13 @@
                                                          revisionDescriptor);
         
         // Invoke interceptors
+       try {
         invokeInterceptors(token, null, revisionDescriptor,
                            revisionContent, POST_RETRIEVE);
+       }
+       catch(InsufficientStorageException e) {
+           // could not happen here
+       }
         
         return revisionContent;
     }
@@ -400,7 +411,8 @@
                        NodeRevisionContent revisionContent)
         throws ObjectNotFoundException, AccessDeniedException,
         RevisionAlreadyExistException, LinkedObjectNotFoundException,
-        ServiceAccessException, ObjectLockedException {
+        ServiceAccessException, ObjectLockedException,
+       InsufficientStorageException {
         
         // Retrieve the associated object
         ObjectNode associatedObject = 
@@ -501,8 +513,7 @@
             if (!revisionDescriptors.hasRevisions()) {
                 
                 // Invoke interceptors
-                invokeInterceptors(token, revisionDescriptors,
-                                   revisionDescriptor,
+               invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                                    revisionContent, PRE_STORE);
                 
                 if (revisionContent != null) {
@@ -540,8 +551,7 @@
                     } // end of merge
                     
                     // Invoke interceptors
-                    invokeInterceptors(token, revisionDescriptors,
-                                       revisionDescriptor,
+                   invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                                        revisionContent, PRE_STORE);
                     
                     if (revisionContent != null) {
@@ -570,8 +580,7 @@
                     // HAS revisions.
                     
                     // Invoke interceptors
-                    invokeInterceptors(token, revisionDescriptors,
-                                       revisionDescriptor,
+                   invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                                        revisionContent, PRE_STORE);
                     
                     objectUri.getStore()
@@ -597,7 +606,6 @@
         // Invoke interceptors
         invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                            revisionContent, POST_STORE);
-        
     }
     
     
@@ -616,7 +624,7 @@
         RevisionAlreadyExistException, LinkedObjectNotFoundException,
         ServiceAccessException, RevisionDescriptorNotFoundException,
         ObjectLockedException, NodeNotVersionedException,
-        BranchNotFoundException {
+        BranchNotFoundException, InsufficientStorageException {
         
         Uri objectUri = namespace.getUri(token, strUri);
         
@@ -650,7 +658,8 @@
         throws ObjectNotFoundException, AccessDeniedException,
         LinkedObjectNotFoundException, ServiceAccessException,
         RevisionDescriptorNotFoundException, ObjectLockedException,
-        NodeNotVersionedException, RevisionAlreadyExistException {
+        NodeNotVersionedException, RevisionAlreadyExistException, 
+       InsufficientStorageException {
         
         fork(token, strUri, branchName,
              basedOnRevisionDescriptor.getRevisionNumber());
@@ -671,7 +680,8 @@
         throws ObjectNotFoundException, AccessDeniedException,
         LinkedObjectNotFoundException, ServiceAccessException,
         RevisionDescriptorNotFoundException, ObjectLockedException,
-        NodeNotVersionedException, RevisionAlreadyExistException {
+        NodeNotVersionedException, RevisionAlreadyExistException,
+       InsufficientStorageException {
         
         if (branchName.equals(NodeRevisionDescriptors.MAIN_BRANCH))
             return;
@@ -751,7 +761,6 @@
         invokeInterceptors(token, revisionDescriptors,
                            basedOnRevisionDescriptor,
                            basedOnRevisionContent, POST_STORE);
-        
     }
     
     
@@ -773,7 +782,7 @@
         LinkedObjectNotFoundException, ServiceAccessException,
         RevisionDescriptorNotFoundException, ObjectLockedException,
         NodeNotVersionedException, BranchNotFoundException,
-        RevisionAlreadyExistException {
+        RevisionAlreadyExistException, InsufficientStorageException {
         
         merge(token, strUri, mainBranch.getBranchName(),
               branch.getBranchName(), newRevisionDescriptor, revisionContent);
@@ -798,7 +807,7 @@
         LinkedObjectNotFoundException, ServiceAccessException,
         RevisionDescriptorNotFoundException, ObjectLockedException,
         NodeNotVersionedException, BranchNotFoundException,
-        RevisionAlreadyExistException {
+        RevisionAlreadyExistException, InsufficientStorageException {
         
         // Retrieve the associated object
         ObjectNode associatedObject = 
@@ -873,7 +882,6 @@
         // Invoke interceptors
         invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor,
                            revisionContent, POST_STORE);
-        
     }
     
     
@@ -890,7 +898,7 @@
         throws ObjectNotFoundException, AccessDeniedException,
         LinkedObjectNotFoundException, ServiceAccessException,
         RevisionDescriptorNotFoundException, ObjectLockedException,
-        RevisionNotFoundException {
+        RevisionNotFoundException, InsufficientStorageException {
         
         // Retrieve the associated object
         ObjectNode associatedObject = 
@@ -946,7 +954,6 @@
         // Invoke interceptors
         invokeInterceptors(token, revisionDescriptors, revisionDescriptor,
                            revisionContent, POST_STORE);
-        
     }
     
     
@@ -981,7 +988,6 @@
         Uri objectUri = namespace.getUri(token, revisionDescriptors.getUri());
         
         objectUri.getStore().removeRevisionDescriptors(objectUri);
-        
     }
     
     
@@ -1042,6 +1048,17 @@
         objectUri.getStore()
             .removeRevisionDescriptor(objectUri, revisionNumber);
         
+
+        // Invoke interceptors
+       try {
+           NodeRevisionDescriptors revisionDescriptors =
+               objectUri.getStore().retrieveRevisionDescriptors(objectUri);
+           invokeInterceptors(token, revisionDescriptors,
+                              revisionDescriptor, null, POST_REMOVE);
+       }
+       catch(InsufficientStorageException e) {
+           // could not happen here
+       }
     }
     
     
@@ -1064,7 +1081,8 @@
         throws ObjectNotFoundException, AccessDeniedException,
         RevisionAlreadyExistException, LinkedObjectNotFoundException,
         ServiceAccessException, RevisionDescriptorNotFoundException,
-        ObjectLockedException, NodeNotVersionedException {
+        ObjectLockedException, NodeNotVersionedException,
+       InsufficientStorageException {
         
         // Retrieve the associated object
         ObjectNode associatedObject = 
@@ -1160,7 +1178,6 @@
         // Invoke interceptors
         invokeInterceptors(token, revisionDescriptors, newRevisionDescriptor,
                            revisionContent, POST_STORE);
-        
     }
     
     
@@ -1187,7 +1204,11 @@
     protected void invokeInterceptors
         (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
          NodeRevisionDescriptor revisionDescriptor,
-         NodeRevisionContent revisionContent, int type) {
+         NodeRevisionContent revisionContent, int type)
+       throws AccessDeniedException, ObjectNotFoundException,
+              LinkedObjectNotFoundException, ObjectLockedException,
+              InsufficientStorageException, ServiceAccessException {
+
         ContentInterceptor[] contentInterceptors =
             namespace.getContentInterceptors();
         for (int i = 0; i < contentInterceptors.length; i++) {
@@ -1195,18 +1216,26 @@
                 case PRE_STORE:
                     contentInterceptors[i].preStoreContent
                         (token, revisionDescriptors,
-                         revisionDescriptor, revisionContent);
+                    revisionDescriptor, revisionContent,
+                    this, namespaceConfig);
                     break;
                 case POST_STORE:
                     contentInterceptors[i].postStoreContent
                         (token, revisionDescriptors,
-                         revisionDescriptor, revisionContent);
+                    revisionDescriptor, revisionContent,
+                    this, namespaceConfig);
                     break;
                 case POST_RETRIEVE:
                     contentInterceptors[i].postRetrieveContent
                         (token, revisionDescriptors,
                          revisionDescriptor, revisionContent);
                     break;
+           case POST_REMOVE:
+               contentInterceptors[i].postRemoveContent
+                   (token, revisionDescriptors,
+                    revisionDescriptor, this,
+                    namespaceConfig);
+               break;
             }
         }
     }
--- 1.0.16-origin/src/share/org/apache/slide/common/XMLUnmarshaller.java        Thu 
Nov  8 00:04:26 2001
+++ 1.0.16-modified/src/share/org/apache/slide/common/XMLUnmarshaller.java      Tue 
+Jan 15 15:38:37 2002
@@ -371,6 +371,11 @@
                     (e.toString(),LOG_CHANNEL,Logger.WARNING);
             } catch (ObjectLockedException e) {
                 // Ignore
+           } catch(InsufficientStorageException e) {
+                // Should not happen
+                accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
+                accessToken.getLogger().log
+                    (e.toString(),LOG_CHANNEL,Logger.WARNING);
             }
 
         } else {
@@ -388,8 +393,12 @@
                 accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
                 accessToken.getLogger().log
                     (e.toString(),LOG_CHANNEL,Logger.WARNING);
+            } catch(InsufficientStorageException e) {
+                // Should not happen
+                accessToken.getLogger().log(e,LOG_CHANNEL,Logger.WARNING);
+                accessToken.getLogger().log
+                    (e.toString(),LOG_CHANNEL,Logger.WARNING);
             }
-
         }
         
     }

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

Reply via email to