juergen     02/04/15 04:04:57

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        DeleteMethod.java
               src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java
  Log:
  Update <workspace-checkout-set> correctly (since in our implementation it is not 
computed).
  (ralf)
  
  Revision  Changes    Path
  1.19      +47 -3     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java
  
  Index: DeleteMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DeleteMethod.java 12 Apr 2002 14:23:18 -0000      1.18
  +++ DeleteMethod.java 15 Apr 2002 11:04:56 -0000      1.19
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v
 1.18 2002/04/12 14:23:18 juergen Exp $
  - * $Revision: 1.18 $
  - * $Date: 2002/04/12 14:23:18 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DeleteMethod.java,v
 1.19 2002/04/15 11:04:56 juergen Exp $
  + * $Revision: 1.19 $
  + * $Date: 2002/04/15 11:04:56 $
    *
    * ====================================================================
    *
  @@ -85,6 +85,9 @@
   import org.apache.slide.webdav.util.XMLValue;
   import org.apache.slide.webdav.util.VersioningHelper;
   import org.apache.slide.webdav.util.PropertyHelper;
  +import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
  +import org.apache.slide.webdav.util.resourcekind.ResourceKind;
  +import org.apache.slide.webdav.util.resourcekind.CheckedOutVersionControlled;
   import org.apache.slide.util.Configuration;
   
   import org.jdom.Element;
  @@ -136,6 +139,13 @@
        */
       protected String uriOfAssociatedVR = null;
       
  +    /**
  +     * The URI of the workspace associated with the checked-out VCR which is target
  +     * of the delete operation used in {@link #beforeDelete beforeDelete()} and
  +     * {@link #afterDelete afterDelete()}.
  +     */
  +    protected String uriOfAssociatedWorkspace = null;
  +    
       // ----------------------------------------------------------- Constructors
       
       
  @@ -246,6 +256,7 @@
        *                             MacroDeleteException.
        */
       public void beforeDelete(String targetUri) throws SlideException {
  +        
           if(Configuration.useVersionControl()) {
           
               uriHandler = UriHandler.getUriHandler(token, targetUri);
  @@ -256,7 +267,23 @@
                                                        targetUri);
               }
           
  +            uriOfAssociatedVR = null;
  +            uriOfAssociatedWorkspace = null;
  +            
  +            NodeRevisionDescriptors revisionDescriptors =
  +                versioningHelper.retrieveRevisionDescriptors(targetUri);
  +            NodeRevisionDescriptor revisionDescriptor =
  +                versioningHelper.retrieveLatestRevisionDescriptor(targetUri, 
revisionDescriptors);
  +            ResourceKind resourceKind = 
AbstractResourceKind.determineResourceKind(revisionDescriptor);
  +            if (resourceKind instanceof CheckedOutVersionControlled) {
  +                
               uriOfAssociatedVR = versioningHelper.getUriOfAssociatedVR(targetUri);
  +                
  +                NodeProperty workspaceProperty = 
revisionDescriptor.getProperty(P_WORKSPACE);
  +                if ( (workspaceProperty != null) && (workspaceProperty.getValue() 
!= null) ) {
  +                    uriOfAssociatedWorkspace = 
versioningHelper.getElementValue(workspaceProperty.getValue().toString());
  +                }
  +            }
           }
       }
       
  @@ -273,6 +300,8 @@
        */
       public void afterDelete(String targetUri) throws SlideException {
           
  +        if( Configuration.useVersionControl() ) {
  +            
           if (uriOfAssociatedVR != null) {
               
               // remove the deleted VCR from the <checkout-set> from the
  @@ -286,8 +315,23 @@
                   content.store(slideToken, revisionDescriptors.getUri(), 
revisionDescriptor, null);
               } catch (JDOMException e) {}
           }
  +            
  +            if (uriOfAssociatedWorkspace != null) {
  +                
  +                // update <workspace-checkout-set>
  +                NodeRevisionDescriptors workspaceRevisionDescriptors =
  +                    
versioningHelper.retrieveRevisionDescriptors(uriOfAssociatedWorkspace);
  +                NodeRevisionDescriptor workspaceRevisionDescriptor =
  +                    
versioningHelper.retrieveLatestRevisionDescriptor(uriOfAssociatedWorkspace, 
workspaceRevisionDescriptors);
  +                try {
  +                    
PropertyHelper.removeHrefFromProperty(workspaceRevisionDescriptor, 
P_WORKSPACE_CHECKOUT_SET, targetUri);
  +                    content.store(slideToken, 
workspaceRevisionDescriptors.getUri(), workspaceRevisionDescriptor, null);
  +                } catch (JDOMException e) {}
  +            }
  +        }
       }
       
       
   
   }
  +
  
  
  
  1.29      +87 -3     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
  
  Index: VersioningHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- VersioningHelper.java     13 Apr 2002 14:53:01 -0000      1.28
  +++ VersioningHelper.java     15 Apr 2002 11:04:57 -0000      1.29
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
 1.28 2002/04/13 14:53:01 pnever Exp $
  - * $Revision: 1.28 $
  - * $Date: 2002/04/13 14:53:01 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
 1.29 2002/04/15 11:04:57 juergen Exp $
  + * $Revision: 1.29 $
  + * $Date: 2002/04/15 11:04:57 $
    *
    * ====================================================================
    *
  @@ -548,6 +548,18 @@
               PropertyHelper.addHrefToProperty(cinNrd, P_CHECKOUT_SET, 
rNrds.getUri());
               content.store(sToken, cinNrds.getUri(), cinNrd, null);
               
  +            // update <workspace-checkout-set>
  +            String workspaceUri = getUriOfAssociatedWorkspace(rNrds.getUri());
  +            if (workspaceUri != null) {
  +                NodeRevisionDescriptors workspaceDescriptors = 
retrieveRevisionDescriptors(workspaceUri);
  +                NodeRevisionDescriptor workspaceDescriptor = 
retrieveLatestRevisionDescriptor(workspaceUri,
  +                                                                                    
          workspaceDescriptors);
  +                PropertyHelper.addHrefToProperty(workspaceDescriptor,
  +                                                 P_WORKSPACE_CHECKOUT_SET,
  +                                                 rNrds.getUri());
  +                content.store( sToken, workspaceDescriptors.getUri(), 
workspaceDescriptor, null);
  +            }
  +            
               // do the checkout
               backupProperties(rNrds, rNrd);
               rNrd.removeProperty( cinProp );
  @@ -691,6 +703,18 @@
           PropertyHelper.removeHrefFromProperty(coutNrd, P_CHECKOUT_SET, 
rNrds.getUri());
           content.store( sToken, coutNrds.getUri(), coutNrd, null);
           
  +        // update <workspace-checkout-set>
  +        String workspaceUri = getUriOfAssociatedWorkspace(rNrds.getUri());
  +        if (workspaceUri != null) {
  +            NodeRevisionDescriptors workspaceDescriptors = 
retrieveRevisionDescriptors(workspaceUri);
  +            NodeRevisionDescriptor workspaceDescriptor = 
retrieveLatestRevisionDescriptor(workspaceUri,
  +                                                                                    
      workspaceDescriptors);
  +            PropertyHelper.removeHrefFromProperty(workspaceDescriptor,
  +                                                  P_WORKSPACE_CHECKOUT_SET,
  +                                                  rNrds.getUri());
  +            content.store( sToken, workspaceDescriptors.getUri(), 
workspaceDescriptor, null);
  +        }
  +        
           // restore revision descriptor
           restoreProperties(rNrds, rNrd);
           rNrd.setLastModified(new Date());
  @@ -762,6 +786,18 @@
               PropertyHelper.removeHrefFromProperty(vrNrdOld, P_CHECKOUT_SET, 
rNrds.getUri());
               content.store( sToken, vhrNrds.getUri(), vrNrdOld, null);
               
  +            // update <workspace-checkout-set>
  +            String workspaceUri = getUriOfAssociatedWorkspace(rNrds.getUri());
  +            if (workspaceUri != null) {
  +                NodeRevisionDescriptors workspaceDescriptors = 
retrieveRevisionDescriptors(workspaceUri);
  +                NodeRevisionDescriptor workspaceDescriptor = 
retrieveLatestRevisionDescriptor(workspaceUri,
  +                                                                                    
          workspaceDescriptors);
  +                PropertyHelper.removeHrefFromProperty(workspaceDescriptor,
  +                                                      P_WORKSPACE_CHECKOUT_SET,
  +                                                      rNrds.getUri());
  +                content.store( sToken, workspaceDescriptors.getUri(), 
workspaceDescriptor, null);
  +            }
  +            
               // Create new VR in the MAIN branch
               NodeRevisionDescriptor vrNrdNew =
                   new NodeRevisionDescriptor(req.getContentLength());
  @@ -901,6 +937,21 @@
       }
       
       /**
  +     * If the resource described by the given <code>resourceUri</code> is a
  +     * VCR contained in a workspace, this method returns the URI of the associated
  +     * workspace, otherwise <code>null</code>
  +     *
  +     * @param      resourceUri  the URI of the resource.
  +     *
  +     * @return     the URI of the associated workspace.
  +     *
  +     * @throws     SlideException
  +     */
  +    public String getUriOfAssociatedWorkspace(String resourceUri) throws 
SlideException {
  +        return getUriOfAssociatedWorkspace(nsaToken, sToken, content, resourceUri);
  +    }
  +    
  +    /**
        * Returns the URI of the resource defined by the given 
NodeRevisionDescriptor(s).
        *
        * @param      revisionDescriptors  the NodeRevisionDescriptors of the resource.
  @@ -1456,6 +1507,39 @@
           
           return vrUri;
       }
  +    
  +    /**
  +     * If the resource described by the given <code>resourceUri</code> is a
  +     * VCR contained in a workspace, this method returns the URI of the associated
  +     * workspace, otherwise <code>null</code>
  +     *
  +     * @param      nsaToken      the NamespaceAccessToken to use.
  +     * @param      sToken        the SlideToken to use.
  +     * @param      content       the Content helper to use.
  +     * @param      resourceUri   the URI of the resource.
  +     *
  +     * @return     the URI of the associated workspace.
  +     *
  +     * @throws     SlideException
  +     */
  +    public static String getUriOfAssociatedWorkspace(NamespaceAccessToken nsaToken,
  +                                                     SlideToken sToken,
  +                                                     Content content,
  +                                                     String resourceUri) throws 
SlideException {
  +        
  +        String workspaceUri = null;
  +        NodeRevisionDescriptors revisionDescriptors = 
retrieveRevisionDescriptors(nsaToken, sToken, content, resourceUri);
  +        if (!revisionDescriptors.isVersioned()) {
  +            
  +            NodeRevisionDescriptor revisionDescriptor = 
retrieveLatestRevisionDescriptor(nsaToken, sToken, content, resourceUri, 
revisionDescriptors);
  +            NodeProperty workspaceProperty = 
revisionDescriptor.getProperty(P_WORKSPACE);
  +            if ( (workspaceProperty != null) && (workspaceProperty.getValue() != 
null) ) {
  +                workspaceUri = 
getElementValue(workspaceProperty.getValue().toString());
  +            }
  +        }
  +        return workspaceUri;
  +    }
  +    
       
       /**
        * Returns the URI of the resource defined by the given 
NodeRevisionDescriptor(s).
  
  
  

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

Reply via email to