pnever      2002/07/13 09:59:50

  Modified:    src/webdav/server/org/apache/slide/webdav/util
                        VersioningHelper.java
  Log:
  Fixed bug in uncheckout; also, backup revisions 0.0 are now removed after
  checkin or uncheckout.
  
  Revision  Changes    Path
  1.62      +70 -17    
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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- VersioningHelper.java     11 Jul 2002 14:57:08 -0000      1.61
  +++ VersioningHelper.java     13 Jul 2002 16:59:50 -0000      1.62
  @@ -770,7 +770,7 @@
               NodeRevisionDescriptors vhrNrds = content.retrieve(sToken, cinhUri);
               
               // do the checkout
  -            backupProperties(rNrds, rNrd);
  +            backupSpecificLiveProperties(rNrds, rNrd);
               rNrd.removeProperty( cinProp );
               rNrd.setProperty(
                   new NodeProperty(P_CHECKED_OUT, cinProp.getValue()) );
  @@ -1019,17 +1019,17 @@
           NodeRevisionDescriptor coutNrd = content.retrieve(sToken, coutNrds, 
coutNrn);
           NodeRevisionContent coutNrc = content.retrieve( sToken, coutNrds, coutNrd );
           
  -        NodeRevisionDescriptors vhrNrds = content.retrieve(sToken, coutUri);
  +        // update VCR to previous VR
  +        rNrd.removeProperty( P_CHECKED_OUT );
  +        update( rNrds, rNrd, coutNrds, coutNrd );
           
  -        // restore revision descriptor
  -        restoreProperties(rNrds, rNrd);
  -        rNrd.setLastModified(new Date());
  -        rNrd.setProperty(new NodeProperty(P_CHECKED_IN, coutProp.getValue()) );
  -        NodeRevisionContent oldContent = new NodeRevisionContent();
  -        oldContent.setContent(coutNrc.getContentBytes());
  +        // restore some live properties
  +        restoreSpecificLiveProperties( rNrds, rNrd );
           
           // Store changes
  -        content.store( sToken, rNrds.getUri(), rNrd, oldContent);
  +        content.store( sToken, rNrds.getUri(), rNrd, null ); // revisionContent=null
  +        // remove the hidden 0.0 revision
  +        content.remove( sToken, rNrds.getUri(), NodeRevisionNumber.HIDDEN_0_0 );
       }
       
       /**
  @@ -1184,6 +1184,10 @@
               // Store changes
               if( keepCheckedOut || !isWorkingResource ) {
                   content.store( sToken, rUri, rNrd, null ); //revisionContent=null
  +                // remove the hidden 0.0 revision and create new one if 
keepCheckedOut
  +                content.remove( sToken, rUri, NodeRevisionNumber.HIDDEN_0_0 );
  +                if( keepCheckedOut )
  +                    backupSpecificLiveProperties( rNrds, rNrd );
               }
               else {
                   // remove the WR
  @@ -1371,7 +1375,6 @@
           // ***************************************
           // TODO:
           // 1) Preconditions; Problem: not specified formally.
  -        // 2) Remove Tamino-specifics; invent some kind of "store-proprietary" live 
props
           // ***************************************
           
           ResourceKind vrResourceKind = VersionImpl.getInstance();
  @@ -1420,8 +1423,7 @@
       
       /**
        * Backups the properties of the given <code>revisionDescriptor</code>
  -     * at the {@link #VCR_BACKUP_REVISION_NUMBER special revision} of the
  -     * NodeRevisionDescriptors of the VCR.
  +     * at the 0.0 revision of the NodeRevisionDescriptors of the VCR.
        *
        * @param      revisionDescriptors         the NodeRevisionDescriptors of the
        *                                         VCR to backup.
  @@ -1444,9 +1446,37 @@
       }
       
       /**
  +     * Backups specific live properties of the given <code>revisionDescriptor</code>
  +     * at the 0.0 revision of the NodeRevisionDescriptors of the VCR.
  +     *
  +     * @param      rNrds         the NodeRevisionDescriptors of the
  +     *                           VCR to backup.
  +     * @param      rNrd          the NodeRevisionDescriptor of the
  +     *                           VCR to backup.
  +     *
  +     * @throws     SlideException
  +     */
  +    protected void backupSpecificLiveProperties(NodeRevisionDescriptors rNrds, 
NodeRevisionDescriptor rNrd) throws SlideException {
  +        
  +        NodeRevisionDescriptor backupNrd =
  +            new NodeRevisionDescriptor( NodeRevisionNumber.HIDDEN_0_0, "backup", 
new Vector(), new Hashtable() );
  +
  +        backupNrd.setProperty( rNrd.getProperty(P_AUTO_VERSION) );
  +        backupNrd.setProperty( rNrd.getProperty(P_OWNER) );
  +        backupNrd.setProperty( rNrd.getProperty(P_COMMENT) );
  +        
  +        try {
  +            content.retrieve( sToken, rNrds, NodeRevisionNumber.HIDDEN_0_0 );
  +            content.store( sToken, rNrds.getUri(), backupNrd, null );
  +        }
  +        catch (RevisionDescriptorNotFoundException e) {
  +            content.create( sToken, rNrds.getUri(), null,  backupNrd, null ); // 
branch=null, revisionContent=null
  +        }
  +    }
  +    
  +    /**
        * Restores the properties of the given <code>revisionDescriptor</code>
  -     * from the {@link #VCR_BACKUP_REVISION_NUMBER special revision} of the
  -     * NodeRevisionDescriptors of the VCR.
  +     * from the hidden 0.0 revision of the NodeRevisionDescriptors of the VCR.
        *
        * @param      revisionDescriptors         the NodeRevisionDescriptors of the
        *                                         VCR to restore.
  @@ -1461,6 +1491,29 @@
               content.retrieve(sToken, revisionDescriptors, 
NodeRevisionNumber.HIDDEN_0_0);
           copyRevisionDescriptor(backup, revisionDescriptor);
           content.store(sToken, revisionDescriptors.getUri(), revisionDescriptor, 
null);
  +    }
  +    
  +    /**
  +     * Restores specific live properties of the given 
<code>revisionDescriptor</code>
  +     * from the hidden 0.0 revision of the NodeRevisionDescriptors of the VCR.
  +     *
  +     * @param      rNrds         the NodeRevisionDescriptors of the
  +     *                           VCR to restore.
  +     * @param      rNrd          the NodeRevisionDescriptor of the
  +     *                           VCR to restore.
  +     *
  +     * @throws     SlideException
  +     */
  +    protected void restoreSpecificLiveProperties(NodeRevisionDescriptors rNrds, 
NodeRevisionDescriptor rNrd) throws SlideException {
  +        
  +        NodeRevisionDescriptor backupNrd =
  +            content.retrieve(sToken, rNrds, NodeRevisionNumber.HIDDEN_0_0);
  +        
  +        rNrd.setProperty( backupNrd.getProperty(P_AUTO_VERSION) );
  +        rNrd.setProperty( backupNrd.getProperty(P_OWNER) );
  +        rNrd.setProperty( backupNrd.getProperty(P_COMMENT) );
  +        
  +        content.store(sToken, rNrds.getUri(), rNrd, null);
       }
       
       /**
  
  
  

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

Reply via email to