You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by lu...@apache.org on 2004/11/08 09:39:18 UTC

cvs commit: jakarta-slide/src/share/org/apache/slide/macro MacroImpl.java

luetzkendorf    2004/11/08 00:39:18

  Modified:    src/share/org/apache/slide/macro Tag:
                        SLIDE_2_1_RELEASE_BRANCH MacroImpl.java
  Log:
  fixed a bug for move where a descendant of the desination is locked. (removed
  silly writeLock and introduced Olivers recursiveLockCheck)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.41.2.3  +44 -45    jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java
  
  Index: MacroImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/macro/MacroImpl.java,v
  retrieving revision 1.41.2.2
  retrieving revision 1.41.2.3
  diff -u -r1.41.2.2 -r1.41.2.3
  --- MacroImpl.java	18 Oct 2004 08:42:57 -0000	1.41.2.2
  +++ MacroImpl.java	8 Nov 2004 08:39:18 -0000	1.41.2.3
  @@ -35,7 +35,7 @@
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.SlideException;
   import org.apache.slide.common.SlideToken;
  -import org.apache.slide.common.SlideTokenWrapper;
  +import org.apache.slide.common.Uri;
   import org.apache.slide.content.Content;
   import org.apache.slide.content.NodeProperty;
   import org.apache.slide.content.NodeRevisionContent;
  @@ -51,6 +51,7 @@
   import org.apache.slide.security.NodePermission;
   import org.apache.slide.security.Security;
   import org.apache.slide.store.Store;
  +import org.apache.slide.structure.ActionNode;
   import org.apache.slide.structure.LinkedObjectNotFoundException;
   import org.apache.slide.structure.ObjectHasChildrenException;
   import org.apache.slide.structure.ObjectNode;
  @@ -200,16 +201,6 @@
               throw e;
           }
           
  -        // try to writeLock the complete destination tree
  -        try {
  -            writeLock(token, destinationUri, true);
  -        }
  -        catch( ServiceAccessException x ) {
  -            e.addException(x);
  -            throw e;
  -        }
  -        catch (SlideException x) {}; // ignore silently
  -        
           Map alreadyCopied = new HashMap(); // maps source-UURI -> destination-URI
           parameters.setParameter( ALREADY_COPIED, alreadyCopied );
           
  @@ -228,26 +219,37 @@
           }
       }
       
  -    /**
  -     * WriteLock the specified URI
  -     *
  -     * @param    token               a  SlideToken
  -     * @param    uri                 a  String
  -     * @param    recursive           a  boolean
  -     * @throws   SlideException
  -     */
  -    private void writeLock(SlideToken token, String uri, boolean recursive) throws SlideException {
  -        if (!token.isForceStoreEnlistment()) {
  -            token = new SlideTokenWrapper(token);
  -            token.setForceStoreEnlistment(true);
  -        }
  -        ObjectNode onode = structureHelper.retrieve(token, uri);
  -        if (onode != null && recursive) {
  -            Iterator i = onode.getChildren().iterator();
  +    protected void recursiveAccessCheck(Uri uri, ActionNode action) throws SlideException,
  +    AccessDeniedException {
  +        try {
  +            ObjectNode node = uri.getStore().retrieveObject(uri);
  +            securityHelper.checkCredentials(uri.getToken(), node, action);
  +            Iterator i = node.getChildren().iterator();
               while (i.hasNext()) {
  -                writeLock( token, (String)i.next(), true );
  +                String child = (String) i.next();
  +                Uri childUri = namespace.getUri(uri.getToken(), child);
  +                recursiveAccessCheck(childUri, action);
               }
  -            
  +        } catch (ObjectNotFoundException onfe) {
  +            // if it is not there it access can not be denied
  +        }
  +    }
  +
  +    protected void recursiveLockCheck(Uri uri) throws SlideException,
  +            ObjectLockedException
  +    {
  +        try {
  +            ObjectNode node = uri.getStore().retrieveObject(uri);
  +            ActionNode action = namespaceConfig.getCreateObjectAction();
  +            lockHelper.checkLock(uri.getToken(), node, action);
  +            Iterator i = node.getChildren().iterator();
  +            while (i.hasNext()) {
  +                String child = (String) i.next();
  +                Uri childUri = namespace.getUri(uri.getToken(), child);
  +                recursiveLockCheck(childUri);
  +            }
  +        } catch (ObjectNotFoundException onfe) {
  +            // if it is not there it can not be locked
           }
       }
       
  @@ -267,16 +269,16 @@
               throw e;
           }
           
  -        // try to writeLock the complete destination tree
  +        Uri source = namespace.getUri(token, sourceUri);
  +        Uri destination = namespace.getUri(token, destinationUri);
           try {
  -            writeLock(token, destinationUri, true);
  -        }
  -        catch( ServiceAccessException x ) {
  -            e.addException(x);
  +            recursiveLockCheck(source);
  +            recursiveLockCheck(destination);
  +        } catch (SlideException ex) {
  +            e.addException(ex);
               throw e;
           }
  -        catch (SlideException x) {}; // ignore silently
  -        
  +
           if (parameters.isDeleteCreate()) {
               try {
                   // If the object we want to overwrite exists, we delete is first
  @@ -326,7 +328,6 @@
               if (copyListener != null) {
                   copyListener.beforeCopy(sourceUri, destinationUri, true);
               }
  -            
               structureHelper.addBinding( token, destinationParentNode, destinationSegment, sourceNode );
               structureHelper.removeBinding( token, sourceParentNode, sourceSegment );
           }
  @@ -729,11 +730,9 @@
       
       private boolean destinationExists(SlideToken token, String destinationUri) throws ServiceAccessException, LinkedObjectNotFoundException, RevisionDescriptorNotFoundException, ObjectLockedException, AccessDeniedException, VetoException {
           boolean destinationExists = true;
  -        NodeRevisionDescriptor destinationNrd = null;
           try {
  -            destinationNrd =
  -                contentHelper.retrieve(token,
  -                                       contentHelper.retrieve(token, destinationUri));
  +            contentHelper.retrieve(token, contentHelper.retrieve(
  +                    token, destinationUri));
           }
           catch (ObjectNotFoundException x) {
               destinationExists = false;
  
  
  

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