stefan      2004/07/16 09:38:22

  Modified:    proposals/jcrri/src/org/apache/slide/jcr/core
                        DynamicWorkspaceDef.java HierarchyManager.java
                        HierarchyManagerImpl.java InternalValue.java
                        ItemId.java ItemImpl.java
  Log:
  jcrri
  
  Revision  Changes    Path
  1.4       +8 -8      
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/DynamicWorkspaceDef.java
  
  Index: DynamicWorkspaceDef.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/DynamicWorkspaceDef.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DynamicWorkspaceDef.java  22 Jun 2004 18:03:24 -0000      1.3
  +++ DynamicWorkspaceDef.java  16 Jul 2004 16:38:21 -0000      1.4
  @@ -45,13 +45,13 @@
        * Creates a <code>DynamicWorkspaceDef</code> object, defining a dynamic
        * workspace.
        *
  -     * @param name          name of the dynamic workspace
  -     * @param wspStore      file system where the dynamic workspace stores its state
  -     * @param blobStore     file system where the dynamic workspace stores BLOB data
  +     * @param name                     name of the dynamic workspace
  +     * @param wspStore                 file system where the dynamic workspace 
stores its state
  +     * @param blobStore                file system where the dynamic workspace 
stores BLOB data
        * @param persistenceManagerClass  FQN of class implementing the 
<code>PersistenceManager</code> interface
  -     * @param persistenceManagerParams  parameters for the 
<code>PersistenceManager</code>
  -     * @param stableWorkspace name of the stable workspace the dynamic
  -     *                        workspace should be based on
  +     * @param persistenceManagerParams parameters for the 
<code>PersistenceManager</code>
  +     * @param stableWorkspace          name of the stable workspace the dynamic
  +     *                                 workspace should be based on
        */
       DynamicWorkspaceDef(String name, FileSystem wspStore, FileSystem blobStore,
                        String persistenceManagerClass, HashMap 
persistenceManagerParams,
  
  
  
  1.6       +0 -0      
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/HierarchyManager.java
  
  Index: HierarchyManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/HierarchyManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  
  
  
  1.2       +6 -5      
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/HierarchyManagerImpl.java
  
  Index: HierarchyManagerImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/HierarchyManagerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HierarchyManagerImpl.java 7 Jul 2004 16:04:38 -0000       1.1
  +++ HierarchyManagerImpl.java 16 Jul 2004 16:38:21 -0000      1.2
  @@ -23,13 +23,13 @@
    */
   package org.apache.slide.jcr.core;
   
  +import org.apache.log4j.Logger;
   import org.apache.slide.jcr.core.state.*;
   import org.apache.slide.jcr.util.MalformedPathException;
  -import org.apache.log4j.Logger;
   
   import javax.jcr.ItemNotFoundException;
  -import javax.jcr.RepositoryException;
   import javax.jcr.PathNotFoundException;
  +import javax.jcr.RepositoryException;
   import java.util.*;
   
   /**
  @@ -57,6 +57,7 @@
       /**
        * Failsafe conversion of internal <code>Path</code> to JCR path for use in
        * error messages etc.
  +     *
        * @param path path to convert
        * @return JCR path
        */
  @@ -73,6 +74,7 @@
       /**
        * Failsafe translation of internal <code>ItemId</code> to JCR path for use in
        * error messages etc.
  +     *
        * @param id path to convert
        * @return JCR path
        */
  @@ -413,7 +415,6 @@
       }
   
       /**
  -     *
        * @param nodeId
        * @param builder
        * @param builders
  
  
  
  1.5       +9 -26     
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/InternalValue.java
  
  Index: InternalValue.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/InternalValue.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InternalValue.java        2 Jul 2004 16:25:02 -0000       1.4
  +++ InternalValue.java        16 Jul 2004 16:38:21 -0000      1.5
  @@ -23,16 +23,16 @@
    */
   package org.apache.slide.jcr.core;
   
  +import org.apache.slide.jcr.fs.FileSystemResource;
   import org.apache.slide.jcr.util.MalformedPathException;
   import org.apache.slide.jcr.util.UUID;
   import org.apache.slide.jcr.util.ValueHelper;
  -import org.apache.slide.jcr.fs.FileSystemResource;
   
   import javax.jcr.*;
   import javax.jcr.util.ISO8601;
  +import java.io.File;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.io.File;
   import java.util.Calendar;
   
   /**
  @@ -64,7 +64,6 @@
   
       //------------------------------------------------------< factory methods >
       /**
  -     *
        * @param value
        * @param nsResolver
        * @return
  @@ -81,7 +80,7 @@
            case PropertyType.BINARY:
                try {
                    if (value instanceof BLOBFileValue) {
  -                     return new InternalValue((BLOBFileValue)value);
  +                     return new InternalValue((BLOBFileValue) value);
                    } else {
                        return new InternalValue(new BLOBFileValue(value.getStream()));
                    }
  @@ -113,7 +112,6 @@
       }
   
       /**
  -     *
        * @param value
        * @param targetType
        * @param nsResolver
  @@ -130,7 +128,6 @@
       }
   
       /**
  -     *
        * @param value
        * @param targetType
        * @param nsResolver
  @@ -147,7 +144,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -156,7 +152,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -165,7 +160,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -174,7 +168,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -183,7 +176,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -192,7 +184,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        * @throws IOException
  @@ -202,7 +193,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        * @throws IOException
  @@ -212,7 +202,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        * @throws IOException
  @@ -222,7 +211,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -231,7 +219,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -240,7 +227,6 @@
       }
   
       /**
  -     *
        * @param value
        * @return
        */
  @@ -250,7 +236,6 @@
   
       //----------------------------------------------------< conversions, etc. >
       /**
  -     *
        * @param nsResolver
        * @return
        * @throws RepositoryException
  @@ -268,12 +253,12 @@
            case PropertyType.LONG:
                return new LongValue((Long) val);
            case PropertyType.REFERENCE:
  -             return ReferenceValue.valueOf(((UUID)val).toString());
  +             return ReferenceValue.valueOf(((UUID) val).toString());
            case PropertyType.SOFTLINK:
  -             return SoftLinkValue.valueOf(((Path)val).toJCRPath(nsResolver));
  +             return SoftLinkValue.valueOf(((Path) val).toJCRPath(nsResolver));
            case PropertyType.STRING:
                if (val instanceof QName) {
  -                 return new StringValue(((QName)val).toJCRName(nsResolver));
  +                 return new StringValue(((QName) val).toJCRName(nsResolver));
                } else {
                    return new StringValue((String) val);
                }
  @@ -283,7 +268,6 @@
       }
   
       /**
  -     *
        * @return
        */
       public Object internalValue() {
  @@ -291,7 +275,6 @@
       }
   
       /**
  -     *
        * @return
        */
       public int getType() {
  @@ -301,6 +284,7 @@
       /**
        * Returns the string representation of this internal value. If this is a
        * <i>binary</i> value then the path of its backing file will be returned.
  +     *
        * @return string representation of this internal value
        */
       public String toString() {
  @@ -323,7 +307,6 @@
       }
   
       /**
  -     *
        * @param s
        * @param type
        * @return
  
  
  
  1.4       +0 -0      
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/ItemId.java
  
  Index: ItemId.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/ItemId.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  
  
  
  1.12      +59 -9     
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/ItemImpl.java
  
  Index: ItemImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/ItemImpl.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ItemImpl.java     13 Jul 2004 15:49:58 -0000      1.11
  +++ ItemImpl.java     16 Jul 2004 16:38:21 -0000      1.12
  @@ -27,9 +27,11 @@
   import org.apache.log4j.Logger;
   import org.apache.slide.jcr.core.nodetype.NodeDefImpl;
   import org.apache.slide.jcr.core.nodetype.NodeTypeImpl;
  +import org.apache.slide.jcr.core.nodetype.NodeTypeRegistry;
   import org.apache.slide.jcr.core.nodetype.PropertyDefImpl;
   import org.apache.slide.jcr.core.observation.EventStateCollection;
   import org.apache.slide.jcr.core.state.*;
  +import org.apache.slide.jcr.core.version.VersionImpl;
   import org.apache.slide.jcr.util.IteratorHelper;
   
   import javax.jcr.*;
  @@ -40,6 +42,7 @@
   import javax.jcr.nodetype.NodeDef;
   import javax.jcr.nodetype.NodeType;
   import javax.jcr.nodetype.PropertyDef;
  +import javax.jcr.version.VersionHistory;
   import java.util.*;
   
   /**
  @@ -82,6 +85,11 @@
       protected final TicketImpl ticket;
   
       /**
  +     * the <code>Repository</code> object
  +     */
  +    protected final RepositoryImpl rep;
  +
  +    /**
        * <code>ItemState</code> associated with this <code>Item</code>
        */
       protected ItemState state;
  @@ -113,6 +121,7 @@
       ItemImpl(ItemManager itemMgr, TicketImpl ticket, ItemId id, ItemState state,
             ItemLifeCycleListener[] listeners) {
        this.ticket = ticket;
  +     rep = (RepositoryImpl) ticket.getRepository();
        itemStateMgr = ticket.getItemStateManager();
        this.id = id;
        this.itemMgr = itemMgr;
  @@ -312,10 +321,11 @@
         *   in the property's definition
         *
         * note that the protected flag is checked in Node.remove (for items
  -      * to be removed) and in Property.setValue (for properties to be modified).
  +      * to be removed), in Node.addMixin/removeMixin (for mixin changes on nodes)
  +      * and in Property.setValue (for properties to be modified).
         */
   
  -     AccessManagerImpl accessMgr = (AccessManagerImpl) ticket.getAccessManager();
  +     AccessManagerImpl accessMgr = ticket.getAccessManager();
        // walk through list of transient items and validate each
        while (iter.hasNext()) {
            ItemState itemState = (ItemState) iter.next();
  @@ -400,7 +410,6 @@
                NodeId nodeId = new NodeId(propState.getParentUUID());
                PropertyImpl prop = (PropertyImpl) itemMgr.getItem(propId);
                PropertyDefImpl def = (PropertyDefImpl) prop.getDefinition();
  -             NodeTypeImpl nt = (NodeTypeImpl) prop.getParent().getPrimaryNodeType();
   
                if (!def.isAutoCreate()) {
                    // check SET_PROPERTY permission
  @@ -412,9 +421,21 @@
                }
   
                // check value constraints
  -             if (def.getValueConstraint() != null) {
  -                 InternalValue[] values = propState.getValues();
  -                 nt.checkSetProperty(def, values);
  +             // (no need to check value constraints of protected properties
  +             // as those are set by the implementation only, i.e. they
  +             // cannot be set by the user through the api)
  +             if (!def.isProtected()) {
  +                 if (def.getValueConstraint() != null) {
  +                     InternalValue[] values = propState.getValues();
  +                     try {
  +                         NodeTypeImpl.checkSetPropertyValueConstraints(def, values);
  +                     } catch (RepositoryException e) {
  +                         // repack exception for providing verboser error message
  +                         String msg = prop.safeGetJCRPath() + ": " + e.getMessage();
  +                         log.error(msg);
  +                         throw new ConstraintViolationException(msg);
  +                     }
  +                 }
                }
   
                // no need to check the protected flag
  @@ -454,6 +475,32 @@
       }
   
       /**
  +     * Initializes the version history of all new nodes of node type
  +     * <code>mix:versionable</code>.
  +     * <p/>
  +     * Called by [EMAIL PROTECTED] #validateTransientItems(Iterator)}.
  +     *
  +     * @param iter
  +     * @throws RepositoryException
  +     */
  +    private void initVersionHistories(Iterator iter) throws RepositoryException {
  +     // walk through list of transient items and
  +     // search for new versionable nodes
  +     while (iter.hasNext()) {
  +         ItemState itemState = (ItemState) iter.next();
  +         if (itemState.isNode() && itemState.getStatus() == ItemState.STATUS_NEW) {
  +             NodeImpl node = (NodeImpl) itemMgr.getItem(itemState.getId());
  +             if (node.isNodeType(NodeTypeRegistry.MIX_VERSIONABLE)) {
  +                 VersionHistory hist = 
rep.getVersionManager().createVersionHistory(node);
  +                 node.internalSetProperty(VersionImpl.PROPNAME_VERSION_HISTORY, 
InternalValue.create(hist.getUUID()));
  +                 node.internalSetProperty(VersionImpl.PROPNAME_BASE_VERSION, 
InternalValue.create(hist.getRootVersion().getUUID()));
  +                 node.internalSetProperty(VersionImpl.PROPNAME_IS_CHECKED_OUT, 
InternalValue.create(true));
  +             }
  +         }
  +     }
  +    }
  +
  +    /**
        * Failsafe mapping of internal <code>id</code> to JCR path for use in
        * diagnostic output, error messages etc.
        *
  @@ -787,6 +834,9 @@
            }
        }
   
  +     // initialize version histories for new nodes
  +     initVersionHistories(dirty.iterator());
  +
        // persist 'new' or 'modified' transient states
        persistTransientItems(dirty.iterator());
   
  @@ -981,7 +1031,7 @@
   
            Permission[] perms = ticket.getAccessManager().getSupportedPermissions();
            // check each permission separately
  -         AccessManagerImpl accessMgr = (AccessManagerImpl) 
ticket.getAccessManager();
  +         AccessManagerImpl accessMgr = ticket.getAccessManager();
            for (int i = 0; i < perms.length; i++) {
                Permission perm = perms[i];
                if ((permissions & perm.getValue()) == perm.getValue()) {
  
  
  

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

Reply via email to