juergen     02/04/04 03:43:07

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        MoveMethod.java
  Log:
  Update <checked-out> set of associated VR in case a checked-out VCR has been moved.
  (ralf)
  
  Revision  Changes    Path
  1.23      +88 -5     
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java
  
  Index: MoveMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MoveMethod.java   4 Apr 2002 06:26:35 -0000       1.22
  +++ MoveMethod.java   4 Apr 2002 11:43:07 -0000       1.23
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v
 1.22 2002/04/04 06:26:35 juergen Exp $
  - * $Revision: 1.22 $
  - * $Date: 2002/04/04 06:26:35 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MoveMethod.java,v
 1.23 2002/04/04 11:43:07 juergen Exp $
  + * $Revision: 1.23 $
  + * $Date: 2002/04/04 11:43:07 $
    *
    * ====================================================================
    *
  @@ -81,6 +81,11 @@
   import org.apache.slide.webdav.util.ViolatedPrecondition;
   import org.apache.slide.webdav.util.UriHandler;
   import org.apache.slide.webdav.util.DeltavConstants;
  +import org.apache.slide.webdav.util.XMLValue;
  +import org.apache.slide.webdav.util.VersioningHelper;
  +import org.apache.slide.webdav.util.PropertyHelper;
  +
  +import org.jdom.JDOMException;
   
   import org.jdom.output.XMLOutputter;
   
  @@ -90,9 +95,21 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
    * @author Juergen Pill
    */
  -public class MoveMethod extends AbstractMultistatusResponseMethod implements 
CopyListener {
  +public class MoveMethod extends AbstractMultistatusResponseMethod implements 
DeltavConstants, DeleteListener, CopyListener {
       
       
  +    /**
  +     * The VersioningHelper used by this instance.
  +     */
  +    protected VersioningHelper versioningHelper = null;
  +    
  +    /**
  +     * The URI of the VR associated with the checked-out VCR which is target
  +     * of the delete operation used in {@link #beforeDelete beforeDelete()} and
  +     * {@link #afterDelete afterDelete()}.
  +     */
  +    protected String uriOfAssociatedVR = null;
  +    
       
       // ----------------------------------------------------------- Constructors
       
  @@ -107,6 +124,11 @@
       public MoveMethod(NamespaceAccessToken token, HttpServletRequest req,
                         HttpServletResponse resp, WebdavServletConfig config) {
           super(token, req, resp, config);
  +        versioningHelper = VersioningHelper.getVersioningHelper(slideToken,
  +                                                                token,
  +                                                                req,
  +                                                                resp,
  +                                                                config);
       }
       
       
  @@ -135,7 +157,7 @@
           }
           
           try {
  -            macro.move(slideToken, sourceUri, destinationUri, macroParameters, 
this, null);
  +            macro.move(slideToken, sourceUri, destinationUri, macroParameters, 
this, this);
               if (overwrite) {
                   resp.setStatus(WebdavStatus.SC_NO_CONTENT);
               } else {
  @@ -196,6 +218,8 @@
           }
       }
       
  +    // ------------------------------------------------------ Interface CopyListener
  +    
       /**
        * This method is called prior to copying the resource associated by
        * the given <code>sourceUri</code>. The copy can be prohibited by
  @@ -236,6 +260,65 @@
        */
       public void afterCopy(String sourceUri, String destinationUri) throws 
SlideException {
           
  +        uriOfAssociatedVR = versioningHelper.getUriOfAssociatedVR(destinationUri);
  +        if (uriOfAssociatedVR != null) {
  +            
  +            // add the copy to the <checkout-set> of the associated VR
  +            NodeRevisionDescriptors revisionDescriptors =
  +                versioningHelper.retrieveRevisionDescriptors(uriOfAssociatedVR);
  +            NodeRevisionDescriptor revisionDescriptor =
  +                
versioningHelper.retrieveLatestRevisionDescriptor(uriOfAssociatedVR, 
revisionDescriptors);
  +            try {
  +                PropertyHelper.addHrefToProperty(revisionDescriptor, 
P_CHECKOUT_SET, destinationUri);
  +                content.store(slideToken, revisionDescriptors.getUri(), 
revisionDescriptor, null);
  +            } catch (JDOMException e) {}
  +        }
  +    }
  +    
  +    // ------------------------------------------------------ Interface 
DeleteListener
  +    
  +    /**
  +     * This method is called prior to deleting the resource associated by
  +     * the given <code>targetUri</code>. The deletion can be prohibited by
  +     * throwing a SlideException.
  +     *
  +     * @param      targetUri       the Uri of the resource that will be deleted.
  +     *
  +     * @throws     SlideException  this Exception will be passed to the caller
  +     *                             of the Macro helper (contained in the
  +     *                             MacroDeleteException.
  +     */
  +    public void beforeDelete(String targetUri) throws SlideException {
  +        
  +        uriOfAssociatedVR = versioningHelper.getUriOfAssociatedVR(targetUri);
  +    }
  +    
  +    
  +    /**
  +     * This method is called after deleting the resource associated by
  +     * the given <code>targetUri</code>.
  +     *
  +     * @param      targetUri       the Uri of the resource that will be deleted.
  +     *
  +     * @throws     SlideException  this Exception will be passed to the caller
  +     *                             of the Macro helper (contained in the
  +     *                             MacroDeleteException.
  +     */
  +    public void afterDelete(String targetUri) throws SlideException {
  +        
  +        if (uriOfAssociatedVR != null) {
  +            
  +            // remove the deleted VCR from the <checkout-set> from the
  +            // associated VR
  +            NodeRevisionDescriptors revisionDescriptors =
  +                versioningHelper.retrieveRevisionDescriptors(uriOfAssociatedVR);
  +            NodeRevisionDescriptor revisionDescriptor =
  +                
versioningHelper.retrieveLatestRevisionDescriptor(uriOfAssociatedVR, 
revisionDescriptors);
  +            try {
  +                PropertyHelper.removeHrefFromProperty(revisionDescriptor, 
P_CHECKOUT_SET, targetUri);
  +                content.store(slideToken, revisionDescriptors.getUri(), 
revisionDescriptor, null);
  +            } catch (JDOMException e) {}
  +        }
       }
       
       
  
  
  

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

Reply via email to