jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r453120 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: operation/ state/
Date Thu, 05 Oct 2006 07:10:18 GMT
Author: angela
Date: Thu Oct  5 00:10:16 2006
New Revision: 453120

URL: http://svn.apache.org/viewvc?view=rev&rev=453120
Log:
work in progress

- remove 'add' and 'set' methods on NodeState/PropertyState, that were
  used for initialization and did not mark the state modified. this
  was confusing, since similar methods called 'markmodified'.
  replaced by an 'init' method.
- SessionISM: fix options for addMixin (should not check for protected)
- move validation of PropertyState from ItemStateValidator to state.
- add TODO: TransientISM must clean up operations upon status changes.

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
Thu Oct  5 00:10:16 2006
@@ -38,10 +38,12 @@
         this.nodeState = nodeState;
         this.mixinNames = mixinNames;
 
-        // set affected states
+        // remember node state as affected state
         addAffectedItemState(nodeState);
-        // TODO: correct?
+        // add the jcr:mixinTypes property state as affected if it already exists
+        // and therefore gets modified by this operation.
         if (nodeState.hasPropertyName(QName.JCR_MIXINTYPES)) {
+
             try {
                 addAffectedItemState(nodeState.getPropertyState(QName.JCR_MIXINTYPES));
             } catch (ItemStateException e) {

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ChangeLog.java
Thu Oct  5 00:10:16 2006
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.spi.EventIterator;
-import org.apache.commons.collections.iterators.IteratorChain;
 
 import java.util.Iterator;
 import java.util.Set;
@@ -108,10 +107,10 @@
      * @param state state that has been deleted
      */
     public void deleted(ItemState state) {
-        if (addedStates.remove(state)) {
+        if (!addedStates.remove(state)) {
             modifiedStates.remove(state);
             deletedStates.add(state);
-        }
+        }       
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
Thu Oct  5 00:10:16 2006
@@ -18,7 +18,6 @@
 
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeRegistry;
-import org.apache.jackrabbit.jcr2spi.nodetype.ValueConstraint;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
@@ -26,7 +25,6 @@
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
-import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.AccessDeniedException;
@@ -41,7 +39,6 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.value.QValue;
 
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -176,42 +173,6 @@
                 throw new ConstraintViolationException(msg);
             }
         }
-    }
-
-    /**
-     * Checks whether the given property parameters are consistent and satisfy
-     * the constraints specified by the given definition. The following
-     * validations/checks are performed:
-     * <ul>
-     * <li>make sure the type is not undefined and matches the type of all
-     * values given</li>
-     * <li>make sure all values have the same type.</li>
-     * <li>check if the type of the property values does comply with the
-     * requiredType specified in the property's definition</li>
-     * <li>check if the property values satisfy the value constraints
-     * specified in the property's definition</li>
-     * </ul>
-     *
-     * @param propertyType
-     * @param values
-     * @param definition
-     * @throws ConstraintViolationException If any of the validations fails.
-     * @throws RepositoryException If another error occurs.
-     */
-    public void validate(int propertyType, QValue[] values, QPropertyDefinition definition)
-        throws ConstraintViolationException, RepositoryException {
-        if (propertyType == PropertyType.UNDEFINED) {
-            throw new RepositoryException("'Undefined' is not a valid property type for existing
values.");
-        }
-        if (definition.getRequiredType() != PropertyType.UNDEFINED && definition.getRequiredType()
!= propertyType) {
-            throw new ConstraintViolationException("RequiredType constraint is not satisfied");
-        }
-        for (int i = 0; i < values.length; i++) {
-            if (propertyType != values[i].getType()) {
-                throw new ConstraintViolationException("Inconsistent value types: Required
type = " + PropertyType.nameFromValue(propertyType) + "; Found value with type = " + PropertyType.nameFromValue(values[i].getType()));
-            }
-        }
-        ValueConstraint.checkValueConstraints(definition, values);
     }
 
     //-------------------------------------------------< misc. helper methods >

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Thu Oct  5 00:10:16 2006
@@ -165,6 +165,29 @@
         pull();
     }
 
+    void init(QName[] mixinTypeNames, Collection childEntries, Collection propertyNames,
NodeReferences references) {
+        if (mixinTypeNames != null) {
+            this.mixinTypeNames = mixinTypeNames;
+        }
+        // re-create property references
+        propertiesInAttic.clear();
+        properties.clear(); // TODO: any more cleanup work to do? try some kind of merging?
+        Iterator it = propertyNames.iterator();
+        while (it.hasNext()) {
+            QName propName = (QName) it.next();
+            properties.put(propName, new PropertyReference(this, propName, isf, idFactory));
+        }
+        // re-create child node entries
+        childNodeEntries.removeAll(); // TODO: any mre cleanup work to do? try some kind
of merging?
+        it = childEntries.iterator();
+        while (it.hasNext()) {
+            ChildNodeEntry cne = (ChildNodeEntry) it.next();
+            childNodeEntries.add(cne.getName(), cne.getUUID());
+        }
+        // set the node references
+        this.references = references;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -175,22 +198,9 @@
             uuid = nodeState.uuid;
             //parent = nodeState.parent; // TODO: parent from wrong ism layer
             nodeTypeName = nodeState.nodeTypeName;
-            mixinTypeNames = nodeState.mixinTypeNames;
             definition = nodeState.definition;
-            // re-create property references
-            propertiesInAttic.clear();
-            properties.clear(); // TODO: any more cleanup work to do? try some kind of merging?
-            Iterator it = nodeState.getPropertyNames().iterator();
-            while (it.hasNext()) {
-                addPropertyName((QName) it.next());
-            }
-            // re-create child node entries
-            childNodeEntries.removeAll(); // TODO: any mre cleanup work to do? try some kind
of merging?
-            it = nodeState.getChildNodeEntries().iterator();
-            while (it.hasNext()) {
-                ChildNodeEntry cne = (ChildNodeEntry) it.next();
-                childNodeEntries.add(cne.getName(), cne.getUUID());
-            }
+
+            init(nodeState.getMixinTypeNames(), nodeState.getChildNodeEntries(), nodeState.getPropertyNames(),
nodeState.getNodeReferences());
         }
     }
 
@@ -286,6 +296,7 @@
         } else {
             this.mixinTypeNames = new QName[0];
         }
+        markModified();
     }
 
     /**
@@ -371,7 +382,6 @@
      * @return the <code>ChildNodeEntry</code> with the specified
      *         <code>NodeState</code> or <code>null</code> if there's
no
      *         matching entry.
-     * @see #addChildNodeEntry
      */
     public synchronized ChildNodeEntry getChildNodeEntry(NodeState nodeState) {
         return childNodeEntries.get(nodeState);
@@ -382,7 +392,6 @@
      * denoting the child nodes of this node.
      *
      * @return collection of <code>ChildNodeEntry</code> objects
-     * @see #addChildNodeEntry
      */
     public synchronized Collection getChildNodeEntries() {
         // NOTE: 'childNodeEntries' are already unmodifiable
@@ -395,7 +404,6 @@
      *
      * @param nodeName name of the child node entries that should be returned
      * @return list of <code>ChildNodeEntry</code> objects
-     * @see #addChildNodeEntry
      */
     public synchronized List getChildNodeEntries(QName nodeName) {
         // NOTE: SubList retrieved from 'ChildNodeEntries' is already unmodifiable
@@ -403,21 +411,6 @@
     }
 
     /**
-     * Adds a new <code>ChildNodeEntry</code>.
-     *
-     * @param nodeName <code>QName</code> object specifying the name of the new
-     *                 entry.
-     * @param uuid     the uuid the new entry is refering to or
-     *                 <code>null</code> if the child node state cannot be
-     *                 identified with a uuid.
-     * @return the newly added <code>ChildNodeEntry</code>
-     */
-    synchronized ChildNodeEntry addChildNodeEntry(QName nodeName,
-                                                  String uuid) {
-        return childNodeEntries.add(nodeName, uuid);
-    }
-
-    /**
      * TODO: move this method to a node state implementation which contains all transient
related methods?
      *
      * Adds a child node state to this node state.
@@ -734,15 +727,6 @@
             props = properties.values();
         }
         return Collections.unmodifiableCollection(props);
-    }
-
-    /**
-     * Adds a property name entry. This method will not create a property!
-     *
-     * @param propName <code>QName</code> object specifying the property name
-     */
-    synchronized void addPropertyName(QName propName) {
-        properties.put(propName, new PropertyReference(this, propName, isf, idFactory));
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/PropertyState.java
Thu Oct  5 00:10:16 2006
@@ -18,6 +18,8 @@
 
 import javax.jcr.PropertyType;
 import javax.jcr.ValueFormatException;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.name.QName;
@@ -25,6 +27,7 @@
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.value.QValue;
+import org.apache.jackrabbit.jcr2spi.nodetype.ValueConstraint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -92,6 +95,16 @@
     }
 
     /**
+     *
+     * @param type
+     * @param values
+     */
+    void init(int type, QValue[] values) {
+        this.type = type;
+        this.values = (values == null) ? QValue.EMPTY_ARRAY : values;
+    }
+
+    /**
      * @inheritDoc
      */
     public void remove() {
@@ -232,17 +245,6 @@
     }
 
     /**
-     * Sets the type of the property value(s)
-     *
-     * @param type the type to be set
-     * @see PropertyType
-     */
-    void setType(int type) {
-        this.type = type;
-    }
-
-
-    /**
      * Returns true if this property is multi-valued, otherwise false.
      *
      * @return true if this property is multi-valued, otherwise false.
@@ -276,21 +278,13 @@
      *
      * @param values the new values
      */
-    void setValues(QValue[] values) {
-        internalSetValues(values);
-        markModified();
-    }
-
-    /**
-     * TODO: rather separate PropertyState into interface and implementation
-     * TODO: and move internalSetValues to implementation only.
-     * Sets the value(s) of this property without marking this property state
-     * as modified.
-     *
-     * @param values the new values
-     */
-    void internalSetValues(QValue[] values) {
+    void setValues(QValue[] values, int type) throws RepositoryException {
+        // make sure the arguements are consistent and do not violate the
+        // given property definition.
+        validate(values, type, this.def);
         this.values = values;
+        this.type = type;
+        markModified();
     }
 
     /**
@@ -308,5 +302,41 @@
         } else {
             return values[0];
         }
+    }
+
+    /**
+     * Checks whether the given property parameters are consistent and satisfy
+     * the constraints specified by the given definition. The following
+     * validations/checks are performed:
+     * <ul>
+     * <li>make sure the type is not undefined and matches the type of all
+     * values given</li>
+     * <li>make sure all values have the same type.</li>
+     * <li>check if the type of the property values does comply with the
+     * requiredType specified in the property's definition</li>
+     * <li>check if the property values satisfy the value constraints
+     * specified in the property's definition</li>
+     * </ul>
+     *
+     * @param values
+     * @param propertyType
+     * @param definition
+     * @throws ConstraintViolationException If any of the validations fails.
+     * @throws RepositoryException If another error occurs.
+     */
+    private static void validate(QValue[] values, int propertyType, QPropertyDefinition definition)
+        throws ConstraintViolationException, RepositoryException {
+        if (propertyType == PropertyType.UNDEFINED) {
+            throw new RepositoryException("'Undefined' is not a valid property type for existing
values.");
+        }
+        if (definition.getRequiredType() != PropertyType.UNDEFINED && definition.getRequiredType()
!= propertyType) {
+            throw new ConstraintViolationException("RequiredType constraint is not satisfied");
+        }
+        for (int i = 0; i < values.length; i++) {
+            if (propertyType != values[i].getType()) {
+                throw new ConstraintViolationException("Inconsistent value types: Required
type = " + PropertyType.nameFromValue(propertyType) + "; Found value with type = " + PropertyType.nameFromValue(values[i].getType()));
+            }
+        }
+        ValueConstraint.checkValueConstraints(definition, values);
     }
 }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
Thu Oct  5 00:10:16 2006
@@ -319,7 +319,10 @@
                 }
             }
             if (modified) {
-                setPropertyStateValue(propState, newVals, PropertyType.REFERENCE);
+                // TODO improve
+                int options = ItemStateValidator.CHECK_LOCK //| ItemStateValidator.CHECK_COLLISION
+                    | ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_CONSTRAINTS;
+                setPropertyStateValue(propState, newVals, PropertyType.REFERENCE, options);
             }
         }
         // make sure all entries are removed
@@ -527,7 +530,8 @@
         // mixin-names to be execute on the nodestate (and corresponding property state)
         if (mixinNames != null && mixinNames.length > 0) {
             // find out if any of the existing mixins is removed
-            List originalMixins = Arrays.asList(nState.getMixinTypeNames());
+            List originalMixins = new ArrayList();
+            originalMixins.addAll(Arrays.asList(nState.getMixinTypeNames()));
             originalMixins.removeAll(Arrays.asList(mixinNames));
             anyRemoved = originalMixins.size() > 0;
 
@@ -539,7 +543,8 @@
                 // execute value of existing property
                 try {
                     PropertyState pState = nState.getPropertyState(QName.JCR_MIXINTYPES);
-                    setPropertyStateValue(pState, QValue.create(mixinNames), PropertyType.NAME);
+                    int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
+                    setPropertyStateValue(pState, QValue.create(mixinNames), PropertyType.NAME,
options);
                 } catch (ItemStateException e) {
                     // should not occur, since existance has been asserted before
                     throw new RepositoryException(e);
@@ -625,7 +630,10 @@
      */
     public void visit(SetPropertyValue operation) throws ValueFormatException, LockException,
ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException,
VersionException, RepositoryException {
         PropertyState pState = operation.getPropertyState();
-        setPropertyStateValue(pState, operation.getValues(), operation.getPropertyType());
+        // TODO improve
+        int options = ItemStateValidator.CHECK_LOCK //| ItemStateValidator.CHECK_COLLISION
+            | ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_CONSTRAINTS;
+        setPropertyStateValue(pState, operation.getValues(), operation.getPropertyType(),
options);
         transientStateMgr.addOperation(operation);
     }
 
@@ -662,7 +670,8 @@
     }
 
     public void visit(Update operation) throws NoSuchWorkspaceException, AccessDeniedException,
LockException, InvalidItemStateException, RepositoryException {
-        throw new UnsupportedOperationException("Internal error: Update cannot be handled
by session ItemStateManager.");
+        // TODO: TOBEFIXED. not correct.
+        workspaceItemStateMgr.execute(operation);
     }
 
     public void visit(Restore operation) throws VersionException, PathNotFoundException,
ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException,
RepositoryException {
@@ -724,16 +733,11 @@
 
         validator.checkAddProperty(parent, propertyName, pDef, options);
 
-        // make sure the arguements are consistent and do not violate the
-        // given property definition.
-        validator.validate(propertyType, values, pDef);
-
         // create property state
         PropertyState propState = transientStateMgr.createNewPropertyState(propertyName,
parent, pDef);
 
         // NOTE: callers must make sure, the property type is not 'undefined'
-        propState.setType(propertyType);
-        propState.setValues(values);
+        propState.setValues(values, propertyType);
     }
 
     private void addNodeState(NodeState parent, QName nodeName, QName nodeTypeName, String
uuid, QNodeDefinition definition, int options) throws RepositoryException, ConstraintViolationException,
AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchNodeTypeException, ItemExistsException,
VersionException {
@@ -817,16 +821,12 @@
      * @throws VersionException
      * @throws RepositoryException
      */
-    private void setPropertyStateValue(PropertyState propState, QValue[] iva, int valueType)
throws ValueFormatException, LockException, ConstraintViolationException, AccessDeniedException,
ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException
{
+    private void setPropertyStateValue(PropertyState propState, QValue[] iva,
+                                       int valueType, int options)
+        throws ValueFormatException, LockException, ConstraintViolationException, AccessDeniedException,
ItemExistsException, UnsupportedRepositoryOperationException, VersionException, RepositoryException
{
         // assert that the property can be modified.
-        // TODO improve
-        int options = ItemStateValidator.CHECK_LOCK //| ItemStateValidator.CHECK_COLLISION
-            | ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_CONSTRAINTS;
         validator.checkSetProperty(propState, options);
 
-        // make sure property is valid according to its definition
-        validator.validate(valueType, iva, propState.getDefinition());
-
         // free old values as necessary
         QValue[] oldValues = propState.getValues();
         if (oldValues != null) {
@@ -839,9 +839,7 @@
                 }
             }
         }
-
-        propState.setValues(iva);
-        propState.setType(valueType);
+        propState.setValues(iva, valueType);
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/TransientItemStateManager.java
Thu Oct  5 00:10:16 2006
@@ -268,6 +268,7 @@
      * @see ItemStateLifeCycleListener#statusChanged(ItemState, int)
      */
     public void statusChanged(ItemState state, int previousStatus) {
+        // TODO: cleanup operations as well.
         // TODO: depending on status of state adapt change log
         // e.g. a revert on states will reset the status from
         // 'existing modified' to 'existing'.
@@ -316,6 +317,7 @@
                 if (previousStatus == ItemState.STATUS_NEW) {
                     // was new and now removed again
                     changeLog.addedStates.remove(state);
+                    // TODO remove the 'add' operation as well
                 } else if (previousStatus == ItemState.STATUS_EXISTING_REMOVED) {
                     // was removed and is now saved
                     changeLog.deletedStates.remove(state);

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?view=diff&rev=453120&r1=453119&r2=453120
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Thu Oct  5 00:10:16 2006
@@ -31,10 +31,12 @@
 import org.apache.jackrabbit.jcr2spi.WorkspaceManager;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeConflictException;
+import org.apache.jackrabbit.name.QName;
 
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.PropertyType;
+import javax.jcr.ItemNotFoundException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import java.io.InputStream;
@@ -91,7 +93,7 @@
             NodeState parent = (parentId != null) ? (NodeState) ism.getItemState(parentId)
: null;
 
             return createNodeState(info, parent);
-        } catch (PathNotFoundException e) {
+        } catch (ItemNotFoundException e) {
             throw new NoSuchItemStateException(e.getMessage(), e);
         } catch (RepositoryException e) {
             throw new ItemStateException(e.getMessage(), e);
@@ -146,32 +148,34 @@
             NodeState state = new NodeState(info.getQName(), uuid, parent, info.getNodetype(),
                 definition, ItemState.STATUS_EXISTING, this, service.getIdFactory());
 
-            // set mixin nodetypes
-            state.setMixinTypeNames(info.getMixins());
-
-            // references to child items
+            // child node entries
+            Set childNodeEntries = new HashSet();
             for (IdIterator it = info.getNodeIds(); it.hasNext(); ) {
                 NodeInfo childInfo = service.getNodeInfo(sessionInfo, (NodeId) it.nextId());
                 String childUUID = null;
                 if (childInfo.getId().getRelativePath() == null) {
                     childUUID = childInfo.getId().getUUID();
                 }
-                state.addChildNodeEntry(childInfo.getQName(), childUUID);
+                childNodeEntries.add(new CNE(childInfo.getQName(), childUUID));
             }
 
-            // references to properties
+            // names of child property entries
+            Set propNames = new HashSet();
             for (IdIterator it = info.getPropertyIds(); it.hasNext(); ) {
                 PropertyId pId = (PropertyId) it.nextId();
-                state.addPropertyName(pId.getQName());
+                propNames.add(pId.getQName());
             }
 
             // If the uuid is not null, the state could include mix:referenceable.
             // Therefore build a NodeReference instance and add it to the state.
+            NodeReferences nodeRefs = null;
             if (uuid != null) {
                 PropertyId[] references = info.getReferences();
-                state.setNodeReferences(new NodeReferencesImpl(info.getId(), references));
+                nodeRefs = new NodeReferencesImpl(info.getId(), references);
             }
 
+            state.init(info.getMixins(), childNodeEntries, propNames, nodeRefs);
+
             // copied from local-state-mgr TODO... check
             // register as listener
             // TODO check if needed
@@ -238,7 +242,7 @@
             // build the PropertyState
             PropertyState state = new PropertyState(info.getQName(), parent,
                 def, ItemState.STATUS_EXISTING, service.getIdFactory());
-            state.setType(info.getType());
+
             QValue[] qValues;
             if (info.getType() == PropertyType.BINARY) {
                 InputStream[] ins = info.getValuesAsStream();
@@ -254,7 +258,7 @@
                 }
             }
 
-            state.internalSetValues(qValues);
+            state.init(info.getType(), qValues);
 
             // register as listener
             // TODO check if needed
@@ -274,6 +278,43 @@
             String msg = "internal error: failed to retrieve property definition.";
             log.debug(msg);
             throw new ItemStateException(msg, e);
+        }
+    }
+
+
+    //------------------------------------------------------< ChildNodeEntry >---
+    private class CNE implements ChildNodeEntry {
+
+        private final QName name;
+        private final String uuid;
+
+        private CNE(QName name, String uuid) {
+            this.name = name;
+            this.uuid = uuid;
+        }
+
+        public NodeId getId() {
+            throw new UnsupportedOperationException();
+        }
+
+        public QName getName() {
+            return name;
+        }
+
+        public String getUUID() {
+            return uuid;
+        }
+
+        public int getIndex() {
+            throw new UnsupportedOperationException();
+        }
+
+        public NodeState getNodeState() throws NoSuchItemStateException, ItemStateException
{
+            throw new UnsupportedOperationException();
+        }
+
+        public boolean isAvailable() {
+            throw new UnsupportedOperationException();
         }
     }
 



Mime
View raw message