[exo-jcr-commits] exo-jcr SVN: r462 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Nov 1 17:10:06 EST 2009


Author: pnedonosko
Date: 2009-11-01 17:10:06 -0500 (Sun, 01 Nov 2009)
New Revision: 462

Added:
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java
Modified:
   jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
   jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
Log:
EXOJCR-201: new loader: get, getChilds impls

Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java	2009-11-01 22:06:48 UTC (rev 461)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java	2009-11-01 22:10:06 UTC (rev 462)
@@ -3,7 +3,7 @@
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 3 of
+ * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
@@ -16,51 +16,59 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.exoplatform.services.jcr.impl.storage.jbosscache;
 
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
 import org.exoplatform.services.jcr.datamodel.ItemData;
 import org.exoplatform.services.jcr.datamodel.NodeData;
 import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
 import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.jboss.cache.CacheSPI;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
 import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.RegionManager;
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.AbstractCacheLoader;
 
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-
 /**
  * Created by The eXo Platform SAS.
  * 
- * <br/>Date: 23.10.2009
+ * <br/>Date: 31.10.2009
  *
  * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
  * @version $Id$
  */
-public class ExoJCRCacheLoader implements CacheLoader
+public class ExoJCRCacheLoader extends AbstractCacheLoader
 {
-   //private CacheSPI cache;
 
-   //private RegionManager regionManager;
-
-   private IndividualCacheLoaderConfig config;
-
    private WorkspaceDataContainer dataContainer;
 
-   private HashMap<Object, List<Modification>> transactions = new HashMap<Object, List<Modification>>();
-
    /**
     * Init the loader DataContainer with given WorkspaceDataContainer instance.
     *
@@ -77,25 +85,17 @@
       this.dataContainer = dataContainer;
    }
 
-   /**
-    * {@inheritDoc}
-    */
-   public void commit(Object tx) throws Exception
+   protected QPathEntry[] makeNodePath(Fqn<String> nodeFqn) throws NumberFormatException, IllegalNameException
    {
-      List<Modification> modifications = transactions.remove(tx);
-      if (modifications != null)
-         doModified(modifications);
-      else
-         throw new ExoJCRCacheLoaderException("Transaction " + tx + " not exist in transaction table");
-   }
+      List<String> elements = nodeFqn.peekElements();
+      QPathEntry[] path = new QPathEntry[elements.size()];
 
-   /**
-    * {@inheritDoc}
-    */
-   public boolean exists(Fqn name) throws Exception
-   {
-      // TODO use get(Fqn), i.e. get Node!=null  
-      return false;
+      for (int i = 0; i < elements.size(); i++)
+      {
+         path[i] = QPathEntry.parse(elements.get(i));
+      }
+
+      return path;
    }
 
    /**
@@ -103,182 +103,182 @@
     */
    public Map<Object, Object> get(Fqn name) throws Exception
    {
-      // TODO get Node
-      return null;
-   }
 
-   /**
-    * {@inheritDoc}
-    */
-   public Set<?> getChildrenNames(Fqn fqn) throws Exception
-   {
-      // TODO get child nodes names
-      return null;
-   }
+      Map<Object, Object> attrs = new LinkedHashMap<Object, Object>();
+      if (name.size() > 1)
+      {
+         if (name.get(1).equals(JBossCacheStorage.TREE))
+         {
+            // return Node
+            if (name.size() > 3)
+            {
+               QPathEntry nodeName = QPathEntry.parse(name.getLastElementAsString());
 
-   /**
-    * {@inheritDoc}
-    */
-   public IndividualCacheLoaderConfig getConfig()
-   {
-      return config;
-   }
+               // TODO non effective, in this way 1) all subtree will be cached
+               // 2) all subtree will be read from DB (with allprops) for only Ids.
+               // The effective way DON NOT use calls to cache and use special SQLs for Ids only read. 
+               String parentId = (String)cache.get(name.getParent(), JBossCacheStorage.ITEM_ID);
 
-   /**
-    * {@inheritDoc}
-    */
-   public void loadEntireState(ObjectOutputStream os) throws Exception
-   {
-      // TODO Auto-generated method stub
+               WorkspaceStorageConnection conn = dataContainer.openConnection();
+               try
+               {
+                  NodeData parent = (NodeData)conn.getItemData(parentId);
 
-   }
+                  ItemData item = conn.getItemData(parent, nodeName);
 
-   /**
-    * {@inheritDoc}
-    */
-   public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
-   {
-      // TODO Auto-generated method stub
+                  // item Id
+                  attrs.put(JBossCacheStorage.ITEM_ID, item.getIdentifier());
 
+                  // if Node (Property cannot due to logic of StorageConnection) add props
+                  for (PropertyData prop : conn.getChildPropertiesData(parent))
+                  {
+                     attrs.put(prop.getQPath().getName().getAsString(), prop.getIdentifier());
+                  }
+               }
+               finally
+               {
+                  conn.close();
+               }
+            }
+            else
+            {
+               // root Node (/$TREE/[]:1)
+               attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
+            }
+         }
+         else if (name.get(1).equals(JBossCacheStorage.ITEMS))
+         {
+            // we have all data on thrid level 
+            if (name.size() == 3)
+            {
+               // return Node or Property
+               String itemId = name.getLastElementAsString();
+
+               WorkspaceStorageConnection conn = dataContainer.openConnection();
+               try
+               {
+                  attrs.put(JBossCacheStorage.ITEM_DATA, conn.getItemData(itemId));
+               }
+               finally
+               {
+                  conn.close();
+               }
+            }
+         }
+      }
+      return attrs;
    }
 
    /**
     * {@inheritDoc}
     */
-   public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+   public boolean exists(Fqn name) throws Exception
    {
-      if (onePhase)
-      {
-         doModified(modifications);
-      }
-      else
-      {
-         transactions.put(tx, modifications);
-      }
+      // TODO do it with less cost
+      return get(name) != null;
    }
 
    /**
-    * Will be added data to DB. 
-    * 
-    * @param modifications
-    * @throws Exception
+    * {@inheritDoc}
     */
-   private void doModified(List<Modification> modifications) throws Exception
+   public Set<?> getChildrenNames(Fqn fqn) throws Exception
    {
-      JDBCStorageConnection jdbcConnection = (JDBCStorageConnection)dataContainer.openConnection();
+      // return child nodes names
 
-      try
+      Set<String> childs = new LinkedHashSet<String>();
+      if (fqn.size() > 2)
       {
-         for (int modificatinIndex = 0; modificatinIndex < modifications.size(); modificatinIndex++)
+         if (fqn.get(2).equals(JBossCacheStorage.TREE))
          {
-            Modification md = modifications.get(modificatinIndex);
-            switch (md.getType())
+            // return Node
+            if (fqn.size() > 3)
             {
-               case PUT_KEY_VALUE :
-                  doAddOrUpdate(md, jdbcConnection);
-                  break;
-               case REMOVE_NODE :
-                  doRemove(md, jdbcConnection, "TODO $<Node identifier>");
-                  break;
-            }
-         }
+               QPathEntry nodeName = QPathEntry.parse(fqn.getLastElementAsString());
 
-         if (jdbcConnection != null)
-            jdbcConnection.commit();
-      }
-      finally
-      {
-         if (jdbcConnection != null && jdbcConnection.isOpened())
-            jdbcConnection.rollback();
-      }
-   }
+               // TODO non effective, in this way 1) all subtree will be cached
+               // 2) all subtree will be read from DB (with allprops) for only Ids.
+               // The effective way DON NOT use calls to cache and use special SQLs for Ids only read. 
+               String parentId = (String)cache.get(fqn.getParent(), JBossCacheStorage.ITEM_ID);
 
-   private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
-      throws IllegalStateException, RepositoryException
-   {
+               WorkspaceStorageConnection conn = dataContainer.openConnection();
+               try
+               {
+                  NodeData parent = (NodeData)conn.getItemData(parentId);
 
-      ItemData itemData = jdbcConnection.getItemData(identifier);
+                  NodeData node = (NodeData)conn.getItemData(parent, nodeName);
 
-      if (itemData instanceof NodeData)
-         jdbcConnection.delete((NodeData)itemData);
-      if (itemData instanceof PropertyData)
-         jdbcConnection.delete((PropertyData)itemData);
-   }
-
-   /**
-    * Performs ADD and UPDATE to NodeData and PropertyData.
-    * @param modification
-    * @param jdbcConnection
-    * @throws IllegalStateException
-    * @throws RepositoryException
-    */
-   private void doAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
-      throws IllegalStateException, RepositoryException
-   {
-      if (modification.getValue() instanceof NodeData)
-      {
-         //add or update node data
-         NodeData nodeData = (NodeData)modification.getValue();
-
-         ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
-
-         if (itemData == null)
-         {
-            //add
-            jdbcConnection.add(nodeData);
+                  // get child nodes by parent Id
+                  for (NodeData prop : conn.getChildNodesData(node))
+                  {
+                     childs
+                        .add(node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getAsString(true));
+                  }
+               }
+               finally
+               {
+                  conn.close();
+               }
+            }
+            else
+            {
+               // root Node (/$TREE/[]:1)
+               childs.add(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+                  .getAsString(true));
+            }
          }
-         else
+         else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
          {
-            //update
-            jdbcConnection.update(nodeData);
+            // we have all data on thrid level 
+            if (fqn.size() == 3)
+            {
+               // return all Nodes and Properties Ids
+
+//               WorkspaceStorageConnection conn = dataContainer.openConnection();
+//               try
+//               {
+//                  for (String itemId : conn.getAllItemIdentifiers())
+//                  {
+//                     childs.add(itemId);
+//                  }
+//               }
+//               finally
+//               {
+//                  conn.close();
+//               }
+            }
          }
       }
-      else if (modification.getValue() instanceof PropertyData)
+      else if (fqn.equals(Fqn.ROOT))
       {
-         //add or update property data
-         PropertyData propertyData = (PropertyData)modification.getValue();
-
-         ItemData itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
-
-         if (itemData == null)
-         {
-            //add
-            jdbcConnection.add(propertyData);
-         }
-         else
-         {
-            //update
-            jdbcConnection.update(propertyData);
-         }
+         childs.add(JBossCacheStorage.TREE);
+         childs.add(JBossCacheStorage.ITEMS);
       }
+      return childs;
    }
 
    /**
     * {@inheritDoc}
     */
-   public Object put(Fqn name, Object key, Object value) throws Exception
+   public IndividualCacheLoaderConfig getConfig()
    {
-      // i.e. put Property
+      // TODO Auto-generated method stub
       return null;
    }
 
    /**
     * {@inheritDoc}
     */
-   public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+   public Object put(Fqn name, Object key, Object value) throws Exception
    {
-      // i.e. put set of Properties    
-      
       // TODO Auto-generated method stub
-
+      return null;
    }
 
    /**
     * {@inheritDoc}
     */
-   public void put(List<Modification> modifications) throws Exception
+   public void put(Fqn name, Map<Object, Object> attributes) throws Exception
    {
-      
       // TODO Auto-generated method stub
 
    }
@@ -288,7 +288,6 @@
     */
    public Object remove(Fqn fqn, Object key) throws Exception
    {
-      // i.e. remove Property
       // TODO Auto-generated method stub
       return null;
    }
@@ -298,8 +297,6 @@
     */
    public void remove(Fqn fqn) throws Exception
    {
-      // i.e. remove Node
-      
       // TODO Auto-generated method stub
 
    }
@@ -309,8 +306,6 @@
     */
    public void removeData(Fqn fqn) throws Exception
    {
-      // i.e. remove all Properties of Node 
-      
       // TODO Auto-generated method stub
 
    }
@@ -318,88 +313,10 @@
    /**
     * {@inheritDoc}
     */
-   public void rollback(Object tx)
-   {
-      transactions.remove(tx);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void setCache(CacheSPI c)
-   {
-      //this.cache = c;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
    public void setConfig(IndividualCacheLoaderConfig config)
    {
-      this.config = config;
-
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void setRegionManager(RegionManager manager)
-   {
-      //this.regionManager = manager;
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void storeEntireState(ObjectInputStream is) throws Exception
-   {
       // TODO Auto-generated method stub
 
    }
 
-   /**
-    * {@inheritDoc}
-    */
-   public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void create() throws Exception
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void destroy()
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void start() throws Exception
-   {
-      // TODO Auto-generated method stub
-
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   public void stop()
-   {
-      // TODO Auto-generated method stub
-
-   }
-
 }

Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java (from rev 460, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java	                        (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java	2009-11-01 22:10:06 UTC (rev 462)
@@ -0,0 +1,408 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.CacheLoader;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 23.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a> 
+ * @version $Id$
+ */
+public class ExoJCRCacheLoader1 implements CacheLoader
+{
+   //private CacheSPI cache;
+
+   //private RegionManager regionManager;
+
+   private IndividualCacheLoaderConfig config;
+
+   private WorkspaceDataContainer dataContainer;
+
+   private HashMap<Object, List<Modification>> transactions = new HashMap<Object, List<Modification>>();
+
+   /**
+    * Init the loader DataContainer with given WorkspaceDataContainer instance.
+    *
+    * @param dataContainer WorkspaceDataContainer
+    */
+   @Inject
+   public void initDataContainer(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
+   {
+      if (this.dataContainer != null)
+      {
+         throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
+      }
+
+      this.dataContainer = dataContainer;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void commit(Object tx) throws Exception
+   {
+      List<Modification> modifications = transactions.remove(tx);
+      if (modifications != null)
+         doModified(modifications);
+      else
+         throw new ExoJCRCacheLoaderException("Transaction " + tx + " not exist in transaction table");
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean exists(Fqn name) throws Exception
+   {
+      // TODO use get(Fqn), i.e. get Node!=null  
+      return false;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Map<Object, Object> get(Fqn name) throws Exception
+   {
+      // TODO get Node or Property
+      // e.g.
+      // if $TREE/[]:1 - return $ITEM_ID attribute and all JCR Node Properties IDs   
+      // if $ITEM/idxxx - return $ITEM_DATA of JCR Node or Property  
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Set<?> getChildrenNames(Fqn fqn) throws Exception
+   {
+      // TODO get child nodes names
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public IndividualCacheLoaderConfig getConfig()
+   {
+      return config;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void loadEntireState(ObjectOutputStream os) throws Exception
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void loadState(Fqn subtree, ObjectOutputStream os) throws Exception
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+   {
+      if (onePhase)
+      {
+         doModified(modifications);
+      }
+      else
+      {
+         transactions.put(tx, modifications);
+      }
+   }
+
+   /**
+    * Will be added data to DB. 
+    * 
+    * @param modifications
+    * @throws Exception
+    */
+   private void doModified(List<Modification> modifications) throws Exception
+   {
+      JDBCStorageConnection jdbcConnection = (JDBCStorageConnection)dataContainer.openConnection();
+
+      try
+      {
+         for (int modificatinIndex = 0; modificatinIndex < modifications.size(); modificatinIndex++)
+         {
+            Modification md = modifications.get(modificatinIndex);
+            switch (md.getType())
+            {
+               case PUT_KEY_VALUE :
+                  doAddOrUpdate(md, jdbcConnection);
+                  break;
+               case REMOVE_NODE :
+                  doRemove(md, jdbcConnection, "TODO $<Node identifier>");
+                  break;
+            }
+         }
+
+         if (jdbcConnection != null)
+            jdbcConnection.commit();
+      }
+      finally
+      {
+         if (jdbcConnection != null && jdbcConnection.isOpened())
+            jdbcConnection.rollback();
+      }
+   }
+
+   private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
+      throws IllegalStateException, RepositoryException
+   {
+
+      ItemData itemData = jdbcConnection.getItemData(identifier);
+
+      if (itemData instanceof NodeData)
+         jdbcConnection.delete((NodeData)itemData);
+      if (itemData instanceof PropertyData)
+         jdbcConnection.delete((PropertyData)itemData);
+   }
+
+   /**
+    * Performs ADD and UPDATE to NodeData and PropertyData.
+    * @param modification
+    * @param jdbcConnection
+    * @throws IllegalStateException
+    * @throws RepositoryException
+    */
+   private void doAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
+      throws IllegalStateException, RepositoryException
+   {
+      if (modification.getValue() instanceof NodeData)
+      {
+         //add or update node data
+         NodeData nodeData = (NodeData)modification.getValue();
+
+         ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
+
+         if (itemData == null)
+         {
+            //add
+            jdbcConnection.add(nodeData);
+         }
+         else
+         {
+            //update
+            jdbcConnection.update(nodeData);
+         }
+      }
+      else if (modification.getValue() instanceof PropertyData)
+      {
+         //add or update property data
+         PropertyData propertyData = (PropertyData)modification.getValue();
+
+         ItemData itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
+
+         if (itemData == null)
+         {
+            //add
+            jdbcConnection.add(propertyData);
+         }
+         else
+         {
+            //update
+            jdbcConnection.update(propertyData);
+         }
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Object put(Fqn name, Object key, Object value) throws Exception
+   {
+      // i.e. put Property
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+   {
+      // i.e. put set of Properties    
+      
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void put(List<Modification> modifications) throws Exception
+   {
+      
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public Object remove(Fqn fqn, Object key) throws Exception
+   {
+      // i.e. remove Property
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void remove(Fqn fqn) throws Exception
+   {
+      // i.e. remove Node
+      
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void removeData(Fqn fqn) throws Exception
+   {
+      // i.e. remove all Properties of Node 
+      
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void rollback(Object tx)
+   {
+      transactions.remove(tx);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setCache(CacheSPI c)
+   {
+      //this.cache = c;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setConfig(IndividualCacheLoaderConfig config)
+   {
+      this.config = config;
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void setRegionManager(RegionManager manager)
+   {
+      //this.regionManager = manager;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void storeEntireState(ObjectInputStream is) throws Exception
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void storeState(Fqn subtree, ObjectInputStream is) throws Exception
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void create() throws Exception
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void destroy()
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void start() throws Exception
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void stop()
+   {
+      // TODO Auto-generated method stub
+
+   }
+
+}


Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id

Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java	2009-11-01 22:06:48 UTC (rev 461)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java	2009-11-01 22:10:06 UTC (rev 462)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 eXo Platform SAS.
+    * Copyright (C) 2009 eXo Platform SAS.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as



More information about the exo-jcr-commits mailing list