pnever      2003/09/18 04:01:43

  Modified:    src/share/org/apache/slide/content ContentImpl.java
                        NodeRevisionDescriptor.java
               src/share/org/apache/slide/structure StructureImpl.java
               src/webdav/server/org/apache/slide/webdav/util
                        PropertyHelper.java WebdavConstants.java
               src/webdav/server/org/apache/slide/webdav/util/resourcekind
                        AbstractResourceKind.java
  Log:
  Added new live properties:
  - DAV:modificationdate
  - DAV:modificationuser
  
  Reason: as DAV:getlastmodified only changes when the GET-able content
  changes, it does not change when properties are updated. Moreover,  the
  behavior for collections is unclear.
  
  The new property DAV:modificationdate
  changes when:
  - content changes
  - properties change
  - bindings of a collection change
  
  DAV.modificationuser keeps the authenticated principal how did the modification.
  
  Both properties are not yet standard but have been proposed to the WebDAV
  community.
  
  Revision  Changes    Path
  1.47      +31 -5     
jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java
  
  Index: ContentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- ContentImpl.java  18 Aug 2003 06:48:14 -0000      1.46
  +++ ContentImpl.java  18 Sep 2003 11:01:43 -0000      1.47
  @@ -532,6 +532,9 @@
                                              revisionContent);
               }
               // Now creating the revision desriptor in the store
  +            
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
  +            revisionDescriptor.setModificationUser(
  +                token.getCredentialsToken().getPublicCredentials());
               objectUri.getStore()
                   .createRevisionDescriptor(objectUri, revisionDescriptor);
               
  @@ -559,6 +562,9 @@
                                                  revisionContent);
                   }
                   // Now creating the revision desriptor in the store
  +                
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
  +                revisionDescriptor.setModificationUser(
  +                    token.getCredentialsToken().getPublicCredentials());
                   objectUri.getStore()
                       .createRevisionDescriptor(objectUri, revisionDescriptor);
                   
  @@ -605,6 +611,9 @@
                           }
                       }
                       
  +                    
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
  +                    revisionDescriptor.setModificationUser(
  +                        token.getCredentialsToken().getPublicCredentials());
                       objectUri.getStore()
                           .storeRevisionDescriptor
                           (objectUri, revisionDescriptor);
  @@ -620,6 +629,9 @@
                                          revisionDescriptor,
                                          revisionContent, PRE_STORE);
                       
  +                    
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
  +                    revisionDescriptor.setModificationUser(
  +                        token.getCredentialsToken().getPublicCredentials());
                       objectUri.getStore()
                           .createRevisionDescriptor(objectUri,
                                                     revisionDescriptor);
  @@ -798,6 +810,8 @@
                              basedOnRevisionContent, PRE_STORE);
           
           // Storing back everything
  +        // TODO: setModificationDate
  +        //       clone of NRD required??
           if (basedOnRevisionContent != null) {
               objectUri.getStore().createRevisionContent
                   (objectUri, basedOnRevisionDescriptor, basedOnRevisionContent);
  @@ -926,6 +940,9 @@
               objectUri.getStore().createRevisionContent
                   (objectUri, newRevisionDescriptor, revisionContent);
           }
  +        
newRevisionDescriptor.setModificationDate(newRevisionDescriptor.getCreationDate());
  +        newRevisionDescriptor.setModificationUser(
  +            token.getCredentialsToken().getPublicCredentials());
           objectUri.getStore().createRevisionDescriptor
               (objectUri, newRevisionDescriptor);
           objectUri.getStore().storeRevisionDescriptors
  @@ -1009,6 +1026,9 @@
                   }
               }
           }
  +        revisionDescriptor.setModificationDate(new Date());
  +        revisionDescriptor.setModificationUser(
  +            token.getCredentialsToken().getPublicCredentials());
           objectUri.getStore().storeRevisionDescriptor
               (objectUri, revisionDescriptor);
           
  @@ -1226,6 +1246,9 @@
                                          revisionContent);
           }
           // Now creating the revision desriptor in the store
  +        
newRevisionDescriptor.setModificationDate(newRevisionDescriptor.getCreationDate());
  +        newRevisionDescriptor.setModificationUser(
  +            token.getCredentialsToken().getPublicCredentials());
           objectUri.getStore()
               .createRevisionDescriptor(objectUri, newRevisionDescriptor);
           
  @@ -1300,6 +1323,9 @@
                              null, PRE_STORE);
           
           // Now creating the revision desriptor in the store
  +        
revisionDescriptor.setModificationDate(revisionDescriptor.getCreationDate());
  +        revisionDescriptor.setModificationUser(
  +            token.getCredentialsToken().getPublicCredentials());
           objectUri.getStore()
               .createRevisionDescriptor(objectUri, revisionDescriptor);
           
  
  
  
  1.29      +73 -4     
jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java
  
  Index: NodeRevisionDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/NodeRevisionDescriptor.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- NodeRevisionDescriptor.java       18 Aug 2003 06:48:14 -0000      1.28
  +++ NodeRevisionDescriptor.java       18 Sep 2003 11:01:43 -0000      1.29
  @@ -93,6 +93,8 @@
        * Creation date.
        */
       public static final String CREATION_DATE = "creationdate";
  +    public static final String MODIFICATION_DATE = "modificationdate";
  +    public static final String MODIFICATION_USER = "modificationuser";
       
       
       /**
  @@ -778,6 +780,40 @@
       
       
       /**
  +     * Modification date accessor.
  +     *
  +     * @return String modification date
  +     */
  +    public String getModificationDate() {
  +        NodeProperty modificationDate = getProperty(MODIFICATION_DATE);
  +        if (modificationDate == null) {
  +            return null;
  +        } else {
  +            if (modificationDate.getValue() instanceof Date) {
  +                return creationDateFormat.format
  +                    ((Date) modificationDate.getValue());
  +            }
  +            return modificationDate.getValue().toString();
  +        }
  +    }
  +    
  +    
  +    /**
  +     * Get the mofications user
  +     *
  +     * @return String
  +     */
  +    public String getModificationUser() {
  +        NodeProperty modificationUser = getProperty(MODIFICATION_USER);
  +        if (modificationUser == null) {
  +            return new String();
  +        } else {
  +            return (String) modificationUser.getValue();
  +        }
  +    }
  +    
  +    
  +    /**
        * Creation date accessor.
        *
        * @return String creation date
  @@ -814,6 +850,39 @@
       public void setCreationDate(Date creationDate) {
           // live property, can not be modified
           setProperty(CREATION_DATE, creationDateFormat.format(creationDate));
  +    }
  +     
  +    
  +    /**
  +     * Modification date mutator.
  +     *
  +     * @param modificationDate New modification date
  +     */
  +    public void setModificationDate(Date modificationDate) {
  +        // live property, can not be modified
  +        setProperty(MODIFICATION_DATE, creationDateFormat.format(modificationDate));
  +    }
  +     
  +    
  +    /**
  +     * Modification date mutator.
  +     *
  +     * @param modificationDate New modification date
  +     */
  +    public void setModificationDate(String modificationDate) {
  +        // live property, can not be modified
  +        setProperty(MODIFICATION_DATE, modificationDate);
  +    }
  +     
  +    
  +    /**
  +     * Modification user mutator.
  +     *
  +     * @param modificationUser New modification user
  +     */
  +    public void setModificationUser(String modificationUser) {
  +        // live property, can not be modified
  +        setProperty(MODIFICATION_USER, modificationUser);
       }
       
       
  
  
  
  1.31      +36 -10    
jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java
  
  Index: StructureImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/structure/StructureImpl.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- StructureImpl.java        16 Sep 2003 19:04:35 -0000      1.30
  +++ StructureImpl.java        18 Sep 2003 11:01:43 -0000      1.31
  @@ -63,6 +63,7 @@
   
   package org.apache.slide.structure;
   
  +import java.util.Date;
   import java.util.Enumeration;
   import java.util.Vector;
   import org.apache.slide.common.Domain;
  @@ -72,6 +73,9 @@
   import org.apache.slide.common.SlideToken;
   import org.apache.slide.common.Uri;
   import org.apache.slide.common.UriTokenizer;
  +import org.apache.slide.content.NodeRevisionDescriptor;
  +import org.apache.slide.content.NodeRevisionNumber;
  +import org.apache.slide.content.RevisionDescriptorNotFoundException;
   import org.apache.slide.lock.Lock;
   import org.apache.slide.lock.ObjectLockedException;
   import org.apache.slide.security.AccessDeniedException;
  @@ -444,7 +448,7 @@
                       parentObject.addChild(newObject);
                       //namespace.getUri(token, parentObject.getUri())
                       //.getDataSource().storeObject(parentObject, false);
  -                    store(token, parentObject);
  +                    store(token, parentObject, true);
                       store(token, newObject);
                       
                   } else {
  @@ -498,7 +502,7 @@
                   // during start up
                   if (!parentObject.hasChild(courObject)) {
                       parentObject.addChild(courObject);
  -                    store(token, parentObject);
  +                    store(token, parentObject, true);
                   }
               }
               throw new ObjectAlreadyExistsException(strUri);
  @@ -535,6 +539,14 @@
           throws ServiceAccessException, ObjectNotFoundException,
           AccessDeniedException, LinkedObjectNotFoundException {
           
  +        store(token, object, false);
  +    }
  +    
  +    
  +    public void store(SlideToken token, ObjectNode object, boolean 
setModificationDate)
  +        throws ServiceAccessException, ObjectNotFoundException,
  +        AccessDeniedException, LinkedObjectNotFoundException {
  +        
           // Checking roles
           Enumeration roles = securityHelper.getRoles(object);
           while (roles.hasMoreElements()) {
  @@ -556,7 +568,21 @@
               .checkCredentials(token, realObject,
                                 namespaceConfig.getCreateObjectAction());
           Uri realObjectUri = namespace.getUri(token, realObject.getUri());
  -        realObjectUri.getStore().storeObject(realObjectUri, object);
  +        Store store = realObjectUri.getStore();
  +        store.storeObject(realObjectUri, object);
  +        
  +        if (setModificationDate) {
  +            try {
  +                NodeRevisionDescriptor revisionDescriptor = 
store.retrieveRevisionDescriptor(realObjectUri, new NodeRevisionNumber());
  +                revisionDescriptor.setModificationDate(new Date());
  +                revisionDescriptor.setModificationUser(
  +                    token.getCredentialsToken().getPublicCredentials());
  +                store.storeRevisionDescriptor(realObjectUri, revisionDescriptor );
  +            }
  +            catch (RevisionDescriptorNotFoundException e) {
  +                // ignore silently
  +            }
  +        }
       }
       
       
  @@ -603,7 +629,7 @@
                   }
                   uri.getStore().removeObject(uri, nodeToDelete);
               }
  -            store(token, parentNode);
  +            store(token, parentNode, true);
           }
       }
       
  @@ -646,7 +672,7 @@
               }
               collectionNode.addBinding( segment, sourceNode );
               
  -            store( token, collectionNode );
  +            store( token, collectionNode, true );
               store( token, sourceNode );
           }
       }
  @@ -680,7 +706,7 @@
               collectionNode.removeChild( childNode );
               
               store( token, childNode );
  -            store( token, collectionNode );
  +            store( token, collectionNode, true );
           }
       }
   }
  
  
  
  1.52      +46 -15    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java
  
  Index: PropertyHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- PropertyHelper.java       8 Sep 2003 13:42:10 -0000       1.51
  +++ PropertyHelper.java       18 Sep 2003 11:01:43 -0000      1.52
  @@ -643,6 +643,9 @@
           else if (P_OWNER.equals(propertyName)) {
               property = new NodeProperty(propertyName, 
computeOwner(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
           }
  +        else if (P_MODIFICATIONUSER.equals(propertyName)) {
  +            property = new NodeProperty(propertyName, 
computeModificationUser(revisionDescriptors, revisionDescriptor, contextPath, 
serverURL));
  +        }
           
           return property;
       }
  @@ -1143,7 +1146,21 @@
        */
       public XMLValue computeWorkspace(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws SlideException, JDOMException {
           XMLValue result = null;
  +        
  +        UriHandler rUh = new UriHandler(revisionDescriptors.getUri());
  +        if (rUh.getAssociatedWorkspaceUri() != null) {
  +            result = new XMLValue();
  +            Element hrElm = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  +            hrElm.setText(rUh.getAssociatedWorkspaceUri());
  +            result.add(hrElm);
  +            return result;
  +        }
  +        
           NodeProperty psProp = revisionDescriptor.getProperty(P_PARENT_SET);
  +        if (psProp == null) {
  +            return new XMLValue();
  +        }
  +        
           List psUris = new ArrayList();
           XMLValue xv = new XMLValue(String.valueOf(psProp.getValue()));
           Iterator i = xv.getList().iterator();
  @@ -2112,30 +2129,45 @@
        */
       public XMLValue computeOwner(NodeRevisionDescriptors revisionDescriptors, 
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL) 
throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
           
  -        XMLValue xmlValue = new XMLValue();
  -        
           NodeProperty ownerProperty = revisionDescriptor.getProperty(P_OWNER,
                                                                       
NodeProperty.DEFAULT_NAMESPACE);
  -        String ownerHref;
  +        
  +        XMLValue xmlValue = createUserPath(ownerProperty, contextPath);
  +        
  +        return xmlValue;
  +    }
  +    
  +    public XMLValue computeModificationUser(NodeRevisionDescriptors 
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, 
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException, 
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, 
ObjectNotFoundException, LockTokenNotFoundException, JDOMException {
  +        
  +        NodeProperty modificationUserProperty = 
revisionDescriptor.getProperty(P_MODIFICATIONUSER,
  +                                                                               
NodeProperty.DEFAULT_NAMESPACE);
  +        
  +        XMLValue xmlValue = createUserPath(modificationUserProperty, contextPath);
  +        
  +        return xmlValue;
  +    }
  +    
  +    private XMLValue createUserPath(NodeProperty userProperty, String contextPath) 
throws IllegalArgumentException {
  +        XMLValue xmlValue = new XMLValue();
  +        String userHref;
           NamespaceConfig config = nsaToken.getNamespaceConfig();
           String userCollection = config.getParameter(USER_COLLECTION);
  -        if ((ownerProperty != null) && (ownerProperty.getValue()!=null) &&
  -                (!"".equals(ownerProperty.getValue().toString()))) {
  +        if ((userProperty != null) && (userProperty.getValue()!=null) &&
  +                (!"".equals(userProperty.getValue().toString()))) {
               
               if (userCollection == null){
  -                ownerHref = contextPath + config.getUsersPath() + "/" + 
ownerProperty.getValue().toString();
  +                userHref = contextPath + config.getUsersPath() + "/" + 
userProperty.getValue().toString();
               } else {
  -                ownerHref = contextPath + config.getUsersPath() + "/" + 
userCollection + "/" + ownerProperty.getValue().toString();
  +                userHref = contextPath + config.getUsersPath() + "/" + 
userCollection + "/" + userProperty.getValue().toString();
               }
           } else {
  -            ownerHref =  contextPath + config.getUsersPath();
  +            userHref =  contextPath + config.getUsersPath();
               if ( config.getGuestPath() != null && !config.getGuestPath().equals("") 
)
  -                ownerHref = ownerHref + "/" + config.getGuestPath();
  +                userHref = userHref + "/" + config.getGuestPath();
           }
           Element href = new Element(E_HREF, NamespaceCache.DEFAULT_NAMESPACE);
  -        href.setText(ownerHref);
  +        href.setText(userHref);
           xmlValue.add(href);
  -        
           return xmlValue;
       }
       
  @@ -2378,7 +2410,6 @@
       }
       
   }
  -
   
   
   
  
  
  
  1.17      +5 -3      
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WebdavConstants.java
  
  Index: WebdavConstants.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WebdavConstants.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- WebdavConstants.java      7 Sep 2003 15:50:12 -0000       1.16
  +++ WebdavConstants.java      18 Sep 2003 11:01:43 -0000      1.17
  @@ -151,6 +151,8 @@
   
       /** Live Properties */
       String P_CREATIONDATE         = "creationdate";
  +    String P_MODIFICATIONDATE     = "modificationdate";
  +    String P_MODIFICATIONUSER     = "modificationuser";
       String P_DISPLAYNAME          = "displayname";
       String P_GETCONTENTLANGUAGE   = "getcontentlanguage";
       String P_GETCONTENTLENGTH     = "getcontentlength";
  
  
  
  1.21      +5 -3      
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/resourcekind/AbstractResourceKind.java
  
  Index: AbstractResourceKind.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/resourcekind/AbstractResourceKind.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AbstractResourceKind.java 18 Aug 2003 07:04:42 -0000      1.20
  +++ AbstractResourceKind.java 18 Sep 2003 11:01:43 -0000      1.21
  @@ -194,6 +194,7 @@
           computedProperties.add( P_ECLIPSED_SET );
           computedProperties.add( P_LOCKDISCOVERY );
           computedProperties.add( P_OWNER);
  +        computedProperties.add( P_MODIFICATIONUSER );
           computedProperties.add( P_PRINCIPAL_COLLECTION_SET);
           computedProperties.add( P_ROOT_VERSION );
           computedProperties.add( P_SUCCESSOR_SET );
  @@ -216,6 +217,7 @@
           protectedProperties.add( P_CHECKED_OUT );
           protectedProperties.add( P_CHECKOUT_SET ); //"computed" in spec but made 
protected for performance reasons
           protectedProperties.add( P_CREATIONDATE );
  +        protectedProperties.add( P_MODIFICATIONDATE );
           protectedProperties.add( P_GETLASTMODIFIED );
   //        protectedProperties.add( P_GETCONTENTTYPE ); // so what ... let the 
client set the content-type via PROPPATCH
           protectedProperties.add( P_GETCONTENTLENGTH );
  
  
  

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

Reply via email to