[exo-jcr-commits] exo-jcr SVN: r2700 - in jcr/branches/1.12.x/exo.jcr.component.core/src: test/java/org/exoplatform/services/jcr/usecases and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jun 24 11:19:13 EDT 2010


Author: sergiykarpenko
Date: 2010-06-24 11:19:13 -0400 (Thu, 24 Jun 2010)
New Revision: 2700

Added:
   jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestMixin.java
Modified:
   jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
Log:
EXOJCR-813: ItemImpl.getParent method return session pooled parent

Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java	2010-06-24 15:17:59 UTC (rev 2699)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java	2010-06-24 15:19:13 UTC (rev 2700)
@@ -224,7 +224,7 @@
       if (isRoot())
          throw new ItemNotFoundException("Root node does not have a parent");
 
-      return parent();
+      return parent(true);
    }
 
    /**
@@ -723,27 +723,32 @@
       return getData().getQPath().getName();
    }
 
-   protected ItemImpl item(String identifier) throws RepositoryException
+   /**
+    * Get parent node item. Session pool is ignored.
+    * 
+    * @return parent item
+    * @throws RepositoryException if parent item is null
+    */
+   protected NodeImpl parent() throws RepositoryException
    {
-      return dataManager.getItemByIdentifier(identifier, false);
+      return parent(false);
    }
 
    /**
-    * Get parent node item.
+    * Get parent node item. 
     * 
+    * @param pool - take a parent from session pool
     * @return parent item
-    * @throws RepositoryException
-    *           if parent item is null
+    * @throws RepositoryException if parent item is null
     */
-   protected NodeImpl parent() throws RepositoryException
+   protected NodeImpl parent(final boolean pool) throws RepositoryException
    {
-      NodeImpl parent = (NodeImpl)item(getParentIdentifier());
+      NodeImpl parent = (NodeImpl)dataManager.getItemByIdentifier(getParentIdentifier(), pool);
       if (parent == null)
       {
          throw new ItemNotFoundException("FATAL: Parent is null for " + getPath() + " parent UUID: "
             + getParentIdentifier());
       }
-
       return parent;
    }
 

Added: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestMixin.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestMixin.java	                        (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/TestMixin.java	2010-06-24 15:19:13 UTC (rev 2700)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.usecases;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a> 
+ * @version $Id: TestMixin.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestMixin extends BaseUsecasesTest
+{
+
+   public void testMixin() throws Exception
+   {
+      Node a = session.getRootNode().addNode("a");
+      a.addMixin("mix:referenceable");
+
+      Property p = a.setProperty("prop", "string");
+      Node a1 = p.getParent();
+
+      a1.addMixin("mix:lockable");
+      a.addMixin("mix:versionable");
+      session.save();
+
+      //check result
+      Node a2 = session.getRootNode().getNode("a");
+      assertTrue(a2.isNodeType("mix:referenceable"));
+      assertTrue(a2.isNodeType("mix:versionable"));
+      assertTrue(a2.isNodeType("mix:lockable"));
+   }
+}



More information about the exo-jcr-commits mailing list