jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1157177 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: operation/ state/
Date Fri, 12 Aug 2011 16:32:52 GMT
Author: angela
Date: Fri Aug 12 16:32:51 2011
New Revision: 1157177

URL: http://svn.apache.org/viewvc?rev=1157177&view=rev
Log:
move validation-options from sessionitemstatemgr to the invidual transient operations

Added:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
  (with props)
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddProperty.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveActivity.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveVersion.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPrimaryType.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java

Added: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java?rev=1157177&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
Fri Aug 12 16:32:51 2011
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.operation;
+
+import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
+import org.apache.jackrabbit.jcr2spi.state.NodeState;
+import org.apache.jackrabbit.spi.ItemId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.version.VersionException;
+
+/**
+ * <code>AbstractRemove</code> is the base class for non-transient remove
+ * operations executed on the workspace such as removing versions or activites.
+ */
+public abstract class AbstractRemove extends AbstractOperation {
+
+    private static Logger log = LoggerFactory.getLogger(Remove.class);
+
+    protected ItemState removeState;
+    protected NodeState parent;
+
+    protected AbstractRemove(ItemState removeState, NodeState parent) throws RepositoryException
{
+        this.removeState = removeState;
+        this.parent = parent;
+
+        addAffectedItemState(removeState);
+        addAffectedItemState(parent);
+    }
+
+    //----------------------------------------------------------< Operation >---
+    /**
+     * @see Operation#undo()
+     */
+    @Override
+    public void undo() throws RepositoryException {
+        assert status == STATUS_PENDING;
+        status = STATUS_UNDO;
+        parent.getHierarchyEntry().complete(this);
+    }
+
+    //----------------------------------------< Access Operation Parameters >---
+    public ItemId getRemoveId() throws RepositoryException {
+        return removeState.getWorkspaceId();
+    }
+
+    public NodeState getParentState() {
+        return parent;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AbstractRemove.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddNode.java
Fri Aug 12 16:32:51 2011
@@ -29,6 +29,7 @@ import javax.jcr.nodetype.NoSuchNodeType
 import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
@@ -38,7 +39,7 @@ import org.slf4j.LoggerFactory;
 /**
  * <code>AddNode</code>...
  */
-public class AddNode extends AbstractOperation {
+public class AddNode extends TransientOperation {
 
     private static Logger log = LoggerFactory.getLogger(AddNode.class);
 
@@ -52,6 +53,13 @@ public class AddNode extends AbstractOpe
 
     private AddNode(NodeState parentState, Name nodeName, Name nodeTypeName, String uuid)
             throws RepositoryException {
+        this(parentState, nodeName, nodeTypeName, uuid, DEFAULT_OPTIONS);
+    }
+
+    private AddNode(NodeState parentState, Name nodeName, Name nodeTypeName,
+                    String uuid, int options)
+            throws RepositoryException {
+        super(options);
         this.parentId = parentState.getNodeId();
         this.parentState = parentState;
         this.nodeName = nodeName;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddProperty.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddProperty.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/AddProperty.java
Fri Aug 12 16:32:51 2011
@@ -34,7 +34,7 @@ import org.apache.jackrabbit.spi.QValue;
 /**
  * <code>AddProperty</code>...
  */
-public class AddProperty extends AbstractOperation {
+public class AddProperty extends TransientOperation {
 
     private final NodeId parentId;
     private final NodeState parentState;
@@ -47,6 +47,13 @@ public class AddProperty extends Abstrac
     private AddProperty(NodeState parentState, Name propName,
                         int propertyType, QValue[] values,
                         QPropertyDefinition definition) throws RepositoryException {
+        this(parentState, propName, propertyType, values, definition, DEFAULT_OPTIONS);
+    }
+    
+    private AddProperty(NodeState parentState, Name propName,
+                        int propertyType, QValue[] values,
+                        QPropertyDefinition definition, int options) throws RepositoryException
{
+        super(options);
         this.parentId = parentState.getNodeId();
         this.parentState = parentState;
         this.propertyName = propName;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
Fri Aug 12 16:32:51 2011
@@ -28,6 +28,7 @@ import javax.jcr.version.VersionExceptio
 
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.spi.Name;
@@ -40,10 +41,15 @@ import org.slf4j.LoggerFactory;
 /**
  * <code>Move</code>...
  */
-public class Move extends AbstractOperation {
+public class Move extends TransientOperation {
 
     private static Logger log = LoggerFactory.getLogger(Move.class);
 
+    private static final int MOVE_OPTIONS = ItemStateValidator.CHECK_ACCESS
+            | ItemStateValidator.CHECK_LOCK
+            | ItemStateValidator.CHECK_VERSIONING
+            | ItemStateValidator.CHECK_CONSTRAINTS;
+
     private final NodeId srcId;
     private final NodeId destParentId;
     private final Name destName;
@@ -56,6 +62,7 @@ public class Move extends AbstractOperat
 
     private Move(NodeState srcNodeState, NodeState srcParentState, NodeState destParentState,
Name destName, boolean sessionMove)
             throws RepositoryException {
+        super(sessionMove ? MOVE_OPTIONS : ItemStateValidator.CHECK_NONE);
 
         this.srcId = (NodeId) srcNodeState.getId();
         this.destParentId = destParentState.getNodeId();

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Remove.java
Fri Aug 12 16:32:51 2011
@@ -22,6 +22,7 @@ import javax.jcr.UnsupportedRepositoryOp
 import javax.jcr.version.VersionException;
 
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.ItemId;
 import org.slf4j.Logger;
@@ -30,15 +31,25 @@ import org.slf4j.LoggerFactory;
 /**
  * <code>Remove</code>...
  */
-public class Remove extends AbstractOperation {
+public class Remove extends TransientOperation {
 
     private static Logger log = LoggerFactory.getLogger(Remove.class);
 
+    private static final int REMOVE_OPTIONS =
+            ItemStateValidator.CHECK_LOCK
+            | ItemStateValidator.CHECK_VERSIONING
+            | ItemStateValidator.CHECK_CONSTRAINTS;
+
     private final ItemId removeId;
     protected ItemState removeState;
     protected NodeState parent;
 
-    protected Remove(ItemState removeState, NodeState parent) throws RepositoryException
{
+    private Remove(ItemState removeState, NodeState parent) throws RepositoryException {
+        this(removeState, parent, REMOVE_OPTIONS);
+    }
+
+    private Remove(ItemState removeState, NodeState parent, int options) throws RepositoryException
{
+        super(options);
         this.removeId = removeState.getId();
         this.removeState = removeState;
         this.parent = parent;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveActivity.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveActivity.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveActivity.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveActivity.java
Fri Aug 12 16:32:51 2011
@@ -26,7 +26,6 @@ import javax.jcr.version.VersionExceptio
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry;
 import org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyManager;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
-import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,7 +33,7 @@ import org.slf4j.LoggerFactory;
 /**
  * <code>RemoveActivity</code>...
  */
-public class RemoveActivity extends Remove {
+public class RemoveActivity extends AbstractRemove {
 
     private static Logger log = LoggerFactory.getLogger(RemoveActivity.class);
 
@@ -52,7 +51,6 @@ public class RemoveActivity extends Remo
     /**
      * @see org.apache.jackrabbit.jcr2spi.operation.Operation#accept(org.apache.jackrabbit.jcr2spi.operation.OperationVisitor)
      */
-    @Override
     public void accept(OperationVisitor visitor) throws AccessDeniedException, UnsupportedRepositoryOperationException,
VersionException, RepositoryException {
         assert status == STATUS_PENDING;
         visitor.visit(this);
@@ -64,7 +62,6 @@ public class RemoveActivity extends Remo
      *
      * @see org.apache.jackrabbit.jcr2spi.operation.Operation#persisted()
      */
-    @Override
     public void persisted() {
         assert status == STATUS_PENDING;
         status = STATUS_PERSISTED;
@@ -81,12 +78,6 @@ public class RemoveActivity extends Remo
         parent.getNodeEntry().invalidate(false);
     }
 
-    //----------------------------------------< Access Operation Parameters >---
-    @Override
-    public ItemId getRemoveId() throws RepositoryException {
-        return removeState.getWorkspaceId();
-    }
-
     //------------------------------------------------------------< Factory >---
     public static Operation create(NodeState activityState, HierarchyManager hierarchyMgr)
             throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveVersion.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveVersion.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveVersion.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/RemoveVersion.java
Fri Aug 12 16:32:51 2011
@@ -28,14 +28,13 @@ import org.apache.jackrabbit.jcr2spi.hie
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.version.VersionManager;
-import org.apache.jackrabbit.spi.ItemId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * <code>RemoveVersion</code>...
  */
-public class RemoveVersion extends Remove {
+public class RemoveVersion extends AbstractRemove {
 
     private static Logger log = LoggerFactory.getLogger(RemoveVersion.class);
 
@@ -55,7 +54,6 @@ public class RemoveVersion extends Remov
     /**
      * @see Operation#accept(OperationVisitor)
      */
-    @Override
     public void accept(OperationVisitor visitor) throws AccessDeniedException, UnsupportedRepositoryOperationException,
VersionException, RepositoryException {
         assert status == STATUS_PENDING;
         visitor.visit(this);
@@ -67,7 +65,6 @@ public class RemoveVersion extends Remov
      *
      * @see Operation#persisted()
      */
-    @Override
     public void persisted() {
         assert status == STATUS_PENDING;
         status = STATUS_PERSISTED;
@@ -86,12 +83,6 @@ public class RemoveVersion extends Remov
         parent.getNodeEntry().invalidate(true);
     }
 
-    //----------------------------------------< Access Operation Parameters >---
-    @Override
-    public ItemId getRemoveId() throws RepositoryException {
-        return removeState.getWorkspaceId();
-    }
-
     //------------------------------------------------------------< Factory >---
     public static Operation create(NodeState versionState, NodeState vhState, VersionManager
mgr)
             throws RepositoryException {

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
Fri Aug 12 16:32:51 2011
@@ -30,7 +30,7 @@ import org.apache.jackrabbit.spi.Path;
 /**
  * <code>ReorderNodes</code>...
  */
-public class ReorderNodes extends AbstractOperation {
+public class ReorderNodes extends TransientOperation {
 
     private final NodeId parentId;
     private final NodeId insertId;
@@ -42,6 +42,7 @@ public class ReorderNodes extends Abstra
 
     private ReorderNodes(NodeState parentState, NodeState insert, NodeState before)
             throws RepositoryException {
+        super(NO_OPTIONS);
         this.parentState = parentState;
         this.insert = insert;
         this.before = before;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetMixin.java
Fri Aug 12 16:32:51 2011
@@ -22,6 +22,7 @@ import javax.jcr.UnsupportedRepositoryOp
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
@@ -30,13 +31,22 @@ import org.apache.jackrabbit.spi.commons
 /**
  * <code>SetMixin</code>...
  */
-public class SetMixin extends AbstractOperation {
+public class SetMixin extends TransientOperation {
+
+    private static final int SET_MIXIN_OPTIONS =
+            ItemStateValidator.CHECK_LOCK
+            | ItemStateValidator.CHECK_VERSIONING;
 
     private final NodeId nodeId;
     private final NodeState nodeState;
     private final Name[] mixinNames;
 
     private SetMixin(NodeState nodeState, Name[] mixinNames) throws RepositoryException {
+        this(nodeState, mixinNames, SET_MIXIN_OPTIONS);
+    }
+
+    private SetMixin(NodeState nodeState, Name[] mixinNames, int options) throws RepositoryException
{
+        super(options);
         this.nodeState = nodeState;
         this.nodeId = nodeState.getNodeId();
         this.mixinNames = mixinNames;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPrimaryType.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPrimaryType.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPrimaryType.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPrimaryType.java
Fri Aug 12 16:32:51 2011
@@ -22,6 +22,7 @@ import javax.jcr.UnsupportedRepositoryOp
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
@@ -29,13 +30,21 @@ import org.apache.jackrabbit.spi.NodeId;
 /**
  * <code>SetPrimaryNodeType</code>...
  */
-public class SetPrimaryType extends AbstractOperation {
+public class SetPrimaryType extends TransientOperation {
+
+    private final static int SET_PRIMARY_TYPE_OPTIONS =
+            ItemStateValidator.CHECK_VERSIONING
+            | ItemStateValidator.CHECK_LOCK;
 
     private final NodeId nodeId;
     private final NodeState nodeState;
     private final Name primaryTypeName;
 
     private SetPrimaryType(NodeState nodeState, Name primaryTypeName) throws RepositoryException
{
+        this(nodeState, primaryTypeName, SET_PRIMARY_TYPE_OPTIONS);
+    }
+    private SetPrimaryType(NodeState nodeState, Name primaryTypeName, int options) throws
RepositoryException {
+        super(options);
         this.nodeState = nodeState;
         this.nodeId = nodeState.getNodeId();
         this.primaryTypeName = primaryTypeName;

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/SetPropertyValue.java
Fri Aug 12 16:32:51 2011
@@ -28,6 +28,7 @@ import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.version.VersionException;
 
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.QValue;
@@ -35,8 +36,13 @@ import org.apache.jackrabbit.spi.QValue;
 /**
  * <code>SetPropertyValue</code>...
  */
-public class SetPropertyValue extends AbstractOperation {
+public class SetPropertyValue extends TransientOperation {
 
+    private static final int SET_PROPERTY_OPTIONS =
+            ItemStateValidator.CHECK_LOCK
+            | ItemStateValidator.CHECK_VERSIONING
+            | ItemStateValidator.CHECK_CONSTRAINTS;
+    
     private final PropertyId propertyId;
     private final PropertyState propertyState;
     private final QValue[] values;
@@ -46,6 +52,13 @@ public class SetPropertyValue extends Ab
 
     private SetPropertyValue(PropertyState propertyState, int valueType, QValue[] values)
             throws RepositoryException {
+        this(propertyState, valueType, values, SET_PROPERTY_OPTIONS);
+
+    }
+
+    private SetPropertyValue(PropertyState propertyState, int valueType,
+                             QValue[] values, int options) throws RepositoryException {
+        super(options);
         this.propertyState = propertyState;
 
         propertyId = (PropertyId) propertyState.getId();
@@ -124,9 +137,9 @@ public class SetPropertyValue extends Ab
                                    int valueType) throws RepositoryException {
         // compact array (purge null entries)
         List<QValue> list = new ArrayList<QValue>();
-        for (int i = 0; i < qValues.length; i++) {
-            if (qValues[i] != null) {
-                list.add(qValues[i]);
+        for (QValue qValue : qValues) {
+            if (qValue != null) {
+                list.add(qValue);
             }
         }
         QValue[] cleanValues = list.toArray(new QValue[list.size()]);

Added: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java?rev=1157177&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java
Fri Aug 12 16:32:51 2011
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jcr2spi.operation;
+
+import org.apache.jackrabbit.jcr2spi.state.ItemStateValidator;
+
+/**
+ * <code>TransientOperation</code>...
+ */
+public abstract class TransientOperation extends AbstractOperation {
+
+    static final int NO_OPTIONS = ItemStateValidator.CHECK_NONE;
+    static final int DEFAULT_OPTIONS =
+            ItemStateValidator.CHECK_LOCK |
+            ItemStateValidator.CHECK_COLLISION |
+            ItemStateValidator.CHECK_VERSIONING |
+            ItemStateValidator.CHECK_CONSTRAINTS;
+
+    private final int options;
+
+    TransientOperation(int options) {
+        this.options = options;
+    }
+
+    /**
+     * Return the set of options that should be used to validate the transient
+     * modification. Valid options are a combination of any of the following
+     * options:
+     *
+     * <ul>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_NONE
CHECK_NONE} if no validation check is required,</li>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_ACCESS
CHECK_ACCESS},</li>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_COLLISION
CHECK_COLLISION},</li>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_CONSTRAINTS
CHECK_CONSTRAINTS},</li>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_LOCK
CHECK_LOCK},</li>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_VERSIONING
CHECK_VERSIONING},</li>
+     * <li>{@link org.apache.jackrabbit.jcr2spi.state.ItemStateValidator#CHECK_ALL
CHECK_ALL} as shortcut for all options.</li>
+     * </ul>
+     *
+     * @return The set of options used to validate the transient modification.
+     * @see org.apache.jackrabbit.jcr2spi.state.ItemStateValidator
+     */
+    public int getOptions() {
+        return options;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/TransientOperation.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?rev=1157177&r1=1157176&r2=1157177&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
Fri Aug 12 16:32:51 2011
@@ -239,13 +239,10 @@ public class SessionItemStateManager ext
      * @see OperationVisitor#visit(AddNode)
      */
     public void visit(AddNode operation) throws LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException,
VersionException, RepositoryException {
-        int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_COLLISION
-            | ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_CONSTRAINTS;
-
         NodeState parent = operation.getParentState();
         ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
         QNodeDefinition def = defProvider.getQNodeDefinition(parent.getAllNodeTypeNames(),
operation.getNodeName(), operation.getNodeTypeName());
-        List<ItemState> newStates = addNodeState(parent, operation.getNodeName(), operation.getNodeTypeName(),
operation.getUuid(), def, options);
+        List<ItemState> newStates = addNodeState(parent, operation.getNodeName(), operation.getNodeTypeName(),
operation.getUuid(), def, operation.getOptions());
         operation.addedState(newStates);
 
         transientStateMgr.addOperation(operation);
@@ -265,11 +262,8 @@ public class SessionItemStateManager ext
                 targetType = PropertyType.STRING;
             }
         }
-        int options = ItemStateValidator.CHECK_LOCK
-            | ItemStateValidator.CHECK_COLLISION
-            | ItemStateValidator.CHECK_VERSIONING
-            | ItemStateValidator.CHECK_CONSTRAINTS;
-        addPropertyState(parent, propertyName, targetType, operation.getValues(), pDef, options);
+
+        addPropertyState(parent, propertyName, targetType, operation.getValues(), pDef, operation.getOptions());
 
         transientStateMgr.addOperation(operation);
     }
@@ -285,17 +279,9 @@ public class SessionItemStateManager ext
         NodeState destParent = operation.getDestinationParentState();
 
         // state validation: move-Source can be removed from old/added to new parent
-        validator.checkRemoveItem(srcState,
-            ItemStateValidator.CHECK_ACCESS
-            | ItemStateValidator.CHECK_LOCK
-            | ItemStateValidator.CHECK_VERSIONING
-            | ItemStateValidator.CHECK_CONSTRAINTS);
+        validator.checkRemoveItem(srcState, operation.getOptions());
         validator.checkAddNode(destParent, operation.getDestinationName(),
-            srcState.getNodeTypeName(),
-            ItemStateValidator.CHECK_ACCESS
-            | ItemStateValidator.CHECK_LOCK
-            | ItemStateValidator.CHECK_VERSIONING
-            | ItemStateValidator.CHECK_CONSTRAINTS);
+            srcState.getNodeTypeName(), operation.getOptions());
 
         // retrieve applicable definition at the new place
         ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
@@ -313,10 +299,7 @@ public class SessionItemStateManager ext
      */
     public void visit(Remove operation) throws ConstraintViolationException, AccessDeniedException,
UnsupportedRepositoryOperationException, VersionException, RepositoryException {
         ItemState state = operation.getRemoveState();
-        int options = ItemStateValidator.CHECK_LOCK
-            | ItemStateValidator.CHECK_VERSIONING
-            | ItemStateValidator.CHECK_CONSTRAINTS;
-        removeItemState(state, options);
+        removeItemState(state, operation.getOptions());
 
         transientStateMgr.addOperation(operation);
         operation.getParentState().markModified();
@@ -339,23 +322,20 @@ public class SessionItemStateManager ext
             if (mixinEntry != null) {
                 // execute value of existing property
                 PropertyState pState = mixinEntry.getPropertyState();
-                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-                setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory), PropertyType.NAME,
options);
+                setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory), PropertyType.NAME,
operation.getOptions());
             } else {
                 // create new jcr:mixinTypes property
                 ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
                 QPropertyDefinition pd = defProvider.getQPropertyDefinition(nState.getAllNodeTypeNames(),
NameConstants.JCR_MIXINTYPES, PropertyType.NAME, true);
                 QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
-                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-                addPropertyState(nState, pd.getName(), pd.getRequiredType(), mixinValue,
pd, options);
+                addPropertyState(nState, pd.getName(), pd.getRequiredType(), mixinValue,
pd, operation.getOptions());
             }
             nState.markModified();
             transientStateMgr.addOperation(operation);
         } else if (mixinEntry != null) {
             // remove the jcr:mixinTypes property state if already present
             PropertyState pState = mixinEntry.getPropertyState();
-            int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
-            removeItemState(pState, options);
+            removeItemState(pState, operation.getOptions());
 
             nState.markModified();
             transientStateMgr.addOperation(operation);
@@ -386,8 +366,7 @@ public class SessionItemStateManager ext
         // changing the node state itself
         PropertyEntry pEntry = nEntry.getPropertyEntry(NameConstants.JCR_PRIMARYTYPE);
         PropertyState pState = pEntry.getPropertyState();
-        int options = ItemStateValidator.CHECK_VERSIONING | ItemStateValidator.CHECK_LOCK;
-        setPropertyStateValue(pState, getQValues(new Name[] {primaryName}, qValueFactory),
PropertyType.NAME, options);
+        setPropertyStateValue(pState, getQValues(new Name[] {primaryName}, qValueFactory),
PropertyType.NAME, operation.getOptions());
 
         // mark the affected node state modified and remember the operation
         nState.markModified();
@@ -399,10 +378,7 @@ public class SessionItemStateManager ext
      */
     public void visit(SetPropertyValue operation) throws ValueFormatException, LockException,
ConstraintViolationException, AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException,
VersionException, RepositoryException {
         PropertyState pState = operation.getPropertyState();
-        int options = ItemStateValidator.CHECK_LOCK
-            | ItemStateValidator.CHECK_VERSIONING
-            | ItemStateValidator.CHECK_CONSTRAINTS;
-        setPropertyStateValue(pState, operation.getValues(), operation.getValueType(), options);
+        setPropertyStateValue(pState, operation.getValues(), operation.getValueType(), operation.getOptions());
         transientStateMgr.addOperation(operation);
     }
 



Mime
View raw message