[exo-jcr-commits] exo-jcr SVN: r736 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/storage/inmemory and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Nov 18 03:03:57 EST 2009


Author: nzamosenchuk
Date: 2009-11-18 03:03:56 -0500 (Wed, 18 Nov 2009)
New Revision: 736

Modified:
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
Log:
EXOJCR-242: WorkspaceStorageConnection (and all their implementators) extended with addLockData() and removeLockData(). JBossCacheStorageConnection filled with logic: locks are written and removed to or from /$LOCKS subtree of cache.

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/JBossCacheWorkspaceDataManager.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -18,11 +18,8 @@
  */
 package org.exoplatform.services.jcr.impl.dataflow.persistent;
 
-import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
-import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
 import org.exoplatform.services.jcr.dataflow.ItemState;
 import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
 import org.exoplatform.services.jcr.dataflow.ReadOnlyThroughChanges;
 import org.exoplatform.services.jcr.datamodel.QPath;
 import org.exoplatform.services.jcr.impl.Constants;
@@ -31,10 +28,8 @@
 import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
 import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
 
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
 import javax.jcr.RepositoryException;

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -249,7 +249,7 @@
    /**
     * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLockData(java.lang.String)
     */
-   public LockData getLockData(String identifier)
+   public LockData getLockData(String identifier) throws RepositoryException
    {
       return null;
    }
@@ -257,9 +257,23 @@
    /**
     * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLocksData()
     */
-   public List<LockData> getLocksData()
+   public List<LockData> getLocksData() throws RepositoryException
    {
       return null;
    }
 
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
+    */
+   public void addLockData(LockData lockData) throws RepositoryException
+   {
+   }
+
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#removeLockData(java.lang.String)
+    */
+   public void removeLockData(String identifier) throws RepositoryException
+   {
+   }
+
 }

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -38,6 +38,7 @@
 
 import javax.jcr.InvalidItemStateException;
 import javax.jcr.RepositoryException;
+import javax.jcr.lock.LockException;
 
 /**
  * Created by The eXo Platform SAS.
@@ -660,7 +661,7 @@
    /**
     * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLockData(java.lang.String)
     */
-   public LockData getLockData(String identifier)
+   public LockData getLockData(String identifier) throws RepositoryException
    {
       LockData lockData = null;
       Node<Serializable, Object> node = locksRoot.getChild(makeNodeFqn(identifier));
@@ -674,7 +675,7 @@
    /**
     * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLocksData()
     */
-   public List<LockData> getLocksData()
+   public List<LockData> getLocksData() throws RepositoryException
    {
       Set<Node<Serializable, Object>> lockSet = locksRoot.getChildren();
       List<LockData> locksData = new ArrayList<LockData>();
@@ -691,4 +692,44 @@
       }
       return locksData;
    }
+
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
+    */
+   public void addLockData(LockData lockData) throws RepositoryException
+   {
+      if (lockData == null)
+      {
+         throw new RepositoryException("Lock data to write can't be null!");
+      }
+      // check that there is no lock data for given node
+      Node<Serializable, Object> oldNode = locksRoot.getChild(makeNodeFqn(lockData.getNodeIdentifier()));
+      if (oldNode.get(JBossCacheStorage.LOCK_DATA) != null)
+      {
+         throw new LockException("Unable to write lock data. Node [" + lockData.getNodeIdentifier()
+            + "] already has LockData!");
+      }
+      // try to write LockData 
+      Node<Serializable, Object> node = locksRoot.addChild(makeNodeFqn(lockData.getNodeIdentifier()));
+      if (node == null)
+      {
+         throw new RepositoryException("Unable to write to cache!");
+      }
+      // this will prevent from deleting it by eviction.
+      node.setResident(true);
+      node.put(JBossCacheStorage.LOCK_DATA, lockData);
+
+   }
+
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#removeLockData(java.lang.String)
+    */
+   public void removeLockData(String identifier) throws RepositoryException
+   {
+      if (identifier != null)
+      {
+         throw new RepositoryException("Item ID to clear lock can't be null!");
+      }
+      locksRoot.removeChild(makeNodeFqn(identifier));
+   }
 }

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -422,4 +422,22 @@
       throw new UnsupportedOperationException();
    }
 
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
+    */
+   public void addLockData(LockData lockData) throws RepositoryException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#removeLockData(java.lang.String)
+    */
+   public void removeLockData(String identifier) throws RepositoryException
+   {
+      // TODO Auto-generated method stub
+      
+   }
+
 }

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -716,6 +716,22 @@
       return null;
    }
 
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
+    */
+   public void addLockData(LockData lockData) throws RepositoryException
+   {
+      // TODO Add logic HERE! Need to store locks some where
+   }
+
+   /**
+    * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#removeLockData(java.lang.String)
+    */
+   public void removeLockData(String identifier) throws RepositoryException
+   {
+      // TODO Add logic HERE! Need to store locks some where
+   }
+
    // ------------------ Private methods ---------------
 
    /**

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -321,11 +321,27 @@
     * @return
     *    LockData by given node uuid, or null if not present
     */
-   LockData getLockData(String identifier);
+   LockData getLockData(String identifier) throws RepositoryException;
 
    /**
     * @return
     *    List of all locks.
     */
-   List<LockData> getLocksData();
+   List<LockData> getLocksData() throws RepositoryException;
+
+   /**
+    * Writes lock data
+    * 
+    * @param lockData
+    * @throws RepositoryException
+    */
+   void addLockData(LockData lockData) throws RepositoryException;
+
+   /**
+    * Removes lock data
+    * 
+    * @param identifier
+    * @throws RepositoryException
+    */
+   void removeLockData(String identifier) throws RepositoryException;
 }

Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java	2009-11-18 06:44:11 UTC (rev 735)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java	2009-11-18 08:03:56 UTC (rev 736)
@@ -547,7 +547,7 @@
       /**
        * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLockData(java.lang.String)
        */
-      public LockData getLockData(String identifier)
+      public LockData getLockData(String identifier) throws RepositoryException
       {
          return null;
       }
@@ -555,11 +555,25 @@
       /**
        * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLocksData()
        */
-      public List<LockData> getLocksData()
+      public List<LockData> getLocksData() throws RepositoryException
       {
          return null;
       }
 
+      /**
+       * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
+       */
+      public void addLockData(LockData lockData) throws RepositoryException
+      {
+      }
+
+      /**
+       * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#removeLockData(java.lang.String)
+       */
+      public void removeLockData(String identifier) throws RepositoryException
+      {
+      }
+
    }
 
 }



More information about the exo-jcr-commits mailing list