[exo-jcr-commits] exo-jcr SVN: r1301 - 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.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jan 5 12:43:15 EST 2010
Author: sergiykarpenko
Date: 2010-01-05 12:43:15 -0500 (Tue, 05 Jan 2010)
New Revision: 1301
Removed:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnectionIJ.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainerIJ.java
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/CQJDBCWorkspaceDataContainer.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: code cleanup
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 2010-01-05 17:23:13 UTC (rev 1300)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java 2010-01-05 17:43:15 UTC (rev 1301)
@@ -82,7 +82,10 @@
*/
protected String FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ;
- protected String FIND_REFERENCE_PROPERTIES;
+ /**
+ * FIND_REFERENCE_PROPERTIES_CQ.
+ */
+ protected String FIND_REFERENCE_PROPERTIES_CQ;
/**
* FIND_ITEM_QPATH_BY_ID_CQ.
@@ -125,13 +128,13 @@
* @param dbConnection
* JDBC connection
* @param containerName
- * Workspace conatiner name
+ * Workspace container name
* @param valueStorageProvider
* External Value Storage provider
* @param maxBufferSize
- * maximum buffer size (config)
+ * maximum buffer size (configuration)
* @param swapDirectory
- * swap directory (config)
+ * swap directory (configuration)
* @param swapCleaner
* swap cleaner (FileCleaner)
* @throws SQLException
@@ -203,7 +206,6 @@
checkIfOpened();
try
{
-
ResultSet resultSet = findChildPropertiesByParentIdentifierCQ(getInternalId(parent.getIdentifier()));
List<PropertyData> children = new ArrayList<PropertyData>();
if (resultSet.next())
@@ -211,9 +213,7 @@
while (!resultSet.isAfterLast())
children.add(loadPropertyRecord(resultSet, parent.getQPath()));
}
-
return children;
-
}
catch (SQLException e)
{
@@ -234,15 +234,6 @@
try
{
ResultSet refProps = findReferencePropertiesCQ(getInternalId(nodeIdentifier));
- // List<PropertyData> references = new ArrayList<PropertyData>();
- //
- //
- // while (refProps.next())
- // {
- // while (!refProps.isAfterLast())
- // references.add(loadPropertyRecord(refProps, null));
- // }
- // return references;
return loadReferences(refProps);
}
catch (SQLException e)
@@ -255,14 +246,21 @@
}
}
+ /**
+ * Load Property references
+ *
+ * @param resultSet
+ * @return
+ * @throws RepositoryException
+ * @throws SQLException
+ * @throws IOException
+ */
private List<PropertyData> loadReferences(ResultSet resultSet) throws RepositoryException, SQLException, IOException
{
-
List<PropertyData> resultProps = new ArrayList<PropertyData>();
- // id and how many copies in result
+ // Property Id and amount of copies in result
Map<String, Integer> dublicatedProps = new HashMap<String, Integer>();
-
Map<String, PersistedPropertyData> propertyBuffer = new HashMap<String, PersistedPropertyData>();
Map<String, List<ValueData>> valuesBuffer = new HashMap<String, List<ValueData>>();
@@ -313,7 +311,6 @@
.getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, valueOrderNum, storageId);
values.add(vdata);
- //TODO do we need reset values list into buffer?
valuesBuffer.put(identifier, values);
}
}
@@ -337,10 +334,8 @@
resultProps.add(new PersistedPropertyData(prop.getIdentifier(), prop.getQPath(), prop
.getParentIdentifier(), prop.getPersistedVersion(), prop.getType(), prop.isMultiValued(), newValues));
}
-
values.clear();
}
-
}
catch (IllegalNameException e)
{
@@ -348,7 +343,6 @@
}
finally
{
-
// clean buffers
propertyBuffer.clear();
valuesBuffer.clear();
@@ -356,9 +350,17 @@
}
return resultProps;
-
}
+ /**
+ * Read ACL Permissions from properties set.
+ *
+ * @param cid node id (used only for error messages)
+ * @param properties - Property name and property values
+ * @return list ACL
+ * @throws SQLException
+ * @throws IllegalACLException
+ */
protected List<AccessControlEntry> readACLPermisions(String cid, Map<String, List<byte[]>> properties)
throws SQLException, IllegalACLException
{
@@ -379,6 +381,14 @@
throw new IllegalACLException("Property exo:permissions is not found for node with id: " + getIdentifier(cid));
}
+ /**
+ * Read ACL owner.
+ *
+ * @param cid - node id (used only in exception message)
+ * @param properties - Proeprty name and property values
+ * @return ACL owner
+ * @throws IllegalACLException
+ */
protected String readACLOwner(String cid, Map<String, List<byte[]>> properties) throws IllegalACLException
{
List<byte[]> ownerValues = properties.get(Constants.EXO_OWNER.getAsString());
@@ -386,7 +396,6 @@
return new String(ownerValues.get(0));
else
throw new IllegalACLException("Property exo:owner is not found for node with id: " + getIdentifier(cid));
-
}
/**
@@ -431,7 +440,7 @@
}
/**
- * Create a new node from the given parameter
+ * 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)
@@ -441,7 +450,6 @@
{
InternalQName qname = InternalQName.parse(cname);
- // TODO can't avoid QPath traverse
QPath qpath;
String parentCid;
if (parentPath != null)
@@ -598,8 +606,6 @@
String cpid = resultSet.getString(COLUMN_PARENTID);
// if parent ID is empty string - it's a root node
- // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
-
try
{
int cptype = resultSet.getInt(COLUMN_PTYPE);
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnectionIJ.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnectionIJ.java 2010-01-05 17:23:13 UTC (rev 1300)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnectionIJ.java 2010-01-05 17:43:15 UTC (rev 1301)
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2003-2009 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation;
-
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-
-import java.io.File;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
- * @version $Id: CQJDBCStorageConnectionIJ.java 111 2008-11-11 11:11:11Z serg $
- */
-abstract class CQJDBCStorageConnectionIJ extends CQJDBCStorageConnection
-{
-
- /**
- * JDBCStorageConnection constructor.
- *
- * @param dbConnection
- * JDBC connection
- * @param containerName
- * Workspace conatiner name
- * @param valueStorageProvider
- * External Value Storage provider
- * @param maxBufferSize
- * maximum buffer size (config)
- * @param swapDirectory
- * swap directory (config)
- * @param swapCleaner
- * swap cleaner (FileCleaner)
- * @throws SQLException
- * database error
- */
- protected CQJDBCStorageConnectionIJ(Connection dbConnection, boolean readOnly, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
- }
-
-}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-01-05 17:23:13 UTC (rev 1300)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainer.java 2010-01-05 17:43:15 UTC (rev 1301)
@@ -236,7 +236,7 @@
}
/**
- * Prepare sefault connection factory.
+ * Prepare default connection factory.
*
* @return GenericConnectionFactory
* @throws NamingException
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainerIJ.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainerIJ.java 2010-01-05 17:23:13 UTC (rev 1300)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCWorkspaceDataContainerIJ.java 2010-01-05 17:43:15 UTC (rev 1301)
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2003-2009 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation;
-
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import org.exoplatform.services.naming.InitialContextInitializer;
-
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-import javax.naming.NamingException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a>
- * @version $Id: CQJDBWorkspaceDataContainerIJ.java 111 2008-11-11 11:11:11Z serg $
- */
-public class CQJDBCWorkspaceDataContainerIJ extends CQJDBCWorkspaceDataContainer
-{
- /**
- * Constructor with value storage plugins.
- *
- * @param wsConfig
- * Workspace configuration
- * @param valueStrorageProvider
- * External Value Stprages provider
- * @throws RepositoryConfigurationException
- * if Repository configuration is wrong
- * @throws NamingException
- * if JNDI exception (on DataSource lookup)
- */
- public CQJDBCWorkspaceDataContainerIJ(WorkspaceEntry wsConfig, RepositoryEntry repConfig,
- InitialContextInitializer contextInit, ValueStoragePluginProvider valueStorageProvider)
- throws RepositoryConfigurationException, NamingException, RepositoryException, IOException
- {
- super(wsConfig, repConfig, contextInit, valueStorageProvider);
- }
-}
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 2010-01-05 17:23:13 UTC (rev 1300)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/MultiDbJDBCConnection.java 2010-01-05 17:43:15 UTC (rev 1301)
@@ -189,7 +189,7 @@
"select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_MREF R, JCR_MITEM P"
+ " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
- FIND_REFERENCE_PROPERTIES =
+ FIND_REFERENCE_PROPERTIES_CQ =
"select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
+ " from JCR_MREF R, JCR_MITEM P, JCR_MVALUE V"
+ " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by P.ID, V.ORDER_NUM";
@@ -621,6 +621,9 @@
return findValuesStorageDescriptorsByPropertyId.executeQuery();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
@@ -633,6 +636,9 @@
return findPropertiesByParentIdCQ.executeQuery();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
@@ -646,6 +652,9 @@
return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
{
@@ -665,7 +674,7 @@
protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
{
if (findReferencePropertiesCQ == null)
- findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES);
+ findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES_CQ);
else
findReferencePropertiesCQ.clearParameters();
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 2010-01-05 17:23:13 UTC (rev 1300)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java 2010-01-05 17:43:15 UTC (rev 1301)
@@ -195,7 +195,7 @@
"select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_SREF R, JCR_SITEM P"
+ " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
- FIND_REFERENCE_PROPERTIES =
+ FIND_REFERENCE_PROPERTIES_CQ =
"select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
+ " from JCR_SREF R, JCR_SITEM P, JCR_SVALUE V"
+ " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2 and V.PROPERTY_ID=P.ID order by P.ID, V.ORDER_NUM";
@@ -621,6 +621,9 @@
return renameNode.executeUpdate();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
@@ -635,6 +638,9 @@
return findNodesByParentIdCQ.executeQuery();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
@@ -649,6 +655,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
{
@@ -663,6 +672,9 @@
return findNodeMainPropertiesByParentIdentifierCQ.executeQuery();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
{
@@ -675,11 +687,14 @@
return findItemQPathByIdentifierCQ.executeQuery();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
protected ResultSet findReferencePropertiesCQ(String nodeIdentifier) throws SQLException
{
if (findReferencePropertiesCQ == null)
- findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES);
+ findReferencePropertiesCQ = dbConnection.prepareStatement(FIND_REFERENCE_PROPERTIES_CQ);
else
findReferencePropertiesCQ.clearParameters();
More information about the exo-jcr-commits
mailing list