jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1171185 - in /jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: JcrVersionManager.java SessionImpl.java hierarchy/NodeEntry.java
Date Thu, 15 Sep 2011 17:25:23 GMT
Author: mduerig
Date: Thu Sep 15 17:25:23 2011
New Revision: 1171185

URL: http://svn.apache.org/viewvc?rev=1171185&view=rev
Log:
Microkernel based Jackrabbit prototype (WIP) 
refactor: use cast function instead of explicit cast wherever cast is provably correct

Modified:
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntry.java

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java?rev=1171185&r1=1171184&r2=1171185&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/JcrVersionManager.java
Thu Sep 15 17:25:23 2011
@@ -37,6 +37,8 @@ import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import java.util.Iterator;
 
+import static org.apache.jackrabbit.spi.commons.util.Unchecked.cast;
+
 /**
  * {@code VersionManagerImpl}...
  */
@@ -297,11 +299,15 @@ public class JcrVersionManager implement
     private NodeImpl getValidActivity(Node activityNode, String methodName) throws RepositoryException
{
         NodeImpl activity;
         if (session == activityNode.getSession()) {
-            activity = (NodeImpl) activityNode;
+            if (!(activityNode instanceof NodeImpl)) {
+                throw new RepositoryException("Invalid argument: " + activityNode);
+            }
+
+            activity = cast(activityNode);
         } else {
             String msg = "Attempt to " + methodName + " an activity node that has been retrieved
by another session.";
             log.warn(msg);
-            activity = (NodeImpl) session.getNodeByIdentifier(activityNode.getIdentifier());
+            activity = session.getNodeByIdentifier(activityNode.getIdentifier());
         }
         if (!activity.isNodeType(NameConstants.NT_ACTIVITY)) {
             throw new UnsupportedRepositoryOperationException("Given node is not an activity.");

Modified: jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=1171185&r1=1171184&r2=1171185&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/sandbox/jackrabbit-mk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Thu Sep 15 17:25:23 2011
@@ -56,6 +56,7 @@ import org.apache.jackrabbit.spi.commons
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeResolver;
+import org.apache.jackrabbit.spi.commons.util.Unchecked;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -530,7 +531,7 @@ public class SessionImpl extends Abstrac
      * @see Session#getNodeByIdentifier(String)
      */
     @Override
-    public Node getNodeByIdentifier(String id) throws RepositoryException {
+    public NodeImpl getNodeByIdentifier(String id) throws RepositoryException {
         return getNodeById(getIdFactory().fromJcrIdentifier(id));
     }
 
@@ -849,7 +850,11 @@ public class SessionImpl extends Abstrac
     NodeState getVersionState(Version version) throws RepositoryException {
         NodeState nodeState;
         if (version.getSession() == this) {
-            nodeState = ((NodeImpl) version).getItemState();
+            if (!(version instanceof NodeImpl)) {
+                throw new RepositoryException("Invalid argument" + version);
+            }
+
+            nodeState = Unchecked.<NodeImpl>cast(version).getItemState();
         } else {
             Path p = getQPath(version.getPath());
             Path parentPath = p.getAncestor(1);

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=1171185&r1=1171184&r2=1171185&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
Thu Sep 15 17:25:23 2011
@@ -1116,7 +1116,11 @@ public class NodeEntry extends Hierarchy
                         // special cases: jcr:uuid and jcr:mixinTypes affect the
                         // parent (i.e. this NodeEntry)
                         if (isUuidOrMixin(eventName)) {
-                            notifyUUIDorMIXINModified((PropertyEntry) child);
+                            if (!(child instanceof PropertyEntry)) {
+                                throw new IllegalArgumentException("Invalid event: " + childEvent);
+                            }
+
+                            notifyUUIDorMIXINModified(Unchecked.<PropertyEntry>cast(child));
                         }
                     }
                 } // else: existing entry but state not yet built -> ignore event



Mime
View raw message