jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r463327 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state: ChangeLog.java ItemState.java ItemStateValidator.java NodeState.java SessionItemStateManager.java
Date Thu, 12 Oct 2006 17:10:42 GMT
Author: angela
Date: Thu Oct 12 10:10:42 2006
New Revision: 463327

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

- ChangeLog.checkIsSelfContained should throw destinct exception
  instead of general ItemStateException, which results in RepositoryEx.
- NodeState.refresh: 'add' event must only create a new childentry
  if it has not been indirectly created by a previous event.
- add more todos for SNS-handling

Modified:
    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/ItemState.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/SessionItemStateManager.java

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=463327&r1=463326&r2=463327
==============================================================================
--- 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 12 10:10:42 2006
@@ -18,6 +18,7 @@
 
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 
+import javax.jcr.nodetype.ConstraintViolationException;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.LinkedHashSet;
@@ -189,8 +190,7 @@
      * (e.g. moving a node requires that the target node including both
      * old and new parents are saved)
      */
-    public void checkIsSelfContained()
-            throws ItemStateException {
+    public void checkIsSelfContained() throws ConstraintViolationException {
         Set affectedStates = new HashSet();
         affectedStates.addAll(modifiedStates);
         affectedStates.addAll(deletedStates);
@@ -206,7 +206,7 @@
             if (!affectedStates.containsAll(opStates)) {
                 // need to save the parent as well
                 String msg = "ChangeLog is not self contained.";
-                throw new ItemStateException(msg);
+                throw new ConstraintViolationException(msg);
             }
         }
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java?view=diff&rev=463327&r1=463326&r2=463327
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemState.java
Thu Oct 12 10:10:42 2006
@@ -361,6 +361,12 @@
         }
     }
 
+    /**
+     * @return true, if this state is overlaying a workspace state.
+     */
+    public boolean hasOverlayedState() {
+        return overlayedState != null;
+    }
     //--------------------------------------------------< Workspace - State >---
     /**
      * Used on 'workspace' states in order to update the state according to

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=463327&r1=463326&r2=463327
==============================================================================
--- 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 12 10:10:42 2006
@@ -570,10 +570,6 @@
         // access rights
         if ((options & CHECK_ACCESS) == CHECK_ACCESS) {
             try {
-                // make sure current session is granted read access on parent node
-                if (!mgrProvider.getAccessManager().canRead(targetState)) {
-                    throw new PathNotFoundException(safeGetJCRPath(targetState));
-                }
                 // make sure current session is allowed to remove target node
                 if (!mgrProvider.getAccessManager().canRemove(targetState)) {
                     throw new AccessDeniedException(safeGetJCRPath(targetState)

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=463327&r1=463326&r2=463327
==============================================================================
--- 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 12 10:10:42 2006
@@ -571,8 +571,16 @@
 
                     if (evId.denotesNode()) {
                         QName name = event.getQPath().getNameElement().getName();
+                        int index = event.getQPath().getNameElement().getNormalizedIndex();
                         String uuid = (((NodeId)evId).getPath() != null) ? null : ((NodeId)evId).getUUID();
-                        ChildNodeEntry cne = childNodeEntries.add(name, uuid);
+
+                        // add new childNodeEntry if it has not been added by
+                        // some earlier 'add' event
+                        // TODO: TOBEFIXED for SNSs
+                        ChildNodeEntry cne = getChildNodeEntry(name, index);
+                        if (cne == null || ((uuid == null) ? cne.getUUID() != null : !uuid.equals(cne.getUUID())))
{
+                            cne = childNodeEntries.add(name, uuid);
+                        }
                         try {
                             newState = cne.getNodeState();
                         } catch (ItemStateException e) {
@@ -580,8 +588,15 @@
                         }
                     } else {
                         QName pName = ((PropertyId) event.getItemId()).getQName();
-                        ChildPropertyEntry re = PropertyReference.create(this, pName, isf,
idFactory);
-                        properties.put(pName, re);
+                        // create a new property reference if it has not been
+                        // added by some earlier 'add' event
+                        ChildPropertyEntry re;
+                        if (hasPropertyName(pName)) {
+                            re = (ChildPropertyEntry) properties.get(pName);
+                        } else {
+                            re = PropertyReference.create(this, pName, isf, idFactory);
+                            properties.put(pName, re);
+                        }
                         try {
                             newState = re.getPropertyState();
                         } catch (ItemStateException e) {
@@ -596,6 +611,11 @@
                     if (newState != null && changeLog != null) {
                         for (Iterator it = changeLog.addedStates(); it.hasNext();) {
                             ItemState added = (ItemState) it.next();
+                            if (added.hasOverlayedState()) {
+                                // already connected
+                                continue;
+                            }
+                            // TODO: TOBEFIXED. may fail (produce wrong results) for SNSs,
since currently events upon 'save' are not garantied to be 'local' changes only
                             if (added.getId().equals(evId)) {
                                 added.connect(newState);
                                 added.merge();

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=463327&r1=463326&r2=463327
==============================================================================
--- 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 12 10:10:42 2006
@@ -281,7 +281,7 @@
      *                            changes. That is, at least another item needs
      *                            to be canceled as well in another sub-tree.
      */
-    public void undo(ItemState itemState) throws ItemStateException {
+    public void undo(ItemState itemState) throws ItemStateException, ConstraintViolationException
{
         // check if self contained
         ChangeLog changeLog = new ChangeLog(itemState);
         collectTransientStates(itemState, changeLog, false);
@@ -341,7 +341,7 @@
      * @throws StaleItemStateException
      * @throws ItemStateException
      */
-    private ChangeLog getChangeLog(ItemState itemState) throws StaleItemStateException, ItemStateException
{
+    private ChangeLog getChangeLog(ItemState itemState) throws StaleItemStateException, ItemStateException,
ConstraintViolationException {
         // build changelog for affected and decendant states only
         ChangeLog changeLog = new ChangeLog(itemState);
         collectTransientStates(itemState, changeLog, true);
@@ -493,6 +493,7 @@
             | ItemStateValidator.CHECK_LOCK
             | ItemStateValidator.CHECK_VERSIONING
             | ItemStateValidator.CHECK_CONSTRAINTS);
+        
         // retrieve applicable definition at the new place
         // TODO: improve. definition has already retrieve within the checkAddNode...
         // TODO: improve. if move is simple rename, the definition must not be calculated
again.



Mime
View raw message