jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1171695 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: hierarchy/HierarchyEntry.java hierarchy/NodeEntry.java state/NodeState.java state/WorkspaceItemStateFactory.java
Date Fri, 16 Sep 2011 17:49:30 GMT
Author: mduerig
Date: Fri Sep 16 17:49:30 2011
New Revision: 1171695

URL: http://svn.apache.org/viewvc?rev=1171695&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
minor cleanup   

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java?rev=1171695&r1=1171694&r2=1171695&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
Fri Sep 16 17:49:30 2011
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.jcr2spi.hi
 import org.apache.jackrabbit.jcr2spi.operation.Operation;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.ItemState.MergeResult;
-import org.apache.jackrabbit.jcr2spi.state.ItemStateFactory;
 import org.apache.jackrabbit.jcr2spi.state.Status;
 import org.apache.jackrabbit.jcr2spi.state.TransientItemStateFactory;
 import org.apache.jackrabbit.spi.IdFactory;
@@ -92,7 +91,7 @@ public abstract class HierarchyEntry<STA
      * Shortcut for {@link EntryFactory#getItemStateFactory()}
      * @return
      */
-    protected TransientItemStateFactory getItemStateFactory() {
+    protected final TransientItemStateFactory getItemStateFactory() {
         return factory.getItemStateFactory();
     }
 
@@ -100,7 +99,7 @@ public abstract class HierarchyEntry<STA
      * Shortcut for {@link EntryFactory#getPathFactory()}
      * @return
      */
-    protected PathFactory getPathFactory() {
+    protected final PathFactory getPathFactory() {
         return factory.getPathFactory();
     }
 
@@ -108,11 +107,19 @@ public abstract class HierarchyEntry<STA
      * Shortcut for {@link EntryFactory#getIdFactory()}
      * @return
      */
-    protected IdFactory getIdFactory() {
+    protected final IdFactory getIdFactory() {
         return factory.getIdFactory();
     }
 
     /**
+     * Shortcut for {@link EntryFactory#getInvalidationStrategy()}
+     * @return
+     */
+    protected EntryFactory.InvalidationStrategy getInvalidationStrategy() {
+        return factory.getInvalidationStrategy();
+    }
+
+    /**
      * Resolves this {@code HierarchyEntryImpl} and returns the target
      * {@code ItemState} of this reference. This method may return a
      * cached {@code ItemState} if this method was called before already
@@ -191,10 +198,6 @@ public abstract class HierarchyEntry<STA
             : null;
     }
 
-    protected EntryFactory.InvalidationStrategy getInvalidationStrategy() {
-        return factory.getInvalidationStrategy();
-    }
-
     /**
      * Invalidates the underlying {@link ItemState}. If {@code recursive} is
      * true also invalidates the underlying item states of all child entries.
@@ -202,9 +205,7 @@ public abstract class HierarchyEntry<STA
      */
     protected void invalidateInternal(boolean recursive) {
         STATE_TYPE state = internalGetItemState();
-        if (state == null) {
-            log.debug("Skip invalidation for unresolved HierarchyEntry " + name);
-        } else {
+        if (state != null) {
             state.invalidate();
         }
     }
@@ -247,19 +248,17 @@ public abstract class HierarchyEntry<STA
     /**
      * If this {@code HierarchyEntry} provides an underlying
      * {@code ItemState} this method returns the status of that state,
-     * otherwise it returns {@link org.apache.jackrabbit.jcr2spi.state.Status#_UNDEFINED_}.
+     * otherwise it returns {@link Status#_UNDEFINED_}.
      *
-     * @return Status of the ItemState or {@link org.apache.jackrabbit.jcr2spi.state.Status#_UNDEFINED_}
if this
+     * @return Status of the ItemState or {@link Status#_UNDEFINED_} if this
      * entry has not been resolved yet.
      * @see ItemState#getStatus()
      */
     public Status getStatus() {
         STATE_TYPE state = internalGetItemState();
-        if (state == null) {
-            return Status._UNDEFINED_;
-        } else {
-            return state.getStatus();
-        }
+        return state == null
+            ? Status._UNDEFINED_
+            : state.getStatus();
     }
 
     /**
@@ -330,7 +329,7 @@ public abstract class HierarchyEntry<STA
      * also invalidates the child entries recursively.<br>
      * Note, that in contrast to {@link HierarchyEntry#reload(boolean)}
      * this method only sets the status of this item state to {@link
-     * org.apache.jackrabbit.jcr2spi.state.Status#INVALIDATED} and does not actually update
it with the persistent
+     * Status#INVALIDATED} and does not actually update it with the persistent
      * state in the repository.
      */
     public void invalidate(boolean recursive) {
@@ -348,7 +347,7 @@ public abstract class HierarchyEntry<STA
     /**
      * Traverses the hierarchy and reverts all transient modifications such as
      * adding, modifying or removing item states. 'Existing' item states
-     * are reverted to their initial state and their status is reset to {@link org.apache.jackrabbit.jcr2spi.state.Status#EXISTING}.
+     * are reverted to their initial state and their status is reset to {@link Status#EXISTING}.
      *
      * @throws RepositoryException if an error occurs.
      */
@@ -363,10 +362,6 @@ public abstract class HierarchyEntry<STA
         switch (oldStatus) {
             case EXISTING_MODIFIED:
             case STALE_MODIFIED:
-                // revert state modifications
-                state.revert();
-                state.setStatus(Status.EXISTING);
-                break;
             case EXISTING_REMOVED:
                 // revert state modifications
                 state.revert();
@@ -406,7 +401,7 @@ public abstract class HierarchyEntry<STA
      *
      * @param recursive
      */
-    public void reload(boolean recursive) {
+    public void reload(boolean recursive) throws RepositoryException {
         Status status = getStatus();
         if (status == Status._UNDEFINED_) {
             // unresolved: entry will be loaded and validated upon resolution.
@@ -422,28 +417,24 @@ public abstract class HierarchyEntry<STA
         // Retrieved a fresh ItemState from the persistent layer. Which will
         // then be merged into the current state.
         try {
-            ItemStateFactory isf = getItemStateFactory();
             if (denotesNode()) {
                 NodeEntry ne = cast(this);
-                isf.createNodeState(ne.getWorkspaceId(), ne);
+                getItemStateFactory().createNodeState(ne.getWorkspaceId(), ne);
             } else {
                 PropertyEntry pe = cast(this);
-                isf.createPropertyState(pe.getWorkspaceId(), pe);
+                getItemStateFactory().createPropertyState(pe.getWorkspaceId(), pe);
             }
         } catch (ItemNotFoundException e) {
             // remove hierarchyEntry including all children
-            log.debug("Item '" + getName() + "' cannot be found on the persistent layer ->
remove.");
+            log.debug("Item '" + getName() + "' cannot be found on the persistent layer ->
remove.", e);
             remove();
-        } catch (RepositoryException e) {
-            // TODO: rather throw?
-            log.error("Exception while reloading item: " + e);
         }
     }
 
     /**
      * Traverses the hierarchy and marks all available item states as transiently
-     * removed. They will change their status to either {@link org.apache.jackrabbit.jcr2spi.state.Status#EXISTING_REMOVED}
if
-     * the item is existing in the persistent storage or {@link org.apache.jackrabbit.jcr2spi.state.Status#REMOVED}
+     * removed. They will change their status to either {@link Status#EXISTING_REMOVED} if
+     * the item is existing in the persistent storage or {@link Status#REMOVED}
      * if the item has been transiently added before. In the latter case, the
      * corresponding HierarchyEntries can be removed as well from their parent.
      *
@@ -492,8 +483,8 @@ public abstract class HierarchyEntry<STA
 
     /**
      * Removes this {@code HierarchyEntry} from its parent and sets the
-     * status of the underlying ItemState to {@link org.apache.jackrabbit.jcr2spi.state.Status#REMOVED}
or to
-     * {@link org.apache.jackrabbit.jcr2spi.state.Status#STALE_DESTROYED}, respectively.
If this entry is a
+     * status of the underlying ItemState to {@link Status#REMOVED} or to
+     * {@link Status#STALE_DESTROYED}, respectively. If this entry is a
      * NodeEntry all descending ItemStates must get their status changed as well.
      */
     public void remove() {

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java?rev=1171695&r1=1171694&r2=1171695&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java
Fri Sep 16 17:49:30 2011
@@ -198,7 +198,7 @@ public class NodeEntry extends Hierarchy
      * @see HierarchyEntry#reload(boolean)
      */
     @Override
-    public void reload(boolean recursive) {
+    public void reload(boolean recursive) throws RepositoryException {
         // reload this entry
         super.reload(recursive);
 

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?rev=1171695&r1=1171694&r2=1171695&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Fri Sep 16 17:49:30 2011
@@ -123,23 +123,23 @@ public class NodeState extends ItemState
                 throw new IllegalArgumentException("Attempt to merge node state with property
state.");
             }
             synchronized (another) {
-                NodeState nState = cast(another);
+                NodeState otherState = cast(another);
 
-                if (!nodeTypeName.equals(nState.nodeTypeName)) {
-                    nodeTypeName = nState.nodeTypeName;
+                if (!nodeTypeName.equals(otherState.nodeTypeName)) {
+                    nodeTypeName = otherState.nodeTypeName;
                     modified = true;
                 }
 
-                if (nState.definition != null && !nState.definition.equals(definition))
{
-                    definition = nState.definition;
+                if (otherState.definition != null && !otherState.definition.equals(definition))
{
+                    definition = otherState.definition;
                     modified = true;
                 }
 
                 // since 'mixinTypeNames' are modified upon save only, no special
                 // merging is required here. just reset the mixinTypeNames.
-                List<Name> mixN = Arrays.asList(nState.mixinTypeNames);
+                List<Name> mixN = Arrays.asList(otherState.mixinTypeNames);
                 if (mixN.size() != mixinTypeNames.length || !mixN.containsAll(Arrays.asList(mixinTypeNames)))
{
-                    setMixinTypeNames(nState.mixinTypeNames);
+                    setMixinTypeNames(otherState.mixinTypeNames);
                     modified = true;
                 }
             }

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java?rev=1171695&r1=1171694&r2=1171695&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/WorkspaceItemStateFactory.java
Fri Sep 16 17:49:30 2011
@@ -339,8 +339,7 @@ public class WorkspaceItemStateFactory e
         }
 
         // now build or update the node state itself
-        NodeState tmp = new NodeState(entry, info, this, definitionProvider);
-        entry.setItemState(tmp);
+        entry.setItemState(new NodeState(entry, info, this, definitionProvider));
 
         NodeState nState = entry.getNodeState();
         if (previousStatus == Status._UNDEFINED_) {



Mime
View raw message