exo-jcr SVN: r1385 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-01-14 03:57:09 -0500 (Thu, 14 Jan 2010)
New Revision: 1385
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
Log:
EXOJCR-331 : (Set<String>)data.get(LIST_KEY);
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-01-14 08:46:46 UTC (rev 1384)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-01-14 08:57:09 UTC (rev 1385)
@@ -92,7 +92,8 @@
* @param fileName where index names are stored.
* @param cache instance of JbossCache that is used to deliver index names
*/
- public JBossCacheIndexInfos(String fileName, Cache<Serializable, Object> cache, boolean system, IndexerIoModeHandler modeHandler)
+ public JBossCacheIndexInfos(String fileName, Cache<Serializable, Object> cache, boolean system,
+ IndexerIoModeHandler modeHandler)
{
super(fileName);
this.cache = cache;
@@ -172,14 +173,14 @@
}
else
{
- set = (Set<String>)data.get(namesFqn);
+ set = (Set<String>)data.get(LIST_KEY);
}
if (set == null)
{
log.warn("The data cannot be found, we will try to get it from the cache");
// read from cache to update lists
set = (Set<String>)cache.get(namesFqn, LIST_KEY);
- }
+ }
if (set != null)
{
setNames(set);
16 years, 3 months
exo-jcr SVN: r1384 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-14 03:46:46 -0500 (Thu, 14 Jan 2010)
New Revision: 1384
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-391: List of child properties is not modified on single item get from DB, modified onSaveItems if parent is present in CHILD_x_LISTS/parentID and force-written if list of child is read from DB.
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-14 08:44:21 UTC (rev 1383)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-14 08:46:46 UTC (rev 1384)
@@ -379,7 +379,15 @@
*/
public void put(ItemData item)
{
- putItem(item);
+ // TODO: Omit writing to list!
+ if (item.isNode())
+ {
+ putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
+ }
+ else
+ {
+ putProperty((PropertyData)item, ModifyChildOption.NOT_MODIFY);
+ }
}
/**
@@ -457,7 +465,7 @@
// add all new
for (NodeData child : childs)
{
- putNode(child);
+ putNode(child, ModifyChildOption.FORCE_MODIFY);
}
}
else
@@ -474,13 +482,12 @@
{
// remove previous all (to be sure about consistency)
cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
-
if (childs.size() > 0)
{
// add all new
for (PropertyData child : childs)
{
- putProperty(child);
+ putProperty(child, ModifyChildOption.FORCE_MODIFY);
}
}
else
@@ -703,11 +710,11 @@
{
if (item.isNode())
{
- return putNode((NodeData)item);
+ return putNode((NodeData)item, ModifyChildOption.MODIFY);
}
else
{
- return putProperty((PropertyData)item);
+ return putProperty((PropertyData)item, ModifyChildOption.MODIFY);
}
}
@@ -717,7 +724,7 @@
* @param node, NodeData, new data to put in the cache
* @return NodeData, previous data or null
*/
- protected ItemData putNode(NodeData node)
+ protected ItemData putNode(NodeData node, ModifyChildOption modifyListsOfChild)
{
if (node.getParentIdentifier() != null)
{
@@ -735,7 +742,14 @@
// {
// cache.put(makeChildListFqn(childNodesList, node.getParentIdentifier(), node.getIdentifier()), NULL_DATA);
// }
- cache.put(makeChildListFqn(childNodesList, node.getParentIdentifier(), node.getIdentifier()), NULL_DATA);
+ if (modifyListsOfChild == ModifyChildOption.MODIFY || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ if (cache.getNode(makeChildListFqn(childNodesList, node.getParentIdentifier())) != null
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ cache.put(makeChildListFqn(childNodesList, node.getParentIdentifier(), node.getIdentifier()), NULL_DATA);
+ }
+ }
}
// add in ITEMS
@@ -748,7 +762,7 @@
* @param node, PropertyData, new data to put in the cache
* @return PropertyData, previous data or null
*/
- protected PropertyData putProperty(PropertyData prop)
+ protected PropertyData putProperty(PropertyData prop, ModifyChildOption modifyListsOfChild)
{
// add in CHILD_PROPS
cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
@@ -762,7 +776,14 @@
// {
// cache.put(makeChildListFqn(childPropsList, prop.getParentIdentifier(), prop.getIdentifier()), NULL_DATA);
// }
- cache.put(makeChildListFqn(childPropsList, prop.getParentIdentifier(), prop.getIdentifier()), NULL_DATA);
+ if (modifyListsOfChild == ModifyChildOption.MODIFY || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ if (cache.getNode(makeChildListFqn(childPropsList, prop.getParentIdentifier())) != null
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ cache.put(makeChildListFqn(childPropsList, prop.getParentIdentifier(), prop.getIdentifier()), NULL_DATA);
+ }
+ }
// TODO REFERENCEs hadnling
//if (prop.getType() == PropertyType.REFERENCE)
@@ -1007,4 +1028,13 @@
{
return true;
}
+
+ /**
+ * <li>NOT_MODIFY - node(property) is not added to the parent's list (no persistent changes performed, cache used as cache)</li>
+ * <li>MODIFY - node(property) is added to the parent's list if parent in the cache (new item is added to persistent, add to list if it is present)</li>
+ * <li>FORCE_MODIFY - node(property) is added to the parent's list anyway (when list is read from DB, forcing write)</li>
+ */
+ private enum ModifyChildOption {
+ NOT_MODIFY, MODIFY, FORCE_MODIFY
+ }
}
16 years, 3 months
exo-jcr SVN: r1383 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-01-14 03:44:21 -0500 (Thu, 14 Jan 2010)
New Revision: 1383
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
Log:
EXOJCR-391: use getItemData by uuid instead of getItemData by parent and name. (see http://wiki-int.exoplatform.org/display/exoproducts/Problems+encountered+...)
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-01-13 21:34:21 UTC (rev 1382)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-01-14 08:44:21 UTC (rev 1383)
@@ -401,9 +401,7 @@
// WARN. DON'T USE access item BY PATH - it's may be a node in case of
// residual definitions in NT
List<ValueData> data =
- prop.getValues().size() > 0 ? prop.getValues() : ((PropertyData)stateProvider.getItemData(
- (NodeData)stateProvider.getItemData(prop.getParentIdentifier()), prop.getQPath().getEntries()[prop
- .getQPath().getEntries().length - 1])).getValues();
+ prop.getValues().size() > 0 ? prop.getValues() : ((PropertyData)stateProvider.getItemData(prop.getIdentifier())).getValues();
if (data == null)
log.warn("null value found at property " + prop.getQPath().getAsString());
16 years, 3 months
exo-jcr SVN: r1382 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache and 6 other directories.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2010-01-13 16:34:21 -0500 (Wed, 13 Jan 2010)
New Revision: 1382
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Removed:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
Log:
EXOJCR-334: Finish implementing XA Transaction
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -34,12 +34,14 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
import javax.jcr.InvalidItemStateException;
import javax.jcr.ItemExistsException;
import javax.jcr.RepositoryException;
import javax.transaction.RollbackException;
import javax.transaction.Status;
+import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@@ -398,116 +400,186 @@
* {@inheritDoc}
*/
@Override
- public void save(ItemStateChangesLog changesLog) throws RepositoryException
+ public void save(final ItemStateChangesLog changesLog) throws RepositoryException
{
if (transactionManager == null)
{
super.save(changesLog);
+
+ // notify listeners after transaction commit
+ notifySaveItems(changesLog, false);
}
else
{
try
{
- transactionManager.begin();
- transactionManager.setTransactionTimeout(20); // TODO manage it via the confguration
- cache.beginTransaction(); // TODO keep it into the cache impl
- super.save(changesLog);
- cache.commitTransaction();
- transactionManager.commit();
+ if (transactionManager.getStatus() == Status.STATUS_COMMITTING)
+ {
+ // The JCR session has been enrolled into a XA Transaction, the method applyChanges must be called in another thread since the operations
+ // that we do into the cache are not allowed within the current Transaction, so to do it in another Transaction we need to call the method
+ // from another Thread
+ final AtomicReference<Exception> exception = new AtomicReference<Exception>();
+ final CountDownLatch doneSignal = new CountDownLatch(1);
+ Thread t = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ applyChanges(changesLog);
+ }
+ catch (Exception e)
+ {
+ exception.set(e);
+ }
+ finally
+ {
+ doneSignal.countDown();
+ }
+ }
+ };
+ t.start();
+ doneSignal.await();
+ Exception e = exception.get();
+ if (e != null)
+ {
+ if (e instanceof RepositoryException)
+ {
+ throw (RepositoryException)e;
+ }
+ else
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ else
+ {
+ // Normal Transaction
+ applyChanges(changesLog);
+ }
}
- catch (RollbackException e)
+ catch (RepositoryException e)
{
- // Indicate that the transaction has been rolled back rather than committed.
- throw new RepositoryException(e);
+ throw e;
}
- catch (JCRInvalidItemStateException e)
+ catch (InterruptedException e)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ catch (SystemException e)
+ {
+ throw new RepositoryException(e.getLocalizedMessage(), e.getCause());
+ }
+ }
+ }
- throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+ /**
+ * Apply all the current changes
+ */
+ private void applyChanges(ItemStateChangesLog changesLog) throws RepositoryException
+ {
+ try
+ {
+ transactionManager.begin();
+ transactionManager.setTransactionTimeout(20); // TODO manage it via the configuration
+ cache.beginTransaction(); // TODO keep it into the cache impl
+ super.save(changesLog);
+ cache.commitTransaction();
+ transactionManager.commit();
+ }
+ catch (RollbackException e)
+ {
+ // Indicate that the transaction has been rolled back rather than committed.
+ throw new RepositoryException(e);
+ }
+ catch (JCRInvalidItemStateException e)
+ {
+ try
+ {
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (InvalidItemStateException e)
+ catch (Exception e1)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
+ LOG.error("Rollback error ", e1);
+ }
- throw new InvalidItemStateException(e);
+ throw new JCRInvalidItemStateException(e.getMessage(), e.getIdentifier(), e.getState(), e);
+ }
+ catch (InvalidItemStateException e)
+ {
+ try
+ {
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (ItemExistsException e)
+ catch (Exception e1)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
+ LOG.error("Rollback error ", e1);
+ }
- throw new ItemExistsException(e);
+ throw new InvalidItemStateException(e);
+ }
+ catch (ItemExistsException e)
+ {
+ try
+ {
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (ReadOnlyWorkspaceException e)
+ catch (Exception e1)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
+ LOG.error("Rollback error ", e1);
+ }
- throw new ReadOnlyWorkspaceException(e);
+ throw new ItemExistsException(e);
+ }
+ catch (ReadOnlyWorkspaceException e)
+ {
+ try
+ {
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (RepositoryException e)
+ catch (Exception e1)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
+ LOG.error("Rollback error ", e1);
+ }
- throw new RepositoryException(e);
+ throw new ReadOnlyWorkspaceException(e);
+ }
+ catch (RepositoryException e)
+ {
+ try
+ {
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
- catch (Exception e)
+ catch (Exception e1)
{
- try
- {
- cache.rollbackTransaction();
- transactionManager.rollback();
- }
- catch (Exception e1)
- {
- LOG.error("Rollback error ", e1);
- }
+ LOG.error("Rollback error ", e1);
+ }
- throw new RepositoryException(e);
+ throw new RepositoryException(e);
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ cache.rollbackTransaction();
+ transactionManager.rollback();
}
+ catch (Exception e1)
+ {
+ LOG.error("Rollback error ", e1);
+ }
+
+ throw new RepositoryException(e);
}
// notify listeners after transaction commit
- notifySaveItems(changesLog, false);
+ notifySaveItems(changesLog, false);
}
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -297,6 +297,10 @@
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
LOG.info("JBoss Cache configuration used: " + jbcConfig);
this.cache = new BufferedJBossCache(factory.createCache(jbcConfig, false));
+ if (transactionManager != null)
+ {
+ cache.getConfiguration().getRuntimeConfig().setTransactionManager(transactionManager);
+ }
this.cache.create();
this.cache.start();
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/ArjunaTransactionService.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 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.transaction.jbosscache;
+
+import com.arjuna.ats.jta.xa.XidImple;
+
+import org.exoplatform.container.xml.InitParams;
+import org.jboss.cache.transaction.TransactionManagerLookup;
+
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.Xid;
+
+/**
+ * Add the specific part for Arjuna
+ *
+ * @author <a href="mailto:nicolas.filotto@exoplatform.com">Nicolas Filotto</a>
+ * @version $Id$
+ *
+ */
+public class ArjunaTransactionService extends GenericTransactionService
+{
+
+ public ArjunaTransactionService(TransactionManagerLookup tmLookup)
+ {
+ super(tmLookup);
+ }
+
+ public ArjunaTransactionService(TransactionManagerLookup tmLookup, InitParams params)
+ {
+ super(tmLookup, params);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Xid createXid()
+ {
+ return new XidImple();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public UserTransaction getUserTransaction()
+ {
+ return com.arjuna.ats.jta.UserTransaction.userTransaction();
+ }
+}
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2010 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.transaction.jbosscache;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.transaction.ExoResource;
+import org.exoplatform.services.transaction.TransactionService;
+import org.jboss.cache.transaction.TransactionManagerLookup;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * @author <a href="mailto:dmitry.kataev@exoplatform.com">Dmytro Katayev</a>
+ * @version $Id: GenericTransactionService.java -1 $
+ */
+public class GenericTransactionService implements TransactionService
+{
+ /**
+ * The logger
+ */
+ private final Log log = ExoLogger.getLogger(GenericTransactionService.class);
+
+ /**
+ * The default timeout value of a transaction set to 20s
+ */
+ private static final int DEFAULT_TIME_OUT = 20;
+
+ /**
+ * TransactionManagerLookup.
+ */
+ protected final TransactionManagerLookup tmLookup;
+
+ /**
+ * The default timeout
+ */
+ protected final int defaultTimeout;
+
+ /**
+ * The current Transaction Manager
+ */
+ private volatile TransactionManager tm;
+
+ /**
+ * JBossTransactionManagerLookup constructor.
+ *
+ * @param tmLookup TransactionManagerLookup
+ */
+ public GenericTransactionService(TransactionManagerLookup tmLookup)
+ {
+ this(tmLookup, null);
+ }
+
+ public GenericTransactionService(TransactionManagerLookup tmLookup, InitParams params)
+ {
+ this.tmLookup = tmLookup;
+ if (params != null && params.getValueParam("timeout") != null)
+ {
+ this.defaultTimeout = Integer.parseInt(params.getValueParam("timeout").getValue());
+ }
+ else
+ {
+ this.defaultTimeout = DEFAULT_TIME_OUT;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Xid createXid()
+ {
+ throw new UnsupportedOperationException("Method createXid() not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delistResource(ExoResource exores) throws RollbackException, SystemException
+ {
+ TransactionManager tm = getTransactionManager();
+ Transaction tx = tm.getTransaction();
+ if (tx != null)
+ {
+ tx.delistResource(exores.getXAResource(), XAResource.TMNOFLAGS);
+ }
+ else
+ {
+ delistResource(tm, exores);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void enlistResource(ExoResource exores) throws RollbackException, SystemException
+ {
+ TransactionManager tm = getTransactionManager();
+ Transaction tx = tm.getTransaction();
+ if (tx != null)
+ {
+ tx.enlistResource(exores.getXAResource());
+ }
+ else
+ {
+ enlistResourceOnTxMissing(tm, exores);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getDefaultTimeout()
+ {
+ return defaultTimeout;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public TransactionManager getTransactionManager()
+ {
+ if (tm == null)
+ {
+ synchronized (this)
+ {
+ if (tm == null)
+ {
+ TransactionManager tm;
+ try
+ {
+ tm = tmLookup.getTransactionManager();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Transaction manager not found", e);
+ }
+ try
+ {
+ tm.setTransactionTimeout(defaultTimeout);
+ }
+ catch (Exception e)
+ {
+ log.warn("Cannot set the transaction timeout", e);
+ }
+ this.tm = tm;
+ }
+ }
+ }
+ return tm;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public UserTransaction getUserTransaction()
+ {
+ throw new UnsupportedOperationException("Method UserTransaction() not supported");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTransactionTimeout(int seconds) throws SystemException
+ {
+ TransactionManager tm = getTransactionManager();
+ tm.setTransactionTimeout(seconds);
+ }
+
+ /**
+ * Allows to execute an action when we try to enlist a resource when there is no active
+ * transaction
+ */
+ protected void enlistResourceOnTxMissing(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
+ {
+ }
+
+ /**
+ * Allows to execute an action when we try to delist a resource when there is no active
+ * transaction
+ */
+ protected void delistResource(TransactionManager tm, ExoResource exores) throws RollbackException, SystemException
+ {
+ }
+}
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionService.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010 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.transaction.jbosscache;
-
-import org.exoplatform.services.transaction.ExoResource;
-import org.exoplatform.services.transaction.TransactionService;
-import org.jboss.cache.transaction.TransactionManagerLookup;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import javax.transaction.xa.Xid;
-
-/**
- * @author <a href="mailto:dmitry.kataev@exoplatform.com">Dmytro Katayev</a>
- * @version $Id$
- */
-public class JBossTransactionService implements TransactionService
-{
-
- /**
- * TransactionManagerLookup.
- */
- final protected TransactionManagerLookup tmLookup;
-
- /**
- * JBossTransactionManagerLookup constructor.
- *
- * @param tmLookup TransactionManagerLookup
- */
- public JBossTransactionService(TransactionManagerLookup tmLookup)
- {
- this.tmLookup = tmLookup;
- }
-
- /**
- * {@inheritDoc}
- */
- public Xid createXid()
- {
- throw new RuntimeException("Method createXid() not supported");
- }
-
- /**
- * {@inheritDoc}
- */
- public void delistResource(ExoResource xares) throws RollbackException, SystemException
- {
- throw new RuntimeException("Method delistResource() not supported");
- }
-
- /**
- * {@inheritDoc}
- */
- public void enlistResource(ExoResource xares) throws RollbackException, SystemException
- {
- throw new RuntimeException("Method enlistResource() not supported");
- }
-
- /**
- * {@inheritDoc}
- */
- public int getDefaultTimeout()
- {
- throw new RuntimeException("Method getDefaultTimeout() not supported");
- }
-
- /**
- * {@inheritDoc}
- */
- public TransactionManager getTransactionManager()
- {
- try
- {
- return tmLookup.getTransactionManager();
- }
- catch (Exception e)
- {
- throw new RuntimeException("Transaction manager not found");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public UserTransaction getUserTransaction()
- {
- throw new RuntimeException("Method UserTransaction() not supported");
- }
-
- /**
- * {@inheritDoc}
- */
- public void setTransactionTimeout(int seconds) throws SystemException
- {
- throw new RuntimeException("Method setTransactionTimeout() not supported");
- }
-
-}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/xa/TestUserTransaction.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -120,6 +120,8 @@
log.info("before begin");
ut.begin();
log.info("after begin");
+ // we need to create the session within the transaction to ensure that it will be enlisted
+ Session session = (SessionImpl)repository.login(credentials, "ws");
session.getRootNode().addNode("txcommit");
session.save();
assertNotNull(session.getItem("/txcommit"));
@@ -146,6 +148,8 @@
UserTransaction ut = txService.getUserTransaction();
ut.begin();
+ // we need to create the session within the transaction to ensure that it will be enlisted
+ Session session = (SessionImpl)repository.login(credentials, "ws");
session.getRootNode().addNode("txrollback");
session.save();
assertNotNull(session.getItem("/txrollback"));
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestJBossCacheWorkspaceStorageCache.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.JBossCacheWorkspaceStorageCache;
+import org.exoplatform.services.transaction.TransactionService;
/**
* Created by The eXo Platform SAS.
@@ -33,8 +34,8 @@
@Override
public WorkspaceStorageCache getCacheImpl() throws Exception
{
- //JBossTransactionService transactionService =
- // (JBossTransactionService)container.getComponentInstanceOfType(JBossTransactionService.class);
- return new JBossCacheWorkspaceStorageCache("conf/standalone/test-jbosscache-config.xml", null);
+ TransactionService transactionService =
+ (TransactionService)container.getComponentInstanceOfType(TransactionService.class);
+ return new JBossCacheWorkspaceStorageCache("conf/standalone/test-jbosscache-config.xml", transactionService == null ? null : transactionService.getTransactionManager());
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestIndexUpdateMonitor.java 2010-01-13 21:34:21 UTC (rev 1382)
@@ -28,15 +28,12 @@
import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.lock.LockType;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.transaction.TransactionManager;
-
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
* @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -62,7 +59,6 @@
// TODO Auto-generated method stub
super.setUp();
cache = createCache();
- TransactionManager tm = ((CacheSPI<Serializable, Object>)cache).getTransactionManager();
indexUpdateMonitor = new JbossCacheIndexUpdateMonitor(cache, new IndexerIoModeHandler(IndexerIoMode.READ_WRITE));
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml 2010-01-13 21:34:21 UTC (rev 1382)
@@ -202,7 +202,8 @@
</component>
<component>
- <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionService</type>
+ <key>org.exoplatform.services.transaction.TransactionService</key>
+ <type>org.exoplatform.services.transaction.jbosscache.ArjunaTransactionService</type>
</component>
<!-- component>
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-01-13 16:44:52 UTC (rev 1381)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/standalone/test-configuration.xml 2010-01-13 21:34:21 UTC (rev 1382)
@@ -195,16 +195,16 @@
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
</component>
- <!-- component>
- <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
- <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
+ <component>
+ <key>org.jboss.cache.transaction.TransactionManagerLookup</key>
+ <type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
</component>
<component>
<key>org.exoplatform.services.transaction.TransactionService</key>
- <type>org.exoplatform.services.transaction.jbosscache.JBossTransactionService</type>
- </component -->
-
+ <type>org.exoplatform.services.transaction.jbosscache.ArjunaTransactionService</type>
+ </component>
+
<!-- component>
<key>org.exoplatform.services.transaction.TransactionService</key>
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
@@ -214,7 +214,7 @@
<value>5</value>
</value-param>
</init-params>
- </component -->
+ </component-->
<external-component-plugins>
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
16 years, 3 months
exo-jcr SVN: r1381 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-01-13 11:44:52 -0500 (Wed, 13 Jan 2010)
New Revision: 1381
Removed:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java
Log:
EXOJCR-331 : remove @Deprecated
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java 2010-01-13 16:43:39 UTC (rev 1380)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java 2010-01-13 16:44:52 UTC (rev 1381)
@@ -1,650 +0,0 @@
-/*
- * 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.config;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov </a>
- * @version $Id: QueryHandlerEntry.java 14931 2008-05-29 15:02:08Z ksm $
- */
-@Deprecated
-public class QueryHandlerEntryWrapper
-{
- //
- // /**
- // * The default value for property {@link #extractorBackLog}.
- // */
- // public static final int DEFAULT_EXTRACTOR_BACKLOG = 100;
- //
- // /**
- // * The default value for property {@link #extractorPoolSize}.
- // */
- // public static final int DEFAULT_EXTRACTOR_POOLSIZE = 0;
- //
- // /**
- // * The default timeout in milliseconds which is granted to the text
- // * extraction process until fulltext indexing is deferred to a background
- // * thread.
- // */
- // public static final int DEFAULT_EXTRACTOR_TIMEOUT = 100;
- //
- // /**
- // * the default value for property {@link #maxFieldLength}.
- // */
- // public static final int DEFAULT_MAX_FIELD_LENGTH = 10000;
- //
- // /**
- // * The default value for property {@link #maxMergeDocs}.
- // */
- // public static final int DEFAULT_MAX_MERGE_DOCS = Integer.MAX_VALUE;
- //
- // /**
- // * the default value for property {@link #mergeFactor}.
- // */
- // public static final int DEFAULT_MERGE_FACTOR = 10;
- //
- // /**
- // * The default value for property {@link #minMergeDocs}.
- // */
- // public static final int DEFAULT_MIN_MERGE_DOCS = 100;
- //
- // /**
- // * Name of the file to persist search internal namespace mappings.
- // */
- // public static final String NS_MAPPING_FILE = "ns_mappings.properties"; // TODO
- //
- // /**
- // * The excerpt provider class. Implements {@link ExcerptProvider}.
- // */
- // private static final String DEDAULT_EXCERPTPROVIDER_CLASS = DefaultHTMLExcerpt.class
- // .getName();
- //
- // private static final String DEDAULT_INDEXINGCONFIGURATIONCLASS = IndexingConfigurationImpl.class
- // .getName();
- //
- // private static final boolean DEFAULT_AUTOREPAIR = true;
- //
- // private static final int DEFAULT_BUFFER_SIZE = 10;
- //
- // private static final int DEFAULT_CACHE_SIZE = 1000;
- //
- // private final static boolean DEFAULT_CONSISTENCYCHECKENABLED = false;
- //
- // private final static boolean DEFAULT_DOCUMENTORDER = true;
- //
- // private final static boolean DEFAULT_FORCECONSISTENCYCHECK = false;
- //
- // /**
- // * Name of the default query implementation class.
- // */
- // private static final String DEFAULT_QUERY_HANDLER_CLASS = SearchIndex.class
- // .getName();
- //
- // /**
- // * Name of the default query implementation class.
- // */
- // private static final String DEFAULT_QUERY_IMPL_CLASS = QueryImpl.class
- // .getName();
- //
- // /**
- // * The number of documents that are pre fetched when a query is executed.
- // * <p/>
- // * Default value is: {@link Integer#MAX_VALUE}.
- // */
- // private final static int DEFAULT_RESULTFETCHSIZE = Integer.MAX_VALUE;
- //
- // private final static boolean DEFAULT_SUPPORTHIGHLIGHTING = false;
- //
- // private final static boolean DEFAULT_USECOMPOUNDFILE = false;
- //
- // private final static int DEFAULT_VOLATILEIDLETIME = 3;
- //
- // // since https://jira.jboss.org/jira/browse/EXOJCR-17
- //
- // public static final boolean DEFAULT_UPGRADE_INDEX = false;
- //
- // private QueryHandlerEntry queryHandlerEntry;
- //
- // public QueryHandlerEntry getQueryHandlerEntry() {
- // return queryHandlerEntry;
- // }
- //
- // private static void initDefaults(QueryHandlerEntry entry) {
- // entry.putBooleanParameter(PARAM_AUTO_REPAIR, DEFAULT_AUTOREPAIR);
- // entry.putIntegerParameter(PARAM_BUFFER_SIZE, DEFAULT_BUFFER_SIZE);
- // entry.putIntegerParameter(PARAM_CACHE_SIZE, DEFAULT_CACHE_SIZE);
- // entry.putBooleanParameter(PARAM_DOCUMENT_ORDER, DEFAULT_DOCUMENTORDER);
- // entry.putParameterValue(PARAM_EXCERPTPROVIDER_CLASS,
- // DEDAULT_EXCERPTPROVIDER_CLASS);
- //// Null value is forbidden according to the binding.xml, it prevents marshalling
- //// entry.putParameterValue(PARAM_EXCLUDED_NODE_IDENTIFERS, null);
- // entry.putIntegerParameter(PARAM_EXTRACTOR_BACKLOG,
- // DEFAULT_EXTRACTOR_BACKLOG);
- // entry.putIntegerParameter(PARAM_EXTRACTOR_POOLSIZE,
- // DEFAULT_EXTRACTOR_POOLSIZE);
- // entry.putIntegerParameter(PARAM_EXTRACTOR_TIMEOUT,
- // DEFAULT_EXTRACTOR_TIMEOUT);
- // }
- //
- // public String getType() {
- // return queryHandlerEntry.getType();
- // }
- //
- // public static QueryHandlerEntry queryHandlerEntryFactory() {
- // QueryHandlerEntry entry = new QueryHandlerEntry();
- // initDefaults(entry);
- // return entry;
- // }
- //
- // /** The logger instance for this class */
- // private static final Log log = ExoLogger.getLogger(QueryHandlerEntry.class);
- //
- // // public QueryHandlerEntry queryHandler;
- //
- // public Integer volatileIdleTime;
- //
- // /**
- // * The analyzer we use for indexing.
- // */
- // private JcrStandartAnalyzer analyzer;
- //
- // private String queryHandlerClass = DEFAULT_QUERY_HANDLER_CLASS;
- //
- // public QueryHandlerEntryWrapper(QueryHandlerEntry queryHandlerEntry) {
- // this.queryHandlerEntry = queryHandlerEntry;
- // this.analyzer = new JcrStandartAnalyzer();
- // initDefaults(queryHandlerEntry);
- // }
- //
- // public QueryHandlerEntryWrapper(String type, List params,
- // QueryHandlerEntry queryHandlerEntry) {
- // this.queryHandlerEntry = queryHandlerEntry;
- // queryHandlerEntry.setType(type);
- // queryHandlerEntry.setParameters(params);
- // this.analyzer = new JcrStandartAnalyzer();
- // initDefaults(queryHandlerEntry);
- // }
- //
- // /**
- // * Creates an excerpt provider for the given <code>query</code>.
- // *
- // * @param query
- // * the query.
- // * @return an excerpt provider for the given <code>query</code>.
- // * @throws IOException
- // * if the provider cannot be created.
- // */
- // public ExcerptProvider createExcerptProvider(Query query)
- // throws IOException {
- // ExcerptProvider ep;
- // try {
- // Class excerptProviderClass = Class.forName(
- // getExcerptProviderClass(), true, this.getClass()
- // .getClassLoader());
- // ep = (ExcerptProvider) excerptProviderClass.newInstance();
- // } catch (Exception e) {
- // IOException ex = new IOException();
- // ex.initCause(e);
- // throw ex;
- // }
- //
- // return ep;
- // }
- //
- // /**
- // * @param namespaceMappings
- // * The namespace mappings
- // * @return the fulltext indexing configuration or <code>null</code> if there
- // * is no configuration.
- // */
- // public IndexingConfiguration createIndexingConfiguration(
- // NamespaceMappings namespaceMappings, QueryHandlerContext context,
- // ConfigurationManager cfm) throws IOException,
- // RepositoryConfigurationException {
- // Element docElement = getIndexingConfigurationDOM(cfm);
- // if (docElement == null) {
- // return null;
- // }
- // IndexingConfiguration idxCfg = null;
- // try {
- // Class indexingConfigurationClass = Class.forName(
- // getIndexingConfigurationClass(), true, this.getClass()
- // .getClassLoader());
- // idxCfg = (IndexingConfiguration) indexingConfigurationClass
- // .newInstance();
- // idxCfg.init(docElement, context, namespaceMappings);
- // } catch (InstantiationException e) {
- // log.warn("Exception initializing indexing configuration from: "
- // + getIndexingConfigurationPath(), e);
- // } catch (IllegalAccessException e) {
- // log.warn("Exception initializing indexing configuration from: "
- // + getIndexingConfigurationPath(), e);
- // } catch (RepositoryException e) {
- // log.warn("Exception initializing indexing configuration from: "
- // + getIndexingConfigurationPath(), e);
- // } catch (IllegalNameException e) {
- // log.warn("Exception initializing indexing configuration from: "
- // + getIndexingConfigurationPath(), e);
- // } catch (Exception e) {
- // log.warn("Exception initializing indexing configuration from: "
- // + getIndexingConfigurationPath(), e);
- // }
- // return idxCfg;
- // }
- //
- // /**
- // * Creates a spell checker for this query handler.
- // *
- // * @return the spell checker or <code>null</code> if none is configured or
- // * an error occurs.
- // */
- // public SpellChecker createSpellChecker(QueryHandler handler) {
- // SpellChecker spCheck = null;
- // if (getSpellCheckerClass() != null) {
- // try {
- // Class spellCheckerClass = Class.forName(getSpellCheckerClass(),
- // true, this.getClass().getClassLoader());
- // spCheck = (SpellChecker) spellCheckerClass.newInstance();
- // spCheck.init(handler);
- // } catch (Exception e) {
- // log.warn("Exception initializing spell checker: "
- // + getSpellCheckerClass(), e);
- // }
- // }
- // return spCheck;
- // }
- //
- // /**
- // * @param cfm
- // * @return the configured synonym provider or <code>null</code> if none is
- // * configured or an error occurs.
- // */
- // public SynonymProvider createSynonymProvider(ConfigurationManager cfm) {
- // SynonymProvider sp = null;
- // if (getSynonymProviderClass() != null) {
- // try {
- // Class synonymProviderClass = Class.forName(
- // getSynonymProviderClass(), true, this.getClass()
- // .getClassLoader());
- // sp = (SynonymProvider) synonymProviderClass.newInstance();
- //
- // sp.initialize(createSynonymProviderConfigResource(cfm));
- // } catch (Exception e) {
- // log.warn("Exception initializing synonym provider: "
- // + getSynonymProviderClass(), e);
- // sp = null;
- // }
- // }
- // return sp;
- // }
- //
- // public JcrStandartAnalyzer getAnalyzer() {
- // return analyzer;
- // }
- //
- // private String getParameterString(String name) {
- // return queryHandlerEntry.getParameterValue(name, null);
- // }
- //
- // private Integer getParameterIntegerInitialized(String name) {
- // String value = queryHandlerEntry.getParameterValue(name, null);
- // return StringNumberParser.parseInt(value);
- // }
- //
- // private Boolean getParameterBooleanInitialized(String name) {
- // String value = queryHandlerEntry.getParameterValue(name, "false");
- // return Boolean.parseBoolean(value);
- // }
- //
- // /**
- // * If set <code>true</code> errors detected by the consistency check are
- // * repaired. If <code>false</code> the errors are only reported in the log.
- // * <p/>
- // * Default value is: <code>true</code>.
- // *
- // * @throws RepositoryConfigurationException
- // */
- // public boolean getAutoRepair() throws RepositoryConfigurationException {
- // return getParameterBooleanInitialized(PARAM_AUTO_REPAIR);
- // }
- //
- // /**
- // * Number of documents that are buffered before they are added to the index.
- // *
- // * @throws RepositoryConfigurationException
- // */
- // public int getBufferSize() {
- // return getParameterIntegerInitialized(PARAM_BUFFER_SIZE);
- // }
- //
- // public int getCacheSize() {
- // return getParameterIntegerInitialized(PARAM_CACHE_SIZE);
- // }
- //
- // /**
- // * Flag indicating whether document order is enable as the default ordering.
- // */
- // public boolean getDocumentOrder() {
- // return getParameterBooleanInitialized(PARAM_DOCUMENT_ORDER);
- // }
- //
- // /**
- // * @return the class name of the excerpt provider implementation.
- // */
- // public String getExcerptProviderClass() {
- // return getParameterString(PARAM_EXCERPTPROVIDER_CLASS);
- // }
- //
- // public String getExcludedNodeIdentifers() {
- // return getParameterString(PARAM_EXCLUDED_NODE_IDENTIFERS);
- // }
- //
- // /**
- // * @return the size of the extractor queue back log.
- // */
- // public int getExtractorBackLogSize() {
- // return getParameterIntegerInitialized(PARAM_EXTRACTOR_BACKLOG);
- // }
- //
- // /**
- // * @return the size of the thread pool which is used to run the text
- // * extractors when binary content is indexed.
- // */
- // public int getExtractorPoolSize() {
- // return getParameterIntegerInitialized(PARAM_EXTRACTOR_POOLSIZE);
- // }
- //
- // /**
- // * @return the extractor timeout in milliseconds.
- // */
- // public long getExtractorTimeout() {
- // return getParameterIntegerInitialized(PARAM_EXTRACTOR_TIMEOUT);
- // }
- //
- // /**
- // * Returns the location of the search index. Returns <code>null</code> if
- // * not set.
- // *
- // * @return the location of the search index.
- // * @throws RepositoryConfigurationException
- // */
- // public String getIndexDir() throws RepositoryConfigurationException {
- //
- // String indexDir;
- // try {
- // indexDir = queryHandlerEntry.getParameterValue(PARAM_INDEX_DIR);
- // } catch (RepositoryConfigurationException e) {
- // indexDir = queryHandlerEntry.getParameterValue(OLD_PARAM_INDEX_DIR);
- // }
- //
- // indexDir = indexDir.replace("${java.io.tmpdir}", System
- // .getProperty("java.io.tmpdir"));
- //
- // return indexDir;
- // }
- //
- // /**
- // * @return the class name of the indexing configuration implementation.
- // */
- // public String getIndexingConfigurationClass() {
- // return queryHandlerEntry.getParameterValue(
- // PARAM_INDEXING_CONFIGURATION_CLASS,
- // DEDAULT_INDEXINGCONFIGURATIONCLASS);
- // }
- //
- // /**
- // * @return the path to the indexing configuration file.
- // */
- // public String getIndexingConfigurationPath() {
- // return queryHandlerEntry.getParameterValue(
- // PARAM_INDEXING_CONFIGURATION_PATH, null);
- // }
- //
- // public int getMaxFieldLength() {
- // return queryHandlerEntry.getParameterInteger(PARAM_MAX_FIELD_LENGTH,
- // DEFAULT_MAX_FIELD_LENGTH);
- // }
- //
- // /**
- // * Returns the current value for maxMergeDocs.
- // *
- // * @return the current value for maxMergeDocs.
- // */
- // public int getMaxMergeDocs() {
- // return queryHandlerEntry.getParameterInteger(PARAM_MAX_MERGE_DOCS,
- // DEFAULT_MAX_MERGE_DOCS);
- // }
- //
- // /**
- // * Returns the current value for the merge factor.
- // *
- // * @return the current value for the merge factor.
- // */
- // public int getMergeFactor() {
- // return queryHandlerEntry.getParameterInteger(PARAM_MERGE_FACTOR,
- // DEFAULT_MERGE_FACTOR);
- // }
- //
- // /**
- // * Returns the current value for minMergeDocs.
- // *
- // * @return the current value for minMergeDocs.
- // */
- // public int getMinMergeDocs() {
- // return queryHandlerEntry.getParameterInteger(PARAM_MIN_MERGE_DOCS,
- // DEFAULT_MIN_MERGE_DOCS);
- // }
- //
- // public String getQueryClass() {
- // return queryHandlerEntry.getParameterValue(PARAM_QUERY_CLASS,
- // DEFAULT_QUERY_IMPL_CLASS);
- // }
- //
- // /**
- // * @return the number of results the query handler will fetch initially when
- // * a query is executed.
- // */
- // public int getResultFetchSize() {
- // return queryHandlerEntry.getParameterInteger(PARAM_RESULT_FETCH_SIZE,
- // DEFAULT_RESULTFETCHSIZE);
- // }
- //
- // public String getRootNodeIdentifer() {
- // return queryHandlerEntry.getParameterValue(PARAM_ROOT_NODE_ID,
- // Constants.ROOT_UUID);
- // }
- //
- // /**
- // * Get spell checker class.
- // *
- // * @return the class name of the spell checker implementation or
- // * <code>null</code> if none is set.
- // */
- // public String getSpellCheckerClass() {
- // return queryHandlerEntry.getParameterValue(PARAM_SPELLCHECKER_CLASS,
- // null);
- // }
- //
- // /**
- // * Get support highlighting.
- // *
- // * @return <code>true</code> if highlighting support is enabled.
- // */
- // public boolean getSupportHighlighting() {
- // return queryHandlerEntry.getParameterBoolean(
- // PARAM_SUPPORT_HIGHLIGHTING, DEFAULT_SUPPORTHIGHLIGHTING);
- // }
- //
- // /**
- // * Get synonym provider class.
- // *
- // * @return the class name of the synonym provider implementation or
- // * <code>null</code> if none is set.
- // */
- // public String getSynonymProviderClass() {
- // return queryHandlerEntry.getParameterValue(PARAM_SYNONYMPROVIDER_CLASS,
- // null);
- // }
- //
- // /**
- // * Get synonym provider configuration path.
- // *
- // * @return the configuration path for the synonym provider. If none is set
- // * this method returns <code>null</code>.
- // */
- // public String getSynonymProviderConfigPath() {
- // return queryHandlerEntry.getParameterValue(
- // PARAM_SYNONYMPROVIDER_CONFIG_PATH, null);
- // }
- //
- // /**
- // * Returns the current value for useCompoundFile.
- // *
- // * @return the current value for useCompoundFile.
- // */
- // public boolean getUseCompoundFile() {
- // return queryHandlerEntry.getParameterBoolean(PARAM_USE_COMPOUNDFILE,
- // DEFAULT_USECOMPOUNDFILE);
- // }
- //
- // /**
- // * Returns the current value for volatileIdleTime.
- // *
- // * @return the current value for volatileIdleTime.
- // */
- // public int getVolatileIdleTime() {
- // if (volatileIdleTime == null)
- // volatileIdleTime = queryHandlerEntry.getParameterInteger(
- // PARAM_VOLATILE_IDLE_TIME, DEFAULT_VOLATILEIDLETIME);
- //
- // return volatileIdleTime;
- // }
- //
- // /**
- // * If set <code>true</code> the index is checked for consistency depending
- // * on the {@link #forceConsistencyCheck} parameter. If set to
- // * <code>false</code>, no consistency check is performed, even if the redo
- // * log had been applied on startup.
- // * <p/>
- // * Default value is: <code>false</code>.
- // *
- // * @return boolean
- // */
- // public boolean isConsistencyCheckEnabled() {
- // return queryHandlerEntry.getParameterBoolean(
- // PARAM_CONSISTENCY_CHECK_ENABLED,
- // DEFAULT_CONSISTENCYCHECKENABLED);
- // }
- //
- // public boolean isForceConsistencyCheck() {
- // return queryHandlerEntry.getParameterBoolean(
- // PARAM_FORCE_CONSISTENCYCHECK, DEFAULT_FORCECONSISTENCYCHECK);
- // }
- //
- // /**
- // *
- // * @return true if index upgrade allowed.
- // */
- // public boolean isUpgradeIndex() {
- // Boolean updateIndex = queryHandlerEntry.getParameterBoolean(
- // PARAM_UPGRADE_INDEX, null);
- // if (updateIndex == null || !updateIndex) {
- // updateIndex = Boolean.valueOf(System
- // .getProperty(PARAM_UPGRADE_INDEX));
- // }
- // return updateIndex;
- // }
- //
- // /**
- // * Creates a file system resource to the synonym provider configuration.
- // *
- // * @param cfm
- // * @return a file system resource or <code>null</code> if no path was
- // * configured.
- // * @throws Exception
- // */
- // protected InputStream createSynonymProviderConfigResource(
- // ConfigurationManager cfm) throws Exception {
- // if (getSynonymProviderConfigPath() != null) {
- // return cfm.getInputStream(getSynonymProviderConfigPath());
- // }
- // return null;
- // }
- //
- // /**
- // * Returns the document element of the indexing configuration or
- // * <code>null</code> if there is no indexing configuration.
- // *
- // * @return the indexing configuration or <code>null</code> if there is none.
- // * @throws IOException
- // * @throws RepositoryConfigurationException
- // */
- // protected Element getIndexingConfigurationDOM(ConfigurationManager cfm)
- // throws IOException, RepositoryConfigurationException {
- // String indexingConfigPath = getIndexingConfigurationPath();
- // Element indexingConfiguration = null;
- // if (indexingConfigPath != null) {
- //
- // InputStream is;
- // try {
- // is = cfm.getInputStream(indexingConfigPath);
- // } catch (Exception e1) {
- // throw new IOException(e1.getLocalizedMessage());
- // }
- //
- // if (is == null)
- // throw new IOException("Resource does not exist: "
- // + indexingConfigPath);
- //
- // DocumentBuilderFactory factory = DocumentBuilderFactory
- // .newInstance();
- // try {
- // DocumentBuilder builder = factory.newDocumentBuilder();
- // builder
- // .setEntityResolver(new IndexingConfigurationEntityResolver());
- // indexingConfiguration = builder.parse(is).getDocumentElement();
- // } catch (ParserConfigurationException e) {
- // throw new RepositoryConfigurationException(e
- // .getLocalizedMessage(), e);
- // } catch (SAXException e) {
- // throw new RepositoryConfigurationException(e
- // .getLocalizedMessage(), e);
- // }
- // }
- //
- // return indexingConfiguration;
- // }
- //
- // /**
- // * Return ErrorLog file size in Kb String representation.
- // *
- // * @return int size in Kb
- // */
- // public int getErrorLogSize() {
- // String size = queryHandlerEntry.getParameterValue(PARAM_ERRORLOG_SIZE,
- // null);
- // if ((size == null) || (size.equals(""))) {
- // return SearchIndex.DEFAULT_ERRORLOG_FILE_SIZE;
- // } else {
- // return new Integer(size);
- // }
- // }
-
-}
16 years, 3 months
exo-jcr SVN: r1380 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2010-01-13 11:43:39 -0500 (Wed, 13 Jan 2010)
New Revision: 1380
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml
Log:
EXOJCR-331 : remove jotm
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml 2010-01-13 16:32:21 UTC (rev 1379)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/resources/conf/cluster/test-configuration.xml 2010-01-13 16:43:39 UTC (rev 1380)
@@ -205,7 +205,7 @@
<type>org.exoplatform.services.transaction.jbosscache.JBossTransactionService</type>
</component>
- <component>
+ <!-- component>
<key>org.exoplatform.services.transaction.TransactionService</key>
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
<init-params>
@@ -214,7 +214,7 @@
<value>5</value>
</value-param>
</init-params>
- </component>
+ </component-->
<external-component-plugins>
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
16 years, 3 months
exo-jcr SVN: r1379 - in jcr/branches/1.12.0-JBCCACHE: exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl and 1 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-13 11:32:21 -0500 (Wed, 13 Jan 2010)
New Revision: 1379
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/replication/WorkspaceDataManagerProxy.java
Log:
EXOJCR-378: jcr.ext merge with OPT
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 16:24:32 UTC (rev 1378)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 16:32:21 UTC (rev 1379)
@@ -299,6 +299,16 @@
transactionManager = null;
}
}
+
+ /**
+ * Get Items Cache.
+ *
+ * @return WorkspaceStorageCache
+ */
+ public WorkspaceStorageCache getCache()
+ {
+ return cache;
+ }
/**
* {@inheritDoc}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java 2010-01-13 16:24:32 UTC (rev 1378)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/PendingChangesLog.java 2010-01-13 16:32:21 UTC (rev 1379)
@@ -471,6 +471,8 @@
*/
public void restore() throws IOException
{
+ // TODO same code as in BackupWorkspaceInitializer?
+
List<ItemState> listItemState = itemDataChangesLog.getAllStates();
for (int i = 0; i < this.listFixupStream.size(); i++)
{
@@ -478,11 +480,12 @@
ItemData itemData = itemState.getData();
TransientPropertyData propertyData = (TransientPropertyData)itemData;
- TransientValueData transientValueData =
+ TransientValueData tvd =
(TransientValueData)(propertyData.getValues().get(listFixupStream.get(i).getValueDataId()));
- transientValueData.setStream(new FileInputStream(listFile.get(i)));
- transientValueData.setFileCleaner(fileCleaner);
- transientValueData.isByteArray();
+
+ // re-init the value
+ tvd.delegate(new TransientValueData(tvd.getOrderNumber(), null, null, listFile.get(i), fileCleaner, -1,
+ null, true));
}
if (listRandomAccessFile != null)
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/replication/WorkspaceDataManagerProxy.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/replication/WorkspaceDataManagerProxy.java 2010-01-13 16:24:32 UTC (rev 1378)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/replication/WorkspaceDataManagerProxy.java 2010-01-13 16:32:21 UTC (rev 1379)
@@ -72,9 +72,15 @@
this.listeners = new ArrayList<ItemsPersistenceListener>();
listeners.add(dataManager.getCache());
if (searchIndex != null)
+ {
listeners.add(searchIndex);
+ }
+
if (lockManager != null)
+ {
listeners.add(lockManager);
+ }
+
log.info("WorkspaceDataManagerProxy is instantiated");
}
@@ -98,7 +104,10 @@
{
listener.onSaveItems(changesLog);
}
+
if (log.isDebugEnabled())
+ {
log.debug("ChangesLog sent to " + listeners);
+ }
}
}
16 years, 3 months
exo-jcr SVN: r1378 - in jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/dataflow/persistent and 16 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2010-01-13 11:24:32 -0500 (Wed, 13 Jan 2010)
New Revision: 1378
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
Removed:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java
Modified:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataBuilder.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeReadException.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractItemDataCopyVisitor.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/StandaloneStoragePluginProvider.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java
Log:
EXOJCR-378: cleanups
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -76,10 +76,8 @@
return new ChangesLogIterator(changesLogs);
}
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.dataflow.ItemStateChangesLog#getAllStates()
+ /**
+ * {@inheritDoc}
*/
public List<ItemState> getAllStates()
{
@@ -98,10 +96,8 @@
return states;
}
- /*
- * (non-Javadoc)
- *
- * @see org.exoplatform.services.jcr.dataflow.ItemStateChangesLog#getSize()
+ /**
+ * {@inheritDoc}
*/
public int getSize()
{
@@ -168,68 +164,6 @@
return list;
}
- /**
- * Find if the node ancestor was renamed in this changes log.
- *
- * @param item - target node
- * @return - the pair of states of item ancestor, ItemState[] {DELETED,
- * RENAMED} or null if renaming is not detected.
- * @throws IllegalPathException
- */
- @Deprecated
- public ItemState[] findRenamed(ItemData item) throws IllegalPathException
- {
- List<ItemState> allStates = getAllStates();
- // search from the end for DELETED state.
- // RENAMED comes after the DELETED in the log immediately
- for (int i = allStates.size() - 1; i >= 0; i--)
- {
- ItemState state = allStates.get(i);
- if (state.getState() == ItemState.DELETED && !state.isPersisted()
- && item.getQPath().isDescendantOf(state.getData().getQPath()))
- {
- // 1. if it's a parent or the parent is descendant of logged data
- try
- {
- ItemState delete = state;
- ItemState rename = allStates.get(i + 1);
-
- if (rename.getState() == ItemState.RENAMED && rename.isPersisted()
- && rename.getData().getIdentifier().equals(delete.getData().getIdentifier()))
- {
-
- // 2. search of most fresh state of rename for searched rename state
- // (i.e. for ancestor
- // state of the given node)
- for (int bi = allStates.size() - 1; bi >= i + 2; bi--)
- {
- state = allStates.get(bi);
- if (state.getState() == ItemState.RENAMED && state.isPersisted()
- && state.getData().getIdentifier().equals(rename.getData().getIdentifier()))
- {
- // got much fresh
- rename = state;
- delete = allStates.get(i - 1); // try the fresh delete state
- if (delete.getData().getIdentifier().equals(rename.getData().getIdentifier()))
- return new ItemState[]{delete, rename}; // 3. ok, got it
- }
- }
-
- return new ItemState[]{delete, rename}; // 4. ok, there are no
- // more fresh we have
- // found before p.2
- } // else, it's not a rename, search deeper
- }
- catch (IndexOutOfBoundsException e)
- {
- // the pair not found
- return null;
- }
- }
- }
- return null;
- }
-
public String dump()
{
String str = "ChangesLog: size" + changesLogs.size() + "\n ";
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -55,13 +55,10 @@
private static final int ACL_IS_NOT_NULL = 1;
- //TODO remove final
protected int orderNumber;
- //TODO remove final
protected InternalQName primaryTypeName;
- //TODO remove final
protected InternalQName[] mixinTypeNames;
protected AccessControlList acl;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -43,7 +43,7 @@
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
-import org.exoplatform.services.jcr.impl.core.nodetype.registration.JcrNodeTypeDataPersister;
+import org.exoplatform.services.jcr.impl.core.nodetype.registration.JCRNodeTypeDataPersister;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
import org.exoplatform.services.jcr.impl.core.query.QueryManagerFactory;
import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
@@ -495,7 +495,7 @@
registerComponentImplementation(LocationFactory.class);
registerComponentImplementation(ValueFactoryImpl.class);
- registerComponentImplementation(JcrNodeTypeDataPersister.class);
+ registerComponentImplementation(JCRNodeTypeDataPersister.class);
registerComponentImplementation(NamespaceDataPersister.class);
registerComponentImplementation(NamespaceRegistryImpl.class);
@@ -561,8 +561,8 @@
nsRegistry.start();
//Node types now.
- JcrNodeTypeDataPersister nodeTypePersister =
- (JcrNodeTypeDataPersister)this.getComponentInstanceOfType(JcrNodeTypeDataPersister.class);
+ JCRNodeTypeDataPersister nodeTypePersister =
+ (JCRNodeTypeDataPersister)this.getComponentInstanceOfType(JCRNodeTypeDataPersister.class);
NodeTypeDataManagerImpl ntManager =
(NodeTypeDataManagerImpl)this.getComponentInstanceOfType(NodeTypeDataManagerImpl.class);
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -22,6 +22,8 @@
import org.exoplatform.services.jcr.config.ConfigurationPersister;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -39,14 +41,14 @@
/**
* Repository service configuration persister.
*
- * TODO use log.
- *
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id: JDBCConfigurationPersister.java 11907 2008-03-13 15:36:21Z ksm $
*/
public class JDBCConfigurationPersister implements ConfigurationPersister
{
+ protected static Log LOG = ExoLogger.getLogger("jcr.JDBCConfigurationPersister");
+
public final static String PARAM_SOURCE_NAME = "source-name";
public final static String PARAM_DIALECT = "dialect";
@@ -112,8 +114,10 @@
{
sourceNameParam = params.getProperty("sourceName"); // try old, pre 1.9 name
if (sourceNameParam == null)
+ {
throw new RepositoryConfigurationException("Repository service configuration. Source name ("
+ PARAM_SOURCE_NAME + ") is expected");
+ }
}
String dialectParam = params.getProperty(PARAM_DIALECT);
@@ -154,8 +158,10 @@
protected void checkInitialized() throws RepositoryConfigurationException
{
if (sourceName == null)
+ {
throw new RepositoryConfigurationException(
"Repository service configuration persister isn not initialized. Call init() before.");
+ }
}
protected Connection openConnection() throws NamingException, SQLException
@@ -322,9 +328,8 @@
if (ps.executeUpdate() <= 0)
{
- System.out
- .println(this.getClass().getCanonicalName()
- + " [WARN] Repository service configuration doesn't stored ok. No rows was affected in JDBC operation. Datasource "
+ LOG
+ .warn("Repository service configuration doesn't stored ok. No rows was affected in JDBC operation. Datasource "
+ sourceName + ". SQL: " + sql);
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -806,19 +806,6 @@
abstract void loadData(ItemData data, NodeData parent) throws RepositoryException;
/**
- * Loads data.
- *
- * @param data
- * source item data
- * @param itemDefinitionData
- * source item definition data
- * @throws RepositoryException
- * if errors occurs
- */
- @Deprecated
- abstract void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws RepositoryException;
-
- /**
* Returns Item definition data.
*
* @return
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -403,8 +403,6 @@
dataManager.save(new TransactionChangesLog(changesLog));
}
- // TODO remove me
- @Deprecated
private boolean isInialized()
{
return nsRoot != null;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -44,7 +44,6 @@
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.itemfilters.ItemDataFilter;
import org.exoplatform.services.jcr.impl.core.itemfilters.ItemDataNamePatternFilter;
-import org.exoplatform.services.jcr.impl.core.itemfilters.NamePatternFilter;
import org.exoplatform.services.jcr.impl.core.lock.LockImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.ItemAutocreator;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeDefinitionImpl;
@@ -1504,13 +1503,6 @@
ConstraintViolationException
{
- // TODO
- // if (data == null)
- // {
- // throw new InvalidItemStateException("Data is null for " + this.getPath()
- // + " Probably was deleted by another session and can not be loaded from container ");
- // }
-
if (data.isNode())
{
NodeData nodeData = (NodeData)data;
@@ -1547,46 +1539,6 @@
}
/**
- * {@inheritDoc}
- */
- @Override
- @Deprecated
- public void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws RepositoryException,
- InvalidItemStateException, ConstraintViolationException
- {
-
- if (data == null)
- {
- throw new InvalidItemStateException("Data is null for " + this.getPath()
- + " Probably was deleted by another session and can not be loaded from container ");
- }
-
- if (!data.isNode())
- {
- throw new RepositoryException("Load data failed: Node expected");
- }
-
- NodeData nodeData = (NodeData)data;
-
- // TODO do we need this three checks here?
- if (nodeData.getPrimaryTypeName() == null)
- throw new RepositoryException("Load data: NodeData has no primaryTypeName. Null value found. "
- + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() : "[null path node]") + " " + nodeData);
-
- if (nodeData.getMixinTypeNames() == null)
- throw new RepositoryException("Load data: NodeData has no mixinTypeNames. Null value found. "
- + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() : "[null path node]"));
-
- if (nodeData.getACL() == null)
- throw new RepositoryException("ACL is NULL " + nodeData.getQPath().getAsString());
-
- this.data = nodeData;
- this.location = null;
- this.qpath = nodeData.getQPath();
- this.definition = (NodeDefinitionData)itemDefinitionData;
- }
-
- /**
* Init NodeDefinition.
*
* @param parent NodeData
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -26,12 +26,9 @@
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.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.nodetype.PropertyDefinitionImpl;
import org.exoplatform.services.jcr.impl.core.value.BaseValue;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.InputStream;
import java.util.Calendar;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -28,7 +28,6 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
@@ -1497,48 +1496,6 @@
}
/**
- * Wraps NodeData into NodeImpl.
- *
- * @param data
- * NodeData to wrap
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
- * @param pool
- * indicates does the item fall in pool
- * @return NodeImpl object
- * @throws RepositoryException
- * if errors is occurs
- */
- public NodeImpl wrapNodeData(NodeData data, NodeData parent) throws RepositoryException
- {
-
- NodeImpl node = itemFactory.createNode(data, parent);
- //NodeImpl node = (NodeImpl)itemsPool.get(data);
- session.getActionHandler().postRead(node);
-
- NodeImpl pooledItem = (NodeImpl)itemsPool.getItem(data.getIdentifier());
- if (pooledItem == null)
- {
- NodeData pooledData = (NodeData)itemsPool.getData(data.getIdentifier());
- if (pooledData != null)
- {
- node.loadData(pooledData);
- }
-
- // TODO
- node = (NodeImpl)itemsPool.get(node);
- }
- else
- {
- node = pooledItem;
- }
-
- return node;
- }
-
- /**
* Removes all pending changes of this item
*
* @param item
@@ -1988,30 +1945,6 @@
}
/**
- * @param newItem
- * @return the item
- * @throws RepositoryException
- */
- @Deprecated
- ItemImpl get(ItemImpl newItem) throws RepositoryException
- {
- String identifier = newItem.getInternalIdentifier();
-
- ItemImpl item = items.get(identifier);
- if (item == null)
- {
- //datas.remove(identifier);
- items.put(identifier, newItem);
- return newItem;
- }
- else
- {
- item.loadData(newItem.getData(), newItem.getItemDefinitionData());
- return item;
- }
- }
-
- /**
* Get ItemImpl from the pool using given data.
*
* @param newData ItemData
@@ -2056,32 +1989,6 @@
}
/**
- * Gets item from pool.
- *
- * @param identifier
- * item identifier
- * @return ItemImpl object from pool
- */
- @Deprecated
- ItemImpl getItem(String identifier)
- {
- return items.get(identifier);
- }
-
- /**
- * Gets item from pool.
- *
- * @param identifier
- * item identifier
- * @return ItemData object from pool
- */
- @Deprecated
- ItemData getData(String identifier)
- {
- return null; //datas.get(identifier);
- }
-
- /**
* Reload an existed item in the pool with given data
*
* @param itemData
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/AbstractNodeTypeRepository.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -34,7 +34,6 @@
import javax.jcr.RepositoryException;
-
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
* @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -58,22 +57,19 @@
*/
public List<NodeTypeData> getAllNodeTypes() throws RepositoryException
{
- // TODO Auto-generated method stub
return nodeTypeDataPersister.getAllNodeTypes();
}
/**
- * @see org.exoplatform.services.jcr.core.ComponentPersister#isStorageFilled()
+ * {@inheritDoc}
*/
public boolean isStorageFilled()
{
- // TODO Auto-generated method stub
return nodeTypeDataPersister.isStorageFilled();
}
/**
- * @throws RepositoryException
- * @see org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeRepository#update(java.util.List, org.exoplatform.services.jcr.impl.core.nodetype.registration.UpdateNodeTypeObserver)
+ * {@inheritDoc}
*/
public void registerNodeType(final List<NodeTypeData> nodeTypes, final NodeTypeDataManager nodeTypeDataManager,
final String accessControlPolicy, final int alreadyExistsBehaviour) throws RepositoryException
@@ -163,7 +159,6 @@
*/
public void start()
{
- // TODO Auto-generated method stub
}
@@ -172,7 +167,6 @@
*/
public void stop()
{
- // TODO Auto-generated method stub
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -19,7 +19,6 @@
package org.exoplatform.services.jcr.impl.core.nodetype;
import org.exoplatform.services.jcr.access.AccessControlEntry;
-import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -28,7 +28,6 @@
import javax.jcr.RepositoryException;
import javax.jcr.ValueFactory;
import javax.jcr.nodetype.NodeDefinition;
-
import javax.jcr.nodetype.PropertyDefinition;
/**
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
+import org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeReadException;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -44,7 +45,6 @@
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
-import javax.jcr.ValueFormatException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
Copied: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java (from rev 1377, jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java)
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -0,0 +1,418 @@
+/*
+ * 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.
+ */
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
+ * @version $Id: $
+ */
+package org.exoplatform.services.jcr.impl.core.nodetype.registration;
+
+import org.exoplatform.services.jcr.access.AccessControlEntry;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.access.AccessControlPolicy;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.core.ExtendedPropertyType;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
+import org.exoplatform.services.jcr.dataflow.DataManager;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.ItemDataRemoveVisitor;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
+ * @version $Id: $
+ */
+public class JCRNodeTypeDataPersister implements NodeTypeDataPersister
+{
+
+ protected final Log log = ExoLogger.getLogger(getClass().getName());
+
+ private final DataManager dataManager;
+
+ private NodeData nodeTypeStorageRoot;
+
+ private final NodeTypeDefinitionAccessProvider definitionAccessProvider;
+
+ private final boolean addACL;
+
+ private boolean started = false;
+
+ /**
+ * @param dataManager
+ * @throws RepositoryException
+ */
+ public JCRNodeTypeDataPersister(DataManager dataManager, boolean addACL) throws RepositoryException
+ {
+ super();
+ this.dataManager = dataManager;
+ this.addACL = addACL;
+
+ this.definitionAccessProvider = new NodeTypeDefinitionAccessProvider(dataManager);
+ }
+
+ /**
+ * @param dataManager
+ * @throws RepositoryException
+ */
+ public JCRNodeTypeDataPersister(DataManager dataManager, NodeData nodeTypeStorageRoot) throws RepositoryException
+ {
+ super();
+ this.dataManager = dataManager;
+ this.nodeTypeStorageRoot = nodeTypeStorageRoot;
+ this.definitionAccessProvider = new NodeTypeDefinitionAccessProvider(dataManager);
+ this.addACL = true;
+
+ }
+
+ /**
+ * @param dataManager
+ * @throws RepositoryException
+ */
+ public JCRNodeTypeDataPersister(DataManager dataManager, RepositoryEntry repConfig) throws RepositoryException
+ {
+ this(dataManager, !repConfig.getAccessControl().equals(AccessControlPolicy.DISABLE));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addNodeType(NodeTypeData nodeType) throws RepositoryException
+ {
+ if (!started)
+ {
+ log.warn("Unable save nodetype " + nodeType.getName().getAsString()
+ + " in to the storage. Storage not initialized");
+ return;
+ }
+
+ PlainChangesLog changesLog = new PlainChangesLogImpl();
+ definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeType);
+ dataManager.save(new TransactionChangesLog(changesLog));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasNodeType(InternalQName nodeTypeName) throws RepositoryException
+ {
+ if (!validatate())
+ {
+ return false;
+ }
+
+ NodeData nodeTypeData = (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1));
+
+ return nodeTypeData != null;
+ }
+
+ public NodeData initNodetypesRoot(NodeData nsSystem, boolean addACL) throws RepositoryException
+ {
+ PlainChangesLog changesLog = new PlainChangesLogImpl();
+ TransientNodeData jcrNodetypes;
+
+ long start = System.currentTimeMillis();
+
+ if (addACL)
+ {
+ AccessControlList acl = new AccessControlList();
+ InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
+
+ jcrNodetypes =
+ TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
+ Constants.NODETYPESROOT_UUID);
+
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
+ new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
+
+ // jcr:mixinTypes
+ List<ValueData> mixValues = new ArrayList<ValueData>();
+ for (InternalQName mixin : mixins)
+ {
+ mixValues.add(new TransientValueData(mixin));
+ }
+ TransientPropertyData exoMixinTypes =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_MIXINTYPES, PropertyType.NAME, true,
+ mixValues);
+
+ TransientPropertyData exoOwner =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.EXO_OWNER, PropertyType.STRING, false,
+ new TransientValueData(acl.getOwner()));
+
+ List<ValueData> permsValues = new ArrayList<ValueData>();
+ for (int i = 0; i < acl.getPermissionEntries().size(); i++)
+ {
+ AccessControlEntry entry = acl.getPermissionEntries().get(i);
+ permsValues.add(new TransientValueData(entry));
+ }
+ TransientPropertyData exoPerms =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.EXO_PERMISSIONS,
+ ExtendedPropertyType.PERMISSION, true, permsValues);
+
+ changesLog.add(ItemState.createAddedState(exoMixinTypes)).add(ItemState.createAddedState(exoOwner)).add(
+ ItemState.createAddedState(exoPerms));
+ changesLog.add(new ItemState(jcrNodetypes, ItemState.MIXIN_CHANGED, false, null));
+ }
+ else
+ {
+ jcrNodetypes =
+ TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED,
+ Constants.NODETYPESROOT_UUID);
+
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
+ new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("/jcr:system/jcr:nodetypes is created, creation time: " + (System.currentTimeMillis() - start)
+ + " ms");
+
+ dataManager.save(new TransactionChangesLog(changesLog));
+
+ return jcrNodetypes;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isStorageFilled()
+ {
+ if (nodeTypeStorageRoot == null)
+ {
+ log.warn(" Storage not initialized");
+ return false;
+ }
+ try
+ {
+ List<NodeData> storageContent = dataManager.getChildNodesData(nodeTypeStorageRoot);
+ return storageContent.size() > 0;
+ }
+ catch (RepositoryException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addNodeTypes(List<NodeTypeData> nodeTypes) throws RepositoryException
+ {
+ if (!validatate())
+ {
+ return;
+ }
+
+ PlainChangesLog changesLog = new PlainChangesLogImpl();
+ for (NodeTypeData nodeTypeData : nodeTypes)
+ {
+ definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeTypeData);
+ }
+
+ dataManager.save(new TransactionChangesLog(changesLog));
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeNodeType(NodeTypeData nodeType) throws RepositoryException
+ {
+ if (!validatate())
+ {
+ return;
+ }
+
+ validatate();
+ NodeData nodeTypeData =
+ (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeType.getName(), 1));
+ ItemDataRemoveVisitor removeVisitor = new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
+ nodeTypeData.accept(removeVisitor);
+
+ PlainChangesLog changesLog = new PlainChangesLogImpl();
+ changesLog.addAll(removeVisitor.getRemovedStates());
+ dataManager.save(new TransactionChangesLog(changesLog));
+ }
+
+ public void start()
+ {
+ if (!started)
+ {
+ try
+ {
+ NodeData jcrSystem = (NodeData)dataManager.getItemData(Constants.SYSTEM_UUID);
+ if (jcrSystem != null)
+ {
+ NodeData jcrNodetypes =
+ (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.JCR_NODETYPES, 1));
+ if (jcrNodetypes == null)
+ this.nodeTypeStorageRoot = initNodetypesRoot(jcrSystem, addACL);
+ else
+ this.nodeTypeStorageRoot = jcrNodetypes;
+ }
+ else
+ {
+ throw new RuntimeException("Nodetypes storage (/jcr:systemnode) is not initialized.");
+ }
+ }
+ catch (RepositoryException e)
+ {
+ throw new RuntimeException(e.getLocalizedMessage(), e);
+ }
+ started = true;
+ }
+ }
+
+ public void stop()
+ {
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeDataPersister#unmarshall(org.exoplatform.services.jcr.datamodel.InternalQName, java.util.Set)
+ */
+ public NodeTypeData getNodeType(InternalQName nodeTypeName) throws RepositoryException, NoSuchNodeTypeException
+ {
+ if (nodeTypeStorageRoot == null)
+ {
+ log.warn(" Storage not initialized");
+ return null;
+ }
+ //Searching nodeType root
+ ItemData nodeType = dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1));
+ if (nodeType == null)
+ throw new NoSuchNodeTypeException("Node type definition " + nodeTypeName.getAsString() + "not found");
+ if (!nodeType.isNode())
+ throw new RepositoryException("Unexpected property found " + nodeType.getQPath().getAsString()
+ + ". Should be node.");
+
+ NodeData nodeTypeRoot = (NodeData)nodeType;
+
+ if (!Constants.NT_NODETYPE.equals(nodeTypeRoot.getPrimaryTypeName()))
+ throw new RepositoryException("Unexpected node type of NodeData found "
+ + nodeTypeRoot.getPrimaryTypeName().getAsString() + ". Should be " + Constants.NT_NODETYPE.getAsString());
+
+ return definitionAccessProvider.read(nodeTypeRoot);
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeDataPersister#getNodeType(java.util.Set)
+ */
+ public List<NodeTypeData> getAllNodeTypes() throws RepositoryException
+ {
+ if (!validatate())
+ {
+ return new ArrayList<NodeTypeData>();
+ }
+
+ validatate();
+ List<NodeData> nodeTypes = dataManager.getChildNodesData(nodeTypeStorageRoot);
+ List<NodeTypeData> result = new ArrayList<NodeTypeData>();
+ for (NodeData nodeData : nodeTypes)
+ {
+ if (Constants.NT_NODETYPE.equals(nodeData.getPrimaryTypeName()))
+ result.add(definitionAccessProvider.read(nodeData));
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(List<NodeTypeData> nodeTypes, UpdateNodeTypeObserver observer) throws RepositoryException
+ {
+
+ PlainChangesLog changesLog = new PlainChangesLogImpl();
+
+ for (NodeTypeData nodeTypeData : nodeTypes)
+ {
+
+ if (observer != null)
+ {
+ if (observer.shouldSkip(nodeTypeData, changesLog))
+ continue;
+ observer.beforeUpdate(nodeTypeData, changesLog);
+
+ }
+ if (!validatate())
+ {
+ continue;
+ }
+ // remove first
+ NodeData removeNodeTypeData =
+ (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeData.getName(), 1));
+ if (removeNodeTypeData != null)
+ {
+ ItemDataRemoveVisitor removeVisitor =
+ new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
+ removeNodeTypeData.accept(removeVisitor);
+
+ changesLog.addAll(removeVisitor.getRemovedStates());
+ }
+ // add
+ definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeTypeData);
+ if (observer != null)
+ observer.afterUpdate(nodeTypeData, changesLog);
+ }
+
+ dataManager.save(new TransactionChangesLog(changesLog));
+
+ }
+
+ private boolean validatate()
+ {
+ if (this.nodeTypeStorageRoot == null)
+ {
+ if (log.isDebugEnabled())
+ log.debug(" Storage not initialized");
+ return false;
+ }
+ return true;
+ }
+}
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -1,425 +0,0 @@
-/*
- * 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.
- */
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
- * @version $Id: $
- */
-package org.exoplatform.services.jcr.impl.core.nodetype.registration;
-
-import org.exoplatform.services.jcr.access.AccessControlEntry;
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.access.AccessControlPolicy;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.core.ExtendedPropertyType;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
-import org.exoplatform.services.jcr.dataflow.DataManager;
-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.PlainChangesLogImpl;
-import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.ItemDataRemoveVisitor;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
- * @version $Id: $
- */
-public class JcrNodeTypeDataPersister implements NodeTypeDataPersister
-{
-
- protected final Log log = ExoLogger.getLogger(getClass().getName());
-
- private final DataManager dataManager;
-
- private NodeData nodeTypeStorageRoot;
-
- private final NodeTypeDefinitionAccessProvider definitionAccessProvider;
-
- private final boolean addACL;
-
- private boolean started = false;
-
- // /**
- // * ChangesLog Buffer (used for saves before start).
- // */
- // private List<ItemStateChangesLog> changesLogBuffer = new ArrayList<ItemStateChangesLog>();
-
- /**
- * @param dataManager
- * @throws RepositoryException
- */
- public JcrNodeTypeDataPersister(DataManager dataManager, boolean addACL) throws RepositoryException
- {
- super();
- this.dataManager = dataManager;
- this.addACL = addACL;
-
- this.definitionAccessProvider = new NodeTypeDefinitionAccessProvider(dataManager);
- }
-
- /**
- * @param dataManager
- * @throws RepositoryException
- */
- public JcrNodeTypeDataPersister(DataManager dataManager, NodeData nodeTypeStorageRoot) throws RepositoryException
- {
- super();
- this.dataManager = dataManager;
- this.nodeTypeStorageRoot = nodeTypeStorageRoot;
- this.definitionAccessProvider = new NodeTypeDefinitionAccessProvider(dataManager);
- this.addACL = true;
-
- }
-
- /**
- * @param dataManager
- * @throws RepositoryException
- */
- public JcrNodeTypeDataPersister(DataManager dataManager, RepositoryEntry repConfig) throws RepositoryException
- {
- this(dataManager, !repConfig.getAccessControl().equals(AccessControlPolicy.DISABLE));
- }
-
- /**
- * {@inheritDoc}
- */
- public void addNodeType(NodeTypeData nodeType) throws RepositoryException
- {
- if (!started)
- {
- log.warn("Unable save nodetype " + nodeType.getName().getAsString()
- + " in to the storage. Storage not initialized");
- return;
- }
-
- PlainChangesLog changesLog = new PlainChangesLogImpl();
- definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeType);
- dataManager.save(new TransactionChangesLog(changesLog));
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasNodeType(InternalQName nodeTypeName) throws RepositoryException
- {
- if (!validatate())
- {
- return false;
- }
-
- NodeData nodeTypeData = (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1));
-
- return nodeTypeData != null;
- }
-
- public NodeData initNodetypesRoot(NodeData nsSystem, boolean addACL) throws RepositoryException
- {
- PlainChangesLog changesLog = new PlainChangesLogImpl();
- TransientNodeData jcrNodetypes;
-
- long start = System.currentTimeMillis();
-
- if (addACL)
- {
- AccessControlList acl = new AccessControlList();
- InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
-
- jcrNodetypes =
- TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
- Constants.NODETYPESROOT_UUID);
-
- TransientPropertyData primaryType =
- TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
- new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
-
- changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
-
- // jcr:mixinTypes
- List<ValueData> mixValues = new ArrayList<ValueData>();
- for (InternalQName mixin : mixins)
- {
- mixValues.add(new TransientValueData(mixin));
- }
- TransientPropertyData exoMixinTypes =
- TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_MIXINTYPES, PropertyType.NAME, true,
- mixValues);
-
- TransientPropertyData exoOwner =
- TransientPropertyData.createPropertyData(jcrNodetypes, Constants.EXO_OWNER, PropertyType.STRING, false,
- new TransientValueData(acl.getOwner()));
-
- List<ValueData> permsValues = new ArrayList<ValueData>();
- for (int i = 0; i < acl.getPermissionEntries().size(); i++)
- {
- AccessControlEntry entry = acl.getPermissionEntries().get(i);
- permsValues.add(new TransientValueData(entry));
- }
- TransientPropertyData exoPerms =
- TransientPropertyData.createPropertyData(jcrNodetypes, Constants.EXO_PERMISSIONS,
- ExtendedPropertyType.PERMISSION, true, permsValues);
-
- changesLog.add(ItemState.createAddedState(exoMixinTypes)).add(ItemState.createAddedState(exoOwner)).add(
- ItemState.createAddedState(exoPerms));
- changesLog.add(new ItemState(jcrNodetypes, ItemState.MIXIN_CHANGED, false, null));
- }
- else
- {
- jcrNodetypes =
- TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED,
- Constants.NODETYPESROOT_UUID);
-
- TransientPropertyData primaryType =
- TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
- new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
-
- changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
- }
-
- if (log.isDebugEnabled())
- log.debug("/jcr:system/jcr:nodetypes is created, creation time: " + (System.currentTimeMillis() - start)
- + " ms");
-
- dataManager.save(new TransactionChangesLog(changesLog));
-
- return jcrNodetypes;
-
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isStorageFilled()
- {
- if (nodeTypeStorageRoot == null)
- {
- log.warn(" Storage not initialized");
- return false;
- }
- try
- {
- List<NodeData> storageContent = dataManager.getChildNodesData(nodeTypeStorageRoot);
- return storageContent.size() > 0;
- }
- catch (RepositoryException e)
- {
- log.error(e.getLocalizedMessage(), e);
-
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void addNodeTypes(List<NodeTypeData> nodeTypes) throws RepositoryException
- {
- if (!validatate())
- {
- return;
- }
-
- PlainChangesLog changesLog = new PlainChangesLogImpl();
- for (NodeTypeData nodeTypeData : nodeTypes)
- {
- definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeTypeData);
- }
-
- dataManager.save(new TransactionChangesLog(changesLog));
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeNodeType(NodeTypeData nodeType) throws RepositoryException
- {
- if (!validatate())
- {
- return;
- }
-
- validatate();
- NodeData nodeTypeData =
- (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeType.getName(), 1));
- ItemDataRemoveVisitor removeVisitor = new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
- nodeTypeData.accept(removeVisitor);
-
- PlainChangesLog changesLog = new PlainChangesLogImpl();
- changesLog.addAll(removeVisitor.getRemovedStates());
- dataManager.save(new TransactionChangesLog(changesLog));
-
- }
-
- public void start()
- {
- if (!started)
- {
- try
- {
- NodeData jcrSystem = (NodeData)dataManager.getItemData(Constants.SYSTEM_UUID);
- if (jcrSystem != null)
- {
- NodeData jcrNodetypes =
- (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.JCR_NODETYPES, 1));
- if (jcrNodetypes == null)
- this.nodeTypeStorageRoot = initNodetypesRoot(jcrSystem, addACL);
- else
- this.nodeTypeStorageRoot = jcrNodetypes;
- }
- else
- {
- throw new RuntimeException("Nodetypes storage (/jcr:systemnode) is not initialized.");
- }
- }
- catch (RepositoryException e)
- {
- throw new RuntimeException(e.getLocalizedMessage(), e);
- }
- started = true;
- }
- }
-
- public void stop()
- {
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeDataPersister#unmarshall(org.exoplatform.services.jcr.datamodel.InternalQName, java.util.Set)
- */
- public NodeTypeData getNodeType(InternalQName nodeTypeName) throws RepositoryException, NoSuchNodeTypeException
- {
- if (nodeTypeStorageRoot == null)
- {
- log.warn(" Storage not initialized");
- return null;
- }
- //Searching nodeType root
- ItemData nodeType = dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1));
- if (nodeType == null)
- throw new NoSuchNodeTypeException("Node type definition " + nodeTypeName.getAsString() + "not found");
- if (!nodeType.isNode())
- throw new RepositoryException("Unexpected property found " + nodeType.getQPath().getAsString()
- + ". Should be node.");
-
- NodeData nodeTypeRoot = (NodeData)nodeType;
-
- if (!Constants.NT_NODETYPE.equals(nodeTypeRoot.getPrimaryTypeName()))
- throw new RepositoryException("Unexpected node type of NodeData found "
- + nodeTypeRoot.getPrimaryTypeName().getAsString() + ". Should be " + Constants.NT_NODETYPE.getAsString());
-
- return definitionAccessProvider.read(nodeTypeRoot);
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeDataPersister#getNodeType(java.util.Set)
- */
- public List<NodeTypeData> getAllNodeTypes() throws RepositoryException
- {
- if (!validatate())
- {
- return new ArrayList<NodeTypeData>();
- }
-
- validatate();
- List<NodeData> nodeTypes = dataManager.getChildNodesData(nodeTypeStorageRoot);
- List<NodeTypeData> result = new ArrayList<NodeTypeData>();
- for (NodeData nodeData : nodeTypes)
- {
- if (Constants.NT_NODETYPE.equals(nodeData.getPrimaryTypeName()))
- result.add(definitionAccessProvider.read(nodeData));
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(List<NodeTypeData> nodeTypes, UpdateNodeTypeObserver observer) throws RepositoryException
- {
-
- PlainChangesLog changesLog = new PlainChangesLogImpl();
-
- for (NodeTypeData nodeTypeData : nodeTypes)
- {
-
- if (observer != null)
- {
- if (observer.shouldSkip(nodeTypeData, changesLog))
- continue;
- observer.beforeUpdate(nodeTypeData, changesLog);
-
- }
- if (!validatate())
- {
- continue;
- }
- // remove first
- NodeData removeNodeTypeData =
- (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeData.getName(), 1));
- if (removeNodeTypeData != null)
- {
- ItemDataRemoveVisitor removeVisitor =
- new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
- removeNodeTypeData.accept(removeVisitor);
-
- changesLog.addAll(removeVisitor.getRemovedStates());
- }
- // add
- definitionAccessProvider.write(changesLog, nodeTypeStorageRoot, nodeTypeData);
- if (observer != null)
- observer.afterUpdate(nodeTypeData, changesLog);
- }
-
- dataManager.save(new TransactionChangesLog(changesLog));
-
- }
-
- private boolean validatate()
- {
- if (this.nodeTypeStorageRoot == null)
- {
- if (log.isDebugEnabled())
- log.debug(" Storage not initialized");
- return false;
- }
- return true;
- }
-}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataBuilder.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataBuilder.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataBuilder.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.Constants;
-
import java.util.LinkedList;
import java.util.List;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeReadException.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeReadException.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeReadException.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -39,7 +39,6 @@
public NodeTypeReadException()
{
super();
- // TODO Auto-generated constructor stub
}
/**
@@ -49,7 +48,6 @@
public NodeTypeReadException(String message, Throwable rootCause)
{
super(message, rootCause);
- // TODO Auto-generated constructor stub
}
/**
@@ -58,7 +56,6 @@
public NodeTypeReadException(String message)
{
super(message);
- // TODO Auto-generated constructor stub
}
/**
@@ -67,7 +64,6 @@
public NodeTypeReadException(Throwable rootCause)
{
super(rootCause);
- // TODO Auto-generated constructor stub
}
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueConstraintsMatcher.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -27,7 +27,6 @@
import org.exoplatform.services.jcr.impl.core.JCRPath;
import org.exoplatform.services.jcr.impl.core.JCRPathMatcher;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
-import org.exoplatform.services.jcr.dataflow.ItemDataTraversingVisitor;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
@@ -41,7 +40,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractItemDataCopyVisitor.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractItemDataCopyVisitor.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractItemDataCopyVisitor.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -63,7 +63,6 @@
{
for (ValueData vd : src)
{
- // TODO fix according OPT branch code
if (vd.isByteArray())
{
copy.add(new TransientValueData(vd.getOrderNumber(), vd.getAsByteArray()));
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/DefaultItemDataCopyVisitor.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -27,12 +27,8 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.util.IdGenerator;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -42,7 +42,6 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
public class TransientNodeData extends TransientItemData implements Comparable, NodeData, ItemData, Externalizable
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -185,9 +185,6 @@
{
if (isByteArrayAfterSpool())
{
- // TODO JCR-992 don't copy bytes
- // byte[] bytes = new byte[data.length];
- // System.arraycopy(data, 0, bytes, 0, data.length);
return data;
}
else
@@ -1105,7 +1102,7 @@
* int
*/
// TODO make it protected
- public TransientValueData()
+ TransientValueData()
{
}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -18,12 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
-import java.util.Calendar;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
@@ -35,6 +29,12 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.util.Calendar;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS. Data Manager supported ACL Inheritance
*
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -290,8 +290,6 @@
this.requestCache = new HashMap<Integer, DataRequest>();
addItemPersistenceListener(cache);
- //TODO transactionManager = null;
-
if (cache instanceof JBossCacheWorkspaceStorageCache)
{
transactionManager = ((JBossCacheWorkspaceStorageCache)cache).getTransactionManager();
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -25,7 +25,6 @@
import org.exoplatform.services.log.Log;
import java.io.FileNotFoundException;
-import java.io.IOException;
import javax.jcr.RepositoryException;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -18,12 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
import org.exoplatform.services.jcr.dataflow.DataManager;
@@ -42,6 +36,12 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS. Responsible for: *redirecting repository operations if item is
* descendant of /jcr:system/jcr:versionStorage *adding version history for newly added/assigned
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -689,40 +689,6 @@
return Fqn.fromRelativeElements(root, parentId);
}
- // /**
- // * Internal put Item.
- // *
- // * @param item ItemData, new data to put in the cache
- // * @return ItemData, previous data or null
- // */
- // protected ItemData cacheItem(ItemData item)
- // {
- // if (item.isNode())
- // {
- // if (item.getParentIdentifier() != null)
- // {
- // // if not a root node - add in CHILD_NODES
- // cache.put(makeChildFqn(childNodes, item.getParentIdentifier(), item.getQPath().getEntries()[item.getQPath()
- // .getEntries().length - 1]), ITEM_ID, item.getIdentifier());
- // }
- // }
- // else
- // {
- // // add in CHILD_PROPS
- // cache.put(makeChildFqn(childProps, item.getParentIdentifier(), item.getQPath().getEntries()[item.getQPath()
- // .getEntries().length - 1]), ITEM_ID, item.getIdentifier());
- //
- // // TODO REFERENCEs hadnling
- // //if (prop.getType() == PropertyType.REFERENCE)
- // //{
- // // addReferences(data);
- // //}
- // }
- //
- // // add in ITEMS
- // return (ItemData)cache.put(makeItemFqn(item.getIdentifier()), ITEM_DATA, item);
- // }
-
/**
* Internal put Item.
*
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.dataflow.serialization.ObjectWriter;
import org.exoplatform.services.jcr.dataflow.serialization.SerializationConstants;
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.util.IdGenerator;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -27,7 +27,6 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
import java.util.ArrayList;
import java.util.Collection;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/StandaloneStoragePluginProvider.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/StandaloneStoragePluginProvider.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/StandaloneStoragePluginProvider.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -125,10 +125,7 @@
}
/**
- * @param property
- * @return ValueIOChannel appropriate for this property (by path, id etc) or null if no such
- * channel found
- * @throws IOException
+ * {@inheritDoc}
*/
public ValueIOChannel getApplicableChannel(PropertyData property, int valueOrderNumer) throws IOException
{
@@ -146,6 +143,9 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public void checkConsistency(WorkspaceStorageConnection dataConnection)
{
Iterator<ValueStoragePlugin> plugins = iterator();
@@ -156,6 +156,9 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
public ValueIOChannel getChannel(String storageId) throws IOException, ValueStorageNotFoundException
{
Iterator<ValueStoragePlugin> plugins = iterator();
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2003-2009 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.impl.util;
-
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.impl.core.NodeImpl;
-import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>
- * Date: 2009
- *
- * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
- * @version $Id$
- */
-@Deprecated
-public class NodeIteratorOnDemand extends EntityCollection
-{
- protected static Log log = ExoLogger.getLogger("jcr.NodeIteratorOnDemand");
-
- private final Iterator<Object> iter;
-
- private final List<Object> list;
-
- private final SessionDataManager dataManager;
-
- private final NodeData parent;
-
- private NodeImpl next;
-
- private int pos;
-
- /**
- * NodeIteratorOnDemand constructor. Gets list of NodeData and returns NodeImpl object on demand.
- * NodeImpl objects will be created on next() or nextNode() methods when will be called.
- *
- * @param list
- * NodeData list
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
- * @param dataManager
- * session data manager
- */
- @Deprecated
- public NodeIteratorOnDemand(List<Object> list, SessionDataManager dataManager, NodeData parent)
- {
- this.list = list;
-
- this.dataManager = dataManager;
- this.parent = parent;
-
- this.iter = list.iterator();
- this.pos = 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public Node nextNode()
- {
- wrapNodeData();
-
- pos++;
- return (Node)iter.next();
- }
-
- /**
- * {@inheritDoc}
- */
- public void skip(long skipNum)
- {
- pos += skipNum;
- while (skipNum-- > 0)
- {
- iter.next();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public long getSize()
- {
- return list.size();
- }
-
- /**
- * {@inheritDoc}
- */
- public long getPosition()
- {
- return pos;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasNext()
- {
- return iter.hasNext();
- }
-
- /**
- * {@inheritDoc}
- */
- public Object next()
- {
- wrapNodeData();
-
- pos++;
- return iter.next();
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove()
- {
- iter.remove();
- }
-
- /**
- * Wraps NodeData into NodeImpl.
- */
- private void wrapNodeData()
- {
- if (pos >= list.size())
- {
- return;
- }
-
- Object item = list.get(pos);
- if (!(item instanceof NodeImpl))
- {
- try
- {
- list.set(pos, dataManager.wrapNodeData((NodeData)item, parent));
- }
- catch (RepositoryException e)
- {
- log.error(e);
- }
- }
- }
-
-
-}
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -40,7 +40,6 @@
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
import org.exoplatform.services.jcr.impl.dataflow.ItemDataRemoveVisitor;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.version.VersionHistoryDataHelper;
import org.exoplatform.services.jcr.impl.xml.VersionHistoryRemover;
import org.exoplatform.services.jcr.impl.xml.importing.dataflow.ImportItemData;
Modified: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java 2010-01-13 15:57:16 UTC (rev 1377)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java 2010-01-13 16:24:32 UTC (rev 1378)
@@ -124,7 +124,7 @@
System.out.println("item >" + node1.getPath());
assertTrue(pool.contains(uuid));
// return the same value
- assertEquals(node1, pool.get(node1));
+ assertEquals(node1, pool.get(node1.getData()));
// add one more node
data =
16 years, 3 months
exo-jcr SVN: r1376 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-01-13 08:52:14 -0500 (Wed, 13 Jan 2010)
New Revision: 1376
Removed:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java
Log:
EXOJCR-332: CacheableLockManager removed
Deleted: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java 2010-01-13 13:33:22 UTC (rev 1375)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java 2010-01-13 13:52:14 UTC (rev 1376)
@@ -1,844 +0,0 @@
-/*
- * 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.impl.core.lock;
-
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.jmx.annotations.NameTemplate;
-import org.exoplatform.management.jmx.annotations.Property;
-import org.exoplatform.services.jcr.access.SystemIdentity;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.core.ExtendedSession;
-import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
-import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
-import org.exoplatform.services.jcr.dataflow.DataManager;
-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.PlainChangesLogImpl;
-import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-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.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.NodeImpl;
-import org.exoplatform.services.jcr.impl.core.SessionImpl;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.BufferedJBossCache;
-import org.exoplatform.services.jcr.observation.ExtendedEvent;
-import org.exoplatform.services.jcr.util.IdGenerator;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.DefaultCacheFactory;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.lock.Lock;
-import javax.jcr.lock.LockException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: CacheableLockManager.java 111 2008-11-11 11:11:11Z serg $
- */
-@Managed
-@NameTemplate(@Property(key = "service", value = "lockmanager"))
-public class CacheableLockManager extends LockManagerImpl
-{
-
- /**
- * Default lock time out. 30min
- */
- public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
-
- // Search constants
- /**
- * The exact lock token.
- */
- private static final int SEARCH_EXECMATCH = 1;
-
- /**
- * Lock token of closed parent
- */
- private static final int SEARCH_CLOSEDPARENT = 2;
-
- /**
- * Lock token of closed child
- */
- private static final int SEARCH_CLOSEDCHILD = 4;
-
- /**
- * Path to jbosscache-configuration
- */
- public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
-
- /**
- * Logger
- */
- private final Log log = ExoLogger.getLogger("jcr.lock.LockManager");
-
- /**
- * Map NodeIdentifier -- lockData
- */
- private final Map<String, LockData> locks;
-
- /**
- * Data manager.
- */
- private final DataManager dataManager;
-
- /**
- * Map NodeIdentifier -- lockData
- */
- private final Map<String, LockData> pendingLocks;
-
- /**
- * Map lockToken --lockData
- */
- private final Map<String, LockData> tokensMap;
-
- /**
- * Run time lock time out.
- */
- private long lockTimeOut;
-
- /**
- * Lock remover thread.
- */
- private LockRemover lockRemover;
-
- /**
- * Lock persister instance.
- */
- private final LockPersister persister;
-
- private BufferedJBossCache cache;
-
- /**
- * Constructor for workspace without LockPersister
- *
- * @param dataManager
- * @param config
- */
- public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
- throws RepositoryConfigurationException
- {
- this(dataManager, config, null);
- }
-
- public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
- LockPersister persister) throws RepositoryConfigurationException
- {
- super(dataManager, config, null);
- this.dataManager = dataManager;
- this.persister = persister;
- if (config.getLockManager() != null)
- {
- lockTimeOut =
- config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
- }
- else
- lockTimeOut = DEFAULT_LOCK_TIMEOUT;
-
- locks = new HashMap<String, LockData>();
- pendingLocks = new HashMap<String, LockData>();
- tokensMap = new HashMap<String, LockData>();
-
- dataManager.addItemPersistenceListener(this);
-
- CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
- this.cache = new BufferedJBossCache(factory.createCache(readJBCConfig(config), false));
-
- // cache.create();
-
- }
-
- protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
- {
- if (wsConfig.getLockManager() != null)
- {
- return wsConfig.getLockManager().getCacheConfig();
- }
- else
- {
- throw new RepositoryConfigurationException("Cache configuration not found");
- }
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#lockTokenAdded(org.exoplatform.services
- * .jcr.impl.core.SessionImpl, java.lang.String)
- */
- public synchronized void addLockToken(String sessionId, String lt)
- {
- LockData currLock = tokensMap.get(lt);
- if (currLock != null)
- {
- currLock.addLockHolder(sessionId);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#addPendingLock(org.exoplatform.services
- * .jcr.impl.core.NodeImpl, boolean, boolean, long)
- */
- public synchronized Lock addPendingLock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timeOut)
- throws LockException
- {
- LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
- if (lData != null)
- {
- if (lData.getNodeIdentifier().equals(node.getInternalIdentifier()))
- {
- throw new LockException("Node already locked: " + node.getData().getQPath());
- }
- else if (lData.isDeep())
- {
- throw new LockException("Parent node has deep lock.");
- }
- }
-
- if (isDeep && getLockData((NodeData)node.getData(), SEARCH_CLOSEDCHILD) != null)
- {
- throw new LockException("Some child node is locked.");
- }
-
- String lockToken = IdGenerator.generate();
- lData =
- new LockData(node.getInternalIdentifier(), lockToken, isDeep, isSessionScoped, node.getSession().getUserID(),
- timeOut > 0 ? timeOut : lockTimeOut);
-
- lData.addLockHolder(node.getSession().getId());
- pendingLocks.put(node.getInternalIdentifier(), lData);
- tokensMap.put(lockToken, lData);
-
- LockImpl lock = new LockImpl(node.getSession(), lData);
- return lock;
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#getLock(org.exoplatform.services.jcr
- * .impl.core.NodeImpl)
- */
- public LockImpl getLock(NodeImpl node) throws LockException, RepositoryException
- {
-
- LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
-
- if (lData == null || (!node.getInternalIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
- {
- throw new LockException("Node not locked: " + node.getData().getQPath());
-
- }
- return new LockImpl(node.getSession(), lData);
- }
-
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.lock.LockManager#getLockTokens(java.lang.String)
- */
- public synchronized String[] getLockTokens(String sessionID)
- {
- List<String> retval = new ArrayList<String>();
-
- for (LockData lockData : locks.values())
- {
- if (lockData.isLockHolder(sessionID))
- retval.add(lockData.getLockToken(sessionID));
-
- }
- return retval.toArray(new String[retval.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#holdsLock(org.exoplatform.services.
- * jcr.impl.core.NodeImpl)
- */
- public boolean holdsLock(NodeData node) throws RepositoryException
- {
- return getLockData(node, SEARCH_EXECMATCH) != null;
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#isLocked(org.exoplatform.services.jcr
- * .datamodel.NodeData)
- */
- public boolean isLocked(NodeData node)
- {
- LockData lData = getLockData(node, SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
-
- if (lData == null || (!node.getIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
- {
- return false;
- }
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#isLockHolder(org.exoplatform.services
- * .jcr.impl.core.NodeImpl)
- */
- public boolean isLockHolder(NodeImpl node) throws RepositoryException
- {
- LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
- return lData != null && lData.isLockHolder(node.getSession().getId());
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.core.SessionLifecycleListener#onCloseSession(org.exoplatform.services
- * .jcr.core.ExtendedSession)
- */
- public synchronized void onCloseSession(ExtendedSession session)
- {
- // List<String> deadLocksList = new ArrayList<String>();
- SessionImpl sessionImpl = (SessionImpl)session;
- for (Iterator<Map.Entry<String, LockData>> entries = locks.entrySet().iterator(); entries.hasNext();)
- {
- Map.Entry<String, LockData> entry = entries.next();
- LockData lockData = entry.getValue();
- if (lockData.isLive())
- {
- if (lockData.isLockHolder(session.getId()))
- {
- if (lockData.isSessionScoped())
- {
- // if no session currently holds lock except this
- try
- {
- // TODO it's possible to have next error
- // java.lang.NullPointerException
- // at
- // org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl.onCloseSession(LockManagerImpl.java:312)
- // at org.exoplatform.services.jcr.impl.core.SessionImpl.logout(SessionImpl.java:794)
- // at
- // org.exoplatform.services.jcr.impl.core.XASessionImpl.logout(XASessionImpl.java:254)
- // at
- // org.exoplatform.services.jcr.impl.core.SessionRegistry$SessionCleaner.callPeriodically(SessionRegistry.java:165)
- // at
- // org.exoplatform.services.jcr.impl.proccess.WorkerThread.run(WorkerThread.java:46)
- ((NodeImpl)sessionImpl.getTransientNodesManager().getItemByIdentifier(
- lockData.getNodeIdentifier(), false)).unlock();
- }
- catch (UnsupportedRepositoryOperationException e)
- {
- log.error(e.getLocalizedMessage());
- }
- catch (LockException e)
- {
- log.error(e.getLocalizedMessage());
- }
- catch (AccessDeniedException e)
- {
- log.error(e.getLocalizedMessage());
- }
- catch (RepositoryException e)
- {
- log.error(e.getLocalizedMessage());
- }
-
- }
- else
- {
- lockData.removeLockHolder(session.getId());
- }
- }
- }
- else
- {
- entries.remove();
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @seeorg.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.
- * exoplatform.services.jcr.dataflow.ItemStateChangesLog)
- */
- public void onSaveItems(ItemStateChangesLog changesLog)
- {
- List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
- if (changesLog instanceof TransactionChangesLog)
- {
- ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
-
- while (logIterator.hasNextLog())
- {
- chengesLogList.add(logIterator.nextLog());
- }
- }
- else if (changesLog instanceof PlainChangesLog)
- {
- chengesLogList.add((PlainChangesLog)changesLog);
- }
- else if (changesLog instanceof CompositeChangesLog)
- {
- for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
- {
- chengesLogList.add(iter.nextLog());
- }
- }
-
- for (PlainChangesLog currChangesLog : chengesLogList)
- {
- String nodeIdentifier;
- try
- {
- switch (currChangesLog.getEventType())
- {
- case ExtendedEvent.LOCK :
- if (currChangesLog.getSize() < 2)
- {
- log.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
- break;
- }
- nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
-
- if (pendingLocks.containsKey(nodeIdentifier))
- {
- internalLock(nodeIdentifier);
- }
- else
- {
- log.warn("No lock in pendingLocks for identifier " + nodeIdentifier
- + " Probably lock come from replication.");
-
- String lockToken = IdGenerator.generate();
- ItemState ownerState = getItemState(currChangesLog, Constants.JCR_LOCKOWNER);
- ItemState isDeepState = getItemState(currChangesLog, Constants.JCR_LOCKISDEEP);
- if (ownerState != null && isDeepState != null)
- {
-
- String owner =
- new String(((((TransientPropertyData)(ownerState.getData())).getValues()).get(0))
- .getAsByteArray(), Constants.DEFAULT_ENCODING);
-
- boolean isDeep =
- Boolean.valueOf(
- new String(((((TransientPropertyData)(isDeepState.getData())).getValues()).get(0))
- .getAsByteArray(), Constants.DEFAULT_ENCODING)).booleanValue();
-
- createRemoteLock(currChangesLog.getSessionId(), nodeIdentifier, lockToken, isDeep, false, owner);
- }
- }
- break;
- case ExtendedEvent.UNLOCK :
- if (currChangesLog.getSize() < 2)
- {
- log.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
- + "<2 \n" + currChangesLog.dump());
- break;
- }
-
- internalUnLock(currChangesLog.getSessionId(), currChangesLog.getAllStates().get(0).getData()
- .getParentIdentifier());
- break;
- default :
- HashSet<String> removedLock = new HashSet<String>();
- for (ItemState itemState : currChangesLog.getAllStates())
- {
- // this is a node and node is locked
- if (itemState.getData().isNode() && locks.containsKey(itemState.getData().getIdentifier()))
- {
- nodeIdentifier = itemState.getData().getIdentifier();
- if (itemState.isDeleted())
- {
- removedLock.add(nodeIdentifier);
- }
- else if (itemState.isAdded() || itemState.isRenamed() || itemState.isUpdated())
- {
- removedLock.remove(nodeIdentifier);
- }
- }
- }
- for (String identifier : removedLock)
- {
- internalUnLock(currChangesLog.getSessionId(), identifier);
- }
- break;
- }
- }
- catch (LockException e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- catch (UnsupportedEncodingException e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- catch (IllegalStateException e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- catch (IOException e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.impl.core.lock.LockManager#lockTokenRemoved(org.exoplatform.services
- * .jcr.impl.core.SessionImpl, java.lang.String)
- */
- public synchronized void removeLockToken(String sessionId, String lt)
- {
- LockData lData = tokensMap.get(lt);
- if (lData != null && lData.isLockHolder(sessionId))
- {
- lData.removeLockHolder(sessionId);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.picocontainer.Startable#start()
- */
- public void start()
- {
- // cache.start();
- lockRemover = new LockRemover(this);
-
- }
-
- // Quick method. We need to reconstruct
- synchronized List<LockData> getLockList()
- {
- return new ArrayList<LockData>(locks.values());
- }
-
- /**
- * Remove expired locks. Used from LockRemover.
- */
- public synchronized void removeExpired()
- {
- final List<String> removeLockList = new ArrayList<String>();
-
- for (LockData lock : locks.values())
- {
- if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
- {
- removeLockList.add(lock.getNodeIdentifier());
- }
- }
-
- for (String rLock : removeLockList)
- {
- removeLock(rLock);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.picocontainer.Startable#stop()
- */
- public void stop()
- {
-
- lockRemover.halt();
- lockRemover.interrupt();
- locks.clear();
- pendingLocks.clear();
- tokensMap.clear();
- // cache.stop();
- }
-
- /**
- * Copy <code>PropertyData prop<code> to new TransientItemData
- *
- * @param prop
- * @return
- * @throws RepositoryException
- */
- private TransientItemData copyItemData(PropertyData prop) throws RepositoryException
- {
-
- if (prop == null)
- return null;
-
- // make a copy
- TransientPropertyData newData =
- new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
- prop.getParentIdentifier(), prop.isMultiValued());
-
- List<ValueData> values = null;
- // null is possible for deleting items
- if (prop.getValues() != null)
- {
- values = new ArrayList<ValueData>();
- for (ValueData val : prop.getValues())
- {
- values.add(((AbstractValueData)val).createTransientCopy());
- }
- }
- newData.setValues(values);
- return newData;
- }
-
- /**
- * Search item with name <code>itemName<code> in changesLog
- *
- * @param changesLog
- * @param itemName
- * @return Item
- */
- private ItemState getItemState(PlainChangesLog changesLog, InternalQName itemName)
- {
- List<ItemState> allStates = changesLog.getAllStates();
- for (int i = allStates.size() - 1; i >= 0; i--)
- {
- ItemState state = allStates.get(i);
- if (state.getData().getQPath().getName().equals(itemName))
- return state;
- }
- return null;
- }
-
- /**
- * Search lock in maps.
- *
- * @param data
- * @param searchType
- * @return
- */
- private LockData getLockData(NodeData data, int searchType)
- {
- if (data == null || locks.size() == 0)
- return null;
- LockData retval = null;
- try
- {
- if ((searchType & SEARCH_EXECMATCH) != 0)
- {
- retval = locks.get(data.getIdentifier());
- }
- if (retval == null && (searchType & SEARCH_CLOSEDPARENT) != 0)
- {
-
- NodeData parentData = (NodeData)dataManager.getItemData(data.getParentIdentifier());
- if (parentData != null)
- {
- retval = locks.get(parentData.getIdentifier());
- // parent not found try to fo upper
- if (retval == null)
- {
- retval = getLockData(parentData, SEARCH_CLOSEDPARENT);
- }
- }
- }
- if (retval == null && (searchType & SEARCH_CLOSEDCHILD) != 0)
- {
-
- List<NodeData> childData = dataManager.getChildNodesData(data);
- for (NodeData nodeData : childData)
- {
- retval = locks.get(nodeData.getIdentifier());
- if (retval != null)
- break;
- }
- if (retval == null)
- {
- // child not found try to find diper
- for (NodeData nodeData : childData)
- {
- retval = getLockData(nodeData, SEARCH_CLOSEDCHILD);
- if (retval != null)
- break;
- }
- }
- }
- }
- catch (RepositoryException e)
- {
- return null;
- }
-
- return retval;
- }
-
- /**
- * Internal lock
- *
- * @param nodeIdentifier
- * @throws LockException
- */
- private synchronized void internalLock(String nodeIdentifier) throws LockException
- {
- LockData ldata = pendingLocks.get(nodeIdentifier);
- if (ldata != null)
- {
- locks.put(nodeIdentifier, ldata);
-
- if (persister != null)
- {
- persister.add(ldata);
- }
- pendingLocks.remove(nodeIdentifier);
- }
- else
- {
- throw new LockException("No lock in pending locks");
- }
- }
-
- /**
- * Internal unlock.
- *
- * @param sessionId
- * @param nodeIdentifier
- * @throws LockException
- */
- private synchronized void internalUnLock(String sessionId, String nodeIdentifier) throws LockException
- {
- LockData lData = locks.get(nodeIdentifier);
-
- if (lData != null)
- {
- tokensMap.remove(lData.getLockToken(sessionId));
- locks.remove(nodeIdentifier);
-
- lData.setLive(false);
- if (persister != null)
- {
- persister.remove(lData);
- }
- lData = null;
- }
- }
-
- /**
- * For locks comes from remote JCRs (replication usecase)
- *
- * @param sessionId
- * String
- * @param nodeIdentifier
- * String
- * @param lockToken
- * String
- * @param isDeep
- * boolean
- * @param sessionScoped
- * boolean
- * @param owner
- * String
- * @return LockData
- */
- private synchronized LockData createRemoteLock(String sessionId, String nodeIdentifier, String lockToken,
- boolean isDeep, boolean sessionScoped, String owner)
- {
- LockData lData = new LockData(nodeIdentifier, lockToken, isDeep, sessionScoped, owner, lockTimeOut);
- lData.addLockHolder(sessionId);
- locks.put(nodeIdentifier, lData);
- tokensMap.put(lockToken, lData);
-
- return lData;
- }
-
- /**
- * Remove lock, used by Lock remover.
- *
- * @param nodeIdentifier String
- */
- protected void removeLock(String nodeIdentifier)
- {
- try
- {
- NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
- PlainChangesLog changesLog =
- new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
-
- ItemData lockOwner =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
-
- changesLog.add(ItemState.createDeletedState(lockOwner));
-
- ItemData lockIsDeep =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
- changesLog.add(ItemState.createDeletedState(lockIsDeep));
-
- // lock probably removed by other thread
- if (lockOwner == null && lockIsDeep == null)
- return;
- dataManager.save(new TransactionChangesLog(changesLog));
- }
- catch (RepositoryException e)
- {
- log.error("Error occur during removing lock" + e.getLocalizedMessage());
- }
- }
-
- @Managed
- @ManagedDescription("The number of active locks")
- public int getNumLocks()
- {
- return locks.size();
- }
-
- @Managed
- @ManagedDescription("Remove the expired locks")
- public void cleanExpiredLocks()
- {
- removeExpired();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTXAware()
- {
- return true;
- }
-}
16 years, 3 months
exo-jcr SVN: r1375 - jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-01-13 08:33:22 -0500 (Wed, 13 Jan 2010)
New Revision: 1375
Added:
jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java
Log:
EXOJCR-332: CacheableLockManager added
Added: jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java (rev 0)
+++ jcr/branches/1.12.0-JBCCACHE/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/CacheableLockManager.java 2010-01-13 13:33:22 UTC (rev 1375)
@@ -0,0 +1,844 @@
+/*
+ * 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.impl.core.lock;
+
+import org.exoplatform.management.annotations.Managed;
+import org.exoplatform.management.annotations.ManagedDescription;
+import org.exoplatform.management.jmx.annotations.NameTemplate;
+import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.services.jcr.access.SystemIdentity;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.core.ExtendedSession;
+import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
+import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
+import org.exoplatform.services.jcr.dataflow.DataManager;
+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.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.dataflow.AbstractValueData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.jbosscache.BufferedJBossCache;
+import org.exoplatform.services.jcr.observation.ExtendedEvent;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.DefaultCacheFactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.lock.Lock;
+import javax.jcr.lock.LockException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: CacheableLockManager.java 111 2008-11-11 11:11:11Z serg $
+ */
+@Managed
+@NameTemplate(@Property(key = "service", value = "lockmanager"))
+public class CacheableLockManager extends LockManagerImpl
+{
+
+ /**
+ * Default lock time out. 30min
+ */
+ public static final long DEFAULT_LOCK_TIMEOUT = 1000 * 60 * 30;
+
+ // Search constants
+ /**
+ * The exact lock token.
+ */
+ private static final int SEARCH_EXECMATCH = 1;
+
+ /**
+ * Lock token of closed parent
+ */
+ private static final int SEARCH_CLOSEDPARENT = 2;
+
+ /**
+ * Lock token of closed child
+ */
+ private static final int SEARCH_CLOSEDCHILD = 4;
+
+ /**
+ * Path to jbosscache-configuration
+ */
+ public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
+
+ /**
+ * Logger
+ */
+ private final Log log = ExoLogger.getLogger("jcr.lock.LockManager");
+
+ /**
+ * Map NodeIdentifier -- lockData
+ */
+ private final Map<String, LockData> locks;
+
+ /**
+ * Data manager.
+ */
+ private final DataManager dataManager;
+
+ /**
+ * Map NodeIdentifier -- lockData
+ */
+ private final Map<String, LockData> pendingLocks;
+
+ /**
+ * Map lockToken --lockData
+ */
+ private final Map<String, LockData> tokensMap;
+
+ /**
+ * Run time lock time out.
+ */
+ private long lockTimeOut;
+
+ /**
+ * Lock remover thread.
+ */
+ private LockRemover lockRemover;
+
+ /**
+ * Lock persister instance.
+ */
+ private final LockPersister persister;
+
+ private BufferedJBossCache cache;
+
+ /**
+ * Constructor for workspace without LockPersister
+ *
+ * @param dataManager
+ * @param config
+ */
+ public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
+ throws RepositoryConfigurationException
+ {
+ this(dataManager, config, null);
+ }
+
+ public CacheableLockManager(WorkspacePersistentDataManager dataManager, WorkspaceEntry config,
+ LockPersister persister) throws RepositoryConfigurationException
+ {
+ super(dataManager, config, null);
+ this.dataManager = dataManager;
+ this.persister = persister;
+ if (config.getLockManager() != null)
+ {
+ lockTimeOut =
+ config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
+ }
+ else
+ lockTimeOut = DEFAULT_LOCK_TIMEOUT;
+
+ locks = new HashMap<String, LockData>();
+ pendingLocks = new HashMap<String, LockData>();
+ tokensMap = new HashMap<String, LockData>();
+
+ dataManager.addItemPersistenceListener(this);
+
+ CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
+ this.cache = new BufferedJBossCache(factory.createCache(readJBCConfig(config), false));
+
+ // cache.create();
+
+ }
+
+ protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ if (wsConfig.getLockManager() != null)
+ {
+ return wsConfig.getLockManager().getCacheConfig();
+ }
+ else
+ {
+ throw new RepositoryConfigurationException("Cache configuration not found");
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#lockTokenAdded(org.exoplatform.services
+ * .jcr.impl.core.SessionImpl, java.lang.String)
+ */
+ public synchronized void addLockToken(String sessionId, String lt)
+ {
+ LockData currLock = tokensMap.get(lt);
+ if (currLock != null)
+ {
+ currLock.addLockHolder(sessionId);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#addPendingLock(org.exoplatform.services
+ * .jcr.impl.core.NodeImpl, boolean, boolean, long)
+ */
+ public synchronized Lock addPendingLock(NodeImpl node, boolean isDeep, boolean isSessionScoped, long timeOut)
+ throws LockException
+ {
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ if (lData != null)
+ {
+ if (lData.getNodeIdentifier().equals(node.getInternalIdentifier()))
+ {
+ throw new LockException("Node already locked: " + node.getData().getQPath());
+ }
+ else if (lData.isDeep())
+ {
+ throw new LockException("Parent node has deep lock.");
+ }
+ }
+
+ if (isDeep && getLockData((NodeData)node.getData(), SEARCH_CLOSEDCHILD) != null)
+ {
+ throw new LockException("Some child node is locked.");
+ }
+
+ String lockToken = IdGenerator.generate();
+ lData =
+ new LockData(node.getInternalIdentifier(), lockToken, isDeep, isSessionScoped, node.getSession().getUserID(),
+ timeOut > 0 ? timeOut : lockTimeOut);
+
+ lData.addLockHolder(node.getSession().getId());
+ pendingLocks.put(node.getInternalIdentifier(), lData);
+ tokensMap.put(lockToken, lData);
+
+ LockImpl lock = new LockImpl(node.getSession(), lData);
+ return lock;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#getLock(org.exoplatform.services.jcr
+ * .impl.core.NodeImpl)
+ */
+ public LockImpl getLock(NodeImpl node) throws LockException, RepositoryException
+ {
+
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+
+ if (lData == null || (!node.getInternalIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
+ {
+ throw new LockException("Node not locked: " + node.getData().getQPath());
+
+ }
+ return new LockImpl(node.getSession(), lData);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.exoplatform.services.jcr.impl.core.lock.LockManager#getLockTokens(java.lang.String)
+ */
+ public synchronized String[] getLockTokens(String sessionID)
+ {
+ List<String> retval = new ArrayList<String>();
+
+ for (LockData lockData : locks.values())
+ {
+ if (lockData.isLockHolder(sessionID))
+ retval.add(lockData.getLockToken(sessionID));
+
+ }
+ return retval.toArray(new String[retval.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#holdsLock(org.exoplatform.services.
+ * jcr.impl.core.NodeImpl)
+ */
+ public boolean holdsLock(NodeData node) throws RepositoryException
+ {
+ return getLockData(node, SEARCH_EXECMATCH) != null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#isLocked(org.exoplatform.services.jcr
+ * .datamodel.NodeData)
+ */
+ public boolean isLocked(NodeData node)
+ {
+ LockData lData = getLockData(node, SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+
+ if (lData == null || (!node.getIdentifier().equals(lData.getNodeIdentifier()) && !lData.isDeep()))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#isLockHolder(org.exoplatform.services
+ * .jcr.impl.core.NodeImpl)
+ */
+ public boolean isLockHolder(NodeImpl node) throws RepositoryException
+ {
+ LockData lData = getLockData((NodeData)node.getData(), SEARCH_EXECMATCH | SEARCH_CLOSEDPARENT);
+ return lData != null && lData.isLockHolder(node.getSession().getId());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.core.SessionLifecycleListener#onCloseSession(org.exoplatform.services
+ * .jcr.core.ExtendedSession)
+ */
+ public synchronized void onCloseSession(ExtendedSession session)
+ {
+ // List<String> deadLocksList = new ArrayList<String>();
+ SessionImpl sessionImpl = (SessionImpl)session;
+ for (Iterator<Map.Entry<String, LockData>> entries = locks.entrySet().iterator(); entries.hasNext();)
+ {
+ Map.Entry<String, LockData> entry = entries.next();
+ LockData lockData = entry.getValue();
+ if (lockData.isLive())
+ {
+ if (lockData.isLockHolder(session.getId()))
+ {
+ if (lockData.isSessionScoped())
+ {
+ // if no session currently holds lock except this
+ try
+ {
+ // TODO it's possible to have next error
+ // java.lang.NullPointerException
+ // at
+ // org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl.onCloseSession(LockManagerImpl.java:312)
+ // at org.exoplatform.services.jcr.impl.core.SessionImpl.logout(SessionImpl.java:794)
+ // at
+ // org.exoplatform.services.jcr.impl.core.XASessionImpl.logout(XASessionImpl.java:254)
+ // at
+ // org.exoplatform.services.jcr.impl.core.SessionRegistry$SessionCleaner.callPeriodically(SessionRegistry.java:165)
+ // at
+ // org.exoplatform.services.jcr.impl.proccess.WorkerThread.run(WorkerThread.java:46)
+ ((NodeImpl)sessionImpl.getTransientNodesManager().getItemByIdentifier(
+ lockData.getNodeIdentifier(), false)).unlock();
+ }
+ catch (UnsupportedRepositoryOperationException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ catch (LockException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ catch (AccessDeniedException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+ catch (RepositoryException e)
+ {
+ log.error(e.getLocalizedMessage());
+ }
+
+ }
+ else
+ {
+ lockData.removeLockHolder(session.getId());
+ }
+ }
+ }
+ else
+ {
+ entries.remove();
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @seeorg.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener#onSaveItems(org.
+ * exoplatform.services.jcr.dataflow.ItemStateChangesLog)
+ */
+ public void onSaveItems(ItemStateChangesLog changesLog)
+ {
+ List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
+ if (changesLog instanceof TransactionChangesLog)
+ {
+ ChangesLogIterator logIterator = ((TransactionChangesLog)changesLog).getLogIterator();
+
+ while (logIterator.hasNextLog())
+ {
+ chengesLogList.add(logIterator.nextLog());
+ }
+ }
+ else if (changesLog instanceof PlainChangesLog)
+ {
+ chengesLogList.add((PlainChangesLog)changesLog);
+ }
+ else if (changesLog instanceof CompositeChangesLog)
+ {
+ for (ChangesLogIterator iter = ((CompositeChangesLog)changesLog).getLogIterator(); iter.hasNextLog();)
+ {
+ chengesLogList.add(iter.nextLog());
+ }
+ }
+
+ for (PlainChangesLog currChangesLog : chengesLogList)
+ {
+ String nodeIdentifier;
+ try
+ {
+ switch (currChangesLog.getEventType())
+ {
+ case ExtendedEvent.LOCK :
+ if (currChangesLog.getSize() < 2)
+ {
+ log.error("Incorrect changes log of type ExtendedEvent.LOCK size=" + currChangesLog.getSize()
+ + "<2 \n" + currChangesLog.dump());
+ break;
+ }
+ nodeIdentifier = currChangesLog.getAllStates().get(0).getData().getParentIdentifier();
+
+ if (pendingLocks.containsKey(nodeIdentifier))
+ {
+ internalLock(nodeIdentifier);
+ }
+ else
+ {
+ log.warn("No lock in pendingLocks for identifier " + nodeIdentifier
+ + " Probably lock come from replication.");
+
+ String lockToken = IdGenerator.generate();
+ ItemState ownerState = getItemState(currChangesLog, Constants.JCR_LOCKOWNER);
+ ItemState isDeepState = getItemState(currChangesLog, Constants.JCR_LOCKISDEEP);
+ if (ownerState != null && isDeepState != null)
+ {
+
+ String owner =
+ new String(((((TransientPropertyData)(ownerState.getData())).getValues()).get(0))
+ .getAsByteArray(), Constants.DEFAULT_ENCODING);
+
+ boolean isDeep =
+ Boolean.valueOf(
+ new String(((((TransientPropertyData)(isDeepState.getData())).getValues()).get(0))
+ .getAsByteArray(), Constants.DEFAULT_ENCODING)).booleanValue();
+
+ createRemoteLock(currChangesLog.getSessionId(), nodeIdentifier, lockToken, isDeep, false, owner);
+ }
+ }
+ break;
+ case ExtendedEvent.UNLOCK :
+ if (currChangesLog.getSize() < 2)
+ {
+ log.error("Incorrect changes log of type ExtendedEvent.UNLOCK size=" + currChangesLog.getSize()
+ + "<2 \n" + currChangesLog.dump());
+ break;
+ }
+
+ internalUnLock(currChangesLog.getSessionId(), currChangesLog.getAllStates().get(0).getData()
+ .getParentIdentifier());
+ break;
+ default :
+ HashSet<String> removedLock = new HashSet<String>();
+ for (ItemState itemState : currChangesLog.getAllStates())
+ {
+ // this is a node and node is locked
+ if (itemState.getData().isNode() && locks.containsKey(itemState.getData().getIdentifier()))
+ {
+ nodeIdentifier = itemState.getData().getIdentifier();
+ if (itemState.isDeleted())
+ {
+ removedLock.add(nodeIdentifier);
+ }
+ else if (itemState.isAdded() || itemState.isRenamed() || itemState.isUpdated())
+ {
+ removedLock.remove(nodeIdentifier);
+ }
+ }
+ }
+ for (String identifier : removedLock)
+ {
+ internalUnLock(currChangesLog.getSessionId(), identifier);
+ }
+ break;
+ }
+ }
+ catch (LockException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (IllegalStateException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (IOException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
+ * org.exoplatform.services.jcr.impl.core.lock.LockManager#lockTokenRemoved(org.exoplatform.services
+ * .jcr.impl.core.SessionImpl, java.lang.String)
+ */
+ public synchronized void removeLockToken(String sessionId, String lt)
+ {
+ LockData lData = tokensMap.get(lt);
+ if (lData != null && lData.isLockHolder(sessionId))
+ {
+ lData.removeLockHolder(sessionId);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.picocontainer.Startable#start()
+ */
+ public void start()
+ {
+ // cache.start();
+ lockRemover = new LockRemover(this);
+
+ }
+
+ // Quick method. We need to reconstruct
+ synchronized List<LockData> getLockList()
+ {
+ return new ArrayList<LockData>(locks.values());
+ }
+
+ /**
+ * Remove expired locks. Used from LockRemover.
+ */
+ public synchronized void removeExpired()
+ {
+ final List<String> removeLockList = new ArrayList<String>();
+
+ for (LockData lock : locks.values())
+ {
+ if (!lock.isSessionScoped() && lock.getTimeToDeath() < 0)
+ {
+ removeLockList.add(lock.getNodeIdentifier());
+ }
+ }
+
+ for (String rLock : removeLockList)
+ {
+ removeLock(rLock);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.picocontainer.Startable#stop()
+ */
+ public void stop()
+ {
+
+ lockRemover.halt();
+ lockRemover.interrupt();
+ locks.clear();
+ pendingLocks.clear();
+ tokensMap.clear();
+ // cache.stop();
+ }
+
+ /**
+ * Copy <code>PropertyData prop<code> to new TransientItemData
+ *
+ * @param prop
+ * @return
+ * @throws RepositoryException
+ */
+ private TransientItemData copyItemData(PropertyData prop) throws RepositoryException
+ {
+
+ if (prop == null)
+ return null;
+
+ // make a copy
+ TransientPropertyData newData =
+ new TransientPropertyData(prop.getQPath(), prop.getIdentifier(), prop.getPersistedVersion(), prop.getType(),
+ prop.getParentIdentifier(), prop.isMultiValued());
+
+ List<ValueData> values = null;
+ // null is possible for deleting items
+ if (prop.getValues() != null)
+ {
+ values = new ArrayList<ValueData>();
+ for (ValueData val : prop.getValues())
+ {
+ values.add(((AbstractValueData)val).createTransientCopy());
+ }
+ }
+ newData.setValues(values);
+ return newData;
+ }
+
+ /**
+ * Search item with name <code>itemName<code> in changesLog
+ *
+ * @param changesLog
+ * @param itemName
+ * @return Item
+ */
+ private ItemState getItemState(PlainChangesLog changesLog, InternalQName itemName)
+ {
+ List<ItemState> allStates = changesLog.getAllStates();
+ for (int i = allStates.size() - 1; i >= 0; i--)
+ {
+ ItemState state = allStates.get(i);
+ if (state.getData().getQPath().getName().equals(itemName))
+ return state;
+ }
+ return null;
+ }
+
+ /**
+ * Search lock in maps.
+ *
+ * @param data
+ * @param searchType
+ * @return
+ */
+ private LockData getLockData(NodeData data, int searchType)
+ {
+ if (data == null || locks.size() == 0)
+ return null;
+ LockData retval = null;
+ try
+ {
+ if ((searchType & SEARCH_EXECMATCH) != 0)
+ {
+ retval = locks.get(data.getIdentifier());
+ }
+ if (retval == null && (searchType & SEARCH_CLOSEDPARENT) != 0)
+ {
+
+ NodeData parentData = (NodeData)dataManager.getItemData(data.getParentIdentifier());
+ if (parentData != null)
+ {
+ retval = locks.get(parentData.getIdentifier());
+ // parent not found try to fo upper
+ if (retval == null)
+ {
+ retval = getLockData(parentData, SEARCH_CLOSEDPARENT);
+ }
+ }
+ }
+ if (retval == null && (searchType & SEARCH_CLOSEDCHILD) != 0)
+ {
+
+ List<NodeData> childData = dataManager.getChildNodesData(data);
+ for (NodeData nodeData : childData)
+ {
+ retval = locks.get(nodeData.getIdentifier());
+ if (retval != null)
+ break;
+ }
+ if (retval == null)
+ {
+ // child not found try to find diper
+ for (NodeData nodeData : childData)
+ {
+ retval = getLockData(nodeData, SEARCH_CLOSEDCHILD);
+ if (retval != null)
+ break;
+ }
+ }
+ }
+ }
+ catch (RepositoryException e)
+ {
+ return null;
+ }
+
+ return retval;
+ }
+
+ /**
+ * Internal lock
+ *
+ * @param nodeIdentifier
+ * @throws LockException
+ */
+ private synchronized void internalLock(String nodeIdentifier) throws LockException
+ {
+ LockData ldata = pendingLocks.get(nodeIdentifier);
+ if (ldata != null)
+ {
+ locks.put(nodeIdentifier, ldata);
+
+ if (persister != null)
+ {
+ persister.add(ldata);
+ }
+ pendingLocks.remove(nodeIdentifier);
+ }
+ else
+ {
+ throw new LockException("No lock in pending locks");
+ }
+ }
+
+ /**
+ * Internal unlock.
+ *
+ * @param sessionId
+ * @param nodeIdentifier
+ * @throws LockException
+ */
+ private synchronized void internalUnLock(String sessionId, String nodeIdentifier) throws LockException
+ {
+ LockData lData = locks.get(nodeIdentifier);
+
+ if (lData != null)
+ {
+ tokensMap.remove(lData.getLockToken(sessionId));
+ locks.remove(nodeIdentifier);
+
+ lData.setLive(false);
+ if (persister != null)
+ {
+ persister.remove(lData);
+ }
+ lData = null;
+ }
+ }
+
+ /**
+ * For locks comes from remote JCRs (replication usecase)
+ *
+ * @param sessionId
+ * String
+ * @param nodeIdentifier
+ * String
+ * @param lockToken
+ * String
+ * @param isDeep
+ * boolean
+ * @param sessionScoped
+ * boolean
+ * @param owner
+ * String
+ * @return LockData
+ */
+ private synchronized LockData createRemoteLock(String sessionId, String nodeIdentifier, String lockToken,
+ boolean isDeep, boolean sessionScoped, String owner)
+ {
+ LockData lData = new LockData(nodeIdentifier, lockToken, isDeep, sessionScoped, owner, lockTimeOut);
+ lData.addLockHolder(sessionId);
+ locks.put(nodeIdentifier, lData);
+ tokensMap.put(lockToken, lData);
+
+ return lData;
+ }
+
+ /**
+ * Remove lock, used by Lock remover.
+ *
+ * @param nodeIdentifier String
+ */
+ protected void removeLock(String nodeIdentifier)
+ {
+ try
+ {
+ NodeData nData = (NodeData)dataManager.getItemData(nodeIdentifier);
+ PlainChangesLog changesLog =
+ new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
+
+ ItemData lockOwner =
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+
+ changesLog.add(ItemState.createDeletedState(lockOwner));
+
+ ItemData lockIsDeep =
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+ changesLog.add(ItemState.createDeletedState(lockIsDeep));
+
+ // lock probably removed by other thread
+ if (lockOwner == null && lockIsDeep == null)
+ return;
+ dataManager.save(new TransactionChangesLog(changesLog));
+ }
+ catch (RepositoryException e)
+ {
+ log.error("Error occur during removing lock" + e.getLocalizedMessage());
+ }
+ }
+
+ @Managed
+ @ManagedDescription("The number of active locks")
+ public int getNumLocks()
+ {
+ return locks.size();
+ }
+
+ @Managed
+ @ManagedDescription("Remove the expired locks")
+ public void cleanExpiredLocks()
+ {
+ removeExpired();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
+}
16 years, 3 months