exo-jcr SVN: r1263 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation: db and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-12-31 14:06:31 -0500 (Thu, 31 Dec 2009)
New Revision: 1263
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-302: Rework of JDBC level to use complex queries
1. The methods getItemData are now done in 2 requests for the properties (as we do now) and for the nodes
2. The useless code has been removed
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-31 09:05:39 UTC (rev 1262)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-31 19:06:31 UTC (rev 1263)
@@ -25,11 +25,9 @@
import org.exoplatform.services.jcr.datamodel.IllegalACLException;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
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.QPath;
-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.storage.jdbc.JDBCStorageConnection;
@@ -44,7 +42,6 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -62,26 +59,21 @@
{
/**
- * FIND_ITEM_BY_NAME NEW.
- */
- protected String FIND_ITEM_BY_NAME_CQ;
-
- /**
- * FIND_NODE_BY_ID.
- */
- protected String FIND_ITEM_BY_ID_CQ;
-
- /**
* FIND_NODES_BY_PARENTID NEW.
*/
protected String FIND_NODES_BY_PARENTID_CQ;
/**
- * GET_PROPERTIES_BY_PARENT_ID
+ * FIND_PROPERTIES_BY_PARENTID NEW.
*/
protected String FIND_PROPERTIES_BY_PARENTID_CQ;
/**
+ * FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ.
+ */
+ protected String FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ;
+
+ /**
* Class needed to store node details (property also) since result set is not sorted in valid way.
*/
private static class TempNodeData
@@ -187,63 +179,16 @@
}
}
- protected Map<String, TempNodeData> loadTempNodesFromResultSet(ResultSet resultSet) throws RepositoryException,
- IOException, SQLException
- {
-
- Map<String, TempNodeData> nodesData = new LinkedHashMap<String, TempNodeData>();
- do
- {
- int itemClass = resultSet.getInt(COLUMN_CLASS);
- if (itemClass == I_CLASS_NODE)
- {
- TempNodeData data = new TempNodeData(resultSet);
- nodesData.put(data.cid, data);
- }
- else
- {
- String cpid = resultSet.getString(COLUMN_PARENTID);
- TempNodeData data = nodesData.get(cpid);
- if (data.properties == null)
- {
- data.properties = new HashMap<String, List<byte[]>>();
- }
- Map<String, List<byte[]>> properties = data.properties;
- String key = resultSet.getString(COLUMN_NAME);
- List<byte[]> values = properties.get(key);
- if (values == null)
- {
- values = new ArrayList<byte[]>();
- properties.put(key, values);
- }
- values.add(resultSet.getBytes(COLUMN_VDATA));
- }
- }
- while (resultSet.next());
-
- return nodesData;
-
- }
-
/**
* {@inheritDoc}
*/
- public int getChildNodesCount(NodeData parent) throws RepositoryException
- {
- // nothing to optimize
- return super.getChildNodesCount(parent);
- }
-
- /**
- * {@inheritDoc}
- */
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
{
checkIfOpened();
try
{
- ResultSet resultSet = getChildPropertiesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
+ ResultSet resultSet = findChildPropertiesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
List<PropertyData> children = new ArrayList<PropertyData>();
if (resultSet.next())
{
@@ -276,164 +221,12 @@
/**
* {@inheritDoc}
*/
- public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
- {
- return getItemByIdentifier(getInternalId(identifier));
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
- {
-
- if (parentData != null)
- {
- return getItemByName(parentData, getInternalId(parentData.getIdentifier()), name);
- }
-
- // it's a root node
- return getItemByName(null, null, name);
- }
-
- /**
- * {@inheritDoc}
- */
public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException, IllegalStateException
{
// can't optimize - result may return same node more than one time, so parse result set is difficult
return super.getReferencesData(nodeIdentifier);
}
- /**
- * Get Item By Identifier.
- *
- * @param cid
- * Item id (container internal)
- * @return ItemData
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByIdentifier(String cid) throws RepositoryException, IllegalStateException
- {
- checkIfOpened();
- ResultSet resultSet = null;
- try
- {
- resultSet = findItemByIdentifierCQ(cid);
- if (resultSet.next())
- {
- int itemType = resultSet.getInt(COLUMN_CLASS);
- if (itemType == I_CLASS_NODE)
- {
- Map<String, TempNodeData> node = loadTempNodesFromResultSet(resultSet);
- return loadNodeFromTemporaryNodeData(node.get(cid), null, null);
- }
- else
- {
- return loadPropertyRecord(resultSet, null);
- }
-
- }
- return null;
- }
- catch (SQLException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- catch (IOException e)
- {
- throw new RepositoryException("getItemData() error", e);
- }
- finally
- {
- try
- {
- if (resultSet != null)
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " + e.getMessage());
- }
- }
-
- }
-
- /**
- * Gets an item data from database.
- *
- * @param parentPath
- * - parent QPath
- * @param parentId
- * - parent container internal id (depends on Multi/Single DB)
- * @param name
- * - item name
- * @return - ItemData instance
- * @throws RepositoryException
- * Repository error
- * @throws IllegalStateException
- * if connection is closed
- */
- protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name) throws RepositoryException,
- IllegalStateException
- {
- checkIfOpened();
- ResultSet resultSet = null;
- try
- {
- resultSet = findItemByNameCQ(parentId, name.getAsString(), name.getIndex());
- if (resultSet.next())
- {
- // return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS), parent.getACL());
- int itemType = resultSet.getInt(COLUMN_CLASS);
- if (itemType == I_CLASS_NODE)
- {
- // Remember first node id. If node is not first in result set - it's a bug.
- String firstNodeId = resultSet.getString(COLUMN_ID);
-
- // There may be two or more nodes, so load temp NodeDatas and return first one.
- Map<String, TempNodeData> tempNodes = loadTempNodesFromResultSet(resultSet);
-
- QPath parentQPath = parent.getQPath();
- AccessControlList parentACL = parent.getACL();
-
- NodeData nodeData = loadNodeFromTemporaryNodeData(tempNodes.get(firstNodeId), parentQPath, parentACL);
- tempNodes.clear();
- return nodeData;
- }
- else
- {
- return loadPropertyRecord(resultSet, parent.getQPath());
- }
- }
-
- return null;
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- try
- {
- if (resultSet != null)
- resultSet.close();
- }
- catch (SQLException e)
- {
- LOG.error("getItemData() Error close resultset " + e.getMessage());
- }
- }
- }
-
protected List<AccessControlEntry> readACLPermisions(String cid, Map<String, List<byte[]>> properties)
throws SQLException, IllegalACLException
{
@@ -463,30 +256,55 @@
throw new IllegalACLException("Property exo:owner is not found for node with id: " + getIdentifier(cid));
}
+
+ /**
+ * {@inheritDoc}
+ */
+ protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
+ int cversion, int cnordernumb, AccessControlList parentACL) throws RepositoryException, SQLException
+ {
+ ResultSet ptProp = findNodeMainPropertiesByParentIdentifierCQ(cid);
+ Map<String, List<byte[]>> properties = new HashMap<String, List<byte[]>>();
+ while (ptProp.next())
+ {
+ String key = ptProp.getString(COLUMN_NAME);
+ List<byte[]> values = properties.get(key);
+ if (values == null)
+ {
+ values = new ArrayList<byte[]>();
+ properties.put(key, values);
+ }
+ values.add(ptProp.getBytes(COLUMN_VDATA));
+ }
+ return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, properties, parentACL);
+ }
+
/**
* Create NodeData from TempNodeData content.
*
* @param tempData
* @param parentPath
- * @param pACL
+ * @param parentACL
* @return
* @throws RepositoryException
* @throws SQLException
* @throws IOException
*/
protected PersistedNodeData loadNodeFromTemporaryNodeData(TempNodeData tempData, QPath parentPath,
- AccessControlList pACL) throws RepositoryException, SQLException, IOException
+ AccessControlList parentACL) throws RepositoryException, SQLException, IOException
{
+ return loadNodeRecord(parentPath, tempData.cname, tempData.cid, tempData.cpid, tempData.cindex,
+ tempData.cversion, tempData.cnordernumb, tempData.properties, parentACL);
+ }
- String cid = tempData.cid;
- String cname = tempData.cname;
- int cversion = tempData.cversion;
- String cpid = tempData.cpid;
- int cindex = tempData.cindex;
- int cnordernumb = tempData.cnordernumb;
- AccessControlList parentACL = pACL;
-
+ /**
+ * Create a new node from the given parameter
+ */
+ private PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
+ int cversion, int cnordernumb, Map<String, List<byte[]>> properties, AccessControlList parentACL)
+ throws RepositoryException, SQLException
+ {
try
{
InternalQName qname = InternalQName.parse(cname);
@@ -516,8 +334,6 @@
}
}
- Map<String, List<byte[]>> properties = tempData.properties;
-
// PRIMARY
List<byte[]> primaryType = properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
if (primaryType == null || primaryType.isEmpty())
@@ -629,7 +445,7 @@
throw new RepositoryException(e);
}
}
-
+
/**
* Load property record from result set. Result set must be ordered by property id.
* In other way there may be mistaces.
@@ -843,11 +659,9 @@
// }
// }
- protected abstract ResultSet findItemByIdentifierCQ(String identifier) throws SQLException;
-
- protected abstract ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException;
-
protected abstract ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
- protected abstract ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
+ protected abstract ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException;
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-31 09:05:39 UTC (rev 1262)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-31 19:06:31 UTC (rev 1263)
@@ -53,14 +53,10 @@
protected PreparedStatement findItemById;
- protected PreparedStatement findItemByIdCQ;
-
protected PreparedStatement findItemByPath;
protected PreparedStatement findItemByName;
- protected PreparedStatement findItemByNameCQ;
-
protected PreparedStatement findChildPropertyByPath;
protected PreparedStatement findPropertyByName;
@@ -90,7 +86,9 @@
protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement getPropertiesByParentIdCQ;
+ protected PreparedStatement findPropertiesByParentIdCQ;
+
+ protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
protected PreparedStatement insertNode;
@@ -178,22 +176,9 @@
FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
- FIND_ITEM_BY_ID_CQ =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where (I.ID=?) or (I.PARENT_ID=? and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by V.ORDER_NUM"; //I.I_CLASS, I.N_ORDER_NUM,
-
FIND_ITEM_BY_NAME =
"select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_NAME_CQ =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
- + ", (select ID from JCR_MITEM where PARENT_ID=? and NAME=? and I_INDEX=?) I2"
- + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
-
FIND_PROPERTY_BY_NAME =
"select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
+ " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
@@ -217,6 +202,12 @@
+ " where (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ " order by I.N_ORDER_NUM, PROP_NAME DESC, V.ORDER_NUM";
+ FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
+ "select I.NAME, V.DATA"
+ + " from JCR_SITEM I, JCR_SVALUE V"
+ + " where I.I_CLASS=2 and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
+
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
@@ -404,22 +395,6 @@
/**
* {@inheritDoc}
*/
- protected ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException
- {
- if (findItemByNameCQ == null)
- findItemByNameCQ = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_CQ);
- else
- findItemByNameCQ.clearParameters();
-
- findItemByNameCQ.setString(1, parentId);
- findItemByNameCQ.setString(2, name);
- findItemByNameCQ.setInt(3, index);
- return findItemByNameCQ.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
@Override
protected ResultSet findPropertyByName(String parentId, String name) throws SQLException
{
@@ -635,27 +610,26 @@
}
@Override
- protected ResultSet findItemByIdentifierCQ(String identifier) throws SQLException
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (findItemByIdCQ == null)
- findItemByIdCQ = dbConnection.prepareStatement(FIND_ITEM_BY_ID_CQ);
+ if (findPropertiesByParentIdCQ == null)
+ findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
else
- findItemByIdCQ.clearParameters();
- findItemByIdCQ.setString(1, identifier);
- findItemByIdCQ.setString(2, identifier);
- return findItemByIdCQ.executeQuery();
+ findPropertiesByParentIdCQ.clearParameters();
+
+ findPropertiesByParentIdCQ.setString(1, parentIdentifier);
+ return findPropertiesByParentIdCQ.executeQuery();
}
@Override
- protected ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (getPropertiesByParentIdCQ == null)
- getPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ if (findNodeMainPropertiesByParentIdentifierCQ == null)
+ findNodeMainPropertiesByParentIdentifierCQ = dbConnection.prepareStatement(FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ);
else
- getPropertiesByParentIdCQ.clearParameters();
+ findNodeMainPropertiesByParentIdentifierCQ.clearParameters();
- getPropertiesByParentIdCQ.setString(1, parentIdentifier);
- return getPropertiesByParentIdCQ.executeQuery();
+ findNodeMainPropertiesByParentIdentifierCQ.setString(1, parentIdentifier);
+ return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
}
-
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-31 09:05:39 UTC (rev 1262)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-31 19:06:31 UTC (rev 1263)
@@ -51,14 +51,10 @@
protected PreparedStatement findItemById;
- protected PreparedStatement findItemByIdCQ;
-
protected PreparedStatement findItemByPath;
protected PreparedStatement findItemByName;
- protected PreparedStatement findItemByNameCQ;
-
protected PreparedStatement findChildPropertyByPath;
protected PreparedStatement findPropertyByName;
@@ -85,8 +81,10 @@
protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement getPropertiesByParentIdCQ;
+ protected PreparedStatement findPropertiesByParentIdCQ;
+ protected PreparedStatement findNodeMainPropertiesByParentIdentifierCQ;
+
protected PreparedStatement insertItem;
protected PreparedStatement insertNode;
@@ -184,19 +182,6 @@
"select * from JCR_SITEM"
+ " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_NAME_CQ =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + ", (select ID from JCR_SITEM where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=?) I2"
- + " where (I.ID=I2.ID) or (I.PARENT_ID=I2.ID and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
-
- FIND_ITEM_BY_ID_CQ =
- "select I.*, V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)"
- + " where (I.ID=?) or (I.PARENT_ID=? and I.I_CLASS=2 and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType'"
- + " or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by V.ORDER_NUM"; //I.I_CLASS, I.N_ORDER_NUM,
-
FIND_PROPERTY_BY_NAME =
"select V.DATA"
+ " from JCR_SITEM I, JCR_SVALUE V"
@@ -222,6 +207,11 @@
+ " where (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ " order by I.N_ORDER_NUM, PROP_NAME DESC, V.ORDER_NUM";
+ FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
+ "select I.NAME, V.DATA"
+ + " from JCR_SITEM I, JCR_SVALUE V"
+ + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
FIND_NODES_COUNT_BY_PARENTID =
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
@@ -617,34 +607,6 @@
}
@Override
- protected ResultSet findItemByNameCQ(String parentId, String name, int index) throws SQLException
- {
- if (findItemByNameCQ == null)
- findItemByNameCQ = dbConnection.prepareStatement(FIND_ITEM_BY_NAME_CQ);
- else
- findItemByNameCQ.clearParameters();
-
- findItemByNameCQ.setString(1, containerName);
- findItemByNameCQ.setString(2, parentId);
- findItemByNameCQ.setString(3, name);
- findItemByNameCQ.setInt(4, index);
- return findItemByNameCQ.executeQuery();
- }
-
- @Override
- protected ResultSet findItemByIdentifierCQ(String identifier) throws SQLException
- {
-
- if (findItemByIdCQ == null)
- findItemByIdCQ = dbConnection.prepareStatement(FIND_ITEM_BY_ID_CQ);
- else
- findItemByIdCQ.clearParameters();
- findItemByIdCQ.setString(1, identifier);
- findItemByIdCQ.setString(2, identifier);
- return findItemByIdCQ.executeQuery();
- }
-
- @Override
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
if (findNodesByParentIdCQ == null)
@@ -659,17 +621,29 @@
}
@Override
- protected ResultSet getChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
- if (getPropertiesByParentIdCQ == null)
- getPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ if (findPropertiesByParentIdCQ == null)
+ findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
else
- getPropertiesByParentIdCQ.clearParameters();
+ findPropertiesByParentIdCQ.clearParameters();
- getPropertiesByParentIdCQ.setString(1, containerName);
- getPropertiesByParentIdCQ.setString(2, parentIdentifier);
- return getPropertiesByParentIdCQ.executeQuery();
+ findPropertiesByParentIdCQ.setString(1, containerName);
+ findPropertiesByParentIdCQ.setString(2, parentIdentifier);
+ return findPropertiesByParentIdCQ.executeQuery();
}
+ @Override
+ protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ {
+ if (findNodeMainPropertiesByParentIdentifierCQ == null)
+ findNodeMainPropertiesByParentIdentifierCQ = dbConnection.prepareStatement(FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ);
+ else
+ findNodeMainPropertiesByParentIdentifierCQ.clearParameters();
+
+ findNodeMainPropertiesByParentIdentifierCQ.setString(1, containerName);
+ findNodeMainPropertiesByParentIdentifierCQ.setString(2, parentIdentifier);
+ return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
+ }
}
16 years, 3 months
exo-jcr SVN: r1262 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation: db and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-12-31 04:05:39 -0500 (Thu, 31 Dec 2009)
New Revision: 1262
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
Log:
EXOJCR-302: Rework of JDBC level to use complex queries
We use a new query for findChildNodesByParentIdentifierCQ that is better than the previous one for the following reasons:
1. We don't have to keep all the data into a temporary map since everything cans be done on the fly
2. We get much better performances with a big amount of sub nodes (the most important reason)
3. We don't use an outer join which means that the request should be easily supported by all the main databases
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-30 15:11:04 UTC (rev 1261)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2009-12-31 09:05:39 UTC (rev 1262)
@@ -33,6 +33,7 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.PrimaryTypeNotFoundException;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -145,25 +146,36 @@
{
// query will return nodes and properties in same result set
ResultSet resultSet = findChildNodesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
- if (resultSet.next())
+ TempNodeData data = null;
+ List<NodeData> childNodes = new ArrayList<NodeData>();
+ while (resultSet.next())
{
- Map<String, TempNodeData> tempNodes = loadTempNodesFromResultSet(resultSet);
-
- List<NodeData> childNodes = new ArrayList<NodeData>(tempNodes.size());
- QPath parentQPath = parent.getQPath();
- AccessControlList parentACL = parent.getACL();
- for (TempNodeData data : tempNodes.values())
+ if (data == null)
{
- NodeData nodeData = loadNodeFromTemporaryNodeData(data, parentQPath, parentACL);
+ data = new TempNodeData(resultSet);
+ }
+ else if (!resultSet.getString(COLUMN_ID).equals(data.cid))
+ {
+ NodeData nodeData = loadNodeFromTemporaryNodeData(data, parent.getQPath(), parent.getACL());
childNodes.add(nodeData);
+ data = new TempNodeData(resultSet);
}
- return childNodes;
+ Map<String, List<byte[]>> properties = data.properties;
+ String key = resultSet.getString("PROP_NAME");
+ List<byte[]> values = properties.get(key);
+ if (values == null)
+ {
+ values = new ArrayList<byte[]>();
+ properties.put(key, values);
+ }
+ values.add(resultSet.getBytes(COLUMN_VDATA));
}
- else
+ if (data != null)
{
- return new ArrayList<NodeData>();
+ NodeData nodeData = loadNodeFromTemporaryNodeData(data, parent.getQPath(), parent.getACL());
+ childNodes.add(nodeData);
}
-
+ return childNodes;
}
catch (SQLException e)
{
@@ -508,9 +520,10 @@
// PRIMARY
List<byte[]> primaryType = properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
- if (primaryType == null || primaryType.size() == 0)
+ if (primaryType == null || primaryType.isEmpty())
{
- throw new SQLException("Node finded but primaryType property not " + cid);
+ throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record not found. Node "
+ + qpath.getAsString() + ", id " + cid + ", container " + this.containerName, null);
}
byte[] data = primaryType.get(0);
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-30 15:11:04 UTC (rev 1261)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2009-12-31 09:05:39 UTC (rev 1262)
@@ -212,11 +212,10 @@
FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
FIND_NODES_BY_PARENTID_CQ =
- "select I.*, V.DATA, V.ORDER_NUM"
- + " from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID), (select ID from JCR_MITEM where PARENT_ID=? and I_CLASS=1) I2"
- + " where (PARENT_ID=? and I.I_CLASS=1 and I.ID=I2.ID) or (I.I_CLASS=2 and I.PARENT_ID=I2.ID and"
- + " (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM, V.ORDER_NUM";
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from (select * from JCR_SITEM where PARENT_ID=? AND I_CLASS=1) I, JCR_SITEM P, JCR_SVALUE V"
+ + " where (P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ + " order by I.N_ORDER_NUM, PROP_NAME DESC, V.ORDER_NUM";
FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?";
@@ -491,7 +490,6 @@
findNodesByParentIdCQ.clearParameters();
findNodesByParentIdCQ.setString(1, parentIdentifier);
- findNodesByParentIdCQ.setString(2, parentIdentifier);
return findNodesByParentIdCQ.executeQuery();
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-30 15:11:04 UTC (rev 1261)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2009-12-31 09:05:39 UTC (rev 1262)
@@ -217,11 +217,10 @@
"select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
FIND_NODES_BY_PARENTID_CQ =
- "select I.*, V.DATA, V.ORDER_NUM"
- + " from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID), (select ID from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?) I2"
- + " where (I.PARENT_ID=? and I.I_CLASS=1 and I.ID=I2.ID) or (I.I_CLASS=2 and I.PARENT_ID=I2.ID and"
- + " (I.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or I.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'"
- + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')) order by I.I_CLASS, I.N_ORDER_NUM"; //, V.ORDER_NUM
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA"
+ + " from (select * from JCR_SITEM where CONTAINER_NAME=? and PARENT_ID=? AND I_CLASS=1) I, JCR_SITEM P, JCR_SVALUE V"
+ + " where (P.CONTAINER_NAME=? and P.PARENT_ID=I.ID and P.I_CLASS=2 and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner' or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions') and V.PROPERTY_ID=P.ID)"
+ + " order by I.N_ORDER_NUM, PROP_NAME DESC, V.ORDER_NUM";
FIND_NODES_COUNT_BY_PARENTID =
"select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
@@ -648,7 +647,6 @@
@Override
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
-
if (findNodesByParentIdCQ == null)
findNodesByParentIdCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
else
@@ -656,7 +654,7 @@
findNodesByParentIdCQ.setString(1, containerName);
findNodesByParentIdCQ.setString(2, parentIdentifier);
- findNodesByParentIdCQ.setString(3, parentIdentifier);
+ findNodesByParentIdCQ.setString(3, containerName);
return findNodesByParentIdCQ.executeQuery();
}
16 years, 3 months
exo-jcr SVN: r1261 - in jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test: resources/conf/standalone and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-12-30 10:11:04 -0500 (Wed, 30 Dec 2009)
New Revision: 1261
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/replication/BaseReplicationTest.java
jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-replication.xml
Log:
EXOJCR-273 : The configuration to ext was fixed
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/replication/BaseReplicationTest.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/replication/BaseReplicationTest.java 2009-12-30 15:03:09 UTC (rev 1260)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/replication/BaseReplicationTest.java 2009-12-30 15:11:04 UTC (rev 1261)
@@ -53,7 +53,7 @@
public void setUp() throws Exception
{
- String containerConf = "src/test/java/conf/standalone/test-configuration-replication.xml";
+ String containerConf = "src/test/resources/conf/standalone/test-configuration-replication.xml";
String loginConf = Thread.currentThread().getContextClassLoader().getResource("login.conf").toString();
if (!new File(containerConf).exists())
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-replication.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-replication.xml 2009-12-30 15:03:09 UTC (rev 1260)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.ext/src/test/resources/conf/standalone/test-configuration-replication.xml 2009-12-30 15:11:04 UTC (rev 1261)
@@ -186,7 +186,7 @@
<value-param>
<name>conf-path</name>
<description>JCR configuration file</description>
- <value>file:src/test/java/conf/standalone/test-jcr-ext-config-replication.xml</value>
+ <value>file:src/test/resources/conf/standalone/test-jcr-ext-config-replication.xml</value>
</value-param>
</init-params>
</component>
16 years, 3 months
exo-jcr SVN: r1260 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-30 10:03:09 -0500 (Wed, 30 Dec 2009)
New Revision: 1260
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java
Log:
EXOJCR-359: rework of ItemImpl gets (decrease NodeImpl/propertyImpl creation). not finished - lazy getNodes todoed
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-30 14:47:45 UTC (rev 1259)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-30 15:03:09 UTC (rev 1260)
@@ -30,7 +30,6 @@
*/
public interface ValueData
{
-
/**
* Return Value order number.
*
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-30 14:47:45 UTC (rev 1259)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-30 15:03:09 UTC (rev 1260)
@@ -797,6 +797,7 @@
* @throws RepositoryException
* if errors occurs
*/
+ @Deprecated
abstract void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws RepositoryException;
/**
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 14:47:45 UTC (rev 1259)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 15:03:09 UTC (rev 1260)
@@ -156,21 +156,17 @@
*
* @param data
* Node data
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
+ * @param parent parent NodeData
* @param session
* Session
* @throws RepositoryException
* if error occurs during the Node data loading
*/
- public NodeImpl(NodeData data, InternalQName parentPrimaryTypeName, InternalQName[] parentMixinTypeNames,
- SessionImpl session) throws RepositoryException
+ public NodeImpl(NodeData data, NodeData parent, SessionImpl session) throws RepositoryException
{
super(data, session);
this.sysLocFactory = session.getSystemLocationFactory();
- loadData(data, parentPrimaryTypeName, parentMixinTypeNames);
+ loadNodeData(data, parent);
}
/**
@@ -1013,8 +1009,7 @@
checkValid();
try
{
- return new NodeIteratorOnDemand(childNodesData(), dataManager, nodeData().getPrimaryTypeName(), nodeData()
- .getMixinTypeNames());
+ return new NodeIteratorOnDemand(childNodesData(), dataManager, nodeData());
}
finally
{
@@ -1369,93 +1364,72 @@
public void loadData(ItemData data) 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.qpath = nodeData.getQPath();
- this.location = null;
-
- initDefinition();
+ loadNodeData(data, null);
}
- /**
- * Loads data.
- *
- * @param data
- * source item data for load
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
- * @throws RepositoryException
- * if error occurs
- */
- private void loadData(ItemData data, InternalQName parentPrimaryTypeName, InternalQName[] parentMixinTypeNames)
- throws RepositoryException, InvalidItemStateException, ConstraintViolationException
+ private void loadNodeData(ItemData data, NodeData parent) 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");
+ if (data.isNode())
+ {
+ NodeData nodeData = (NodeData)data;
- 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);
+ }
- // 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.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());
+ }
- if (nodeData.getACL() == null)
- throw new RepositoryException("ACL is NULL " + nodeData.getQPath().getAsString());
+ this.data = nodeData;
+ this.qpath = nodeData.getQPath();
+ this.location = null;
- this.data = nodeData;
- this.qpath = nodeData.getQPath();
- this.location = null;
-
- initDefinition(parentPrimaryTypeName, parentMixinTypeNames);
+ initDefinition(parent);
+ }
+ else
+ {
+ throw new RepositoryException("Load data failed: Node expected");
+ }
}
/**
* {@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;
@@ -1478,6 +1452,41 @@
}
/**
+ * Init NodeDefinition.
+ *
+ * @param parent NodeData
+ * @throws RepositoryException
+ * if error occurs
+ * @throws ConstraintViolationException
+ * if definition not found
+ */
+ private void initDefinition(NodeData parent) throws RepositoryException, ConstraintViolationException
+ {
+ if (this.isRoot())
+ {
+ // root - no parent
+ this.definition =
+ new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, true,
+ new InternalQName[]{Constants.NT_BASE}, null, false);
+ return;
+ }
+
+ if (parent == null)
+ {
+ parent = (NodeData)dataManager.getItemData(getParentIdentifier());
+ }
+
+ this.definition =
+ session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
+ parent.getPrimaryTypeName(), parent.getMixinTypeNames());
+
+ if (definition == null)
+ {
+ throw new ConstraintViolationException("Node definition not found for " + getPath());
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public ItemDefinitionData getItemDefinitionData()
@@ -2571,12 +2580,12 @@
* @throws AccessDeniedException
* if Nodes cannot be listed due to permissions on this Node
*/
- private List childNodesData() throws RepositoryException, AccessDeniedException
+ private List<Object> childNodesData() throws RepositoryException, AccessDeniedException
{
List<NodeData> storedNodes = dataManager.getChildNodesData(nodeData());
Collections.sort(storedNodes, new NodeDataOrderComparator());
- List<Object> results = new ArrayList(storedNodes.size());
+ List<Object> results = new ArrayList<Object>(storedNodes.size());
Iterator<NodeData> it = storedNodes.iterator();
while (it.hasNext())
@@ -2836,68 +2845,6 @@
return false;
}
- /**
- * Init NodeDefinition.
- *
- * @throws RepositoryException
- * if error occurs
- * @throws ConstraintViolationException
- * if definition not found
- */
- private void initDefinition() throws RepositoryException, ConstraintViolationException
- {
-
- if (this.isRoot())
- { // root - no parent
- this.definition =
- new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, true,
- new InternalQName[]{Constants.NT_BASE}, null, false);
- return;
- }
-
- NodeData parent = (NodeData)dataManager.getItemData(getParentIdentifier());
-
- this.definition =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
- parent.getPrimaryTypeName(), parent.getMixinTypeNames());
-
- if (definition == null)
- throw new ConstraintViolationException("Node definition not found for " + getPath());
- }
-
- /**
- * Init NodeDefinition.
- *
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
- *
- * @throws RepositoryException
- * if error occurs
- * @throws ConstraintViolationException
- * if definition not found
- */
- private void initDefinition(InternalQName parentPrimaryTypeName, InternalQName[] parentMixinTypeNames)
- throws RepositoryException, ConstraintViolationException
- {
-
- if (this.isRoot())
- { // root - no parent
- this.definition =
- new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, true,
- new InternalQName[]{Constants.NT_BASE}, null, false);
- return;
- }
-
- this.definition =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(), parentPrimaryTypeName,
- parentMixinTypeNames);
-
- if (definition == null)
- throw new ConstraintViolationException("Node definition not found for " + getPath());
- }
-
private void removeMergeFailed(Version version, PlainChangesLog changesLog) throws RepositoryException
{
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-30 14:47:45 UTC (rev 1259)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-30 15:03:09 UTC (rev 1260)
@@ -187,12 +187,8 @@
return item;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.dataflow.ItemDataConsumer#getItemData(org.
- * exoplatform.services .jcr.datamodel.NodeData,
- * org.exoplatform.services.jcr.datamodel.QPathEntry)
+ /**
+ * {@inheritDoc}
*/
public ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException
{
@@ -261,35 +257,23 @@
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
+ {
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + name.getAsString() + " ) >>>>>");
+ }
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(parent, name);
- if (itemData == null)
- return null;
-
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
- {
- throw new AccessDeniedException("Access denied "
- + QPath.makeChildPath(parent.getQPath(), name).getAsString() + " for " + session.getUserID()
- + " (get item by path)");
- }
-
- if (pool)
- return itemsPool.get(item);
-
- return item;
+ return item = readItem(getItemData(parent, name), pool);
}
finally
{
if (log.isDebugEnabled())
+ {
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + name.getAsString() + ") --> "
+ (item != null ? item.getPath() : "null") + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
+ "sec");
+ }
}
}
@@ -322,23 +306,7 @@
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(parent, relPath);
- if (itemData == null)
- return null;
-
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
- {
- throw new AccessDeniedException("Access denied "
- + session.getLocationFactory().createJCRPath(QPath.makeChildPath(parent.getQPath(), relPath))
- .getAsString(false) + " for " + session.getUserID() + " (get item by path)");
- }
-
- if (pool)
- return itemsPool.get(item);
-
- return item;
+ return item = readItem(getItemData(parent, relPath), pool);
}
finally
{
@@ -370,32 +338,81 @@
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
+ {
log.debug("getItem(" + path.getAsString() + " ) >>>>>");
+ }
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(path);
- if (itemData == null)
- return null;
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
+ return item = readItem(getItemData(path), pool);
+ }
+ finally
+ {
+ if (log.isDebugEnabled())
{
- throw new AccessDeniedException("Access denied " + path.getAsString() + " for " + session.getUserID()
- + " (get item by path)");
+ log.debug("getItem(" + path.getAsString() + ") --> " + (item != null ? item.getPath() : "null") + " <<<<< "
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
+ }
+ }
- if (pool)
- return itemsPool.get(item);
+ /**
+ * Read ItemImpl of given ItemData.
+ * Will call postRead Action and check permissions.
+ *
+ * @param itemData ItemData
+ * @param pool boolean, if true will reload pooled ItemImpl
+ * @return ItemImpl
+ * @throws RepositoryException if errro occurs
+ */
+ protected ItemImpl readItem(ItemData itemData, boolean pool) throws RepositoryException
+ {
+ return readItem(itemData, pool, true);
+ }
+ /**
+ * Read ItemImpl of given ItemData.
+ *
+ * @param itemData ItemData
+ * @param pool boolean, if true will reload pooled ItemImpl
+ * @param jcrAPI, boolean if true will call postRead Action and check permissions
+ * @return ItemImpl
+ * @throws RepositoryException if errro occurs
+ */
+ protected ItemImpl readItem(ItemData itemData, boolean pool, boolean jcrAPI) throws RepositoryException
+ {
+ if (itemData != null)
+ {
+ ItemImpl item;
+ ItemImpl pooledItem;
+ if (pool && (pooledItem = itemsPool.get(itemData)) != null)
+ {
+ // use pooled & reloaded
+ item = pooledItem;
+ }
+ else
+ {
+ // create new
+ item = itemFactory.createItem(itemData);
+ }
+
+ if (jcrAPI)
+ {
+ // TODO post read will be logically to call after the permissions check
+ session.getActionHandler().postRead(item);
+ if (!item.hasPermission(PermissionType.READ))
+ {
+ throw new AccessDeniedException("Access denied " + itemData.getQPath().getAsString() + " for "
+ + session.getUserID());
+ }
+ }
+
return item;
}
- finally
+ else
{
- if (log.isDebugEnabled())
- log.debug("getItem(" + path.getAsString() + ") --> " + (item != null ? item.getPath() : "null") + " <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ return null;
}
}
@@ -413,32 +430,22 @@
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
+ {
log.debug("getItemByIdentifier(" + identifier + " ) >>>>>");
+ }
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(identifier);
- if (itemData == null)
- return null;
-
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
- {
- throw new AccessDeniedException("Access denied, item with id : " + item.getPath()
- + " (get item by id), user " + session.getUserID() + " has no privileges on reading");
- }
- if (pool)
- return itemsPool.get(item);
-
- return item;
+ return item = readItem(getItemData(identifier), pool);
}
finally
{
if (log.isDebugEnabled())
+ {
log.debug("getItemByIdentifier(" + identifier + ") --> " + (item != null ? item.getPath() : "null")
+ " <<<<< " + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ }
}
}
@@ -534,17 +541,24 @@
if (accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.READ}, session.getUserState()
.getIdentity()))
{
- PropertyImpl item = null;
+ PropertyImpl item;
ItemState state = changesLog.getItemState(identifier);
if (state != null)
{
- if (state.isDeleted()) // skip deleted
+ if (state.isDeleted())
+ {
+ // skip deleted
continue;
+ }
- item = (PropertyImpl)itemFactory.createItem(state.getData());
+ item = (PropertyImpl)readItem(state.getData(), true, false);
+ // TODO item = (PropertyImpl)itemFactory.createItem(state.getData());
}
else
- item = (PropertyImpl)itemFactory.createItem(data);
+ {
+ item = (PropertyImpl)readItem(data, true, false);
+ // TODO item = (PropertyImpl)itemFactory.createItem(data);
+ }
refs.add(item);
session.getActionHandler().postRead(item);
@@ -582,15 +596,15 @@
for (int i = 0, length = nodeDatas.size(); i < length; i++)
{
NodeData data = nodeDatas.get(i);
- NodeImpl item = itemFactory.createNode(data, parent.getPrimaryTypeName(), parent.getMixinTypeNames());
-
- session.getActionHandler().postRead(item);
-
if (accessManager.hasPermission(data.getACL(), new String[]{PermissionType.READ}, session.getUserState()
.getIdentity()))
{
- if (pool)
- item = (NodeImpl)itemsPool.get(item);
+ //NodeImpl item = itemFactory.createNode(data, parent.getPrimaryTypeName(), parent.getMixinTypeNames());
+ NodeImpl item = (NodeImpl) readItem(data, pool, false);
+ session.getActionHandler().postRead(item);
+
+ //TODO if (pool)
+ // item = (NodeImpl)itemsPool.get(item);
nodes.add(item);
}
@@ -633,13 +647,15 @@
for (int i = 0, length = propDatas.size(); i < length; i++)
{
PropertyData data = propDatas.get(i);
- ItemImpl item = itemFactory.createItem(data);
- session.getActionHandler().postRead(item);
+ //ItemImpl item = itemFactory.createItem(data);
if (accessManager.hasPermission(parent.getACL(), new String[]{PermissionType.READ}, session.getUserState()
.getIdentity()))
{
- if (pool)
- item = itemsPool.get(item);
+ // TODO if (pool)
+ // item = itemsPool.get(item);
+ ItemImpl item = readItem(data, pool, false);
+ session.getActionHandler().postRead(item);
+
props.add((PropertyImpl)item);
}
}
@@ -823,11 +839,15 @@
{
ItemData ri = getItemData(item.getInternalIdentifier());
if (ri != null)
+ {
itemsPool.reload(ri);
+ }
else
+ {
// the item is invalid, case of version restore - the item from non
// current version
item.invalidate();
+ }
invalidated.add(item);
}
@@ -1021,7 +1041,7 @@
// We can't remove this VH now.
return;
} // else -- if we has a references in workspace where the VH is being
- // deleted we can remove VH now.
+ // deleted we can remove VH now.
}
}
finally
@@ -1117,12 +1137,7 @@
changesLog.add(itemState);
- ItemImpl item = itemFactory.createItem(itemState.getData());
-
- if (pool)
- item = itemsPool.get(item);
-
- return item;
+ return readItem(itemState.getData(), pool, false);
}
/**
@@ -1407,11 +1422,13 @@
* @throws RepositoryException
* if errors is occurs
*/
- public NodeImpl wrapNodeData(NodeData data, InternalQName parentPrimaryTypeName, InternalQName[] parentMixinTypeNames)
+ public NodeImpl wrapNodeData(NodeData data, NodeData parent)
throws RepositoryException
{
- NodeImpl item = itemFactory.createNode(data, parentPrimaryTypeName, parentMixinTypeNames);
- session.getActionHandler().postRead(item);
+
+ 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)
@@ -1419,17 +1436,18 @@
NodeData pooledData = (NodeData)itemsPool.getData(data.getIdentifier());
if (pooledData != null)
{
- item.loadData(pooledData);
+ node.loadData(pooledData);
}
- item = (NodeImpl)itemsPool.get(item);
+ // TODO
+ node = (NodeImpl)itemsPool.get(node);
}
else
{
- item = pooledItem;
+ node = pooledItem;
}
- return item;
+ return node;
}
/**
@@ -1880,6 +1898,7 @@
* @return the item
* @throws RepositoryException
*/
+ @Deprecated
ItemImpl get(ItemImpl newItem) throws RepositoryException
{
String identifier = newItem.getInternalIdentifier();
@@ -1896,7 +1915,34 @@
item.loadData(newItem.getData(), newItem.getItemDefinitionData());
return item;
}
+ }
+ /**
+ * Get ItemImpl from the pool using given data.
+ *
+ * @param newData ItemData
+ * @return ItemImpl item
+ * @throws RepositoryException
+ */
+ ItemImpl get(final ItemData newData) throws RepositoryException
+ {
+ final String identifier = newData.getIdentifier();
+ ItemImpl item = items.get(identifier);
+ if (item != null)
+ {
+ item.loadData(newData);
+ }
+ else
+ {
+// ItemData preloaded = datas.remove(identifier);
+// item =
+// itemFactory.createItem(preloaded != null
+// && preloaded.getPersistedVersion() > newData.getPersistedVersion() ? preloaded : newData);
+ datas.remove(identifier);
+ item = itemFactory.createItem(newData);
+ items.put(item.getInternalIdentifier(), item);
+ }
+ return item;
}
/**
@@ -2080,10 +2126,9 @@
return node;
}
- private NodeImpl createNode(NodeData data, InternalQName parentPrimaryTypeName,
- InternalQName[] parentMixinTypeNames) throws RepositoryException
+ private NodeImpl createNode(NodeData data, NodeData parent) throws RepositoryException
{
- NodeImpl node = new NodeImpl(data, parentPrimaryTypeName, parentMixinTypeNames, session);
+ NodeImpl node = new NodeImpl(data, parent, session);
if (data.getPrimaryTypeName().equals(Constants.NT_VERSION))
{
return new VersionImpl(data, session);
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2009-12-30 14:47:45 UTC (rev 1259)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2009-12-30 15:03:09 UTC (rev 1260)
@@ -87,7 +87,6 @@
public void loadData(ItemData vhData) throws RepositoryException, InvalidItemStateException,
ConstraintViolationException
{
-
super.loadData(new VersionHistoryDataHelper((NodeData)vhData, session.getTransientNodesManager()
.getTransactManager(), session.getWorkspace().getNodeTypesHolder()));
}
@@ -360,7 +359,7 @@
{// V2's successor
if (successorsData != null)
{// to redirect V2's successor
- // case of VH graph merge
+ // case of VH graph merge
for (ValueData svalue : successorsData.getValues())
{
predecessor.removeAddSuccessor(version.getInternalIdentifier(),
@@ -619,7 +618,7 @@
{
LOG.debug("Before frozen visitor: " + changesLog.dump());
}
-
+
versionableNodeData.accept(visitor);
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java 2009-12-30 14:47:45 UTC (rev 1259)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java 2009-12-30 15:03:09 UTC (rev 1260)
@@ -43,16 +43,14 @@
{
protected static Log log = ExoLogger.getLogger("jcr.NodeIteratorOnDemand");
- private Iterator iter;
+ private final Iterator iter;
- private List list;
+ private final List list;
- private SessionDataManager dataManager;
+ private final SessionDataManager dataManager;
- private InternalQName parentPrimaryTypeName;
+ private final NodeData parent;
- private InternalQName[] parentMixinTypeNames;
-
private int pos;
/**
@@ -68,8 +66,7 @@
* @param dataManager
* session data manager
*/
- public NodeIteratorOnDemand(List list, SessionDataManager dataManager, InternalQName parentPrimaryTypeName,
- InternalQName[] parentMixinTypeNames)
+ public NodeIteratorOnDemand(List list, SessionDataManager dataManager, NodeData parent)
{
if (list == null)
this.list = new ArrayList();
@@ -77,8 +74,7 @@
this.list = list;
this.dataManager = dataManager;
- this.parentPrimaryTypeName = parentPrimaryTypeName;
- this.parentMixinTypeNames = parentMixinTypeNames;
+ this.parent = parent;
this.iter = list.iterator();
this.pos = 0;
@@ -165,7 +161,7 @@
{
try
{
- list.set(pos, dataManager.wrapNodeData((NodeData)item, parentPrimaryTypeName, parentMixinTypeNames));
+ list.set(pos, dataManager.wrapNodeData((NodeData)item, parent));
}
catch (RepositoryException e)
{
16 years, 3 months
exo-jcr SVN: r1259 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-30 09:47:45 -0500 (Wed, 30 Dec 2009)
New Revision: 1259
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-338: return result list insread of storedNodes list
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 14:33:23 UTC (rev 1258)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 14:47:45 UTC (rev 1259)
@@ -2602,7 +2602,7 @@
}
}
- return storedNodes;
+ return results;
}
private EntityCollection createMergeFailed(Map<String, String> failed, SessionChangesLog changes)
16 years, 3 months
exo-jcr SVN: r1258 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-30 09:33:23 -0500 (Wed, 30 Dec 2009)
New Revision: 1258
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-338:
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 14:28:02 UTC (rev 1257)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 14:33:23 UTC (rev 1258)
@@ -2578,10 +2578,10 @@
List<Object> results = new ArrayList(storedNodes.size());
- Iterator it = storedNodes.iterator();
+ Iterator<NodeData> it = storedNodes.iterator();
while (it.hasNext())
{
- NodeData node = (NodeData)it.next();
+ NodeData node = it.next();
if (!(session.getAccessManager().hasPermission(node.getACL(), new String[]{PermissionType.READ}, session
.getUserState().getIdentity())))
16 years, 3 months
exo-jcr SVN: r1257 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-30 09:28:02 -0500 (Wed, 30 Dec 2009)
New Revision: 1257
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-338: small changes
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 11:45:14 UTC (rev 1256)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30 14:28:02 UTC (rev 1257)
@@ -2573,24 +2573,32 @@
*/
private List childNodesData() throws RepositoryException, AccessDeniedException
{
-
- List storedNodes = dataManager.getChildNodesData(nodeData());
+ List<NodeData> storedNodes = dataManager.getChildNodesData(nodeData());
Collections.sort(storedNodes, new NodeDataOrderComparator());
- for (int i = storedNodes.size() - 1; i >= 0; i--)
+ List<Object> results = new ArrayList(storedNodes.size());
+
+ Iterator it = storedNodes.iterator();
+ while (it.hasNext())
{
- NodeData node = (NodeData)storedNodes.get(i);
+ NodeData node = (NodeData)it.next();
if (!(session.getAccessManager().hasPermission(node.getACL(), new String[]{PermissionType.READ}, session
.getUserState().getIdentity())))
{
- storedNodes.remove(i);
+ it.remove();
}
-
- ItemImpl pooled = dataManager.reloadItem(node);
- if (pooled != null)
+ else
{
- storedNodes.set(i, pooled);
+ ItemImpl pooled = dataManager.reloadItem(node);
+ if (pooled != null)
+ {
+ results.add(pooled);
+ }
+ else
+ {
+ results.add(node);
+ }
}
}
16 years, 3 months
exo-jcr SVN: r1256 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-12-30 06:45:14 -0500 (Wed, 30 Dec 2009)
New Revision: 1256
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
Log:
EXOJCR-302: test-jcr-config reverted
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-12-30 11:44:23 UTC (rev 1255)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/resources/conf/standalone/test-jcr-config.xml 2009-12-30 11:45:14 UTC (rev 1256)
@@ -30,7 +30,7 @@
<workspaces>
<workspace name="ws">
<!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr" />
<property name="dialect" value="hsqldb" />
@@ -90,7 +90,7 @@
</workspace>
<workspace name="ws1">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr1" />
<property name="dialect" value="hsqldb" />
@@ -130,7 +130,7 @@
</workspace>
<workspace name="ws2">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr2" />
<property name="dialect" value="hsqldb" />
@@ -172,7 +172,7 @@
<workspace name="ws3">
<!-- for system storage -->
<container
- class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr3" />
<property name="dialect" value="hsqldb" />
@@ -253,7 +253,7 @@
<workspaces>
<workspace name="ws">
<!-- for system storage -->
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcrtck" />
<property name="dialect" value="hsqldb" />
@@ -308,7 +308,7 @@
</workspace>
<workspace name="ws1">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr1tck" />
<property name="dialect" value="hsqldb" />
@@ -354,7 +354,7 @@
</workspace>
<workspace name="ws2">
- <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
+ <container class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
<properties>
<property name="source-name" value="jdbcjcr2tck" />
<property name="dialect" value="hsqldb" />
16 years, 3 months
exo-jcr SVN: r1255 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core: src/main/java/org/exoplatform/services/jcr/datamodel and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-30 06:44:23 -0500 (Wed, 30 Dec 2009)
New Revision: 1255
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
Log:
EXOJCR-358: fix
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml 2009-12-30 11:40:02 UTC (rev 1254)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/pom.xml 2009-12-30 11:44:23 UTC (rev 1255)
@@ -567,9 +567,7 @@
</property>
</systemProperties>
<includes>
- <include>**/**/TestErrorMultithreading__.java</include>
- <include>**/**/TestConcurrentItems__.java</include>
- <include>**/**/TestInvalidItemState__.java</include>
+ <include>**/**/TestGetNodesPerf.java</include>
</includes>
</configuration>
</plugin>
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-30 11:40:02 UTC (rev 1254)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-30 11:44:23 UTC (rev 1255)
@@ -31,15 +31,6 @@
public interface ValueData
{
- // TODO cleanup
- // /**
- // * Set Value order number.
- // *
- // * @param orderNum
- // * int, Value order number
- // */
- // void setOrderNumber(int orderNum);
-
/**
* Return Value order number.
*
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2009-12-30 11:40:02 UTC (rev 1254)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2009-12-30 11:44:23 UTC (rev 1255)
@@ -19,7 +19,6 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
-import org.exoplatform.services.jcr.impl.storage.jdbc.monitor.ManagedConnection;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -199,7 +198,7 @@
if (readOnly) // set this feature only if it asked
conn.setReadOnly(readOnly);
- return monitorInterest == 0 ? conn : new ManagedConnection(conn, monitorInterest);
+ return monitorInterest == 0 ? conn : null;
}
catch (SQLException e)
{
16 years, 3 months
exo-jcr SVN: r1254 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc: db and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-30 06:40:02 -0500 (Wed, 30 Dec 2009)
New Revision: 1254
Removed:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/monitor/
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
Log:
EXOJCR-358: org.exoplatform.services.jcr.impl.storage.jdbc.monitor package remove
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2009-12-30 11:23:18 UTC (rev 1253)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java 2009-12-30 11:40:02 UTC (rev 1254)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
-import org.exoplatform.services.jcr.impl.storage.jdbc.monitor.ManagedConnection;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -44,6 +43,28 @@
public class GenericConnectionFactory implements WorkspaceStorageConnectionFactory
{
+ public static final String JCR_JDBC_CONNECTION_MONITOR = "org.exoplatform.jcr.monitor.jdbcMonitor";
+
+ public static final String PREPARE_INTREST_NAME = "PREPARE";
+
+ public static final String COMMIT_INTEREST_NAME = "COMMIT";
+
+ public static final String CLOSE_INTEREST_NAME = "CLOSE";
+
+ public static final String OPEN_INTEREST_NAME = "OPEN";
+
+ public static final String EXECUTE_INTEREST_NAME = "EXECUTE";
+
+ public static final int PREPARE_INTREST = 1;
+
+ public static final int COMMIT_INTREST = 2;
+
+ public static final int CLOSE_INTREST = 4;
+
+ public static final int OPEN_INTREST = 8;
+
+ public static final int EXECUTE_INTREST = 16;
+
protected final Log log = ExoLogger.getLogger("jcr.GenericConnectionFactory");
protected final DataSource dbDataSource;
@@ -239,7 +260,7 @@
if (readOnly) // set this feature only if it asked
conn.setReadOnly(readOnly);
- return monitorInterest == 0 ? conn : new ManagedConnection(conn, monitorInterest);
+ return monitorInterest == 0 ? conn : null;
}
catch (SQLException e)
{
@@ -264,7 +285,7 @@
*/
private void initMonitor()
{
- String monitor = System.getProperty(ManagedConnection.JCR_JDBC_CONNECTION_MONITOR);
+ String monitor = System.getProperty(JCR_JDBC_CONNECTION_MONITOR);
if (monitor != null)
{
// parse
@@ -273,14 +294,14 @@
for (String s : ints)
{
s = s.trim();
- if (s.equalsIgnoreCase(ManagedConnection.EXECUTE_INTEREST_NAME))
- interest |= ManagedConnection.EXECUTE_INTREST;
- else if (s.equalsIgnoreCase(ManagedConnection.COMMIT_INTEREST_NAME))
- interest |= ManagedConnection.COMMIT_INTREST;
- else if (s.equalsIgnoreCase(ManagedConnection.CLOSE_INTEREST_NAME))
- interest |= ManagedConnection.CLOSE_INTREST;
- else if (s.equalsIgnoreCase(ManagedConnection.OPEN_INTEREST_NAME))
- interest |= ManagedConnection.OPEN_INTREST;
+ if (s.equalsIgnoreCase(EXECUTE_INTEREST_NAME))
+ interest |= EXECUTE_INTREST;
+ else if (s.equalsIgnoreCase(COMMIT_INTEREST_NAME))
+ interest |= COMMIT_INTREST;
+ else if (s.equalsIgnoreCase(CLOSE_INTEREST_NAME))
+ interest |= CLOSE_INTREST;
+ else if (s.equalsIgnoreCase(OPEN_INTEREST_NAME))
+ interest |= OPEN_INTREST;
}
this.monitorInterest = interest;
16 years, 3 months