exo-jcr SVN: r768 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-19 07:09:52 -0500 (Thu, 19 Nov 2009)
New Revision: 768
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java
Log:
EXOJCR-243: Updated LockManager, fixed map creation
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java 2009-11-19 11:51:16 UTC (rev 767)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java 2009-11-19 12:09:52 UTC (rev 768)
@@ -43,6 +43,7 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -120,6 +121,8 @@
}
else
lockTimeOut = DEFAULT_LOCK_TIMEOUT;
+ this.tokens = new HashMap<String, String>();
+ this.tokenHash = new HashMap<String, String>();
}
/**
16 years, 8 months
exo-jcr SVN: r767 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage: jdbc and 1 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 06:51:16 -0500 (Thu, 19 Nov 2009)
New Revision: 767
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
Log:
EXOJCR-203: rework of exceptions, childs search, items existsence.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -224,7 +224,10 @@
}
else
{
- LOG.warn("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
+ }
// TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
// throw new RepositoryException("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
@@ -291,7 +294,10 @@
}
else
{
- LOG.warn("FATAL Get child Properties: parent not found " + parent.getQPath().getAsString());
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("FATAL Get child Properties: parent not found " + parent.getQPath().getAsString());
+ }
// TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
//throw new IllegalStateException("FATAL Get child Properties: parent not found "
@@ -382,8 +388,10 @@
}
else
{
- LOG
- .warn("FATAL Parent not found " + parentData.getQPath().getAsString() + " for " + name.getAsString(true));
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("FATAL Parent not found " + parentData.getQPath().getAsString() + " for " + name.getAsString(true));
+ }
// TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
//throw new RepositoryException("FATAL Parent not found " + parentData.getQPath().getAsString() + " for "
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -114,8 +114,10 @@
break;
case PUT_KEY_VALUE :
- if (m.getFqn().size() == 2) {
- if (isUpdate(m, (JDBCStorageConnection) conn)) {
+ if (m.getFqn().size() == 2)
+ {
+ if (isUpdate(m, (JDBCStorageConnection)conn))
+ {
doUpdate(m, conn);
}
else
@@ -148,14 +150,14 @@
/**
* Check update item or add item.
*
- * @param m
- * @param conn
+ * @param m Modification
+ * @param conn JDBCStorageConnection
* @return boolean
- * return true if update
+ * return true if update, false if add
*/
private boolean isUpdate(Modification m, JDBCStorageConnection conn) throws RepositoryException
{
- return (conn.getItemName((String)m.getFqn().get(1)) == null ? false : true);
+ return conn.itemExists((String)m.getFqn().get(1), m.getValue() instanceof NodeData);
}
/**
@@ -320,12 +322,15 @@
QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
String parentId = (String)name.get(1);
- String nodeId = conn.getItemIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
+ String nodeId =
+ conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
if (nodeId != null)
{
attrs = new LinkedHashMap<Object, Object>();
attrs.put(JBossCacheStorage.ITEM_ID, nodeId);
- } else {
+ }
+ else
+ {
attrs = null;
}
}
@@ -403,7 +408,7 @@
if (name.size() == 2)
{
String nodeId = name.getLastElementAsString();
- String nodeName = conn.getItemName(nodeId);
+ String nodeName = conn.getNodeName(nodeId);
if (nodeName != null)
{
@@ -420,7 +425,8 @@
QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
String parentId = (String)name.get(1);
- String nodeId = conn.getItemIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
+ String nodeId =
+ conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
if (nodeId != null)
{
exists = true;
@@ -442,7 +448,7 @@
if (name.size() == 2)
{
String propertyId = name.getLastElementAsString();
- String propertyName = conn.getItemName(propertyId);
+ String propertyName = conn.getPropertyName(propertyId);
if (propertyName != null)
{
@@ -724,5 +730,4 @@
}
}
-
}
\ No newline at end of file
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -145,9 +145,14 @@
/**
* FIND_ITEM_IDENTIFIER.
*/
- protected String FIND_ITEM_IDENTIFIER;
+ protected String FIND_NODE_IDENTIFIER;
/**
+ * FIND_PROPERTY_IDENTIFIER.
+ */
+ protected String FIND_PROPERTY_IDENTIFIER;
+
+ /**
* FIND_ITEM_NAME.
*/
protected String FIND_ITEM_NAME;
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -2000,22 +2000,23 @@
}
/**
- * Find Item ID in database.
+ * Find Node ID in database.
*
* @param parentId String, parent Node id
- * @param name Item, name
- * @param index int, path index (actual for nodes, 1 for properties)
+ * @param name String, Node name
+ * @param index int, path index
* @return String with ID
* @throws RepositoryException if database error occurs
* @throws IllegalStateException if connection closed
*/
- public String getItemIdentifier(String parentId, String name, int index) throws RepositoryException, IllegalStateException
+ public String getNodeIdentifier(String parentId, String name, int index) throws RepositoryException,
+ IllegalStateException
{
checkIfOpened();
try
{
- ResultSet item = findItemIdentifier(getInternalId(parentId), name, index);
+ ResultSet item = findNodeIdentifier(getInternalId(parentId), name, index);
if (item.next())
{
return item.getString(COLUMN_ID);
@@ -2030,14 +2031,108 @@
}
/**
- * Find Item name in database.
+ * Find Property ID in database.
*
+ * TODO not used!
+ *
+ * @param parentId String, parent Node id
+ * @param name String, Property name
+ * @return String with ID
+ * @throws RepositoryException if database error occurs
+ * @throws IllegalStateException if connection closed
+ */
+ @Deprecated
+ public String getPropertyIdentifier(String parentId, String name) throws RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+
+ try
+ {
+ ResultSet item = findPropertyIdentifier(getInternalId(parentId), name);
+ if (item.next())
+ {
+ return item.getString(COLUMN_ID);
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Check if Item exists in database. <code>isNode</code> flag will be used to filter <code>Node</code> or <code>Property</code> asked.
+ *
+ * @param itemId String
+ * @param isNode boolean, true if Node asked, false if Property
+ * @return boolean, true if Item exists, false otherwise
+ * @throws RepositoryException if database error occurs
+ * @throws IllegalStateException if connection closed
+ */
+ public boolean itemExists(String itemId, boolean isNode) throws RepositoryException, IllegalStateException
+ {
+
+ checkIfOpened();
+
+ try
+ {
+ ResultSet item = findItemName(getInternalId(itemId));
+ if (item.next())
+ {
+ return item.getInt(COLUMN_CLASS) == (isNode ? I_CLASS_NODE : I_CLASS_PROPERTY);
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Find Node name in database.
+ *
+ * @param nodeId String
+ * @return String with name
+ * @throws RepositoryException if database error occurs
+ * @throws IllegalStateException if connection closed
+ */
+ public String getNodeName(String nodeId) throws RepositoryException, IllegalStateException
+ {
+
+ checkIfOpened();
+
+ try
+ {
+ ResultSet item = findItemName(getInternalId(nodeId));
+ if (item.next())
+ {
+ if (item.getInt(COLUMN_CLASS) == I_CLASS_NODE)
+ {
+ return item.getString(COLUMN_NAME);
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Find Property name in database.
+ *
* @param propertyId String
* @return String with name
* @throws RepositoryException if database error occurs
* @throws IllegalStateException if connection closed
*/
- public String getItemName(String propertyId) throws RepositoryException, IllegalStateException
+ public String getPropertyName(String propertyId) throws RepositoryException, IllegalStateException
{
checkIfOpened();
@@ -2047,7 +2142,10 @@
ResultSet item = findItemName(getInternalId(propertyId));
if (item.next())
{
- return item.getString(COLUMN_NAME);
+ if (item.getInt(COLUMN_CLASS) == I_CLASS_PROPERTY)
+ {
+ return item.getString(COLUMN_NAME);
+ }
}
}
catch (SQLException e)
@@ -2241,17 +2339,19 @@
// JBC related
- protected abstract ResultSet findChildPropertiesIdNameByParentIdentifier(String parentCid)
- throws SQLException;
+ protected abstract ResultSet findChildPropertiesIdNameByParentIdentifier(String parentCid) throws SQLException;
protected abstract ResultSet findChildNodesNameByParentIdentifier(String parentCid) throws SQLException;
- protected abstract ResultSet findItemIdentifier(String parentCid, String name, int index) throws SQLException;
+ protected abstract ResultSet findNodeIdentifier(String parentCid, String name, int index) throws SQLException;
+ @Deprecated
+ protected abstract ResultSet findPropertyIdentifier(String parentCid, String name) throws SQLException;
+
protected abstract ResultSet findItemName(String cid) throws SQLException;
-
+
protected abstract ResultSet findAllPropertyIdentifiers() throws SQLException;
-
+
protected abstract ResultSet findAllNodeIdentifiers() throws SQLException;
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -87,8 +87,13 @@
FIND_PROPERTIES_BY_PARENTID =
"select * from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=?" + " order by ID";
+
FIND_PROPERTIES_IDNAME_BY_PARENTID =
"select ID, NAME from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=?";
+
+ FIND_NODE_IDENTIFIER = "select ID from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=? and NAME=? and I_INDEX=?";
+
+ FIND_PROPERTY_IDENTIFIER = "select ID from JCR_SITEM" + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=? and NAME=? and I_INDEX=1";
}
/**
@@ -192,4 +197,45 @@
findNodesNameByParentId.setString(2, containerName);
return findNodesNameByParentId.executeQuery();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodeIdentifier(String parentCid, String name, int index) throws SQLException
+ {
+ if (findNodeIdentifier == null)
+ {
+ findNodeIdentifier = dbConnection.prepareStatement(FIND_NODE_IDENTIFIER);
+ }
+ else
+ {
+ findNodeIdentifier.clearParameters();
+ }
+ findNodeIdentifier.setString(1, parentCid);
+ findNodeIdentifier.setString(2, containerName);
+ findNodeIdentifier.setString(3, name);
+ findNodeIdentifier.setInt(4, index);
+ return findNodeIdentifier.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyIdentifier(String parentCid, String name) throws SQLException
+ {
+ if (findPropertyIdentifier == null)
+ {
+ findPropertyIdentifier = dbConnection.prepareStatement(FIND_PROPERTY_IDENTIFIER);
+ }
+ else
+ {
+ findPropertyIdentifier.clearParameters();
+ }
+ findPropertyIdentifier.setString(1, parentCid);
+ findPropertyIdentifier.setString(2, containerName);
+ findPropertyIdentifier.setString(3, name);
+ return findPropertyIdentifier.executeQuery();
+ }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -84,7 +84,9 @@
protected PreparedStatement findPropertiesIdNameByParentId;
- protected PreparedStatement findItemIdentifier;
+ protected PreparedStatement findNodeIdentifier;
+
+ protected PreparedStatement findPropertyIdentifier;
protected PreparedStatement findItemName;
@@ -209,9 +211,11 @@
FIND_ALL_PROPERTIES = "select ID from JCR_MITEM where I_CLASS=2";
- FIND_ITEM_IDENTIFIER = "select ID from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=?";
+ FIND_NODE_IDENTIFIER = "select ID from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=? and NAME=? and I_INDEX=?";
+
+ FIND_PROPERTY_IDENTIFIER = "select ID from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=? and NAME=? and I_INDEX=1";
- FIND_ITEM_NAME = "select NAME from JCR_MITEM" + " where ID=?";
+ FIND_ITEM_NAME = "select NAME, I_CLASS from JCR_MITEM" + " where ID=?";
INSERT_NODE =
"insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
@@ -597,21 +601,40 @@
* {@inheritDoc}
*/
@Override
- protected ResultSet findItemIdentifier(String parentCid, String name, int index) throws SQLException
+ protected ResultSet findNodeIdentifier(String parentCid, String name, int index) throws SQLException
{
- if (findItemIdentifier == null)
+ if (findNodeIdentifier == null)
{
- findItemIdentifier = dbConnection.prepareStatement(FIND_ITEM_IDENTIFIER);
+ findNodeIdentifier = dbConnection.prepareStatement(FIND_NODE_IDENTIFIER);
}
else
{
- findItemIdentifier.clearParameters();
+ findNodeIdentifier.clearParameters();
}
- findItemIdentifier.setString(1, parentCid);
- findItemIdentifier.setString(2, name);
- findItemIdentifier.setInt(3, index);
- return findItemIdentifier.executeQuery();
+ findNodeIdentifier.setString(1, parentCid);
+ findNodeIdentifier.setString(2, name);
+ findNodeIdentifier.setInt(3, index);
+ return findNodeIdentifier.executeQuery();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyIdentifier(String parentCid, String name) throws SQLException
+ {
+ if (findPropertyIdentifier == null)
+ {
+ findPropertyIdentifier = dbConnection.prepareStatement(FIND_PROPERTY_IDENTIFIER);
+ }
+ else
+ {
+ findPropertyIdentifier.clearParameters();
+ }
+ findPropertyIdentifier.setString(1, parentCid);
+ findPropertyIdentifier.setString(2, name);
+ return findPropertyIdentifier.executeQuery();
+ }
/**
* {@inheritDoc}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-11-19 11:32:39 UTC (rev 766)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-11-19 11:51:16 UTC (rev 767)
@@ -81,7 +81,9 @@
protected PreparedStatement findPropertiesIdNameByParentId;
- protected PreparedStatement findItemIdentifier;
+ protected PreparedStatement findNodeIdentifier;
+
+ protected PreparedStatement findPropertyIdentifier;
protected PreparedStatement findItemName;
@@ -219,9 +221,11 @@
FIND_ALL_PROPERTIES = "select ID from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?";
- FIND_ITEM_IDENTIFIER = "select ID from JCR_SITEM" + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?";
+ FIND_NODE_IDENTIFIER = "select ID from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?";
+
+ FIND_PROPERTY_IDENTIFIER = "select ID from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=1";
- FIND_ITEM_NAME = "select NAME from JCR_SITEM" + " where ID=?";
+ FIND_ITEM_NAME = "select NAME, I_CLASS from JCR_SITEM" + " where ID=?";
INSERT_NODE =
"insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
@@ -610,19 +614,42 @@
* {@inheritDoc}
*/
@Override
- protected ResultSet findItemIdentifier(String parentCid, String name, int index) throws SQLException
+ protected ResultSet findNodeIdentifier(String parentCid, String name, int index) throws SQLException
{
- if (findItemIdentifier == null)
- findItemIdentifier = dbConnection.prepareStatement(FIND_ITEM_IDENTIFIER);
+ if (findNodeIdentifier == null)
+ {
+ findNodeIdentifier = dbConnection.prepareStatement(FIND_NODE_IDENTIFIER);
+ }
else
- findItemIdentifier.clearParameters();
-
- findItemIdentifier.setString(1, containerName);
- findItemIdentifier.setString(2, parentCid);
- findItemIdentifier.setString(3, name);
- findItemIdentifier.setInt(4, index);
- return findItemIdentifier.executeQuery();
+ {
+ findNodeIdentifier.clearParameters();
+ }
+ findNodeIdentifier.setString(1, containerName);
+ findNodeIdentifier.setString(2, parentCid);
+ findNodeIdentifier.setString(3, name);
+ findNodeIdentifier.setInt(4, index);
+ return findNodeIdentifier.executeQuery();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyIdentifier(String parentCid, String name) throws SQLException
+ {
+ if (findPropertyIdentifier == null)
+ {
+ findPropertyIdentifier = dbConnection.prepareStatement(FIND_PROPERTY_IDENTIFIER);
+ }
+ else
+ {
+ findPropertyIdentifier.clearParameters();
+ }
+ findPropertyIdentifier.setString(1, containerName);
+ findPropertyIdentifier.setString(2, parentCid);
+ findPropertyIdentifier.setString(3, name);
+ return findPropertyIdentifier.executeQuery();
+ }
/**
* {@inheritDoc}
16 years, 8 months
exo-jcr SVN: r766 - jcr/trunk/exo.jcr.component.ext/src/main/resources/conf.
by do-not-reply@jboss.org
Author: vparfonov
Date: 2009-11-19 06:32:39 -0500 (Thu, 19 Nov 2009)
New Revision: 766
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/resources/conf/ext-nodetypes-config.xml
Log:
EXOJCR-257 : node type definition changed
Modified: jcr/trunk/exo.jcr.component.ext/src/main/resources/conf/ext-nodetypes-config.xml
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/resources/conf/ext-nodetypes-config.xml 2009-11-19 11:07:57 UTC (rev 765)
+++ jcr/trunk/exo.jcr.component.ext/src/main/resources/conf/ext-nodetypes-config.xml 2009-11-19 11:32:39 UTC (rev 766)
@@ -215,16 +215,19 @@
</propertyDefinitions>
</nodeType>
- <nodeType name="exo:groovyResourceContainer" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
- <supertypes>
- <supertype>nt:resource</supertype>
- </supertypes>
- <propertyDefinitions>
- <propertyDefinition name="exo:autoload" requiredType="Boolean" autoCreated="false" mandatory="true" onParentVersion="COPY"
- protected="false" multiple="false">
- <valueConstraints />
- </propertyDefinition>
- </propertyDefinitions>
+
+ <nodeType name="exo:groovyResourceContainer" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+ <supertypes>
+ <supertype>nt:resource</supertype>
+ </supertypes>
+ <propertyDefinitions>
+ <propertyDefinition name="exo:autoload" requiredType="Boolean" autoCreated="true" mandatory="true" onParentVersion="COPY" protected="false" multiple="false">
+ <valueConstraints/>
+ <defaultValues>
+ <defaultValue>false</defaultValue>
+ </defaultValues>
+ </propertyDefinition>
+ </propertyDefinitions>
</nodeType>
</nodeTypes>
\ No newline at end of file
16 years, 8 months
exo-jcr SVN: r765 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-19 06:07:57 -0500 (Thu, 19 Nov 2009)
New Revision: 765
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java
Log:
EXOJCR-243: Check list not null
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java 2009-11-19 10:56:39 UTC (rev 764)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java 2009-11-19 11:07:57 UTC (rev 765)
@@ -404,21 +404,24 @@
return;
}
// list acquired, traversing to cleanup locks;
- for (LockData lockData : lockDatas)
+ if (lockDatas != null)
{
- if (lockData.isSessionScoped() && isLockHolder(lockData))
+ for (LockData lockData : lockDatas)
{
- NodeData node;
- // if can't unlock this, still try to unlock the next one
- try
+ if (lockData.isSessionScoped() && isLockHolder(lockData))
{
- node = (NodeData)sessionDataManager.getItemData(lockData.getNodeIdentifier());
- unlock(node);
+ NodeData node;
+ // if can't unlock this, still try to unlock the next one
+ try
+ {
+ node = (NodeData)sessionDataManager.getItemData(lockData.getNodeIdentifier());
+ unlock(node);
+ }
+ catch (RepositoryException e)
+ {
+ log.error("Can't unlock node on session logout, id:" + lockData.getNodeIdentifier(), e);
+ }
}
- catch (RepositoryException e)
- {
- log.error("Can't unlock node on session logout, id:" + lockData.getNodeIdentifier(), e);
- }
}
}
}
16 years, 8 months
exo-jcr SVN: r764 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 05:56:39 -0500 (Thu, 19 Nov 2009)
New Revision: 764
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-248: get childs optimization (some fixes)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-19 09:25:25 UTC (rev 763)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-19 10:56:39 UTC (rev 764)
@@ -190,40 +190,46 @@
*/
public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
{
+ List<NodeData> childs = new ArrayList<NodeData>();
Node<Serializable, Object> parentNode = nodesRoot.getChild(makeNodeFqn(parent.getIdentifier()));
- if (parentNode == null)
+ if (parentNode != null)
{
- throw new IllegalStateException("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
- }
- Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
-
- List<NodeData> childs = new ArrayList<NodeData>();
- for (Node<Serializable, Object> child : childNodes)
- {
- String nodeId = (String)child.get(ITEM_ID);
- if (nodeId == null)
+ Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
+ for (Node<Serializable, Object> child : childNodes)
{
- throw new RepositoryException("FATAL Child Node Id key is null. Parent " + parent.getQPath().getAsString());
- }
+ String nodeId = (String)child.get(ITEM_ID);
+ if (nodeId == null)
+ {
+ throw new RepositoryException("FATAL Child Node Id key is null. Parent "
+ + parent.getQPath().getAsString());
+ }
- // TODO NodeData or PropertyData? As ItemData check then and cast.
- Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
- if (node == null)
- {
- throw new RepositoryException("FATAL Node record not found(" + nodeId + "), but listed in proprties of "
- + parent.getQPath().getAsString());
+ // TODO NodeData or PropertyData? As ItemData check then and cast.
+ Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
+ if (node == null)
+ {
+ throw new RepositoryException("FATAL Node record not found(" + nodeId + "), but listed in proprties of "
+ + parent.getQPath().getAsString());
+ }
+ NodeData nodeData = (NodeData)node.get(ITEM_DATA);
+ if (nodeData == null)
+ {
+ // TODO should not occurs by contract
+ throw new RepositoryException("Child node data is null. Parent " + parent.getQPath().getAsString());
+ }
+ childs.add(nodeData);
}
- NodeData nodeData = (NodeData)node.get(ITEM_DATA);
- if (nodeData == null)
- {
- // TODO should not occurs by contract
- throw new RepositoryException("Child node data is null. Parent " + parent.getQPath().getAsString());
- }
- childs.add(nodeData);
}
+ else
+ {
+ LOG.warn("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
+ // TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
+ // throw new RepositoryException("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
+ }
+
return childs;
}
@@ -248,43 +254,50 @@
*/
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
{
+ List<PropertyData> childs = new ArrayList<PropertyData>();
+
Node<Serializable, Object> parentNode = nodesRoot.getChild(makeNodeFqn(parent.getIdentifier()));
- if (parentNode == null)
+ if (parentNode != null)
{
- throw new IllegalStateException("FATAL Get child Properties: parent not found "
- + parent.getQPath().getAsString());
- }
- List<PropertyData> childs = new ArrayList<PropertyData>();
-
- for (Serializable key : parentNode.getKeys())
- {
- if (!key.equals(ITEM_DATA))
+ for (Serializable key : parentNode.getKeys())
{
- String propId = (String)parentNode.get(key);
- if (propId == null)
+ if (!key.equals(ITEM_DATA))
{
- throw new RepositoryException("FATAL Child Property Id key is null. Parent "
- + parent.getQPath().getAsString());
- }
+ String propId = (String)parentNode.get(key);
+ if (propId == null)
+ {
+ throw new RepositoryException("FATAL Child Property Id key is null. Parent "
+ + parent.getQPath().getAsString());
+ }
- Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(propId));
- if (prop == null)
- {
- throw new RepositoryException("FATAL Property record not found(" + propId
- + "), but listed in proprties of " + parent.getQPath().getAsString());
- }
+ Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(propId));
+ if (prop == null)
+ {
+ throw new RepositoryException("FATAL Property record not found(" + propId
+ + "), but listed in proprties of " + parent.getQPath().getAsString());
+ }
- PropertyData propData = (PropertyData)prop.get(ITEM_DATA);
- if (propData == null)
- {
- throw new RepositoryException("FATAL Property data is null. Parent " + parent.getQPath().getAsString());
+ PropertyData propData = (PropertyData)prop.get(ITEM_DATA);
+ if (propData == null)
+ {
+ throw new RepositoryException("FATAL Property data is null. Parent "
+ + parent.getQPath().getAsString());
+ }
+
+ childs.add(propData);
}
-
- childs.add(propData);
}
}
+ else
+ {
+ LOG.warn("FATAL Get child Properties: parent not found " + parent.getQPath().getAsString());
+ // TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
+ //throw new IllegalStateException("FATAL Get child Properties: parent not found "
+ // + parent.getQPath().getAsString());
+ }
+
return childs;
}
@@ -369,8 +382,12 @@
}
else
{
- throw new RepositoryException("FATAL Parent not found " + parentData.getQPath().getAsString() + " for "
- + name.getAsString(true));
+ LOG
+ .warn("FATAL Parent not found " + parentData.getQPath().getAsString() + " for " + name.getAsString(true));
+
+ // TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
+ //throw new RepositoryException("FATAL Parent not found " + parentData.getQPath().getAsString() + " for "
+ // + name.getAsString(true));
}
}
@@ -448,7 +465,7 @@
NodeData oldNodeData = (NodeData)node.put(ITEM_DATA, data);
if (oldNodeData == null)
{
- throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
+ throw new RepositoryException("FATAL NodeData is empty " + data.getQPath().getAsString());
}
// 2. remove renamed node from child list of previous parent node
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 09:25:25 UTC (rev 763)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 10:56:39 UTC (rev 764)
@@ -107,7 +107,7 @@
switch (m.getType())
{
case PUT_DATA :
- LOG.warn("PUT_DATA modification");
+ //LOG.warn("PUT_DATA modification");
break;
case PUT_DATA_ERASE :
LOG.warn("PUT_DATA_ERASE modification");
16 years, 8 months
exo-jcr SVN: r763 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-19 04:25:25 -0500 (Thu, 19 Nov 2009)
New Revision: 763
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java
Log:
EXOJCR-248 : The test JCRStorageConnectionTest was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java 2009-11-19 09:22:38 UTC (rev 762)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java 2009-11-19 09:25:25 UTC (rev 763)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.access.AccessControlEntry;
import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.access.SystemIdentity;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.dataflow.DataManager;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
@@ -38,8 +39,15 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.naming.InitialContextInitializer;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@@ -264,9 +272,19 @@
public void testDeleteItemsById() throws Exception
{
- WorkspaceDataContainer dataContainer =
- (WorkspaceDataContainer) session.getContainer().getComponentInstanceOfType(WorkspaceDataContainer.class);
+ WorkspaceEntry we = null;
+
+ for (WorkspaceEntry wsConfig : repository.getConfiguration().getWorkspaceEntries())
+ if (wsConfig.getName().equals(session.getWorkspace().getName()))
+ we = wsConfig;
+
+ InitialContextInitializer contextInit = (InitialContextInitializer) session.getContainer().getComponentInstanceOfType(InitialContextInitializer.class);
+ ValueStoragePluginProvider valueStorageProvider = (ValueStoragePluginProvider) session.getContainer().getComponentInstanceOfType(ValueStoragePluginProvider.class);
+
+ JDBCWorkspaceDataContainer dataContainer = new JDBCWorkspaceDataContainer(we, repository.getConfiguration(), contextInit, valueStorageProvider);
+
+
// create node with property primary type.
TransientNodeData troot =
TransientNodeData.createNodeData(root, InternalQName.parse("[]node_to_delete_by_id"),
@@ -276,14 +294,14 @@
TransientPropertyData.createPropertyData(troot, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
new TransientValueData(Constants.NT_UNSTRUCTURED));
- PlainChangesLogImpl chlog = new PlainChangesLogImpl();
- chlog.add(ItemState.createAddedState(troot));
- chlog.add(ItemState.createAddedState(pt));
+ JDBCStorageConnection connection = (JDBCStorageConnection) dataContainer.openConnection();
- dataManager.save(new TransactionChangesLog(chlog));
-
+ connection.add(troot);
+ connection.add(pt);
+ connection.commit();
+
// Delete node and property by ID.
- JDBCStorageConnection connection = (JDBCStorageConnection) dataContainer.openConnection();
+ connection = (JDBCStorageConnection) dataContainer.openConnection();
connection.deleteProperty(pt.getIdentifier());
connection.deleteNode(troot.getIdentifier());
16 years, 8 months
exo-jcr SVN: r762 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/core/lock and 1 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-19 04:22:38 -0500 (Thu, 19 Nov 2009)
New Revision: 762
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java
Log:
EXOJCR-243: Default lock timeout from config is now handled. Tests updated.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2009-11-19 09:21:17 UTC (rev 761)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2009-11-19 09:22:38 UTC (rev 762)
@@ -176,10 +176,8 @@
this.workspace = new WorkspaceImpl(workspaceName, container, this, observationManager);
- // TODO: try to get lock timeout from workspace configuration, as it was before
this.sessionLockManager =
- new SessionLockManager(this.getId(), this.getUserID(), this.getTransientNodesManager(),
- SessionLockManager.DEFAULT_LOCK_TIMEOUT);
+ new SessionLockManager(this.getId(), this.getUserID(), this.getTransientNodesManager(), wsConfig);
this.lifecycleListeners = new ArrayList<SessionLifecycleListener>();
this.registerLifecycleListener((ObservationManagerImpl)observationManager);
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java 2009-11-19 09:21:17 UTC (rev 761)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/SessionLockManager.java 2009-11-19 09:22:38 UTC (rev 762)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.core.lock;
import org.exoplatform.services.jcr.access.SystemIdentity;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ExtendedSession;
import org.exoplatform.services.jcr.core.SessionLifecycleListener;
import org.exoplatform.services.jcr.dataflow.ItemState;
@@ -106,20 +107,19 @@
* @param session
* @param lockTimeOut
*/
- public SessionLockManager(String sessionID, String userId, SessionDataManager sessionDataManager, long lockTimeOut)
+ public SessionLockManager(String sessionID, String userId, SessionDataManager sessionDataManager,
+ WorkspaceEntry wsConfig)
{
- this.lockTimeOut = lockTimeOut;
this.sessionID = sessionID;
this.userId = userId;
this.sessionDataManager = sessionDataManager;
- // TODO: configured lock timeout should be acquired from WSconfig
- /* if (config.getLockManager() != null)
+ if (wsConfig.getLockManager() != null)
{
- lockTimeOut =
- config.getLockManager().getTimeout() > 0 ? config.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
+ this.lockTimeOut =
+ wsConfig.getLockManager().getTimeout() > 0 ? wsConfig.getLockManager().getTimeout() : DEFAULT_LOCK_TIMEOUT;
}
else
- lockTimeOut = DEFAULT_LOCK_TIMEOUT;*/
+ lockTimeOut = DEFAULT_LOCK_TIMEOUT;
}
/**
@@ -403,12 +403,13 @@
log.error(e.getMessage(), e);
return;
}
- // list acquired, traversing to cleanup;
+ // list acquired, traversing to cleanup locks;
for (LockData lockData : lockDatas)
{
if (lockData.isSessionScoped() && isLockHolder(lockData))
{
NodeData node;
+ // if can't unlock this, still try to unlock the next one
try
{
node = (NodeData)sessionDataManager.getItemData(lockData.getNodeIdentifier());
@@ -416,7 +417,7 @@
}
catch (RepositoryException e)
{
- log.error("Can't unlock node:" + lockData.getNodeIdentifier(), e);
+ log.error("Can't unlock node on session logout, id:" + lockData.getNodeIdentifier(), e);
}
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java 2009-11-19 09:21:17 UTC (rev 761)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java 2009-11-19 09:22:38 UTC (rev 762)
@@ -77,8 +77,50 @@
session2.logout();
}
+ public void testLockUnlock() throws RepositoryException
+ {
+ NodeImpl node1 = (NodeImpl)testRoot.addNode("testLockUnlock");
+ node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ session.save();
+ // lock through session1
+ Lock lock1 = node1.lock(false, false);
+
+ // create new session2
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
+
+ NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
+ // check node locked
+ assertTrue(node1.isLocked());
+ assertTrue(node2.isLocked());
+ // add lock token
+ session2.addLockToken(lock1.getLockToken());
+ // unlock through session2
+ node2.unlock();
+ // asset not locked
+ assertFalse(node1.isLocked());
+ assertFalse(node2.isLocked());
+
+ session2.logout();
+ }
+
+ public void testGetLock() throws RepositoryException
+ {
+ NodeImpl node1 = (NodeImpl)testRoot.addNode("testGetLock");
+ node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ session.save();
+ // lock
+ Lock lock1 = node1.lock(false, false);
+ // get lock
+ Lock lock2 = node1.getLock();
+ assertEquals(lock1.getLockToken(), lock2.getLockToken());
+ //unlock
+ node1.unlock();
+ }
+
public void testRemoveOnLogOut() throws RepositoryException
{
+ // checks that session-scoped locks are removed on logout
NodeImpl node1 = (NodeImpl)testRoot.addNode("testRemoveOnLogOut");
node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
session.save();
@@ -87,7 +129,7 @@
SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
- // lock through session2
+ // lock through session2, as session-scoped
Lock lock2 = node2.lock(false, true);
// check session2 has access to lock
assertTrue(node2.isLocked());
@@ -101,6 +143,35 @@
assertFalse(node1.isLocked());
}
+ public void testNotRemoveOnLogOut() throws RepositoryException
+ {
+ // checks that open-scoped locks are not removed on logout
+ NodeImpl node1 = (NodeImpl)testRoot.addNode("testNotRemoveOnLogOut");
+ node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ session.save();
+ // create new session2
+ CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
+ SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
+
+ NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
+ // lock through session2, as open-scoped
+ Lock lock2 = node2.lock(false, false);
+ // check session2 has access to lock
+ assertTrue(node2.isLocked());
+ assertTrue(session2.getLockManager().isLockHolder((NodeData)node2.getData()));
+
+ // session2 logout
+ session2.logout();
+ // lock should NOT be removed and node should be unlocked
+ assertTrue(lock2.isLive());
+ assertTrue(node2.isLocked());
+ assertTrue(node1.isLocked());
+
+ session.addLockToken(lock2.getLockToken());
+ node1.unlock();
+ assertFalse(node1.isLocked());
+ }
+
public void testRemoveByTimeOut() throws RepositoryException
{
int REMOVER_SCHEDULE_TIME = 10000; // 10s?! need to place correct value
16 years, 8 months
exo-jcr SVN: r761 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 04:21:17 -0500 (Thu, 19 Nov 2009)
New Revision: 761
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-247: getters optimization
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-18 16:40:15 UTC (rev 760)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 09:21:17 UTC (rev 761)
@@ -325,12 +325,9 @@
{
attrs = new LinkedHashMap<Object, Object>();
attrs.put(JBossCacheStorage.ITEM_ID, nodeId);
+ } else {
+ attrs = null;
}
- else
- {
- throw new JDBCCacheLoaderException("FATAL Child Node data not found, parent " + nodeId + " child "
- + childNodeName + " for '" + name + "'");
- }
}
else
{
@@ -727,18 +724,5 @@
}
}
- @Deprecated
- private QPathEntry[] makeNodePath(Fqn<String> nodeFqn) throws NumberFormatException, IllegalNameException
- {
- List<String> elements = nodeFqn.peekElements();
- QPathEntry[] path = new QPathEntry[elements.size()];
- for (int i = 0; i < elements.size(); i++)
- {
- path[i] = QPathEntry.parse(elements.get(i));
- }
-
- return path;
- }
-
}
\ No newline at end of file
16 years, 8 months
exo-jcr SVN: r760 - jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-18 11:40:15 -0500 (Wed, 18 Nov 2009)
New Revision: 760
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-248 : Revert configuration files to revision 758.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml 2009-11-18 16:33:41 UTC (rev 759)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml 2009-11-18 16:40:15 UTC (rev 760)
@@ -9,7 +9,7 @@
<clustering mode="replication">
<jgroupsConfig>
- <!-- UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ <UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
@@ -19,16 +19,16 @@
thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
use_incoming_packet_handler="true" />
- <PING num_initial_members="3" timeout="2000" / -->
+ <PING num_initial_members="3" timeout="2000" />
- <TCP bind_addr="192.168.0.15" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ <!-- TCP bind_addr="192.168.0.15" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34526" bind_addr="192.168.0.15" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34526" bind_addr="192.168.0.15" mcast_addr="224.0.0.1" /-->
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-11-18 16:33:41 UTC (rev 759)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-11-18 16:40:15 UTC (rev 760)
@@ -30,7 +30,7 @@
<workspaces>
<workspace name="ws">
<!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheWorkspaceDataContainer">
<properties>
<property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-config-exoloader.xml" />
<property name="source-name" value="jdbcjcr" />
16 years, 8 months
exo-jcr SVN: r759 - in jcr/branches/1.12.0-JBC/component/core/src: test/resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-18 11:33:41 -0500 (Wed, 18 Nov 2009)
New Revision: 759
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-248 : The JDBCCacheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-18 16:29:24 UTC (rev 758)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-18 16:33:41 UTC (rev 759)
@@ -114,10 +114,15 @@
break;
case PUT_KEY_VALUE :
- if (isUpdate(m, (JDBCStorageConnection) conn))
- doUpdate(m, conn);
- else
- doAdd(m, conn);
+ if (m.getFqn().size() == 2) {
+ if (isUpdate(m, (JDBCStorageConnection) conn)) {
+ doUpdate(m, conn);
+ }
+ else
+ {
+ doAdd(m, conn);
+ }
+ }
break;
case REMOVE_DATA :
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml 2009-11-18 16:29:24 UTC (rev 758)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-jdbcloader.xml 2009-11-18 16:33:41 UTC (rev 759)
@@ -9,7 +9,7 @@
<clustering mode="replication">
<jgroupsConfig>
- <UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ <!-- UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
@@ -19,16 +19,16 @@
thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
use_incoming_packet_handler="true" />
- <PING num_initial_members="3" timeout="2000" />
+ <PING num_initial_members="3" timeout="2000" / -->
- <!-- TCP bind_addr="192.168.0.15" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ <TCP bind_addr="192.168.0.15" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34526" bind_addr="192.168.0.15" mcast_addr="224.0.0.1" /-->
+ <MPING timeout="2000" num_initial_members="3" mcast_port="34526" bind_addr="192.168.0.15" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-11-18 16:29:24 UTC (rev 758)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-11-18 16:33:41 UTC (rev 759)
@@ -30,7 +30,7 @@
<workspaces>
<workspace name="ws">
<!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="jbosscache-configuration" value="conf/standalone/test-jbosscache-config-exoloader.xml" />
<property name="source-name" value="jdbcjcr" />
16 years, 8 months