exo-jcr SVN: r5748 - jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-02 03:59:29 -0500 (Fri, 02 Mar 2012)
New Revision: 5748
Modified:
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml
Log:
EXOJCR-1762: auto-repair doc
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml 2012-03-02 08:59:14 UTC (rev 5747)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml 2012-03-02 08:59:29 UTC (rev 5748)
@@ -26,31 +26,31 @@
available:</para>
<table>
- <title>Available methods</title>
+ <title>Check methods</title>
<tgroup cols="2">
<tbody>
<row>
- <entry>checkRepositoryDataConsistency()</entry>
+ <entry>checkAll()</entry>
<entry>Inspect full repository data (db, value storage and search
index)</entry>
</row>
<row>
- <entry>checkRepositoryDataBaseConsistency()</entry>
+ <entry>checkDataBase()</entry>
<entry>Inspect only DB</entry>
</row>
<row>
- <entry>checkRepositoryValueStorageConsistency()</entry>
+ <entry>checkValueStorage()</entry>
<entry>Inspect only ValueStorage</entry>
</row>
<row>
- <entry>checkRepositorySearchIndexConsistency()</entry>
+ <entry>checkIndex()</entry>
<entry>Inspect only SearchIndex</entry>
</row>
@@ -58,15 +58,84 @@
</tgroup>
</table>
- <para>All inspection activities and corrupted data identifier are stored
- in file, which can be found in app directory by name
- <code>report-<repository name>-dd-MMM-yy-HH-mm.txt</code>. Path to
- file will be returned in result message also. Please, take in account
- thare is three types of inconsistency and two of them are critical. They
- are Errors and Index faults. Index faults are marked as "Reindex" and can
- be fixed by reindexing the workspace, but the Errors can only be fixed
- manually. Warnings found by tool can be a normal situation in some cases
- and usually production system will still remain fully functional.</para>
+ <para>Also tools provides abilities to repair possible inconsistencies:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para><abbrev>Item has no parent node</abbrev> - properties will be
+ removed and root UUID will be assigned in case of nodes</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Node has a single valued property with nothing declared
+ in the VALUE table</abbrev> - property will be removed if it is not
+ required by primary type of its node</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Node has no primary type property</abbrev> - node and
+ whole subtree will be removed if node is not required by primary type
+ of its parent</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Value record has no related property record</abbrev> -
+ value record will be removed from database</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Item is its own parent</abbrev> - properties will be
+ removed and root UUID will be assigned in case of nodes</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Several versions of same item</abbrev> - all earler
+ records with earler versions will be removed from ITEM table</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Reference properties without reference records</abbrev>
+ - property will be removed if it is not required by primary type of
+ its node</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Node is marked as locked in the lockmanager's table but
+ is not in the ITEM table or the opposite</abbrev> - all lock
+ inconsistencies will be removed from both tables</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Property's value is stored in the File System but
+ content is missing</abbrev> - new empty file corresponding to value
+ will be created</para>
+ </listitem>
+ </itemizedlist>
+
+ <table>
+ <title>Repair methods</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>repairDataBase()</entry>
+
+ <entry>repair DB</entry>
+ </row>
+
+ <row>
+ <entry>repairValueStorage()</entry>
+
+ <entry>repair ValueStorage</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>All tool activities are stored in file, which can be found in app
+ directory by name <code>report-<repository
+ name>-dd-MMM-yy-HH-mm.txt</code>.</para>
</section>
<section>
14 years, 1 month
exo-jcr SVN: r5747 - jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-02 03:59:14 -0500 (Fri, 02 Mar 2012)
New Revision: 5747
Modified:
jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml
Log:
EXOJCR-1762: auto-repair doc
Modified: jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml
===================================================================
--- jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml 2012-03-02 08:14:49 UTC (rev 5746)
+++ jcr/branches/1.15.x/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/repository-check-controller.xml 2012-03-02 08:59:14 UTC (rev 5747)
@@ -26,31 +26,31 @@
available:</para>
<table>
- <title>Available methods</title>
+ <title>Check methods</title>
<tgroup cols="2">
<tbody>
<row>
- <entry>checkRepositoryDataConsistency()</entry>
+ <entry>checkAll()</entry>
<entry>Inspect full repository data (db, value storage and search
index)</entry>
</row>
<row>
- <entry>checkRepositoryDataBaseConsistency()</entry>
+ <entry>checkDataBase()</entry>
<entry>Inspect only DB</entry>
</row>
<row>
- <entry>checkRepositoryValueStorageConsistency()</entry>
+ <entry>checkValueStorage()</entry>
<entry>Inspect only ValueStorage</entry>
</row>
<row>
- <entry>checkRepositorySearchIndexConsistency()</entry>
+ <entry>checkIndex()</entry>
<entry>Inspect only SearchIndex</entry>
</row>
@@ -58,15 +58,84 @@
</tgroup>
</table>
- <para>All inspection activities and corrupted data identifier are stored
- in file, which can be found in app directory by name
- <code>report-<repository name>-dd-MMM-yy-HH-mm.txt</code>. Path to
- file will be returned in result message also. Please, take in account
- thare is three types of inconsistency and two of them are critical. They
- are Errors and Index faults. Index faults are marked as "Reindex" and can
- be fixed by reindexing the workspace, but the Errors can only be fixed
- manually. Warnings found by tool can be a normal situation in some cases
- and usually production system will still remain fully functional.</para>
+ <para>Also tools provides abilities to repair possible inconsistencies:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para><abbrev>Item has no parent node</abbrev> - properties will be
+ removed and root UUID will be assigned in case of nodes</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Node has a single valued property with nothing declared
+ in the VALUE table</abbrev> - property will be removed if it is not
+ required by primary type of its node</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Node has no primary type property</abbrev> - node and
+ whole subtree will be removed if node is not required by primary type
+ of its parent</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Value record has no related property record</abbrev> -
+ value record will be removed from database</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Item is its own parent</abbrev> - properties will be
+ removed and root UUID will be assigned in case of nodes</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Several versions of same item</abbrev> - all earler
+ records with earler versions will be removed from ITEM table</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Reference properties without reference records</abbrev>
+ - property will be removed if it is not required by primary type of
+ its node</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Node is marked as locked in the lockmanager's table but
+ is not in the ITEM table or the opposite</abbrev> - all lock
+ inconsistencies will be removed from both tables</para>
+ </listitem>
+
+ <listitem>
+ <para><abbrev>Property's value is stored in the File System but
+ content is missing</abbrev> - new empty file corresponding to value
+ will be created</para>
+ </listitem>
+ </itemizedlist>
+
+ <table>
+ <title>Repair methods</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>repairDataBase()</entry>
+
+ <entry>repair DB</entry>
+ </row>
+
+ <row>
+ <entry>repairValueStorage()</entry>
+
+ <entry>repair ValueStorage</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>All tool activities are stored in file, which can be found in app
+ directory by name <code>report-<repository
+ name>-dd-MMM-yy-HH-mm.txt</code>.</para>
</section>
<section>
14 years, 1 month
exo-jcr SVN: r5746 - jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-02 03:14:49 -0500 (Fri, 02 Mar 2012)
New Revision: 5746
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
Log:
EXOJCR-1762: auto-repair for DB inconsistency
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-02 08:13:20 UTC (rev 5745)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-02 08:14:49 UTC (rev 5746)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc;
import org.exoplatform.commons.utils.SecurityHelper;
+import org.exoplatform.services.database.utils.JDBCUtils;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
@@ -30,8 +31,8 @@
import org.exoplatform.services.jcr.impl.checker.InspectionReport;
import org.exoplatform.services.jcr.impl.checker.NodeRemover;
import org.exoplatform.services.jcr.impl.checker.PropertyRemover;
+import org.exoplatform.services.jcr.impl.checker.RootAsParentAssigner;
import org.exoplatform.services.jcr.impl.checker.ValueRecordsRemover;
-import org.exoplatform.services.jcr.impl.checker.RootAsParentAssigner;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandlerFactory;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
14 years, 1 month
exo-jcr SVN: r5745 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-02 03:13:20 -0500 (Fri, 02 Mar 2012)
New Revision: 5745
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java
Log:
EXOJCR-1762: auto-repair for DB inconsistency
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java 2012-03-02 08:13:20 UTC (rev 5745)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: PropertyRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class PropertyRemover extends AbstractInconsistencyRepair
+{
+ private final NodeTypeDataManager nodeTypeManager;
+
+ /**
+ * PropertyRemover constructor.
+ */
+ public PropertyRemover(WorkspaceStorageConnectionFactory connFactory, NodeTypeDataManager nodeTypeManager)
+ {
+ super(connFactory);
+ this.nodeTypeManager = nodeTypeManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String parentId = exctractId(resultSet, DBConstants.COLUMN_PARENTID);
+ InternalQName propertyName = InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME));
+ boolean multiValued = resultSet.getBoolean(DBConstants.COLUMN_PMULTIVALUED);
+
+ NodeData parent = (NodeData)conn.getItemData(parentId);
+
+ PropertyDefinitionDatas def =
+ nodeTypeManager.getPropertyDefinitions(propertyName, parent.getPrimaryTypeName(),
+ parent.getMixinTypeNames());
+
+ if (def == null || def.getDefinition(multiValued) == null || def.getDefinition(multiValued).isResidualSet())
+ {
+ String propertyId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ QPath path = new QPath(new QPathEntry[]{extractName(resultSet)});
+
+ PropertyData data =
+ new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
+
+ conn.delete(data);
+ }
+ else
+ {
+ throw new SQLException("Propety is required by its parent.");
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+}
14 years, 1 month
exo-jcr SVN: r5744 - in jcr/branches/1.15.x/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache and 4 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-02 02:58:54 -0500 (Fri, 02 Mar 2012)
New Revision: 5744
Added:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig
Removed:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignRootAsParentRepair.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java
Modified:
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java
jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
Log:
EXOJCR-1762: auto-repair for DB inconsistency
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -18,6 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.checker;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
@@ -41,6 +44,9 @@
protected final WorkspaceStorageConnectionFactory connFactory;
+ /**
+ * AbstractInconsistencyRepair constructor.
+ */
AbstractInconsistencyRepair(WorkspaceStorageConnectionFactory connFactory)
{
this.connFactory = connFactory;
@@ -60,7 +66,7 @@
throw new SQLException("Connection is instance of " + conn);
}
- repairInternally((JDBCStorageConnection)conn, resultSet);
+ repairRow((JDBCStorageConnection)conn, resultSet);
conn.commit();
}
@@ -76,7 +82,7 @@
}
}
- abstract void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException;
+ abstract void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException;
protected void rollback(WorkspaceStorageConnection conn)
{
@@ -97,7 +103,7 @@
}
}
- protected String exctractId(ResultSet resultSet) throws SQLException
+ protected String exctractId(ResultSet resultSet, String column) throws SQLException
{
String containerName = "";
try
@@ -108,6 +114,12 @@
{
}
- return resultSet.getString(DBConstants.COLUMN_ID).substring(containerName.length());
+ return resultSet.getString(column).substring(containerName.length());
}
+
+ protected QPathEntry extractName(ResultSet resultSet) throws SQLException, IllegalNameException
+ {
+ return new QPathEntry(InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME)),
+ resultSet.getInt(DBConstants.COLUMN_INDEX));
+ }
}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignRootAsParentRepair.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignRootAsParentRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignRootAsParentRepair.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-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.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: AssignRootAsParentRepair.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class AssignRootAsParentRepair implements InconsistencyRepair
-{
-
- protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.AssignRootAsParentRepair");
-
- protected final WorkspaceStorageConnectionFactory connFactory;
-
- public AssignRootAsParentRepair(WorkspaceStorageConnectionFactory connFactory)
- {
- this.connFactory = connFactory;
- }
-
- /**
- * {@inheritDoc}
- */
- public void doRepair(ResultSet resultSet) throws SQLException
- {
- WorkspaceStorageConnection conn = null;
- try
- {
- conn = connFactory.openConnection();
- if (!(conn instanceof JDBCStorageConnection))
- {
- throw new SQLException("Connection is instance of " + conn);
- }
-
- if (resultSet.getInt(DBConstants.COLUMN_CLASS) == 1)
- {
- repairNode((JDBCStorageConnection)conn, resultSet);
- }
- else
- {
- repairProperty((JDBCStorageConnection)conn, resultSet);
- }
-
- conn.commit();
- }
- catch (RepositoryException e)
- {
- rollback(conn);
- throw new SQLException(e);
- }
- finally
- {
- closeConnection(conn);
- }
- }
-
- private void repairProperty(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String propertyId = exctractId(resultSet);
- QPath path = QPath.parse(resultSet.getString(DBConstants.COLUMN_NAME));
-
- PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
-
- conn.delete(data);
- }
- catch (UnsupportedOperationException e)
- {
- throw new SQLException(e);
- }
- catch (InvalidItemStateException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-
- private void repairNode(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String nodeId = exctractId(resultSet);
- int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
- int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
- QPath path =
- new QPath(new QPathEntry[]{new QPathEntry(
- InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME)),
- resultSet.getInt(DBConstants.COLUMN_INDEX))});
-
- NodeData data =
- new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
-
- conn.rename(data);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalNameException e)
- {
- throw new SQLException(e);
- }
- }
-
- private void closeConnection(WorkspaceStorageConnection conn) throws SQLException
- {
- try
- {
- conn.close();
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-
- private void rollback(WorkspaceStorageConnection conn)
- {
- try
- {
- if (conn != null)
- {
- conn.rollback();
- }
- }
- catch (IllegalStateException e)
- {
- LOG.error("Can not rollback", e);
- }
- catch (RepositoryException e)
- {
- LOG.error("Can not rollback", e);
- }
- }
-
- private String exctractId(ResultSet resultSet) throws SQLException
- {
- String containerName = "";
- try
- {
- containerName = resultSet.getString(DBConstants.CONTAINER_NAME);
- }
- catch (SQLException e)
- {
- }
-
- return resultSet.getString(DBConstants.COLUMN_ID).substring(containerName.length());
- }
-
- private String concatId(ResultSet resultSet, String id) throws SQLException
- {
- String containerName = "";
- try
- {
- containerName = resultSet.getString(DBConstants.CONTAINER_NAME);
- }
- catch (SQLException e)
- {
- }
-
- return containerName + id;
- }
-
-}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-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.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: AssignRootAsParentRepair.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class AssignerRootAsParent extends AbstractInconsistencyRepair
-{
-
- public AssignerRootAsParent(WorkspaceStorageConnectionFactory connFactory)
- {
- super(connFactory);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- if (resultSet.getInt(DBConstants.COLUMN_CLASS) == 1)
- {
- repairNode(conn, resultSet);
- }
- else
- {
- repairProperty(conn, resultSet);
- }
- }
-
- private void repairProperty(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String propertyId = exctractId(resultSet);
- QPath path = QPath.parse(resultSet.getString(DBConstants.COLUMN_NAME));
-
- PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
-
- conn.delete(data);
- }
- catch (UnsupportedOperationException e)
- {
- throw new SQLException(e);
- }
- catch (InvalidItemStateException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-
- private void repairNode(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String nodeId = exctractId(resultSet);
- int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
- int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
- QPath path =
- new QPath(new QPathEntry[]{new QPathEntry(
- InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME)),
- resultSet.getInt(DBConstants.COLUMN_INDEX))});
-
- NodeData data =
- new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
-
- conn.rename(data);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalNameException e)
- {
- throw new SQLException(e);
- }
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -33,6 +33,6 @@
*/
public void doRepair(ResultSet resultSet) throws SQLException
{
- // do nothing
+ throw new SQLException("Inconsistency can not be fixed automatically");
}
}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: EarlierVersionsRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class EarlierVersionsRemover extends AbstractInconsistencyRepair
+{
+
+ /**
+ * RemoveEarlierVersions constructor.
+ */
+ public EarlierVersionsRemover(WorkspaceStorageConnectionFactory connFactory)
+ {
+ super(connFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ PropertyData data = (PropertyData)conn.getItemData(exctractId(resultSet, DBConstants.COLUMN_ID));
+ int maxVersion = conn.getMaxPropertyVersion(data);
+
+ if (resultSet.getInt(DBConstants.COLUMN_VERSION) < maxVersion)
+ {
+ conn.delete(data);
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -28,7 +28,7 @@
public interface InconsistencyRepair
{
/**
- * Repair inconsistency based on resultSet.
+ * Repair inconsistency represented in row of resultSet.
*
* @param resultSet
* @throws SQLException
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: NodeRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class NodeRemover extends AbstractInconsistencyRepair
+{
+ private final NodeTypeDataManager nodeTypeManager;
+
+ /**
+ * NodeRemover constructor.
+ */
+ public NodeRemover(WorkspaceStorageConnectionFactory connFactory, NodeTypeDataManager nodeTypeManager)
+ {
+ super(connFactory);
+ this.nodeTypeManager = nodeTypeManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String parentId = exctractId(resultSet, DBConstants.COLUMN_PARENTID);
+ InternalQName nodeName = InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME));
+
+ NodeData parent = (NodeData)conn.getItemData(parentId);
+
+ NodeDefinitionData def =
+ nodeTypeManager.getChildNodeDefinition(nodeName, parent.getPrimaryTypeName(),
+ parent.getMixinTypeNames());
+
+ if (def == null || def.isResidualSet())
+ {
+ String nodeId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
+ int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
+ QPath path = QPath.makeChildPath(parent.getQPath(), extractName(resultSet));
+
+ NodeData data =
+ new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
+
+ deleteTree(conn, data);
+ }
+ else
+ {
+ throw new SQLException("Node is required by its parent.");
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+
+ private void deleteTree(JDBCStorageConnection conn, NodeData data) throws IllegalStateException,
+ RepositoryException
+ {
+ for (NodeData child : conn.getChildNodesData(data))
+ {
+ deleteTree(conn, child);
+ }
+
+ for (PropertyData prop : conn.getChildPropertiesData(data))
+ {
+ conn.delete(prop);
+ }
+
+ conn.delete(data);
+ }
+}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/PropertyRemover.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: PropertyRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class PropertyRemover extends AbstractInconsistencyRepair
+{
+ private final NodeTypeDataManager nodeTypeManager;
+
+ /**
+ * PropertyRemover constructor.
+ */
+ public PropertyRemover(WorkspaceStorageConnectionFactory connFactory, NodeTypeDataManager nodeTypeManager)
+ {
+ super(connFactory);
+ this.nodeTypeManager = nodeTypeManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String parentId = exctractId(resultSet, DBConstants.COLUMN_PARENTID);
+ InternalQName propertyName = InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME));
+ boolean multiValued = resultSet.getBoolean(DBConstants.COLUMN_PMULTIVALUED);
+
+ NodeData parent = (NodeData)conn.getItemData(parentId);
+
+ PropertyDefinitionDatas def =
+ nodeTypeManager.getPropertyDefinitions(propertyName, parent.getPrimaryTypeName(),
+ parent.getMixinTypeNames());
+
+ if (def == null || def.getDefinition(multiValued) == null || def.getDefinition(multiValued).isResidualSet())
+ {
+ String propertyId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ QPath path = new QPath(new QPathEntry[]{extractName(resultSet)});
+
+ PropertyData data =
+ new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
+
+ conn.delete(data);
+ }
+ else
+ {
+ throw new SQLException("Propety is required by its parent.");
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: RemoveEarlierVersions.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class RemoverEarlierVersions extends AbstractInconsistencyRepair
-{
-
- /**
- * RemoveEarlierVersions constructor.
- */
- public RemoverEarlierVersions(WorkspaceStorageConnectionFactory connFactory)
- {
- super(connFactory);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- PropertyData data = (PropertyData)conn.getItemData(exctractId(resultSet));
- int maxVersion = conn.getMaxPropertyVersion(data);
-
- if (resultSet.getInt(DBConstants.COLUMN_VERSION) < maxVersion)
- {
- conn.delete(data);
- }
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-}
Deleted: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.IllegalPathException;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: RemoverValueRecords.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class RemoverValueRecords extends AbstractInconsistencyRepair
-{
-
- private final String containerName;
-
- private final boolean multiDb;
-
- public RemoverValueRecords(WorkspaceStorageConnectionFactory connFactory, String containerName, boolean multiDb)
- {
- super(connFactory);
- this.containerName = containerName;
- this.multiDb = multiDb;
- }
-
- /**
- * {@inheritDoc}
- */
- void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String propertyId = exctractId(resultSet);
- QPath path = QPath.parse("[]");
-
- PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
-
- conn.delete(data);
- }
- catch (IllegalPathException e)
- {
- throw new SQLException(e);
- }
- catch (UnsupportedOperationException e)
- {
- throw new SQLException(e);
- }
- catch (JCRInvalidItemStateException e)
- {
- // this is ok, since record is absent in ITEM table
- }
- catch (InvalidItemStateException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-
- protected String exctractId(ResultSet resultSet) throws SQLException
- {
- return resultSet.getString(DBConstants.COLUMN_VPROPERTY_ID).substring(multiDb ? 0 : containerName.length());
- }
-}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.impl.AbstractRepositorySuspender;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainerChecker;
@@ -353,7 +354,9 @@
WorkspaceEntry wsEntry = (WorkspaceEntry)getComponent(WorkspaceEntry.class, wsName);
- return new JDBCWorkspaceDataContainerChecker(dataContainer, vsPlugin, wsEntry, lastReport);
+ NodeTypeDataManagerImpl nodeTypeManager = (NodeTypeDataManagerImpl)getComponent(NodeTypeDataManagerImpl.class, wsName);
+
+ return new JDBCWorkspaceDataContainerChecker(dataContainer, vsPlugin, wsEntry, nodeTypeManager, lastReport);
}
private Object getComponent(Class forClass, String wsName)
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+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.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: AssignRootAsParentRepair.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class RootAsParentAssigner extends AbstractInconsistencyRepair
+{
+
+ public RootAsParentAssigner(WorkspaceStorageConnectionFactory connFactory)
+ {
+ super(connFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ if (resultSet.getInt(DBConstants.COLUMN_CLASS) == 1)
+ {
+ assignRootAsParent(conn, resultSet);
+ }
+ else
+ {
+ deleteProperty(conn, resultSet);
+ }
+ }
+
+ private void deleteProperty(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String propertyId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ QPath path = QPath.parse(resultSet.getString(DBConstants.COLUMN_NAME));
+
+ PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
+
+ conn.delete(data);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+
+ private void assignRootAsParent(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String nodeId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
+ int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
+ QPath path = new QPath(new QPathEntry[]{extractName(resultSet)});
+
+ NodeData data = new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
+
+ conn.rename(data);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.datamodel.IllegalPathException;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: ValueRecordsRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class ValueRecordsRemover extends AbstractInconsistencyRepair
+{
+
+ private final String containerName;
+
+ private final boolean multiDb;
+
+ /**
+ * ValueRecordsRemover constructor.
+ */
+ public ValueRecordsRemover(WorkspaceStorageConnectionFactory connFactory, String containerName, boolean multiDb)
+ {
+ super(connFactory);
+ this.containerName = containerName;
+ this.multiDb = multiDb;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String propertyId = exctractId(resultSet, DBConstants.COLUMN_VPROPERTY_ID);
+ QPath path = QPath.parse("[]");
+
+ PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
+
+ conn.delete(data);
+ }
+ catch (IllegalPathException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (JCRInvalidItemStateException e)
+ {
+ // this is ok, since record is absent in ITEM table
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+
+ protected String exctractId(ResultSet resultSet, String column) throws SQLException
+ {
+ return resultSet.getString(column).substring(multiDb ? 0 : containerName.length());
+ }
+}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/JBCShareableLockTableHandler.java.orig 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
+
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.checker.InspectionQuery;
+import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
+
+import java.sql.SQLException;
+
+/**
+ * Provides means for nodes' IDs extraction in case we use {@link CacheableLockManagerImpl}
+ * as {@link LockManager} based on shareable JBoss Cache instance.
+ * Equally applicable for single and multi db configurations.
+ *
+ * @author <a href="mailto:dkuleshov@exoplatform.com">Dmitry Kuleshov</a>
+ * @version $Id: JBCShareableLockTableHandler.java 34360 2009-07-22 23:58:59Z dkuleshov $
+ *
+ */
+public class JBCShareableLockTableHandler extends JBCLockTableHandler implements LockTableHandler
+{
+
+ /**
+ * JBCShareableLockTableHandler constructor.
+ */
+ public JBCShareableLockTableHandler(WorkspaceEntry workspaceEntry)
+ {
+ super(workspaceEntry);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected InspectionQuery getSelectQuery() throws SQLException
+ {
+ return new InspectionQuery("SELECT * FROM " + getTableName() + " WHERE " + getParentColumn() + "='/"
+ + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "'", new String[]{getIdColumn()},
+ "Locks table match");
+ }
+
+ protected InspectionQuery getDeleteQuery(String nodeId) throws SQLException
+ {
+ return new InspectionQuery("DELETE FROM " + getTableName() + " WHERE " + getIdColumn() + "='/"
+ + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "/" + nodeId + "'", new String[]{},
+ "");
+ }
+
+}
\ No newline at end of file
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/DBConstants.java.orig 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,280 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc;
+
+import org.exoplatform.services.database.utils.DialectConstants;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author Gennady Azarenkov
+ * @version $Id: DBConstants.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+public class DBConstants extends DialectConstants
+{
+ // ======================== Error constants ========================
+ /**
+ * JCR_PK_ITEM.
+ */
+ protected String JCR_PK_ITEM;
+
+ /**
+ * JCR_FK_ITEM_PARENT.
+ */
+ protected String JCR_FK_ITEM_PARENT;
+
+ /**
+ * JCR_IDX_ITEM_PARENT.
+ */
+ protected String JCR_IDX_ITEM_PARENT;
+
+ /**
+ * JCR_IDX_ITEM_PARENT_ID.
+ */
+ protected String JCR_IDX_ITEM_PARENT_ID;
+
+ /**
+ * JCR_PK_VALUE.
+ */
+ protected String JCR_PK_VALUE;
+
+ /**
+ * JCR_FK_VALUE_PROPERTY.
+ */
+ protected String JCR_FK_VALUE_PROPERTY;
+
+ /**
+ * JCR_IDX_VALUE_PROPERTY.
+ */
+ protected String JCR_IDX_VALUE_PROPERTY;
+
+ /**
+ * JCR_PK_REF.
+ */
+ protected String JCR_PK_REF;
+
+ /**
+ * JCR_IDX_REF_PROPERTY.
+ */
+ protected String JCR_IDX_REF_PROPERTY;
+
+ // ======================== SQL scripts ========================
+ /**
+ * FIND_ITEM_BY_ID.
+ */
+ protected String FIND_ITEM_BY_ID;
+
+ /**
+ * FIND_ITEM_BY_PATH.
+ */
+ protected String FIND_ITEM_BY_PATH;
+
+ /**
+ * FIND_ITEM_BY_NAME.
+ */
+ protected String FIND_ITEM_BY_NAME;
+
+ /**
+ * FIND_CHILD_PROPERTY_BY_PATH.
+ */
+ protected String FIND_CHILD_PROPERTY_BY_PATH;
+
+ /**
+ * FIND_PROPERTY_BY_NAME.
+ */
+ protected String FIND_PROPERTY_BY_NAME;
+
+ /**
+ * FIND_REFERENCES.
+ */
+ protected String FIND_REFERENCES;
+
+ /**
+ * FIND_VALUES_BY_PROPERTYID.
+ */
+ protected String FIND_VALUES_BY_PROPERTYID;
+
+ /**
+ * FIND_VALUE_BY_PROPERTYID_OREDERNUMB.
+ */
+ protected String FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID;
+
+ /**
+ * FIND_VALUE_BY_PROPERTYID_OREDERNUMB.
+ */
+ protected String FIND_VALUE_BY_PROPERTYID_OREDERNUMB;
+
+ /**
+ * FIND_NODES_BY_PARENTID.
+ */
+ protected String FIND_NODES_BY_PARENTID;
+
+ /**
+ * FIND_LAST_ORDER_NUMBER_BY_PARENTID.
+ */
+ protected String FIND_LAST_ORDER_NUMBER_BY_PARENTID;
+
+ /**
+ * FIND_NODES_COUNT_BY_PARENTID.
+ */
+ protected String FIND_NODES_COUNT_BY_PARENTID;
+
+ /**
+ * FIND_PROPERTIES_BY_PARENTID.
+ */
+ protected String FIND_PROPERTIES_BY_PARENTID;
+
+ /**
+ * FIND_LOWEST_PROPERTY_VERSIONS.
+ */
+ protected String FIND_LOWEST_PROPERTY_VERSIONS;
+
+ /**
+ * INSERT_NODE.
+ */
+ protected String INSERT_NODE;
+
+ /**
+ * INSERT_PROPERTY.
+ */
+ protected String INSERT_PROPERTY;
+
+ /**
+ * INSERT_VALUE.
+ */
+ protected String INSERT_VALUE;
+
+ /**
+ * INSERT_REF.
+ */
+ protected String INSERT_REF;
+
+ /**
+ * RENAME_NODE.
+ */
+ protected String RENAME_NODE;
+
+ /**
+ * UPDATE_NODE.
+ */
+ protected String UPDATE_NODE;
+
+ /**
+ * UPDATE_PROPERTY.
+ */
+ protected String UPDATE_PROPERTY;
+
+ /**
+ * DELETE_ITEM.
+ */
+ protected String DELETE_ITEM;
+
+ /**
+ * DELETE_VALUE.
+ */
+ protected String DELETE_VALUE;
+
+ /**
+ * DELETE_REF.
+ */
+ protected String DELETE_REF;
+
+ /**
+ * FIND_NODES.
+ */
+ protected String FIND_NODES_AND_PROPERTIES;
+
+ /**
+ * FIND_NODES_COUNT
+ */
+ protected String FIND_NODES_COUNT;
+
+ // ======================== ITEMS table ========================
+ /**
+ * COLUMN_ID.
+ */
+ public static final String COLUMN_ID = "ID";
+
+ /**
+ * COLUMN_PARENTID.
+ */
+ public static final String COLUMN_PARENTID = "PARENT_ID";
+
+ /**
+ * COLUMN_NAME.
+ */
+ public static final String COLUMN_NAME = "NAME";
+
+ /**
+ * COLUMN_VERSION.
+ */
+ public static final String COLUMN_VERSION = "VERSION";
+
+ /**
+ * CONTAINER_NAME. Exists only for single-db.
+ */
+ public static final String CONTAINER_NAME = "CONTAINER_NAME";
+
+ /**
+ * COLUMN_CLASS.
+ */
+ public static final String COLUMN_CLASS = "I_CLASS";
+
+ /**
+ * COLUMN_INDEX.
+ */
+ public static final String COLUMN_INDEX = "I_INDEX";
+
+ /**
+ * COLUMN_NORDERNUM.
+ */
+ public static final String COLUMN_NORDERNUM = "N_ORDER_NUM";
+
+ /**
+ * COLUMN_PTYPE.
+ */
+ public static final String COLUMN_PTYPE = "P_TYPE";
+
+ /**
+ * COLUMN_PMULTIVALUED.
+ */
+ public static final String COLUMN_PMULTIVALUED = "P_MULTIVALUED";
+
+ // VALUE table
+ /**
+ * PROPERTY_ID
+ */
+ public static final String COLUMN_VPROPERTY_ID = "PROPERTY_ID";
+
+ /**
+ * COLUMN_VDATA.
+ */
+ public static final String COLUMN_VDATA = "DATA";
+
+ /**
+ * COLUMN_VORDERNUM.
+ */
+ public static final String COLUMN_VORDERNUM = "ORDER_NUM";
+
+ /**
+ * COLUMN_VSTORAGE_DESC.
+ */
+ public static final String COLUMN_VSTORAGE_DESC = "STORAGE_DESC";
+
+}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java.orig 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,2776 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc;
+
+import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.services.jcr.access.AccessControlEntry;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
+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.ItemType;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NodeDataIndexing;
+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.core.itemfilters.QPathEntryFilter;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.ACLHolder;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFilePersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
+import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SwapFile;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
+ * @version $Id: JDBCStorageConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ */
+public abstract class JDBCStorageConnection extends DBConstants implements WorkspaceStorageConnection
+{
+
+ /**
+ * Helper.
+ */
+ protected class WriteValueHelper extends ValueFileIOHelper
+ {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void writeStreamedValue(File file, ValueData value) throws IOException
+ {
+ super.writeStreamedValue(file, value);
+ }
+ }
+
+ /**
+ * Connection logger.
+ */
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JDBCStorageConnection");
+
+ /**
+ * NODE type.
+ */
+ public static final int I_CLASS_NODE = 1;
+
+ /**
+ * PROPERTY type.
+ */
+ public static final int I_CLASS_PROPERTY = 2;
+
+ protected final ValueStoragePluginProvider valueStorageProvider;
+
+ protected final int maxBufferSize;
+
+ protected final File swapDirectory;
+
+ protected final FileCleaner swapCleaner;
+
+ protected final Connection dbConnection;
+
+ protected final String containerName;
+
+ protected final SQLExceptionHandler exceptionHandler;
+
+ protected final List<ValueIOChannel> valueChanges;
+
+ protected final WriteValueHelper writeValueHelper = new WriteValueHelper();
+
+ // All statements should be closed in closeStatements() method.
+
+ protected PreparedStatement findItemById;
+
+ protected PreparedStatement findItemByPath;
+
+ protected PreparedStatement findItemByName;
+
+ protected PreparedStatement findChildPropertyByPath;
+
+ protected PreparedStatement findPropertyByName;
+
+ protected PreparedStatement findDescendantNodes;
+
+ protected PreparedStatement findDescendantProperties;
+
+ protected PreparedStatement findReferences;
+
+ protected PreparedStatement findValuesByPropertyId;
+
+ protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+
+ protected PreparedStatement findValuesDataByPropertyId;
+
+ protected PreparedStatement findValueByPropertyIdOrderNumber;
+
+ protected PreparedStatement findNodesByParentId;
+
+ protected PreparedStatement findLastOrderNumberByParentId;
+
+ protected PreparedStatement findNodesCountByParentId;
+
+ protected PreparedStatement findPropertiesByParentId;
+
+ protected PreparedStatement findLowestPropertyVersions;
+
+ protected PreparedStatement insertItem;
+
+ protected PreparedStatement insertNode;
+
+ protected PreparedStatement insertProperty;
+
+ protected PreparedStatement insertReference;
+
+ protected PreparedStatement insertValue;
+
+ protected PreparedStatement updateItem;
+
+ protected PreparedStatement updateItemPath;
+
+ protected PreparedStatement updateNode;
+
+ protected PreparedStatement updateProperty;
+
+ protected PreparedStatement deleteItem;
+
+ protected PreparedStatement deleteNode;
+
+ protected PreparedStatement deleteProperty;
+
+ protected PreparedStatement deleteReference;
+
+ protected PreparedStatement deleteValue;
+
+ protected PreparedStatement renameNode;
+
+ protected PreparedStatement findNodesAndProperties;
+
+ protected PreparedStatement findNodesCount;
+
+ /**
+ * Read-only flag, if true the connection is marked as READ-ONLY.
+ */
+ protected final boolean readOnly;
+
+ /**
+ * 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 JDBCStorageConnection(Connection dbConnection, boolean readOnly, String containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ this.valueStorageProvider = valueStorageProvider;
+
+ this.maxBufferSize = maxBufferSize;
+ this.swapDirectory = swapDirectory;
+ this.swapCleaner = swapCleaner;
+ this.containerName = containerName;
+
+ this.dbConnection = dbConnection;
+ this.readOnly = readOnly;
+
+ if (!readOnly && dbConnection.getAutoCommit())
+ {
+ dbConnection.setAutoCommit(false);
+ }
+
+ prepareQueries();
+ this.exceptionHandler = new SQLExceptionHandler(containerName, this);
+
+ this.valueChanges = new ArrayList<ValueIOChannel>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof JDBCStorageConnection)
+ {
+ JDBCStorageConnection another = (JDBCStorageConnection)obj;
+ return getJdbcConnection() == another.getJdbcConnection();
+ }
+
+ return false;
+ }
+
+ /**
+ * Return JDBC connection obtained from initialized data source. NOTE: Helper can obtain one new
+ * connection per each call of the method or return one obtained once.
+ */
+ public Connection getJdbcConnection()
+ {
+ return dbConnection;
+ }
+
+ /**
+ * Prepared queries at start time.
+ *
+ * @throws SQLException
+ * database error
+ */
+ abstract protected void prepareQueries() throws SQLException;
+
+ /**
+ * Used in Single Db Connection classes for Identifier related queries.
+ *
+ * @param identifier
+ * Item id
+ * @return String with container internal id
+ */
+ protected abstract String getInternalId(String identifier);
+
+ /**
+ * Used in loadXYZRecord methods for extract real Identifier from container value.
+ *
+ * @param internalId
+ * @return
+ */
+ protected abstract String getIdentifier(String internalId);
+
+ // ---------------- WorkspaceStorageConnection -------------
+
+ /**
+ * @throws IllegalStateException
+ * if connection is closed.
+ */
+ protected void checkIfOpened() throws IllegalStateException
+ {
+ if (!isOpened())
+ {
+ throw new IllegalStateException("Connection is closed");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isOpened()
+ {
+ try
+ {
+ return !dbConnection.isClosed();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("An exception occured: " + e.getMessage());
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void rollback() throws IllegalStateException, RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ closeStatements();
+
+ if (!readOnly)
+ {
+ dbConnection.rollback();
+ }
+
+ dbConnection.close();
+
+ // rollback from the end
+ for (int p = valueChanges.size() - 1; p >= 0; p--)
+ {
+ valueChanges.get(p).rollback();
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ valueChanges.clear();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void close() throws IllegalStateException, RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ closeStatements();
+
+ if (!readOnly && dbConnection.getTransactionIsolation() > Connection.TRANSACTION_READ_COMMITTED)
+ {
+ dbConnection.rollback();
+ }
+
+ dbConnection.close();
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Close all statements.
+ *
+ * @throws SQLException
+ */
+ protected void closeStatements()
+ {
+ try
+ {
+ if (findItemById != null)
+ {
+ findItemById.close();
+ }
+
+ if (findItemByPath != null)
+ {
+ findItemByPath.close();
+ }
+
+ if (findItemByName != null)
+ {
+ findItemByName.close();
+ }
+
+ if (findChildPropertyByPath != null)
+ {
+ findChildPropertyByPath.close();
+ }
+
+ if (findPropertyByName != null)
+ {
+ findPropertyByName.close();
+ }
+
+ if (findDescendantNodes != null)
+ {
+ findDescendantNodes.close();
+ }
+
+ if (findDescendantProperties != null)
+ {
+ findDescendantProperties.close();
+ }
+
+ if (findReferences != null)
+ {
+ findReferences.close();
+ }
+
+ if (findValuesByPropertyId != null)
+ {
+ findValuesByPropertyId.close();
+ }
+
+ if (findValuesStorageDescriptorsByPropertyId != null)
+ {
+ findValuesStorageDescriptorsByPropertyId.close();
+ }
+
+ if (findValuesDataByPropertyId != null)
+ {
+ findValuesDataByPropertyId.close();
+ }
+
+ if (findValueByPropertyIdOrderNumber != null)
+ {
+ findValueByPropertyIdOrderNumber.close();
+ }
+
+ if (findNodesByParentId != null)
+ {
+ findNodesByParentId.close();
+ }
+
+ if (findLastOrderNumberByParentId != null)
+ {
+ findLastOrderNumberByParentId.close();
+ }
+
+ if (findNodesCountByParentId != null)
+ {
+ findNodesCountByParentId.close();
+ }
+
+ if (findPropertiesByParentId != null)
+ {
+ findPropertiesByParentId.close();
+ }
+
+ if (findLowestPropertyVersions != null)
+ {
+ findLowestPropertyVersions.close();
+ }
+
+ if (insertItem != null)
+ {
+ insertItem.close();
+ }
+
+ if (insertNode != null)
+ {
+ insertNode.close();
+ }
+
+ if (insertProperty != null)
+ {
+ insertProperty.close();
+ }
+
+ if (insertReference != null)
+ {
+ insertReference.close();
+ }
+
+ if (insertValue != null)
+ {
+ insertValue.close();
+ }
+
+ if (updateItem != null)
+ {
+ updateItem.close();
+ }
+
+ if (updateItemPath != null)
+ {
+ updateItemPath.close();
+ }
+
+ if (updateNode != null)
+ {
+ updateNode.close();
+ }
+
+ if (updateProperty != null)
+ {
+ updateProperty.close();
+ }
+
+ if (deleteItem != null)
+ {
+ deleteItem.close();
+ }
+
+ if (deleteNode != null)
+ {
+ deleteNode.close();
+ }
+
+ if (deleteProperty != null)
+ {
+ deleteProperty.close();
+ }
+
+ if (deleteReference != null)
+ {
+ deleteReference.close();
+ }
+
+ if (deleteValue != null)
+ {
+ deleteValue.close();
+ }
+
+ if (renameNode != null)
+ {
+ renameNode.close();
+ }
+
+ if (findNodesAndProperties != null)
+ {
+ findNodesAndProperties.close();
+ }
+
+ if (findNodesCount != null)
+ {
+ findNodesCount.close();
+ }
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the statement: " + e.getMessage());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void commit() throws IllegalStateException, RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ closeStatements();
+
+ if (!this.readOnly)
+ {
+ dbConnection.commit();
+ }
+
+ dbConnection.close();
+
+ try
+ {
+ for (ValueIOChannel vo : valueChanges)
+ {
+ vo.commit();
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ valueChanges.clear();
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
+ IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ addNodeRecord(data);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Node added " + data.getQPath().getAsString() + ", " + data.getIdentifier() + ", "
+ + data.getPrimaryTypeName().getAsString());
+ }
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Node add. Database error: " + e);
+ }
+
+ exceptionHandler.handleAddException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ try
+ {
+ addPropertyRecord(data);
+
+ if (data.getType() == PropertyType.REFERENCE)
+ {
+ try
+ {
+ addReference(data);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("Can't read REFERENCE property (" + data.getQPath() + " "
+ + data.getIdentifier() + ") value: " + e.getMessage(), e);
+ }
+ }
+
+ addValues(getInternalId(data.getIdentifier()), data);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Property added " + data.getQPath().getAsString() + ", " + data.getIdentifier()
+ + (data.getValues() != null ? ", values count: " + data.getValues().size() : ", NULL data"));
+ }
+
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property add. IO error: " + e, e);
+ }
+ throw new RepositoryException("Error of Property Value add " + e, e);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property add. Database error: " + e, e);
+ }
+ exceptionHandler.handleAddException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+
+ checkIfOpened();
+ try
+ {
+ if (renameNode(data) <= 0)
+ {
+ throw new JCRInvalidItemStateException("(rename) Node not found " + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
+ ItemState.RENAMED);
+ }
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property add. Database error: " + e, e);
+ }
+ exceptionHandler.handleAddException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ final String cid = getInternalId(data.getIdentifier());
+
+ try
+ {
+ int nc = deleteItemByIdentifier(cid);
+ if (nc <= 0)
+ {
+ throw new JCRInvalidItemStateException("(delete) Node not found " + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
+ ItemState.DELETED);
+ }
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Node deleted " + data.getQPath().getAsString() + ", " + data.getIdentifier() + ", "
+ + (data).getPrimaryTypeName().getAsString());
+ }
+
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Node remove. Database error: " + e, e);
+ }
+ exceptionHandler.handleDeleteException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ final String cid = getInternalId(data.getIdentifier());
+
+ try
+ {
+ deleteValues(cid, data, false);
+
+ // delete references
+ deleteReference(cid);
+
+ // delete item
+ int nc = deleteItemByIdentifier(cid);
+ if (nc <= 0)
+ {
+ throw new JCRInvalidItemStateException("(delete) Property not found " + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
+ ItemState.DELETED);
+ }
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Property deleted " + data.getQPath().getAsString() + ", " + data.getIdentifier()
+ + ((data).getValues() != null ? ", values count: " + (data).getValues().size() : ", NULL data"));
+ }
+
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property remove. IO error: " + e, e);
+ }
+ throw new RepositoryException("Error of Property Value delete " + e, e);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property remove. Database error: " + e, e);
+ }
+ exceptionHandler.handleDeleteException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ String cid = getInternalId(data.getIdentifier());
+ // order numb update
+ if (updateNodeByIdentifier(data.getPersistedVersion(), data.getQPath().getIndex(), data.getOrderNumber(), cid) <= 0)
+ {
+ throw new JCRInvalidItemStateException("(update) Node not found " + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
+ ItemState.UPDATED);
+ }
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Node updated " + data.getQPath().getAsString() + ", " + data.getIdentifier() + ", "
+ + data.getPrimaryTypeName().getAsString());
+ }
+
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Node update. Database error: " + e, e);
+ }
+ exceptionHandler.handleUpdateException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ checkIfOpened();
+
+ try
+ {
+ String cid = getInternalId(data.getIdentifier());
+
+ // update type
+ if (updatePropertyByIdentifier(data.getPersistedVersion(), data.getType(), cid) <= 0)
+ {
+ throw new JCRInvalidItemStateException("(update) Property not found " + data.getQPath().getAsString() + " "
+ + data.getIdentifier() + ". Probably was deleted by another session ", data.getIdentifier(),
+ ItemState.UPDATED);
+ }
+
+ // update reference
+ try
+ {
+ deleteReference(cid);
+
+ if (data.getType() == PropertyType.REFERENCE)
+ {
+ addReference(data);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("Can't update REFERENCE property (" + data.getQPath() + " "
+ + data.getIdentifier() + ") value: " + e.getMessage(), e);
+ }
+
+ // do Values update: delete all and add all
+ deleteValues(cid, data, true);
+ addValues(cid, data);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Property updated " + data.getQPath().getAsString() + ", " + data.getIdentifier()
+ + (data.getValues() != null ? ", values count: " + data.getValues().size() : ", NULL data"));
+ }
+
+ }
+ catch (IOException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property update. IO error: " + e, e);
+ }
+ throw new RepositoryException("Error of Property Value update " + e, e);
+ }
+ catch (SQLException e)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.error("Property update. Database error: " + e, e);
+ }
+ exceptionHandler.handleUpdateException(e, data);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet node = findChildNodesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ try
+ {
+ List<NodeData> childrens = new ArrayList<NodeData>();
+ while (node.next())
+ {
+ childrens.add((NodeData)itemData(parent.getQPath(), node, I_CLASS_NODE, parent.getACL()));
+ }
+
+ return childrens;
+ }
+ finally
+ {
+ try
+ {
+ node.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<NodeData> getChildNodesData(NodeData parent, List<QPathEntryFilter> pattern) throws RepositoryException,
+ IllegalStateException
+ {
+ //return all child nodes by default
+ return getChildNodesData(parent);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLastOrderNumber(NodeData parent) throws RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet count = findLastOrderNumberByParentIdentifier(getInternalId(parent.getIdentifier()));
+ try
+ {
+ if (count.next() && count.getInt(1) > 0)
+ {
+ return count.getInt(2);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ finally
+ {
+ try
+ {
+ count.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent) throws RepositoryException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet count = findChildNodesCountByParentIdentifier(getInternalId(parent.getIdentifier()));
+ try
+ {
+ if (count.next())
+ {
+ return count.getInt(1);
+ }
+ else
+ {
+ throw new RepositoryException("FATAL No resulton childNodes count for "
+ + parent.getQPath().getAsString());
+ }
+ }
+ finally
+ {
+ try
+ {
+ count.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet prop = findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ try
+ {
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ {
+ children.add((PropertyData)itemData(parent.getQPath(), prop, I_CLASS_PROPERTY, null));
+ }
+
+ return children;
+ }
+ finally
+ {
+ try
+ {
+ prop.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> getChildPropertiesData(NodeData parent, List<QPathEntryFilter> itemDataFilter)
+ throws RepositoryException, IllegalStateException
+ {
+ //return all child properties by default
+ return getChildPropertiesData(parent);
+ }
+
+ /**
+ * Returns from storage the next page of nodes and its properties.
+ */
+ public List<NodeDataIndexing> getNodesAndProperties(String lastNodeId, int offset, int limit)
+ throws RepositoryException, IllegalStateException
+ {
+ List<NodeDataIndexing> result = new ArrayList<NodeDataIndexing>();
+
+ checkIfOpened();
+ try
+ {
+ ResultSet resultSet = findNodesAndProperties(lastNodeId, offset, limit);
+ int processed = 0;
+
+ try
+ {
+ TempNodeData tempNodeData = null;
+
+ while (resultSet.next())
+ {
+ if (tempNodeData == null)
+ {
+ tempNodeData = new TempNodeData(resultSet);
+ processed++;
+ }
+ else if (!resultSet.getString(COLUMN_ID).equals(tempNodeData.cid))
+ {
+ if (!needToSkipOffsetNodes() || processed > offset)
+ {
+ result.add(createNodeDataIndexing(tempNodeData));
+ }
+
+ tempNodeData = new TempNodeData(resultSet);
+ processed++;
+ }
+
+ if (!needToSkipOffsetNodes() || processed > offset)
+ {
+ String key = resultSet.getString("P_NAME");
+
+ SortedSet<TempPropertyData> values = tempNodeData.properties.get(key);
+ if (values == null)
+ {
+ values = new TreeSet<TempPropertyData>();
+ tempNodeData.properties.put(key, values);
+ }
+
+ values.add(new ExtendedTempPropertyData(resultSet));
+ }
+ }
+
+ if (tempNodeData != null && (!needToSkipOffsetNodes() || processed > offset))
+ {
+ result.add(createNodeDataIndexing(tempNodeData));
+ }
+ }
+ finally
+ {
+ try
+ {
+ resultSet.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ return result;
+ }
+
+ /**
+ * Some implementations could require to skip first 'offset' nodes from
+ * result set.
+ */
+ protected boolean needToSkipOffsetNodes()
+ {
+ return false;
+ }
+
+ /**
+ *
+ * @param parent
+ * @param lastOrderNum
+ * @param limit
+ * @return
+ * @throws RepositoryException
+ * @throws IllegalStateException
+ */
+ public boolean getChildNodesDataByPage(NodeData parent, int fromOrderNum, int toOrderNum, List<NodeData> childNodes)
+ throws RepositoryException, IllegalStateException
+ {
+ // not supported by non-CQ deprecated JDBC container
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet prop = findChildPropertiesByParentIdentifier(getInternalId(parent.getIdentifier()));
+ try
+ {
+ List<PropertyData> children = new ArrayList<PropertyData>();
+ while (prop.next())
+ {
+ children.add(propertyData(parent.getQPath(), prop));
+ }
+
+ return children;
+ }
+ finally
+ {
+ try
+ {
+ prop.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<ACLHolder> getACLHolders() throws RepositoryException, IllegalStateException,
+ UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException(
+ "This method is not supported by the old JDBCWorkspaceDataContainer, use CQJDBCWorkspaceDataContainer instead.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+ {
+ return getItemByIdentifier(getInternalId(identifier));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException
+ {
+
+ if (parentData != null)
+ {
+ return getItemByName(parentData, getInternalId(parentData.getIdentifier()), name, itemType);
+ }
+
+ // it's a root node
+ return getItemByName(null, null, name, itemType);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet refProps = findReferences(getInternalId(nodeIdentifier));
+ try
+ {
+ List<PropertyData> references = new ArrayList<PropertyData>();
+ while (refProps.next())
+ {
+ references.add((PropertyData)itemData(null, refProps, I_CLASS_PROPERTY, null));
+ }
+ return references;
+ }
+ finally
+ {
+ try
+ {
+ refProps.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Reads Property Value from persistent storage.
+ *
+ * @param propertyId String, Property id
+ * @param orderNumb int, Value order number (in list of values)
+ * @param persistedVersion int
+ * @return ValueData
+ * @throws RepositoryException if read error occurs
+ */
+ public ValueData getValue(String propertyId, int orderNumb, int persistedVersion) throws RepositoryException
+ {
+ try
+ {
+ String cid = getInternalId(propertyId);
+ ResultSet valueRecord = findValueByPropertyIdOrderNumber(cid, orderNumb);
+ try
+ {
+ if (valueRecord.next())
+ {
+ String storageId = valueRecord.getString(COLUMN_VSTORAGE_DESC);
+ return valueRecord.wasNull() ? readValueData(cid, orderNumb, persistedVersion, valueRecord
+ .getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb, storageId);
+ }
+
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ valueRecord.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet ", e);
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Reads count of nodes in workspace.
+ *
+ * @return
+ * nodes count
+ * @throws RepositoryException
+ * if a database access error occurs
+ */
+ public long getNodesCount() throws RepositoryException
+ {
+ ResultSet countNodes;
+ try
+ {
+ countNodes = findNodesCount();
+ if (countNodes.next())
+ {
+ return countNodes.getLong(1);
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+
+ throw new RepositoryException("Can not calculate nodes count");
+ }
+
+ // ------------------ Private methods ---------------
+
+ /**
+ * 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();
+ try
+ {
+ ResultSet item = findItemByIdentifier(cid);
+ try
+ {
+ if (item.next())
+ {
+ return itemData(null, item, item.getInt(COLUMN_CLASS), null);
+ }
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ item.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException("getItemData() error", e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("getItemData() error", e);
+ }
+ }
+
+ /**
+ * 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
+ * @param itemType
+ * - item type
+ * @return - ItemData instance
+ * @throws RepositoryException
+ * Repository error
+ * @throws IllegalStateException
+ * if connection is closed
+ */
+ protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name, ItemType itemType)
+ throws RepositoryException, IllegalStateException
+ {
+ checkIfOpened();
+ try
+ {
+ ResultSet item = null;
+ try
+ {
+ item = findItemByName(parentId, name.getAsString(), name.getIndex());
+ while (item.next())
+ {
+ int columnClass = item.getInt(COLUMN_CLASS);
+ if (itemType == ItemType.UNKNOWN || columnClass == itemType.ordinal())
+ {
+ return itemData(parent.getQPath(), item, columnClass, parent.getACL());
+ }
+ }
+
+ return null;
+ }
+ finally
+ {
+ try
+ {
+ if (item != null)
+ {
+ item.close();
+ }
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Build Item path by id.
+ *
+ * @param cpid
+ * - Item id (container id)
+ * @return Item QPath
+ * @throws SQLException
+ * - if database error occurs
+ * @throws InvalidItemStateException
+ * - if parent not found
+ * @throws IllegalNameException
+ * - if name on the path is wrong
+ */
+ protected QPath traverseQPath(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ {
+ return traverseQPathSQ(cpid);
+ }
+
+ /**
+ * The method <code>traverseQPath</code> implemented thanks to simple queries. It allows
+ * to use Simple Queries instead of Complex Queries when complex queries are much slower such
+ * as with HSQLDB for example.
+ */
+ protected QPath traverseQPathSQ(String cpid) throws SQLException, InvalidItemStateException, IllegalNameException
+ {
+ // get item by Identifier usecase
+ List<QPathEntry> qrpath = new ArrayList<QPathEntry>(); // reverted path
+ String caid = cpid; // container ancestor id
+ do
+ {
+ ResultSet parent = findItemByIdentifier(caid);
+ try
+ {
+ if (!parent.next())
+ {
+ throw new InvalidItemStateException("Parent not found, uuid: " + getIdentifier(caid));
+ }
+
+ QPathEntry qpe =
+ new QPathEntry(InternalQName.parse(parent.getString(COLUMN_NAME)), parent.getInt(COLUMN_INDEX), caid);
+ qrpath.add(qpe);
+ caid = parent.getString(COLUMN_PARENTID);
+ }
+ finally
+ {
+ try
+ {
+ parent.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ while (!caid.equals(Constants.ROOT_PARENT_UUID));
+
+ QPathEntry[] qentries = new QPathEntry[qrpath.size()];
+ int qi = 0;
+ for (int i = qrpath.size() - 1; i >= 0; i--)
+ {
+ qentries[qi++] = qrpath.get(i);
+ }
+ return new QPath(qentries);
+ }
+
+ /**
+ * ItemLocationInfo.
+ *
+ */
+ class ItemLocationInfo
+ {
+ /**
+ * Item qpath
+ */
+ final QPath qpath;
+
+ /**
+ * All ancestors of the item with qpath
+ */
+ final List<String> ancestors;
+
+ /**
+ * Item id.
+ */
+ final String itemId;
+
+ /**
+ * ItemLocationInfo constructor.
+ *
+ * @param qpath
+ * Item path
+ * @param ancestors
+ * ancesstors id list
+ * @param itemId
+ * Item id
+ */
+ ItemLocationInfo(QPath qpath, List<String> ancestors, String itemId)
+ {
+ this.qpath = qpath;
+ this.ancestors = ancestors;
+ this.itemId = itemId;
+ }
+ }
+
+ protected String findParentId(String cid) throws SQLException, RepositoryException
+ {
+ ResultSet pidrs = findItemByIdentifier(cid);
+ try
+ {
+ if (pidrs.next())
+ {
+ return pidrs.getString(COLUMN_PARENTID);
+ }
+ else
+ {
+ throw new RepositoryException("Item not found id: " + getIdentifier(cid));
+ }
+ }
+ finally
+ {
+ try
+ {
+ pidrs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Build ItemData.
+ *
+ * @param parentPath
+ * - parent path
+ * @param item
+ * database - ResultSet with Item record(s)
+ * @param itemClass
+ * - Item type (Node or Property)
+ * @param parentACL
+ * - parent ACL
+ * @return ItemData instance
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ */
+ private ItemData itemData(QPath parentPath, ResultSet item, int itemClass, AccessControlList parentACL)
+ throws RepositoryException, SQLException, IOException
+ {
+ String cid = item.getString(COLUMN_ID);
+ String cname = item.getString(COLUMN_NAME);
+ int cversion = item.getInt(COLUMN_VERSION);
+
+ String cpid = item.getString(COLUMN_PARENTID);
+ // if parent ID is empty string - it's a root node
+ // cpid = cpid.equals(Constants.ROOT_PARENT_UUID) ? null : cpid;
+
+ try
+ {
+ if (itemClass == I_CLASS_NODE)
+ {
+ int cindex = item.getInt(COLUMN_INDEX);
+ int cnordernumb = item.getInt(COLUMN_NORDERNUM);
+ return loadNodeRecord(parentPath, cname, cid, cpid, cindex, cversion, cnordernumb, parentACL);
+ }
+
+ int cptype = item.getInt(COLUMN_PTYPE);
+ boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
+ return loadPropertyRecord(parentPath, cname, cid, cpid, cversion, cptype, cpmultivalued);
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new InvalidItemStateException("FATAL: Can't build item path for name " + cname + " id: "
+ + getIdentifier(cid) + ". " + e);
+ }
+ }
+
+ /**
+ * Read property data without value data. For listChildPropertiesData(NodeData).
+ *
+ * @param parentPath
+ * - parent path
+ * @param item
+ * database - ResultSet with Item record(s)
+ * @return PropertyData instance
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ */
+ private PropertyData propertyData(QPath parentPath, ResultSet item) throws RepositoryException, SQLException,
+ IOException
+ {
+ String cid = item.getString(COLUMN_ID);
+ String cname = item.getString(COLUMN_NAME);
+ int cversion = item.getInt(COLUMN_VERSION);
+ String cpid = item.getString(COLUMN_PARENTID);
+ int cptype = item.getInt(COLUMN_PTYPE);
+ boolean cpmultivalued = item.getBoolean(COLUMN_PMULTIVALUED);
+
+ try
+ {
+ InternalQName qname = InternalQName.parse(cname);
+
+ QPath qpath = QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath, qname);
+
+ PersistedPropertyData pdata =
+ new PersistedPropertyData(getIdentifier(cid), qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued,
+ new ArrayList<ValueData>());
+
+ return pdata;
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new InvalidItemStateException("FATAL: Can't build property path for name " + cname + " id: "
+ + getIdentifier(cid) + ". " + e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Mixin types description (internal use).
+ *
+ */
+ public class MixinInfo
+ {
+
+ /**
+ * OWNEABLE constant.
+ */
+ static final int OWNEABLE = 0x0001; // bits 0001
+
+ /**
+ * PRIVILEGEABLE constant.
+ */
+ static final int PRIVILEGEABLE = 0x0002; // bits 0010
+
+ /**
+ * OWNEABLE_PRIVILEGEABLE constant.
+ */
+ static final int OWNEABLE_PRIVILEGEABLE = OWNEABLE | PRIVILEGEABLE; // bits 0011
+
+ /**
+ * Mixin types.
+ */
+ final List<InternalQName> mixinTypes;
+
+ /**
+ * oexo:owneable flag.
+ */
+ final boolean owneable;
+
+ /**
+ * exo:privilegeable flag.
+ */
+ final boolean privilegeable;
+
+ /**
+ * Parent Id.
+ */
+ final String parentId = null;
+
+ /**
+ * MixinInfo constructor.
+ *
+ * @param mixinTypes
+ * mixin types
+ * @param owneable
+ * exo:owneable flag
+ * @param privilegeable
+ * exo:privilegeable flag
+ */
+ public MixinInfo(List<InternalQName> mixinTypes, boolean owneable, boolean privilegeable)
+ {
+ this.mixinTypes = mixinTypes;
+ this.owneable = owneable;
+ this.privilegeable = privilegeable;
+ }
+
+ /**
+ * Return Mixin names array.
+ *
+ * @return InternalQName[] Mixin names array
+ */
+ public InternalQName[] mixinNames()
+ {
+ if (mixinTypes != null)
+ {
+ InternalQName[] mns = new InternalQName[mixinTypes.size()];
+ mixinTypes.toArray(mns);
+ return mns;
+ }
+ else
+ {
+ return new InternalQName[0];
+ }
+ }
+
+ /**
+ * Tell is exo:privilegeable.
+ *
+ * @return boolean
+ */
+ public boolean hasPrivilegeable()
+ {
+ return privilegeable;
+ }
+
+ /**
+ * Tell is exo:owneable.
+ *
+ * @return boolean
+ */
+ public boolean hasOwneable()
+ {
+ return owneable;
+ }
+
+ public String getParentId()
+ {
+ return parentId;
+ }
+ }
+
+ /**
+ * Read mixins from database.
+ *
+ * @param cid
+ * - Item id (internal)
+ * @return MixinInfo
+ * @throws SQLException
+ * database error
+ * @throws IllegalNameException
+ * if nodetype name in mixin record is wrong
+ */
+ protected MixinInfo readMixins(String cid) throws SQLException, IllegalNameException
+ {
+ ResultSet mtrs = findPropertyByName(cid, Constants.JCR_MIXINTYPES.getAsString());
+
+ try
+ {
+ List<InternalQName> mts = null;
+ boolean owneable = false;
+ boolean privilegeable = false;
+ if (mtrs.next())
+ {
+ mts = new ArrayList<InternalQName>();
+ do
+ {
+ byte[] mxnb = mtrs.getBytes(COLUMN_VDATA);
+ if (mxnb != null)
+ {
+ InternalQName mxn = InternalQName.parse(new String(mxnb));
+ mts.add(mxn);
+
+ if (!privilegeable && Constants.EXO_PRIVILEGEABLE.equals(mxn))
+ {
+ privilegeable = true;
+ }
+ else if (!owneable && Constants.EXO_OWNEABLE.equals(mxn))
+ {
+ owneable = true;
+ }
+ } // else, if SQL NULL - skip it
+ }
+ while (mtrs.next());
+ }
+
+ return new MixinInfo(mts, owneable, privilegeable);
+ }
+ finally
+ {
+ try
+ {
+ mtrs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Return permission values or throw an exception. We assume the node is mix:privilegeable.
+ *
+ * @param cid
+ * Node id
+ * @return list of ACL entries
+ * @throws SQLException
+ * database error
+ * @throws IllegalACLException
+ * if property exo:permissions is not found for node
+ */
+ protected List<AccessControlEntry> readACLPermisions(String cid) throws SQLException, IllegalACLException
+ {
+ List<AccessControlEntry> naPermissions = new ArrayList<AccessControlEntry>();
+ ResultSet exoPerm = findPropertyByName(cid, Constants.EXO_PERMISSIONS.getAsString());
+ try
+ {
+ if (exoPerm.next())
+ {
+ do
+ {
+ StringTokenizer parser =
+ new StringTokenizer(new String(exoPerm.getBytes(COLUMN_VDATA)), AccessControlEntry.DELIMITER);
+ naPermissions.add(new AccessControlEntry(parser.nextToken(), parser.nextToken()));
+ }
+ while (exoPerm.next());
+
+ return naPermissions;
+ }
+ else
+ {
+ throw new IllegalACLException("Property exo:permissions is not found for node with id: "
+ + getIdentifier(cid));
+ }
+ }
+ finally
+ {
+ try
+ {
+ exoPerm.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Return owner value or throw an exception. We assume the node is mix:owneable.
+ *
+ * @param cid
+ * Node id
+ * @return ACL owner
+ * @throws SQLException
+ * database error
+ * @throws IllegalACLException
+ * Property exo:owner is not found for node
+ */
+ protected String readACLOwner(String cid) throws SQLException, IllegalACLException
+ {
+ ResultSet exoOwner = findPropertyByName(cid, Constants.EXO_OWNER.getAsString());
+ try
+ {
+ if (exoOwner.next())
+ {
+ return new String(exoOwner.getBytes(COLUMN_VDATA));
+ }
+ else
+ {
+ throw new IllegalACLException("Property exo:owner is not found for node with id: " + getIdentifier(cid));
+ }
+ }
+ finally
+ {
+ try
+ {
+ exoOwner.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Load NodeData record.
+ *
+ * @param parentPath
+ * parent path
+ * @param cname
+ * Node name
+ * @param cid
+ * Node id
+ * @param cpid
+ * Node parent id
+ * @param cindex
+ * Node index
+ * @param cversion
+ * Node persistent version
+ * @param cnordernumb
+ * Node order number
+ * @param parentACL
+ * Node parent ACL
+ * @return PersistedNodeData
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ */
+ protected PersistedNodeData loadNodeRecord(QPath parentPath, String cname, String cid, String cpid, int cindex,
+ int cversion, int cnordernumb, AccessControlList parentACL) throws RepositoryException, SQLException
+ {
+ try
+ {
+ InternalQName qname = InternalQName.parse(cname);
+
+ QPath qpath;
+ String parentCid;
+ if (parentPath != null)
+ {
+ // get by parent and name
+ qpath = QPath.makeChildPath(parentPath, qname, cindex, cid);
+ parentCid = cpid;
+ }
+ else
+ {
+ // get by id
+ if (cpid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ // root node
+ qpath = Constants.ROOT_PATH;
+ parentCid = null;
+ }
+ else
+ {
+ qpath = QPath.makeChildPath(traverseQPath(cpid), qname, cindex, cid);
+ parentCid = cpid;
+ }
+ }
+
+ // PRIMARY
+ ResultSet ptProp = findPropertyByName(cid, Constants.JCR_PRIMARYTYPE.getAsString());
+ try
+ {
+
+ if (!ptProp.next())
+ {
+ throw new PrimaryTypeNotFoundException("FATAL ERROR primary type record not found. Node "
+ + qpath.getAsString() + ", id " + cid + ", container " + this.containerName, null);
+ }
+
+ byte[] data = ptProp.getBytes(COLUMN_VDATA);
+ InternalQName ptName = InternalQName.parse(new String((data != null ? data : new byte[]{})));
+
+ // MIXIN
+ MixinInfo mixins = readMixins(cid);
+
+ // ACL
+ AccessControlList acl; // NO DEFAULT values!
+
+ if (mixins.hasOwneable())
+ {
+ // has own owner
+ if (mixins.hasPrivilegeable())
+ {
+ // and permissions
+ acl = new AccessControlList(readACLOwner(cid), readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use permissions from existed parent
+ acl =
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions() ? parentACL
+ .getPermissionEntries() : null);
+ }
+ else
+ {
+ // have to search nearest ancestor permissions in ACL manager
+ // acl = new AccessControlList(readACLOwner(cid), traverseACLPermissions(cpid));
+ acl = new AccessControlList(readACLOwner(cid), null);
+ }
+ }
+ else if (mixins.hasPrivilegeable())
+ {
+ // has own permissions
+ if (mixins.hasOwneable())
+ {
+ // and owner
+ acl = new AccessControlList(readACLOwner(cid), readACLPermisions(cid));
+ }
+ else if (parentACL != null)
+ {
+ // use owner from existed parent
+ acl = new AccessControlList(parentACL.getOwner(), readACLPermisions(cid));
+ }
+ else
+ {
+ // have to search nearest ancestor owner in ACL manager
+ // acl = new AccessControlList(traverseACLOwner(cpid), readACLPermisions(cid));
+ acl = new AccessControlList(null, readACLPermisions(cid));
+ }
+ }
+ else
+ {
+ if (parentACL != null)
+ {
+ // construct ACL from existed parent ACL
+ acl =
+ new AccessControlList(parentACL.getOwner(), parentACL.hasPermissions() ? parentACL
+ .getPermissionEntries() : null);
+ }
+ else
+ {
+ // have to search nearest ancestor owner and permissions in ACL manager
+ // acl = traverseACL(cpid);
+ acl = null;
+ }
+ }
+
+ return new PersistedNodeData(getIdentifier(cid), qpath, getIdentifier(parentCid), cversion, cnordernumb,
+ ptName, mixins.mixinNames(), acl);
+ }
+ catch (IllegalACLException e)
+ {
+ throw new RepositoryException("FATAL ERROR Node " + getIdentifier(cid) + " " + qpath.getAsString()
+ + " has wrong formed ACL. ", e);
+ }
+ finally
+ {
+ try
+ {
+ ptProp.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Load PropertyData record.
+ *
+ * @param parentPath
+ * parent path
+ * @param cname
+ * Property name
+ * @param cid
+ * Property id
+ * @param cpid
+ * Property parent id
+ * @param cversion
+ * Property persistent verison
+ * @param cptype
+ * Property type
+ * @param cpmultivalued
+ * Property multivalued status
+ * @return PersistedPropertyData
+ * @throws RepositoryException
+ * Repository error
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ */
+ protected PersistedPropertyData loadPropertyRecord(QPath parentPath, String cname, String cid, String cpid,
+ int cversion, int cptype, boolean cpmultivalued) throws RepositoryException, SQLException, IOException
+ {
+
+ // NOTE: cpid never should be null or root parent (' ')
+
+ try
+ {
+ QPath qpath =
+ QPath.makeChildPath(parentPath == null ? traverseQPath(cpid) : parentPath, InternalQName.parse(cname));
+
+ String identifier = getIdentifier(cid);
+ List<ValueData> values = readValues(cid, identifier, cversion);
+ PersistedPropertyData pdata =
+ new PersistedPropertyData(identifier, qpath, getIdentifier(cpid), cversion, cptype, cpmultivalued, values);
+
+ return pdata;
+ }
+ catch (IllegalNameException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+
+ /**
+ * Delete Property Values.
+ *
+ * @param cid
+ * Property id
+ * @param pdata
+ * PropertyData
+ * @param update
+ * boolean true if it's delete-add sequence (update operation)
+ * @throws IOException
+ * i/O error
+ * @throws SQLException
+ * if database error occurs
+ * @throws ValueStorageNotFoundException
+ * if no such storage found with Value storageId
+ */
+ private void deleteValues(String cid, PropertyData pdata, boolean update) throws IOException, SQLException,
+ ValueStorageNotFoundException
+ {
+
+ final ResultSet valueRecords = findValuesStorageDescriptorsByPropertyId(cid);
+ try
+ {
+ if (valueRecords.next())
+ {
+ // delete all Values in database
+ deleteValueData(cid);
+
+ do
+ {
+ final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
+ if (!valueRecords.wasNull())
+ {
+ final ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+ try
+ {
+ channel.delete(pdata.getIdentifier());
+ valueChanges.add(channel);
+ }
+ finally
+ {
+ channel.close();
+ }
+ }
+ }
+ while (valueRecords.next());
+ }
+ }
+ finally
+ {
+ try
+ {
+ valueRecords.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Read Property Values.
+ *
+ * @param identifier
+ * property identifier
+ * @param cid
+ * Property id
+ * @param pdata
+ * PropertyData
+ * @return list of ValueData
+ * @throws IOException
+ * i/O error
+ * @throws SQLException
+ * if database errro occurs
+ * @throws ValueStorageNotFoundException
+ * if no such storage found with Value storageId
+ */
+ private List<ValueData> readValues(String cid, String identifier, int cversion) throws IOException, SQLException,
+ ValueStorageNotFoundException
+ {
+
+ List<ValueData> data = new ArrayList<ValueData>();
+
+ final ResultSet valueRecords = findValuesByPropertyId(cid);
+ try
+ {
+ while (valueRecords.next())
+ {
+ final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
+ final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
+ ValueData vdata =
+ valueRecords.wasNull() ? readValueData(cid, orderNum, cversion, valueRecords
+ .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum, storageId);
+ data.add(vdata);
+ }
+ }
+ finally
+ {
+ try
+ {
+ valueRecords.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e.getMessage());
+ }
+ }
+
+ return data;
+ }
+
+ /**
+ * Read ValueData from External Storage.
+ *
+ * @param pdata
+ * PropertyData
+ * @param orderNumber
+ * Value order number
+ * @param storageId
+ * external Value storage id
+ * @return ValueData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ * @throws ValueStorageNotFoundException
+ * if no such storage found with Value storageId
+ */
+ protected ValueData readValueData(String identifier, int orderNumber, String storageId) throws SQLException,
+ IOException, ValueStorageNotFoundException
+ {
+ ValueIOChannel channel = valueStorageProvider.getChannel(storageId);
+ try
+ {
+ return channel.read(identifier, orderNumber, maxBufferSize);
+ }
+ finally
+ {
+ channel.close();
+ }
+ }
+
+ /**
+ * Read ValueData from database.
+ *
+ * @param cid
+ * Property id
+ * @param orderNumber
+ * Value order number
+ * @param version
+ * persistent version (used for BLOB swapping)
+ * @param content
+ * @return ValueData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error (swap)
+ */
+ protected ValueData readValueData(String cid, int orderNumber, int version, final InputStream content)
+ throws SQLException, IOException
+ {
+
+ byte[] buffer = new byte[0];
+ byte[] spoolBuffer = new byte[ValueFileIOHelper.IOBUFFER_SIZE];
+ int read;
+ int len = 0;
+ OutputStream out = null;
+
+ SwapFile swapFile = null;
+ try
+ {
+ // stream from database
+ if (content != null)
+ {
+ while ((read = content.read(spoolBuffer)) >= 0)
+ {
+ if (out != null)
+ {
+ // spool to temp file
+ out.write(spoolBuffer, 0, read);
+ len += read;
+ }
+ else if (len + read > maxBufferSize)
+ {
+ // threshold for keeping data in memory exceeded;
+ // create temp file and spool buffer contents
+ swapFile = SwapFile.get(swapDirectory, cid + orderNumber + "." + version);
+ if (swapFile.isSpooled())
+ {
+ // break, value already spooled
+ buffer = null;
+ break;
+ }
+ out = PrivilegedFileHelper.fileOutputStream(swapFile);
+ out.write(buffer, 0, len);
+ out.write(spoolBuffer, 0, read);
+ buffer = null;
+ len += read;
+ }
+ else
+ {
+ // reallocate new buffer and spool old buffer contents
+ byte[] newBuffer = new byte[len + read];
+ System.arraycopy(buffer, 0, newBuffer, 0, len);
+ System.arraycopy(spoolBuffer, 0, newBuffer, len, read);
+ buffer = newBuffer;
+ len += read;
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (out != null)
+ {
+ out.close();
+ swapFile.spoolDone();
+ }
+ }
+
+ if (buffer == null)
+ {
+ return new CleanableFilePersistedValueData(orderNumber, swapFile, swapCleaner);
+ }
+
+ return new ByteArrayPersistedValueData(orderNumber, buffer);
+ }
+
+ /**
+ * Add Values to Property record.
+ *
+ * @param data
+ * PropertyData
+ * @throws SQLException
+ * database error
+ * @throws IOException
+ * I/O error
+ * @thorws RepositoryException if Value data large of JDBC accepted (Integer.MAX_VALUE)
+ */
+ protected void addValues(String cid, PropertyData data) throws IOException, SQLException, RepositoryException
+ {
+ List<ValueData> vdata = data.getValues();
+
+ for (int i = 0; i < vdata.size(); i++)
+ {
+ ValueData vd = vdata.get(i);
+ ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
+ InputStream stream;
+ int streamLength;
+ String storageId;
+ if (channel == null)
+ {
+ // prepare write of Value in database
+ if (vd.isByteArray())
+ {
+ byte[] dataBytes = vd.getAsByteArray();
+ stream = new ByteArrayInputStream(dataBytes);
+ streamLength = dataBytes.length;
+ }
+ else
+ {
+ StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
+
+ SwapFile swapFile = SwapFile.get(swapDirectory, cid + i + "." + data.getPersistedVersion());
+ try
+ {
+ writeValueHelper.writeStreamedValue(swapFile, streamData);
+ }
+ finally
+ {
+ swapFile.spoolDone();
+ }
+
+ long vlen = PrivilegedFileHelper.length(swapFile);
+ if (vlen <= Integer.MAX_VALUE)
+ {
+ streamLength = (int)vlen;
+ }
+ else
+ {
+ throw new RepositoryException("Value data large of allowed by JDBC (Integer.MAX_VALUE) " + vlen
+ + ". Property " + data.getQPath().getAsString());
+ }
+
+ stream = streamData.getAsStream();
+ }
+ storageId = null;
+ }
+ else
+ {
+ // write Value in external VS
+ channel.write(data.getIdentifier(), vd);
+ valueChanges.add(channel);
+ storageId = channel.getStorageId();
+ stream = null;
+ streamLength = 0;
+ }
+ addValueData(cid, i, stream, streamLength, storageId);
+ }
+ }
+
+ /**
+ * Build node data and its properties data from temporary stored info.
+ *
+ * @return NodeDataIndexing
+ * @throws RepositoryException
+ * @throws IOException
+ * @throws SQLException
+ * @throws IllegalNameException
+ */
+ protected NodeDataIndexing createNodeDataIndexing(TempNodeData tempNode) throws RepositoryException, SQLException,
+ IOException, IllegalNameException
+ {
+ String parentCid;
+ QPath parentPath;
+
+ if (tempNode.cpid.equals(Constants.ROOT_PARENT_UUID))
+ {
+ // root node
+ parentCid = null;
+ parentPath = Constants.ROOT_PATH;
+ }
+ else
+ {
+ parentCid = tempNode.cpid;
+ parentPath =
+ QPath.makeChildPath(traverseQPath(tempNode.cpid), InternalQName.parse(tempNode.cname), tempNode.cindex);
+ }
+
+ // primary type if exists in the list of properties
+ InternalQName ptName = null;
+ ValueData ptValue = null;
+
+ SortedSet<TempPropertyData> ptTempProp = tempNode.properties.get(Constants.JCR_PRIMARYTYPE.getAsString());
+ if (ptTempProp != null)
+ {
+ ptValue = ptTempProp.first().getValueData();
+ ptName = InternalQName.parse(new String(ptValue.getAsByteArray(), Constants.DEFAULT_ENCODING));
+ }
+
+ // mixins if exist in the list of properties
+ List<ValueData> mixinsData = new ArrayList<ValueData>();
+ List<InternalQName> mixins = new ArrayList<InternalQName>();
+
+ Set<TempPropertyData> mixinsTempProps = tempNode.properties.get(Constants.JCR_MIXINTYPES.getAsString());
+ if (mixinsTempProps != null)
+ {
+ for (TempPropertyData mxnb : mixinsTempProps)
+ {
+ ValueData vdata = mxnb.getValueData();
+
+ mixinsData.add(vdata);
+ mixins.add(InternalQName.parse(new String(vdata.getAsByteArray(), Constants.DEFAULT_ENCODING)));
+ }
+ }
+
+ // build node data. No need to load ACL. The node will be pushed directly for reindexing.
+ NodeData nodeData =
+ new PersistedNodeData(getIdentifier(tempNode.cid), parentPath, getIdentifier(parentCid), tempNode.cversion,
+ tempNode.cnordernumb, ptName, mixins.toArray(new InternalQName[mixins.size()]), null);
+
+ Map<String, PropertyData> childProps = new HashMap<String, PropertyData>();
+ for (String propName : tempNode.properties.keySet())
+ {
+ ExtendedTempPropertyData prop = (ExtendedTempPropertyData)tempNode.properties.get(propName).first();
+
+ String identifier = getIdentifier(prop.id);
+ QPath qpath = QPath.makeChildPath(parentPath, InternalQName.parse(prop.name));
+
+ List<ValueData> valueData = new ArrayList<ValueData>();
+
+ if (propName.equals(Constants.JCR_PRIMARYTYPE.getAsString()))
+ {
+ valueData.add(ptValue);
+ }
+ else if (propName.equals(Constants.JCR_MIXINTYPES.getAsString()))
+ {
+ valueData = mixinsData;
+ }
+ else
+ {
+ for (TempPropertyData tempProp : tempNode.properties.get(propName))
+ {
+ ExtendedTempPropertyData exTempProp = (ExtendedTempPropertyData)tempProp;
+
+ valueData.add(exTempProp.getValueData());
+ }
+ }
+
+ // build property data
+ PropertyData pdata =
+ new PersistedPropertyData(identifier, qpath, tempNode.cid, prop.version, prop.type, prop.multi, valueData);
+
+ childProps.put(propName, pdata);
+ }
+
+ return new NodeDataIndexing(nodeData, childProps);
+ }
+
+ /**
+ * Class needed temporary to store node data info.
+ */
+ protected class TempNodeData
+ {
+ public String cid;
+
+ public String cname;
+
+ public int cversion;
+
+ public String cpid;
+
+ public int cindex;
+
+ public int cnordernumb;
+
+ public Map<String, SortedSet<TempPropertyData>> properties = new HashMap<String, SortedSet<TempPropertyData>>();
+
+ public TempNodeData(ResultSet item) throws SQLException
+ {
+ cid = item.getString(COLUMN_ID);
+ cname = item.getString(COLUMN_NAME);
+ cversion = item.getInt(COLUMN_VERSION);
+ cpid = item.getString(COLUMN_PARENTID);
+ cindex = item.getInt(COLUMN_INDEX);
+ cnordernumb = item.getInt(COLUMN_NORDERNUM);
+ }
+ }
+
+ /**
+ * Class needs temporary to store value info.
+ */
+ protected class TempPropertyData implements Comparable<TempPropertyData>
+ {
+ protected final int orderNum;
+
+ protected ValueData data;
+
+ public TempPropertyData(ResultSet item) throws SQLException
+ {
+ this(item, true);
+ }
+
+ public TempPropertyData(ResultSet item, boolean readValue) throws SQLException
+ {
+ orderNum = item.getInt(COLUMN_VORDERNUM);
+ data = readValue ? new ByteArrayPersistedValueData(orderNum, item.getBytes(COLUMN_VDATA)) : null;
+ }
+
+ public int compareTo(TempPropertyData o)
+ {
+ return orderNum - o.orderNum;
+ }
+
+ public ValueData getValueData()
+ {
+ return data;
+ }
+ }
+
+ /**
+ * Class needs temporary to store whole property data info.
+ */
+ protected class ExtendedTempPropertyData extends TempPropertyData
+ {
+ protected final String id;
+
+ protected final String name;
+
+ protected final int version;
+
+ protected final int type;
+
+ protected final boolean multi;
+
+ protected final String storage_desc;
+
+ public ExtendedTempPropertyData(ResultSet item) throws SQLException, ValueStorageNotFoundException, IOException
+ {
+ super(item, false);
+ id = item.getString("P_ID");
+ name = item.getString("P_NAME");
+ version = item.getInt("P_VERSION");
+ type = item.getInt("P_TYPE");
+ multi = item.getBoolean("P_MULTIVALUED");
+ storage_desc = item.getString(COLUMN_VSTORAGE_DESC);
+ InputStream is = item.getBinaryStream(COLUMN_VDATA);
+ data =
+ storage_desc == null ? readValueData(id, orderNum, version, is) : readValueData(getIdentifier(id),
+ orderNum, storage_desc);
+ }
+ }
+
+ /**
+ * The comparator used to sort the value data
+ */
+ protected static Comparator<ValueData> COMPARATOR_VALUE_DATA = new Comparator<ValueData>()
+ {
+
+ public int compare(ValueData vd1, ValueData vd2)
+ {
+ return vd1.getOrderNumber() - vd2.getOrderNumber();
+ }
+ };
+
+ protected ResultSet findLowestPropertyVersions() throws SQLException
+ {
+ if (findLowestPropertyVersions == null)
+ {
+ findLowestPropertyVersions = dbConnection.prepareStatement(FIND_LOWEST_PROPERTY_VERSIONS);
+ }
+
+ return findLowestPropertyVersions.executeQuery();
+ }
+
+ protected abstract int addNodeRecord(NodeData data) throws SQLException;
+
+ protected abstract int addPropertyRecord(PropertyData prop) throws SQLException;
+
+ protected abstract ResultSet findItemByIdentifier(String identifier) throws SQLException;
+
+ protected abstract ResultSet findPropertyByName(String parentId, String name) throws SQLException;
+
+ protected abstract ResultSet findItemByName(String parentId, String name, int index) throws SQLException;
+
+ protected abstract ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException;
+
+ protected abstract ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException;
+
+ protected abstract ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
+ throws SQLException;
+
+ protected abstract int addReference(PropertyData data) throws SQLException, IOException;
+
+ protected abstract int renameNode(NodeData data) throws SQLException;
+
+ protected abstract int deleteReference(String propertyIdentifier) throws SQLException;
+
+ /**
+ * Deletes [http://www.jcp.org/jcr/1.0]lockOwner and [http://www.jcp.org/jcr/1.0]lockIsDeep
+ * properties directly from DB.
+ */
+ protected abstract void deleteLockProperties() throws SQLException;
+
+ /**
+ * Deletes [http://www.jcp.org/jcr/1.0]lockOwner and [http://www.jcp.org/jcr/1.0]lockIsDeep
+ * properties directly from DB for specific parent.
+ */
+ protected abstract void deleteLockProperties(String nodeIdentifier) throws SQLException;
+
+ protected abstract ResultSet findReferences(String nodeIdentifier) throws SQLException;
+
+ protected abstract int deleteItemByIdentifier(String identifier) throws SQLException;
+
+ protected abstract int updateNodeByIdentifier(int version, int index, int orderNumb, String identifier)
+ throws SQLException;
+
+ protected abstract int updatePropertyByIdentifier(int version, int type, String identifier) throws SQLException;
+
+ protected abstract ResultSet findNodesCount() throws SQLException;
+
+ // -------- values processing ------------
+ protected abstract int addValueData(String cid, int orderNumber, InputStream stream, int streamLength,
+ String storageId) throws SQLException;
+
+ protected abstract int deleteValueData(String cid) throws SQLException;
+
+ protected abstract ResultSet findValuesByPropertyId(String cid) throws SQLException;
+
+ protected abstract ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException;
+
+ protected abstract ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException;
+
+}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -19,20 +19,22 @@
package org.exoplatform.services.jcr.impl.storage.jdbc;
import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.database.utils.JDBCUtils;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.checker.AssignerRootAsParent;
import org.exoplatform.services.jcr.impl.checker.DummyRepair;
+import org.exoplatform.services.jcr.impl.checker.EarlierVersionsRemover;
import org.exoplatform.services.jcr.impl.checker.InspectionQuery;
import org.exoplatform.services.jcr.impl.checker.InspectionQueryFilteredMultivaluedProperties;
import org.exoplatform.services.jcr.impl.checker.InspectionReport;
-import org.exoplatform.services.jcr.impl.checker.RemoverEarlierVersions;
-import org.exoplatform.services.jcr.impl.checker.RemoverValueRecords;
+import org.exoplatform.services.jcr.impl.checker.NodeRemover;
+import org.exoplatform.services.jcr.impl.checker.PropertyRemover;
+import org.exoplatform.services.jcr.impl.checker.ValueRecordsRemover;
+import org.exoplatform.services.jcr.impl.checker.RootAsParentAssigner;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandlerFactory;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
@@ -79,17 +81,21 @@
private LockTableHandler lockHandler;
+ private NodeTypeDataManagerImpl nodeTypeManager;
+
/**
* JDBCWorkspaceDataContainerChecker constructor.
*/
public JDBCWorkspaceDataContainerChecker(JDBCWorkspaceDataContainer jdbcDataContainer,
- ValueStoragePluginProvider vsPlugin, WorkspaceEntry workspaceEntry, InspectionReport report)
+ ValueStoragePluginProvider vsPlugin, WorkspaceEntry workspaceEntry, NodeTypeDataManagerImpl nodeTypeManager,
+ InspectionReport report)
{
this.jdbcDataContainer = jdbcDataContainer;
this.vsPlugin = vsPlugin;
this.workspaceEntry = workspaceEntry;
this.report = report;
this.lockHandler = LockTableHandlerFactory.getHandler(workspaceEntry);
+ this.nodeTypeManager = nodeTypeManager;
initInspectionQueries();
}
@@ -165,13 +171,19 @@
{
((JDBCStorageConnection)conn).deleteLockProperties(nodeId);
}
-
+ conn.commit();
logComment("Lock has been removed form ITEM table. Node UUID: " + nodeId);
}
- finally
+ catch (RepositoryException e)
{
- conn.close();
+ conn.rollback();
+ throw e;
}
+ catch (SQLException e)
+ {
+ conn.rollback();
+ throw e;
+ }
}
}
}
@@ -222,13 +234,21 @@
if (resultSet.next())
{
logDescription(query.getDescription());
+
do
{
logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, query.getFieldNames()));
if (autoRepair)
{
- query.getRepair().doRepair(resultSet);
- logComment("Inconsistency has been fixed");
+ try
+ {
+ query.getRepair().doRepair(resultSet);
+ logComment("Inconsistency has been fixed");
+ }
+ catch (SQLException e)
+ {
+ logExceptionAndSetInconsistency("Inconsistency can not been fixed", e);
+ }
}
}
while (resultSet.next());
@@ -277,24 +297,26 @@
if (resultSet.next())
{
+ logDescription("ValueData not found inconsistency");
+
do
{
- String propertyId = removeWorkspacePrefix(resultSet.getString(DBConstants.COLUMN_VPROPERTY_ID));
- int orderNumber = resultSet.getInt(DBConstants.COLUMN_VORDERNUM);
String storageDesc = resultSet.getString(DBConstants.COLUMN_VSTORAGE_DESC);
ValueIOChannel channel = null;
try
{
channel = getIOChannel(storageDesc);
- doCheckAndRepairValueData(channel, resultSet, propertyId, orderNumber, autoRepair);
+ doCheckAndRepairValueData(channel, resultSet, autoRepair);
}
catch (IOException e)
{
- logDescription("Unexpected exception during checking");
- logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, vsInspectionQuery.getFieldNames()));
- logExceptionAndSetInconsistency(e.getMessage(), e);
+ logExceptionAndSetInconsistency("Unexpected exception during checking.", e);
}
+ catch (SQLException e)
+ {
+ logExceptionAndSetInconsistency("Unexpected exception during checking.", e);
+ }
finally
{
if (channel != null)
@@ -329,32 +351,37 @@
}
catch (ValueStorageNotFoundException e)
{
- logDescription("ValueStorage " + storageDesc + " not found");
- logExceptionAndSetInconsistency(e.getMessage(), e);
+ logExceptionAndSetInconsistency("ValueStorage " + storageDesc + " not found: " + e.getMessage(), e);
}
return channel;
}
- private void doCheckAndRepairValueData(ValueIOChannel channel, ResultSet resultSet, String propertyId,
- int orderNumber, boolean autoRepair) throws IOException
+ private void doCheckAndRepairValueData(ValueIOChannel channel, ResultSet resultSet, boolean autoRepair)
+ throws IOException, SQLException
{
+ String propertyId = removeWorkspacePrefix(resultSet.getString(DBConstants.COLUMN_VPROPERTY_ID));
+ int orderNumber = resultSet.getInt(DBConstants.COLUMN_VORDERNUM);
+
try
{
channel.checkValueData(propertyId, orderNumber);
}
catch (ValueDataNotFoundException e)
{
- String brokenObject = getBrokenObject(resultSet, vsInspectionQuery.getFieldNames());
+ logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, vsInspectionQuery.getFieldNames()));
- logDescription("ValueData not found");
- logBrokenObjectAndSetInconsistency(brokenObject);
- logExceptionAndSetInconsistency(e.getMessage(), e);
-
if (autoRepair)
{
- channel.repairValueData(propertyId, orderNumber);
- logComment("ValueData corresponding to " + brokenObject + " has been repaired. New empty file is created.");
+ try
+ {
+ channel.repairValueData(propertyId, orderNumber);
+ logComment("ValueData has been repaired. New empty file is created.");
+ }
+ catch (IOException e2)
+ {
+ logExceptionAndSetInconsistency("Can not repair value data: " + e.getMessage(), e);
+ }
}
}
}
@@ -459,7 +486,7 @@
: "select * from JCR_SITEM I where I.CONTAINER_NAME='" + jdbcDataContainer.containerName
+ "' and NOT EXISTS(select * from JCR_SITEM P where P.ID = I.PARENT_ID)", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_CLASS},
- "Items that do not have parent nodes", new AssignerRootAsParent(jdbcDataContainer
+ "Items that do not have parent nodes", new RootAsParentAssigner(jdbcDataContainer
.getConnectionFactory())));
itemsInspectionQuery
@@ -470,7 +497,8 @@
+ jdbcDataContainer.containerName + "' and P.I_CLASS=2"
+ " and P.P_MULTIVALUED=? and NOT EXISTS( select * from JCR_SVALUE V where V.PROPERTY_ID=P.ID)",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
- "A node that has a single valued properties with nothing declared in the VALUE table.", new DummyRepair()));
+ "A node that has a single valued properties with nothing declared in the VALUE table.",
+ new PropertyRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MITEM N where N.I_CLASS=1 and NOT EXISTS "
@@ -481,7 +509,7 @@
+ "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
+ "and P.CONTAINER_NAME='" + jdbcDataContainer.containerName + "')", new String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "A node that doesn't have primary type property",
- new DummyRepair()));
+ new NodeRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P "
@@ -489,7 +517,7 @@
: "select * from JCR_SVALUE V where NOT EXISTS(select * from JCR_SITEM P "
+ "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
- new RemoverValueRecords(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerName,
+ new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerName,
jdbcDataContainer.multiDb)));
// The differences in the queries by DB dialect.
@@ -527,7 +555,7 @@
: "select * from JCR_SITEM I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerName + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
- new AssignerRootAsParent(jdbcDataContainer.getConnectionFactory())));
+ new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
itemsInspectionQuery
.add(new InspectionQuery(
@@ -542,7 +570,7 @@
+ " and I.VERSION != J.VERSION)",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME,
DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX},
- "Several versions of same item.", new RemoverEarlierVersions(jdbcDataContainer.getConnectionFactory())));
+ "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));
itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MITEM P, JCR_MVALUE V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS "
@@ -551,6 +579,7 @@
+ jdbcDataContainer.containerName
+ "' and P.P_TYPE=9 and NOT EXISTS (select * from JCR_SREF R where P.ID=R.PROPERTY_ID)", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
- "Reference properties without reference records", new DummyRepair()));
+ "Reference properties without reference records", new PropertyRemover(jdbcDataContainer
+ .getConnectionFactory(), nodeTypeManager)));
}
}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java.orig 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,679 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.ValueDataConvertor;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.List;
+
+/**
+ * Single database connection implementation.
+ *
+ * Created by The eXo Platform SAS. </br>
+ *
+ * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
+ * Azarenkov</a>
+ * @version $Id: MultiDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
+ * pnedonosko $
+ */
+
+public class MultiDbJDBCConnection extends JDBCStorageConnection
+{
+
+ /**
+ * Multidatabase JDBC Connection constructor.
+ *
+ * @param dbConnection JDBC connection, shoudl be opened before
+ * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider External Value Storages provider
+ * @param maxBufferSize Maximum buffer size (see configuration)
+ * @param swapDirectory Swap directory (see configuration)
+ * @param swapCleaner Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getIdentifier(final String internalId)
+ {
+ return internalId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInternalId(final String identifier)
+ {
+ return identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException
+ {
+ JCR_PK_ITEM = "JCR_PK_MITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_MVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_MREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
+
+ FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
+
+ FIND_ITEM_BY_NAME =
+ "select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+
+ 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";
+
+ FIND_REFERENCES =
+ "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_VALUES_BY_PROPERTYID =
+ "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
+
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=?";
+
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
+ "select DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+
+ FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+
+ FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+ "select count(*), max(N_ORDER_NUM) from JCR_MITEM where I_CLASS=1 and PARENT_ID=?";
+
+ 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";
+
+ FIND_LOWEST_PROPERTY_VERSIONS =
+ "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
+ + " GROUP BY PARENT_ID, NAME, I_CLASS, I_INDEX HAVING count(VERSION) > 1";
+
+ INSERT_NODE =
+ "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
+ + I_CLASS_NODE + ",?,?)";
+ INSERT_PROPERTY =
+ "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,"
+ + I_CLASS_PROPERTY + ",?,?,?)";
+
+ INSERT_VALUE = "insert into JCR_MVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into JCR_MREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
+
+ RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX =?, N_ORDER_NUM =? where ID=?";
+
+ UPDATE_NODE = "update JCR_MITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update JCR_MITEM set VERSION=?, P_TYPE=? where ID=?";
+ //UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
+
+ DELETE_ITEM = "delete from JCR_MITEM where ID=?";
+ DELETE_VALUE = "delete from JCR_MVALUE where PROPERTY_ID=?";
+ DELETE_REF = "delete from JCR_MREF where PROPERTY_ID=?";
+
+ FIND_NODES_COUNT = "select count(*) from JCR_MITEM I where I.I_CLASS=1";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException
+ {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
+
+ insertNode.setString(1, data.getIdentifier());
+ insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : data
+ .getParentIdentifier());
+ insertNode.setString(3, data.getQPath().getName().getAsString());
+ insertNode.setInt(4, data.getPersistedVersion());
+ insertNode.setInt(5, data.getQPath().getIndex());
+ insertNode.setInt(6, data.getOrderNumber());
+ return insertNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException
+ {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.clearParameters();
+
+ insertProperty.setString(1, data.getIdentifier());
+ insertProperty.setString(2, data.getParentIdentifier());
+ insertProperty.setString(3, data.getQPath().getName().getAsString());
+ insertProperty.setInt(4, data.getPersistedVersion());
+ insertProperty.setInt(5, data.getQPath().getIndex());
+ insertProperty.setInt(6, data.getType());
+ insertProperty.setBoolean(7, data.isMultiValued());
+
+ return insertProperty.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException
+ {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
+
+ if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
+ LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
+
+ List<ValueData> values = data.getValues();
+ int added = 0;
+ for (int i = 0; i < values.size(); i++)
+ {
+ ValueData vdata = values.get(i);
+ String refNodeIdentifier = ValueDataConvertor.readString(vdata);
+
+ insertReference.setString(1, refNodeIdentifier);
+ insertReference.setString(2, data.getIdentifier());
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
+
+ return added;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyIdentifier) throws SQLException
+ {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
+
+ deleteReference.setString(1, propertyIdentifier);
+ return deleteReference.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String identifier) throws SQLException
+ {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
+
+ deleteItem.setString(1, identifier);
+ return deleteItem.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updateNodeByIdentifier(int version, int index, int orderNumb, String identifier) throws SQLException
+ {
+ if (updateNode == null)
+ updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ else
+ updateNode.clearParameters();
+
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, identifier);
+ return updateNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String identifier) throws SQLException
+ {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
+
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, identifier);
+ return updateProperty.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
+ {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
+
+ findItemByName.setString(1, parentId);
+ findItemByName.setString(2, name);
+ findItemByName.setInt(3, index);
+ return findItemByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentId, String name) throws SQLException
+ {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
+
+ findPropertyByName.setString(1, parentId);
+ findPropertyByName.setString(2, name);
+ return findPropertyByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String identifier) throws SQLException
+ {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
+
+ findItemById.setString(1, identifier);
+ return findItemById.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String nodeIdentifier) throws SQLException
+ {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
+
+ findReferences.setString(1, nodeIdentifier);
+ return findReferences.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
+
+ findNodesByParentId.setString(1, parentIdentifier);
+ return findNodesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findLastOrderNumberByParentId == null)
+ findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ else
+ findLastOrderNumberByParentId.clearParameters();
+
+ findLastOrderNumberByParentId.setString(1, parentIdentifier);
+ return findLastOrderNumberByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+
+ findNodesCountByParentId.setString(1, parentIdentifier);
+ return findNodesCountByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
+
+ findPropertiesByParentId.setString(1, parentIdentifier);
+ return findPropertiesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
+ throws SQLException
+ {
+ throw new UnsupportedOperationException("findChildNodesByParentIdentifier is not supported for old queries");
+ }
+
+ // -------- values processing ------------
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
+ throws SQLException
+ {
+
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
+
+ if (stream == null)
+ {
+ // [PN] store vd reference to external storage etc.
+ insertValue.setNull(1, Types.BINARY);
+ insertValue.setString(4, storageDesc);
+ }
+ else
+ {
+ insertValue.setBinaryStream(1, stream, streamLength);
+ insertValue.setNull(4, Types.VARCHAR);
+ }
+
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteValueData(String cid) throws SQLException
+ {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
+
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException
+ {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
+
+ findValuesByPropertyId.setString(1, cid);
+ return findValuesByPropertyId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
+ {
+ if (findValueByPropertyIdOrderNumber == null)
+ findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ else
+ findValueByPropertyIdOrderNumber.clearParameters();
+
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException
+ {
+ if (renameNode == null)
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ else
+ renameNode.clearParameters();
+
+ renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : data
+ .getParentIdentifier());
+ renameNode.setString(2, data.getQPath().getName().getAsString());
+ renameNode.setInt(3, data.getPersistedVersion());
+ renameNode.setInt(4, data.getQPath().getIndex());
+ renameNode.setInt(5, data.getOrderNumber());
+ renameNode.setString(6, data.getIdentifier());
+ return renameNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
+ {
+ if (findValuesStorageDescriptorsByPropertyId == null)
+ findValuesStorageDescriptorsByPropertyId =
+ dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ else
+ findValuesStorageDescriptorsByPropertyId.clearParameters();
+
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException
+ {
+ throw new UnsupportedOperationException(
+ "The method findNodesAndProperties is not supported for this type of connection use the complex queries instead");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void deleteLockProperties() throws SQLException
+ {
+ PreparedStatement removeValuesStatement = null;
+ PreparedStatement removeItemsStatement = null;
+
+ try
+ {
+ removeValuesStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID IN "
+ + "(SELECT ID FROM JCR_MITEM WHERE NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
+
+ removeItemsStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep'"
+ + " OR NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'");
+
+ removeValuesStatement.executeUpdate();
+ removeItemsStatement.executeUpdate();
+ }
+ finally
+ {
+ if (removeValuesStatement != null)
+ {
+ try
+ {
+ removeValuesStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+
+ if (removeItemsStatement != null)
+ {
+ try
+ {
+ removeItemsStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodesCount() throws SQLException
+ {
+ if (findNodesCount == null)
+ {
+ findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
+ }
+ return findNodesCount.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void deleteLockProperties(String nodeIdentifier) throws SQLException
+ {
+ PreparedStatement removeValuesStatement = null;
+ PreparedStatement removeItemsStatement = null;
+
+ try
+ {
+ removeValuesStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_MVALUE WHERE PROPERTY_ID IN"
+ + " (SELECT ID FROM JCR_MITEM WHERE PARENT_ID=? AND"
+ + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
+
+ removeItemsStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_MITEM WHERE PARENT_ID=? AND"
+ + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
+
+ removeValuesStatement.setString(1, getInternalId(nodeIdentifier));
+ removeItemsStatement.setString(1, getInternalId(nodeIdentifier));
+
+ removeValuesStatement.executeUpdate();
+ removeItemsStatement.executeUpdate();
+ }
+ finally
+ {
+ if (removeValuesStatement != null)
+ {
+ try
+ {
+ removeValuesStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+
+ if (removeItemsStatement != null)
+ {
+ try
+ {
+ removeItemsStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+ }
+ }
+
+}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java.orig 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,711 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.List;
+
+/**
+ * Single database connection implementation.
+ *
+ * Created by The eXo Platform SAS 27.04.2006
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
+ * Nedonosko</a>
+ * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
+ * pnedonosko $
+ */
+public class SingleDbJDBCConnection extends JDBCStorageConnection
+{
+
+ /**
+ * Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection JDBC connection, shoudl be opened before
+ * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider External Value Storages provider
+ * @param maxBufferSize Maximum buffer size (see configuration)
+ * @param swapDirectory Swap directory (see configuration)
+ * @param swapCleaner Swap cleaner (internal FileCleaner).
+ * @throws SQLException in case of database error
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInternalId(final String identifier)
+ {
+ return containerName + identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getIdentifier(final String internalId)
+ {
+
+ if (internalId == null) // possible for root parent
+ return null;
+
+ return internalId.substring(containerName.length());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException
+ {
+
+ JCR_PK_ITEM = "JCR_PK_SITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_SVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_SREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
+
+ FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
+
+ FIND_ITEM_BY_NAME =
+ "select * from JCR_SITEM"
+ + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+
+ FIND_PROPERTY_BY_NAME =
+ "select 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=? and"
+ + " I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
+ FIND_REFERENCES =
+ "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_VALUES_BY_PROPERTYID =
+ "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
+
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=?";
+
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
+ "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+
+ FIND_NODES_BY_PARENTID =
+ "select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+
+ FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+ "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
+ FIND_NODES_COUNT_BY_PARENTID =
+ "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
+ FIND_PROPERTIES_BY_PARENTID =
+ "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
+
+ FIND_LOWEST_PROPERTY_VERSIONS =
+ "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, CONTAINER_NAME, I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
+ + " GROUP BY PARENT_ID, CONTAINER_NAME, NAME, I_CLASS, I_INDEX HAVING count(VERSION) > 1";
+
+ INSERT_NODE =
+ "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
+ + I_CLASS_NODE + ",?,?)";
+ INSERT_PROPERTY =
+ "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) "
+ + "VALUES(?,?,?,?,?," + I_CLASS_PROPERTY + ",?,?,?)";
+
+ INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
+
+ RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+
+ UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
+ //UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
+
+ DELETE_ITEM = "delete from JCR_SITEM where ID=?";
+ DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
+ DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
+
+ FIND_NODES_COUNT = "select count(*) from JCR_SITEM I where I.I_CLASS=1 and I.CONTAINER_NAME=?";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException
+ {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
+
+ insertNode.setString(1, getInternalId(data.getIdentifier()));
+ // if root then parent identifier equals space string
+ insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
+ .getParentIdentifier()));
+ insertNode.setString(3, data.getQPath().getName().getAsString());
+ insertNode.setString(4, containerName);
+ insertNode.setInt(5, data.getPersistedVersion());
+ insertNode.setInt(6, data.getQPath().getIndex());
+ insertNode.setInt(7, data.getOrderNumber());
+ return insertNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException
+ {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.clearParameters();
+
+ insertProperty.setString(1, getInternalId(data.getIdentifier()));
+ insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
+ insertProperty.setString(3, data.getQPath().getName().getAsString());
+ insertProperty.setString(4, containerName);
+ insertProperty.setInt(5, data.getPersistedVersion());
+ insertProperty.setInt(6, data.getQPath().getIndex());
+ insertProperty.setInt(7, data.getType());
+ insertProperty.setBoolean(8, data.isMultiValued());
+
+ return insertProperty.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException
+ {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
+
+ List<ValueData> values = data.getValues();
+ int added = 0;
+ for (int i = 0; i < values.size(); i++)
+ {
+ ValueData vdata = values.get(i);
+ String refNodeIdentifier = new String(vdata.getAsByteArray());
+
+ insertReference.setString(1, getInternalId(refNodeIdentifier));
+ insertReference.setString(2, getInternalId(data.getIdentifier()));
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
+ return added;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyCid) throws SQLException
+ {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
+
+ deleteReference.setString(1, propertyCid);
+ return deleteReference.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String cid) throws SQLException
+ {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
+
+ deleteItem.setString(1, cid);
+ return deleteItem.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
+
+ findNodesByParentId.setString(1, containerName);
+ findNodesByParentId.setString(2, parentCid);
+ return findNodesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findLastOrderNumberByParentId == null)
+ findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ else
+ findLastOrderNumberByParentId.clearParameters();
+
+ findLastOrderNumberByParentId.setString(1, containerName);
+ findLastOrderNumberByParentId.setString(2, parentIdentifier);
+ return findLastOrderNumberByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+
+ findNodesCountByParentId.setString(1, containerName);
+ findNodesCountByParentId.setString(2, parentCid);
+ return findNodesCountByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
+
+ findPropertiesByParentId.setString(1, containerName);
+ findPropertiesByParentId.setString(2, parentCid);
+ return findPropertiesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
+ {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
+
+ findItemByName.setString(1, containerName);
+ findItemByName.setString(2, parentId);
+ findItemByName.setString(3, name);
+ findItemByName.setInt(4, index);
+ return findItemByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException
+ {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
+
+ findPropertyByName.setString(1, containerName);
+ findPropertyByName.setString(2, parentCid);
+ findPropertyByName.setString(3, name);
+ return findPropertyByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String cid) throws SQLException
+ {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
+
+ findItemById.setString(1, cid);
+ return findItemById.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String cid) throws SQLException
+ {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
+
+ findReferences.setString(1, cid);
+ findReferences.setString(2, containerName);
+ return findReferences.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updateNodeByIdentifier(int version, int index, int orderNumb, String cid) throws SQLException
+ {
+ if (updateNode == null)
+ updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ else
+ updateNode.clearParameters();
+
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, cid);
+ return updateNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String cid) throws SQLException
+ {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
+
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, cid);
+ return updateProperty.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
+ throws SQLException
+ {
+ throw new UnsupportedOperationException("findChildNodesByParentIdentifier is not supported for old queries");
+ }
+
+ // -------- values processing ------------
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
+ throws SQLException
+ {
+
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
+
+ if (stream == null)
+ {
+ // [PN] store vd reference to external storage etc.
+ insertValue.setNull(1, Types.BINARY);
+ insertValue.setString(4, storageDesc);
+ }
+ else
+ {
+ insertValue.setBinaryStream(1, stream, streamLength);
+ insertValue.setNull(4, Types.VARCHAR);
+ }
+
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteValueData(String cid) throws SQLException
+ {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
+
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException
+ {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
+
+ findValuesByPropertyId.setString(1, cid);
+ return findValuesByPropertyId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
+ {
+ if (findValuesStorageDescriptorsByPropertyId == null)
+ findValuesStorageDescriptorsByPropertyId =
+ dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ else
+ findValuesStorageDescriptorsByPropertyId.clearParameters();
+
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
+ {
+ if (findValueByPropertyIdOrderNumber == null)
+ {
+ findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ }
+ else
+ {
+ findValueByPropertyIdOrderNumber.clearParameters();
+ }
+
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException
+ {
+ if (renameNode == null)
+ {
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ }
+ else
+ {
+ renameNode.clearParameters();
+ }
+
+ renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
+ .getParentIdentifier()));
+ renameNode.setString(2, data.getQPath().getName().getAsString());
+ renameNode.setInt(3, data.getPersistedVersion());
+ renameNode.setInt(4, data.getQPath().getIndex());
+ renameNode.setInt(5, data.getOrderNumber());
+ renameNode.setString(6, getInternalId(data.getIdentifier()));
+ return renameNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException
+ {
+ throw new UnsupportedOperationException(
+ "The method findNodesAndProperties is not supported for this type of connection use the complex queries instead");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void deleteLockProperties() throws SQLException
+ {
+ PreparedStatement removeValuesStatement = null;
+ PreparedStatement removeItemsStatement = null;
+
+ try
+ {
+ removeValuesStatement =
+ dbConnection
+ .prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID "
+ + "IN (SELECT ID FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND "
+ + "(NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
+ removeValuesStatement.setString(1, containerName);
+
+ removeItemsStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND "
+ + "(NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
+ removeItemsStatement.setString(1, containerName);
+
+ removeValuesStatement.executeUpdate();
+ removeItemsStatement.executeUpdate();
+ }
+ finally
+ {
+ if (removeValuesStatement != null)
+ {
+ try
+ {
+ removeValuesStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+
+ if (removeItemsStatement != null)
+ {
+ try
+ {
+ removeItemsStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodesCount() throws SQLException
+ {
+ if (findNodesCount == null)
+ {
+ findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
+ }
+ else
+ {
+ findNodesCount.clearParameters();
+ }
+
+ findNodesCount.setString(1, containerName);
+
+ return findNodesCount.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void deleteLockProperties(String nodeIdentifier) throws SQLException
+ {
+ PreparedStatement removeValuesStatement = null;
+ PreparedStatement removeItemsStatement = null;
+
+ try
+ {
+ removeValuesStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID IN (SELECT ID FROM JCR_SITEM"
+ + " WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
+ removeValuesStatement.setString(1, containerName);
+ removeValuesStatement.setString(2, getInternalId(nodeIdentifier));
+
+ removeItemsStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND"
+ + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
+ removeItemsStatement.setString(1, containerName);
+ removeItemsStatement.setString(2, getInternalId(nodeIdentifier));
+
+ removeValuesStatement.executeUpdate();
+ removeItemsStatement.executeUpdate();
+ }
+ finally
+ {
+ if (removeValuesStatement != null)
+ {
+ try
+ {
+ removeValuesStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+
+ if (removeItemsStatement != null)
+ {
+ try
+ {
+ removeItemsStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+ }
+ }
+}
Added: jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig (rev 0)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/SingleDbJDBCConnection.java.orig 2012-03-02 07:58:54 UTC (rev 5744)
@@ -0,0 +1,1090 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
+
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
+import org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.List;
+
+/**
+ * Single database connection implementation.
+ *
+ * Created by The eXo Platform SAS 27.04.2006
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
+ * Nedonosko</a>
+ * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
+ * pnedonosko $
+ */
+public class SingleDbJDBCConnection extends CQJDBCStorageConnection
+{
+
+ protected static final String FIND_NODES_BY_PARENTID_CQ_QUERY =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and"
+ + " P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID 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, I.ID";
+
+ protected static final String FIND_PROPERTIES_BY_PARENTID_CQ_QUERY =
+ "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE, I.P_MULTIVALUED, 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.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? order by I.NAME";
+
+ protected static final String FIND_ITEM_QPATH_BY_ID_CQ_QUERY =
+ "select I.ID, I.PARENT_ID, I.NAME, I.I_INDEX"
+ + " from JCR_SITEM I, (SELECT ID, PARENT_ID from JCR_SITEM where ID=?) J"
+ + " where I.ID = J.ID or I.ID = J.PARENT_ID";
+
+ protected static final String PATTERN_ESCAPE_STRING = "\\"; //valid for HSQL, Sybase, DB2, MSSQL, ORACLE
+
+ /**
+ * Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection JDBC connection, shoudl be opened before
+ * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider External Value Storages provider
+ * @param maxBufferSize Maximum buffer size (see configuration)
+ * @param swapDirectory Swap directory (see configuration)
+ * @param swapCleaner Swap cleaner (internal FileCleaner).
+ * @throws SQLException in case of database error
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
+ ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
+ throws SQLException
+ {
+
+ super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getInternalId(final String identifier)
+ {
+ return containerName + identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected String getIdentifier(final String internalId)
+ {
+
+ if (internalId == null) // possible for root parent
+ return null;
+
+ return internalId.substring(containerName.length());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException
+ {
+
+ JCR_PK_ITEM = "JCR_PK_SITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_SVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_SREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
+
+ FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
+
+ FIND_ITEM_BY_NAME =
+ "select * from JCR_SITEM"
+ + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+
+ FIND_PROPERTY_BY_NAME =
+ "select 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=? and"
+ + " I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+
+ FIND_REFERENCES =
+ "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_VALUES_BY_PROPERTYID =
+ "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
+
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=?";
+
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB =
+ "select DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+
+ FIND_NODES_BY_PARENTID =
+ "select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+
+ FIND_NODES_BY_PARENTID_CQ = FIND_NODES_BY_PARENTID_CQ_QUERY;
+
+ FIND_NODE_MAIN_PROPERTIES_BY_PARENTID_CQ =
+ "select I.NAME, V.DATA, V.ORDER_NUM 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";
+
+ FIND_ITEM_QPATH_BY_ID_CQ = FIND_ITEM_QPATH_BY_ID_CQ_QUERY;
+
+ FIND_LAST_ORDER_NUMBER_BY_PARENTID =
+ "select count(*), max(N_ORDER_NUM) from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
+ FIND_NODES_COUNT_BY_PARENTID =
+ "select count(ID) from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
+ FIND_PROPERTIES_BY_PARENTID =
+ "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by NAME";
+
+ FIND_PROPERTIES_BY_PARENTID_CQ = FIND_PROPERTIES_BY_PARENTID_CQ_QUERY;
+ FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
+ "select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_CLASS, I.I_INDEX, I.N_ORDER_NUM, I.P_TYPE,"
+ + " I.P_MULTIVALUED, V.ORDER_NUM, V.DATA, V.STORAGE_DESC"
+ + " from JCR_SITEM I LEFT OUTER JOIN JCR_SVALUE V ON (V.PROPERTY_ID=I.ID)";
+
+ FIND_NODES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V";
+
+ FIND_LOWEST_PROPERTY_VERSIONS =
+ "select max(VERSION) as MAX_VERSION, PARENT_ID, NAME, CONTAINER_NAME, I_CLASS, I_INDEX from JCR_SITEM WHERE I_CLASS=2"
+ + " GROUP BY PARENT_ID, CONTAINER_NAME, NAME, I_CLASS, I_INDEX HAVING count(VERSION) > 1";
+
+ INSERT_NODE =
+ "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
+ + I_CLASS_NODE + ",?,?)";
+ INSERT_PROPERTY =
+ "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED)"
+ + " VALUES(?,?,?,?,?," + I_CLASS_PROPERTY + ",?,?,?)";
+
+ INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
+
+ RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+
+ UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
+
+ DELETE_ITEM = "delete from JCR_SITEM where ID=?";
+ DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
+ DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
+
+ FIND_NODES_AND_PROPERTIES =
+ "select J.*, P.ID AS P_ID, P.NAME AS P_NAME, P.VERSION AS P_VERSION, P.P_TYPE, P.P_MULTIVALUED,"
+ + " V.DATA, V.ORDER_NUM, V.STORAGE_DESC from JCR_SVALUE V, JCR_SITEM P"
+ + " join (select I.ID, I.PARENT_ID, I.NAME, I.VERSION, I.I_INDEX, I.N_ORDER_NUM from JCR_SITEM I"
+ + " where I.CONTAINER_NAME=? AND I.I_CLASS=1 AND I.ID > ? order by I.ID LIMIT ? OFFSET ?) J on P.PARENT_ID = J.ID"
+ + " where P.I_CLASS=2 and P.CONTAINER_NAME=? and V.PROPERTY_ID=P.ID order by J.ID";
+
+ FIND_PROPERTY_BY_ID =
+ "select I.P_TYPE, V.STORAGE_DESC from JCR_SITEM I, JCR_SVALUE V where I.ID = ? and V.PROPERTY_ID = I.ID";
+ DELETE_VALUE_BY_ORDER_NUM = "delete from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM >= ?";
+ UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=? and ORDER_NUM=?";
+
+ FIND_NODES_BY_PARENTID_LAZILY_CQ =
+ "select I.*, P.NAME AS PROP_NAME, V.ORDER_NUM, V.DATA from JCR_SITEM I, JCR_SITEM P, JCR_SVALUE V"
+ + " where I.I_CLASS=1 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.N_ORDER_NUM >= ? and "
+ + " I.N_ORDER_NUM <= ? and P.I_CLASS=2 and P.CONTAINER_NAME=? and P.PARENT_ID=I.ID 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, I.ID";
+
+ FIND_ACL_HOLDERS = "select I.PARENT_ID, I.P_TYPE"
+ + " from JCR_SITEM I where I.I_CLASS=2 and I.CONTAINER_NAME=?"
+ + " and (I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'"
+ + " or I.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')";
+
+ FIND_NODES_COUNT = "select count(*) from JCR_SITEM I where I.I_CLASS=1 and I.CONTAINER_NAME=?";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException
+ {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
+
+ insertNode.setString(1, getInternalId(data.getIdentifier()));
+ // if root then parent identifier equals space string
+ insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
+ .getParentIdentifier()));
+ insertNode.setString(3, data.getQPath().getName().getAsString());
+ insertNode.setString(4, containerName);
+ insertNode.setInt(5, data.getPersistedVersion());
+ insertNode.setInt(6, data.getQPath().getIndex());
+ insertNode.setInt(7, data.getOrderNumber());
+ return insertNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException
+ {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.clearParameters();
+
+ insertProperty.setString(1, getInternalId(data.getIdentifier()));
+ insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
+ insertProperty.setString(3, data.getQPath().getName().getAsString());
+ insertProperty.setString(4, containerName);
+ insertProperty.setInt(5, data.getPersistedVersion());
+ insertProperty.setInt(6, data.getQPath().getIndex());
+ insertProperty.setInt(7, data.getType());
+ insertProperty.setBoolean(8, data.isMultiValued());
+
+ return insertProperty.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException
+ {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
+
+ List<ValueData> values = data.getValues();
+ int added = 0;
+ for (int i = 0; i < values.size(); i++)
+ {
+ ValueData vdata = values.get(i);
+ String refNodeIdentifier = new String(vdata.getAsByteArray());
+
+ insertReference.setString(1, getInternalId(refNodeIdentifier));
+ insertReference.setString(2, getInternalId(data.getIdentifier()));
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
+ return added;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyCid) throws SQLException
+ {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
+
+ deleteReference.setString(1, propertyCid);
+ return deleteReference.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String cid) throws SQLException
+ {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
+
+ deleteItem.setString(1, cid);
+ return deleteItem.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
+
+ findNodesByParentId.setString(1, containerName);
+ findNodesByParentId.setString(2, parentCid);
+ return findNodesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findLastOrderNumberByParentIdentifier(String parentIdentifier) throws SQLException
+ {
+ if (findLastOrderNumberByParentId == null)
+ findLastOrderNumberByParentId = dbConnection.prepareStatement(FIND_LAST_ORDER_NUMBER_BY_PARENTID);
+ else
+ findLastOrderNumberByParentId.clearParameters();
+
+ findLastOrderNumberByParentId.setString(1, containerName);
+ findLastOrderNumberByParentId.setString(2, parentIdentifier);
+ return findLastOrderNumberByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesCountByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findNodesCountByParentId == null)
+ findNodesCountByParentId = dbConnection.prepareStatement(FIND_NODES_COUNT_BY_PARENTID);
+ else
+ findNodesCountByParentId.clearParameters();
+
+ findNodesCountByParentId.setString(1, containerName);
+ findNodesCountByParentId.setString(2, parentCid);
+ return findNodesCountByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException
+ {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
+
+ findPropertiesByParentId.setString(1, containerName);
+ findPropertiesByParentId.setString(2, parentCid);
+ return findPropertiesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
+ {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
+
+ findItemByName.setString(1, containerName);
+ findItemByName.setString(2, parentId);
+ findItemByName.setString(3, name);
+ findItemByName.setInt(4, index);
+ return findItemByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException
+ {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
+
+ findPropertyByName.setString(1, containerName);
+ findPropertyByName.setString(2, parentCid);
+ findPropertyByName.setString(3, name);
+ return findPropertyByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String cid) throws SQLException
+ {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
+
+ findItemById.setString(1, cid);
+ return findItemById.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String cid) throws SQLException
+ {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
+
+ findReferences.setString(1, cid);
+ findReferences.setString(2, containerName);
+ return findReferences.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updateNodeByIdentifier(int version, int index, int orderNumb, String cid) throws SQLException
+ {
+ if (updateNode == null)
+ updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ else
+ updateNode.clearParameters();
+
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, cid);
+ return updateNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String cid) throws SQLException
+ {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
+
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, cid);
+ return updateProperty.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid, int fromOrderNum, int toOrderNum)
+ throws SQLException
+ {
+ if (findNodesByParentIdLazilyCQ == null)
+ findNodesByParentIdLazilyCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_LAZILY_CQ);
+ else
+ findNodesByParentIdLazilyCQ.clearParameters();
+
+ findNodesByParentIdLazilyCQ.setString(1, containerName);
+ findNodesByParentIdLazilyCQ.setString(2, parentCid);
+ findNodesByParentIdLazilyCQ.setInt(3, fromOrderNum);
+ findNodesByParentIdLazilyCQ.setInt(4, toOrderNum);
+ findNodesByParentIdLazilyCQ.setString(5, containerName);
+
+ return findNodesByParentIdLazilyCQ.executeQuery();
+ }
+
+ // -------- values processing ------------
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
+ throws SQLException
+ {
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
+
+ if (stream == null)
+ {
+ // [PN] store vd reference to external storage etc.
+ insertValue.setNull(1, Types.BINARY);
+ insertValue.setString(4, storageDesc);
+ }
+ else
+ {
+ insertValue.setBinaryStream(1, stream, streamLength);
+ insertValue.setNull(4, Types.VARCHAR);
+ }
+
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteValueData(String cid) throws SQLException
+ {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
+
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException
+ {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
+
+ findValuesByPropertyId.setString(1, cid);
+ return findValuesByPropertyId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
+ {
+ if (findValuesStorageDescriptorsByPropertyId == null)
+ findValuesStorageDescriptorsByPropertyId =
+ dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ else
+ findValuesStorageDescriptorsByPropertyId.clearParameters();
+
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
+ {
+ if (findValueByPropertyIdOrderNumber == null)
+ {
+ findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ }
+ else
+ {
+ findValueByPropertyIdOrderNumber.clearParameters();
+ }
+
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException
+ {
+ if (renameNode == null)
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ else
+ renameNode.clearParameters();
+
+ renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
+ .getParentIdentifier()));
+ renameNode.setString(2, data.getQPath().getName().getAsString());
+ renameNode.setInt(3, data.getPersistedVersion());
+ renameNode.setInt(4, data.getQPath().getIndex());
+ renameNode.setInt(5, data.getOrderNumber());
+ renameNode.setString(6, getInternalId(data.getIdentifier()));
+ return renameNode.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ {
+ if (findNodesByParentIdCQ == null)
+ findNodesByParentIdCQ = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID_CQ);
+ else
+ findNodesByParentIdCQ.clearParameters();
+
+ findNodesByParentIdCQ.setString(1, containerName);
+ findNodesByParentIdCQ.setString(2, parentIdentifier);
+ findNodesByParentIdCQ.setString(3, containerName);
+ return findNodesByParentIdCQ.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifierCQ(String parentIdentifier, List<QPathEntryFilter> pattern)
+ throws SQLException
+ {
+ if (pattern.isEmpty())
+ {
+ throw new SQLException("Pattern list is empty.");
+ }
+ else
+ {
+ if (findNodesByParentIdAndComplexPatternCQ == null)
+ {
+ findNodesByParentIdAndComplexPatternCQ = dbConnection.createStatement();
+ }
+ //create query from list
+ StringBuilder query = new StringBuilder(FIND_NODES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE);
+ query.append(" where I.I_CLASS=1 and I.CONTAINER_NAME='");
+ query.append(containerName);
+ query.append("' and I.PARENT_ID='");
+ query.append(parentIdentifier);
+ query.append("' and ( ");
+ appendPattern(query, pattern.get(0).getQPathEntry(), true);
+ for (int i = 1; i < pattern.size(); i++)
+ {
+ query.append(" or ");
+ appendPattern(query, pattern.get(i).getQPathEntry(), true);
+ }
+ query.append(" ) and P.I_CLASS=2 and P.CONTAINER_NAME='");
+ query.append(containerName);
+ query.append("' and P.PARENT_ID=I.ID and (P.NAME='[http://www.jcp.org/jcr/1.0]primaryType'");
+ query.append(" or P.NAME='[http://www.jcp.org/jcr/1.0]mixinTypes'");
+ query.append(" or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]owner'");
+ query.append(" or P.NAME='[http://www.exoplatform.com/jcr/exo/1.0]permissions')");
+ query.append(" and V.PROPERTY_ID=P.ID order by I.N_ORDER_NUM, I.ID");
+
+ return findNodesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentIdentifier) throws SQLException
+ {
+ if (findPropertiesByParentIdCQ == null)
+ findPropertiesByParentIdCQ = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID_CQ);
+ else
+ findPropertiesByParentIdCQ.clearParameters();
+
+ findPropertiesByParentIdCQ.setString(1, containerName);
+ findPropertiesByParentIdCQ.setString(2, parentIdentifier);
+ return findPropertiesByParentIdCQ.executeQuery();
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifierCQ(String parentCid, List<QPathEntryFilter> pattern)
+ throws SQLException
+ {
+ if (pattern.isEmpty())
+ {
+ throw new SQLException("Pattern list is empty.");
+ }
+ else
+ {
+ if (findPropertiesByParentIdAndComplexPatternCQ == null)
+ {
+ findPropertiesByParentIdAndComplexPatternCQ = dbConnection.createStatement();
+ }
+ //create query from list
+ StringBuilder query = new StringBuilder(FIND_PROPERTIES_BY_PARENTID_AND_PATTERN_CQ_TEMPLATE);
+ query.append(" where I.I_CLASS=2 and I.CONTAINER_NAME='");
+ query.append(containerName);
+ query.append("' and I.PARENT_ID='");
+ query.append(parentCid);
+ query.append("' and ( ");
+ appendPattern(query, pattern.get(0).getQPathEntry(), false);
+ for (int i = 1; i < pattern.size(); i++)
+ {
+ query.append(" or ");
+ appendPattern(query, pattern.get(i).getQPathEntry(), false);
+ }
+ query.append(" ) order by I.NAME");
+
+ return findPropertiesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @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();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemQPathByIdentifierCQ(String identifier) throws SQLException
+ {
+ if (findItemQPathByIdentifierCQ == null)
+ findItemQPathByIdentifierCQ = dbConnection.prepareStatement(FIND_ITEM_QPATH_BY_ID_CQ);
+ else
+ findItemQPathByIdentifierCQ.clearParameters();
+
+ findItemQPathByIdentifierCQ.setString(1, identifier);
+ return findItemQPathByIdentifierCQ.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodesAndProperties(String lastNodeId, int offset, int limit) throws SQLException
+ {
+ if (findNodesAndProperties == null)
+ {
+ findNodesAndProperties = dbConnection.prepareStatement(FIND_NODES_AND_PROPERTIES);
+ }
+ else
+ {
+ findNodesAndProperties.clearParameters();
+ }
+
+ findNodesAndProperties.setString(1, containerName);
+ findNodesAndProperties.setString(2, getInternalId(lastNodeId));
+ findNodesAndProperties.setInt(3, limit);
+ findNodesAndProperties.setInt(4, offset);
+ findNodesAndProperties.setString(5, containerName);
+
+ return findNodesAndProperties.executeQuery();
+ }
+
+ @Override
+ protected int deleteValueDataByOrderNum(String id, int orderNum) throws SQLException
+ {
+ if (deleteValueDataByOrderNum == null)
+ deleteValueDataByOrderNum = dbConnection.prepareStatement(DELETE_VALUE_BY_ORDER_NUM);
+ else
+ deleteValueDataByOrderNum.clearParameters();
+
+ deleteValueDataByOrderNum.setString(1, id);
+ deleteValueDataByOrderNum.setInt(2, orderNum);
+ return deleteValueDataByOrderNum.executeUpdate();
+ }
+
+ @Override
+ protected ResultSet findPropertyById(String id) throws SQLException
+ {
+ if (findPropertyById == null)
+ findPropertyById = dbConnection.prepareStatement(FIND_PROPERTY_BY_ID);
+ else
+ findPropertyById.clearParameters();
+
+ findPropertyById.setString(1, id);
+ return findPropertyById.executeQuery();
+ }
+
+ @Override
+ protected int updateValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
+ throws SQLException
+ {
+
+ if (updateValue == null)
+ updateValue = dbConnection.prepareStatement(UPDATE_VALUE);
+ else
+ updateValue.clearParameters();
+
+ if (stream == null)
+ {
+ // [PN] store vd reference to external storage etc.
+ updateValue.setNull(1, Types.BINARY);
+ updateValue.setString(2, storageDesc);
+ }
+ else
+ {
+ updateValue.setBinaryStream(1, stream, streamLength);
+ updateValue.setNull(2, Types.VARCHAR);
+ }
+
+ updateValue.setString(3, cid);
+ updateValue.setInt(4, orderNumber);
+ return updateValue.executeUpdate();
+ }
+
+ /**
+ * Replace underscore in pattern with escaped symbol. Replace jcr-wildcard '*' with sql-wildcard '%'.
+ *
+ * @param pattern
+ * @return pattern with escaped underscore and fixed wildcard symbols
+ */
+ protected String fixEscapeSymbols(String pattern)
+ {
+ char[] chars = pattern.toCharArray();
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < chars.length; i++)
+ {
+ switch (chars[i])
+ {
+ case '*' :
+ sb.append('%');
+ break;
+ case '_' :
+ case '%' :
+ sb.append(getWildcardEscapeSymbold());
+ default :
+ sb.append(chars[i]);
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Append pattern expression.
+ * Appends String "I.NAME LIKE 'escaped pattern' ESCAPE 'escapeString'" or "I.NAME='pattern'"
+ * to String builder sb.
+ *
+ * @param sb StringBuilder
+ * @param indexConstraint
+ * @param pattern
+ */
+ protected void appendPattern(StringBuilder sb, QPathEntry entry, boolean indexConstraint)
+ {
+ String pattern = entry.getAsString(false);
+ sb.append("(I.NAME");
+ if (pattern.contains("*"))
+ {
+ sb.append(" LIKE '");
+ sb.append(fixEscapeSymbols(pattern));
+ sb.append("' ESCAPE '");
+ sb.append(getLikeExpressionEscape());
+ sb.append("'");
+ }
+ else
+ {
+ sb.append("='");
+ sb.append(pattern);
+ sb.append("'");
+ }
+
+ if (indexConstraint && entry.getIndex() != -1)
+ {
+ sb.append(" and I.I_INDEX=");
+ sb.append(entry.getIndex());
+ }
+ sb.append(")");
+ }
+
+ protected String getWildcardEscapeSymbold()
+ {
+ return PATTERN_ESCAPE_STRING;
+ }
+
+ protected String getLikeExpressionEscape()
+ {
+ return PATTERN_ESCAPE_STRING;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findACLHolders() throws SQLException
+ {
+ if (findACLHolders == null)
+ {
+ findACLHolders = dbConnection.prepareStatement(FIND_ACL_HOLDERS);
+ }
+ else
+ {
+ findACLHolders.clearParameters();
+ }
+
+ findACLHolders.setString(1, containerName);
+
+ return findACLHolders.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void deleteLockProperties() throws SQLException
+ {
+ PreparedStatement removeValuesStatement = null;
+ PreparedStatement removeItemsStatement = null;
+
+ try
+ {
+ removeValuesStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID IN (SELECT ID FROM JCR_SITEM"
+ + " WHERE CONTAINER_NAME = ? AND (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
+ removeValuesStatement.setString(1, containerName);
+
+ removeItemsStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND"
+ + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
+ removeItemsStatement.setString(1, containerName);
+
+ removeValuesStatement.executeUpdate();
+ removeItemsStatement.executeUpdate();
+ }
+ finally
+ {
+ if (removeValuesStatement != null)
+ {
+ try
+ {
+ removeValuesStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+
+ if (removeItemsStatement != null)
+ {
+ try
+ {
+ removeItemsStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findNodesCount() throws SQLException
+ {
+ if (findNodesCount == null)
+ {
+ findNodesCount = dbConnection.prepareStatement(FIND_NODES_COUNT);
+ }
+ else
+ {
+ findNodesCount.clearParameters();
+ }
+
+ findNodesCount.setString(1, containerName);
+
+ return findNodesCount.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void deleteLockProperties(String nodeIdentifier) throws SQLException
+ {
+ PreparedStatement removeValuesStatement = null;
+ PreparedStatement removeItemsStatement = null;
+
+ try
+ {
+ removeValuesStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SVALUE WHERE PROPERTY_ID IN (SELECT ID FROM JCR_SITEM"
+ + " WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner'))");
+ removeValuesStatement.setString(1, containerName);
+ removeValuesStatement.setString(2, getInternalId(nodeIdentifier));
+
+ removeItemsStatement =
+ dbConnection.prepareStatement("DELETE FROM JCR_SITEM WHERE CONTAINER_NAME = ? AND PARENT_ID=? AND"
+ + " (NAME = '[http://www.jcp.org/jcr/1.0]lockIsDeep' OR"
+ + " NAME = '[http://www.jcp.org/jcr/1.0]lockOwner')");
+ removeItemsStatement.setString(1, containerName);
+ removeItemsStatement.setString(2, getInternalId(nodeIdentifier));
+
+ removeValuesStatement.executeUpdate();
+ removeItemsStatement.executeUpdate();
+ }
+ finally
+ {
+ if (removeValuesStatement != null)
+ {
+ try
+ {
+ removeValuesStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+
+ if (removeItemsStatement != null)
+ {
+ try
+ {
+ removeItemsStatement.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close statement", e);
+ }
+ }
+ }
+ }
+}
Modified: jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
===================================================================
--- jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2012-03-02 07:57:14 UTC (rev 5743)
+++ jcr/branches/1.15.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2012-03-02 07:58:54 UTC (rev 5744)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.BaseStandaloneTest;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.config.LockManagerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.dataflow.ItemState;
@@ -30,7 +31,7 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.checker.RepositoryCheckController;
-import org.exoplatform.services.jcr.impl.checker.RepositoryCheckController.DataStorage;
+import org.exoplatform.services.jcr.impl.core.ItemImpl;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.PropertyImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -40,6 +41,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -47,14 +49,20 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.List;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.Node;
-import javax.jcr.PropertyIterator;
+import javax.jcr.Property;
import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.sql.DataSource;
/**
@@ -74,27 +82,18 @@
private static boolean CACHE_ENABLED = true;
+ private static boolean CACHE_DISABLED = false;
+
private final TesterConfigurationHelper helper = TesterConfigurationHelper.getInstance();
- /**
- * @see org.exoplatform.services.jcr.BaseStandaloneTest#getRepositoryName()
- */
- @Override
protected String getRepositoryName()
{
- String repName = System.getProperty("test.repository");
- if (repName == null)
- {
- throw new RuntimeException(
- "Test repository is undefined. Set test.repository system property "
- + "(For maven: in project.properties: maven.junit.sysproperties=test.repository\ntest.repository=<rep-name>)");
- }
- return repName;
-
+ return null;
}
public void tearDown() throws Exception
{
+ // remove generated reports
for (File file : new File(".").listFiles())
{
if (file.getName().startsWith("report"))
@@ -106,271 +105,96 @@
super.tearDown();
}
- public void testDB() throws Exception
+ public void testCheckDataBase() throws Exception
{
TesterRepositoryCheckController checkController =
new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.DB}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- checkController.getLastLogFile().delete();
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testConsistentLocksInDataBase() throws Exception
+ public void testLockUsecases() throws Exception
{
- checkConsistentLocksInDataBase(NOT_SHARED_CACHE, SINGLE_DB);
- checkConsistentLocksInDataBase(NOT_SHARED_CACHE, MULTI_DB);
- }
+ checkConsistentLocksInDataBase(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkConsistentLocksInDataBase(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkConsistentLocksInDataBase(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, SHARED_CACHE));
+ checkConsistentLocksInDataBase(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, SHARED_CACHE));
- public void testConsistentLocksInDataBaseSharedCache() throws Exception
- {
- checkConsistentLocksInDataBase(SHARED_CACHE, SINGLE_DB);
- checkConsistentLocksInDataBase(SHARED_CACHE, MULTI_DB);
+ checkInconsistentLocksInLockTable(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkInconsistentLocksInLockTable(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkInconsistentLocksInLockTable(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, SHARED_CACHE));
+ checkInconsistentLocksInLockTable(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, SHARED_CACHE));
}
- private void checkConsistentLocksInDataBase(boolean isCacheShared, boolean isMultiDb) throws Exception
+ private void checkConsistentLocksInDataBase(ManageableRepository repository) throws Exception
{
- ManageableRepository repository = helper.createRepository(container, isMultiDb, CACHE_ENABLED, isCacheShared);
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- node.addMixin("mix:lockable");
- session.save();
- node.lock(false, false);
-
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.DB}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
+ Node node = addTestNode(repository);
+ lockNode(node);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- public void testInconsistentLocksInDataBase() throws Exception
- {
- checkInconsistentLocksInItemTable(NOT_SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInItemTable(NOT_SHARED_CACHE, MULTI_DB);
+ removePropertyInDB(repository, (PropertyImpl)node.getProperty("jcr:lockIsDeep"));
+ removePropertyInDB(repository, (PropertyImpl)node.getProperty("jcr:lockOwner"));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- checkInconsistentLocksInLockTable(NOT_SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInLockTable(NOT_SHARED_CACHE, MULTI_DB);
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testInconsistentLocksInDataBaseWithSharedCache() throws Exception
+ private void checkInconsistentLocksInLockTable(ManageableRepository repository) throws Exception
{
- checkInconsistentLocksInItemTable(SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInItemTable(SHARED_CACHE, MULTI_DB);
-
- checkInconsistentLocksInLockTable(SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInLockTable(SHARED_CACHE, MULTI_DB);
- }
-
- private void checkInconsistentLocksInItemTable(boolean cacheShared, boolean isMultiDb) throws Exception
- {
- ManageableRepository repository = helper.createRepository(container, isMultiDb, CACHE_ENABLED, cacheShared);
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- node.addMixin("mix:lockable");
- session.save();
- node.lock(false, false);
-
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- WorkspaceEntry workspaceEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- String sourceName = workspaceEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ Node node = addTestNode(repository);
+ lockNode(node);
- String multiDbQueryStatement =
- "DELETE FROM JCR_MITEM WHERE I_CLASS=2 "
- + "AND (NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')";
- String singleDbQueryStatement =
- "DELETE FROM JCR_SITEM WHERE CONTAINER_NAME='"
- + workspaceEntry.getName()
- + "' AND I_CLASS=2 AND (NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')";
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- // remove constraint
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "ITEM DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "VALUE_PROPERTY").execute();
- // delete properties (this should cause inconsistency)
- conn.prepareStatement(isMultiDb ? multiDbQueryStatement : singleDbQueryStatement).execute();
-
- // remove constriant
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "VALUE DROP CONSTRAINT JCR_PK_" + (isMultiDb ? "M" : "S")
- + "VALUE").execute();
-
- // clean up properties value to avoid another (except needed) cause of inconsistency
- String lockOwnerPropertyId =
- (isMultiDb ? "" : workspaceEntry.getName())
- + ((PropertyImpl)node.getProperty("jcr:lockIsDeep")).getInternalIdentifier();
- String lockIsDeepPropertyId =
- (isMultiDb ? "" : workspaceEntry.getName())
- + ((PropertyImpl)node.getProperty("jcr:lockOwner")).getInternalIdentifier();
-
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '" + lockOwnerPropertyId
- + "' OR PROPERTY_ID = '" + lockIsDeepPropertyId + "'").execute();
- conn.commit();
- conn.close();
-
+ clearLockTable(repository);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
- assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- private void checkInconsistentLocksInLockTable(boolean cacheShared, boolean isMultiDb) throws Exception
+ public void testCheckValueStorage() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, isMultiDb, true, cacheShared);
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- node.addMixin("mix:lockable");
- session.save();
- node.lock(false, false);
+ TesterRepositoryCheckController checkController =
+ new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- WorkspaceEntry workspaceEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- LockManagerEntry lockManagerEntry = workspaceEntry.getLockManager();
-
- String sourceName = null;
- String queryStatement = null;
-
- if (helper.ispnCacheEnabled())
- {
- sourceName = lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.datasource");
-
- queryStatement =
- "DELETE FROM " + lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.table.name") + "_" + "L"
- + workspaceEntry.getUniqueName().replace("_", "").replace("-", "_");
- }
- else
- {
- sourceName = lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_CL_DATASOURCE);
-
- if (cacheShared)
- {
- queryStatement =
- "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
- + " WHERE PARENT='/" + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "'";
- }
- else
- {
- queryStatement =
- "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
- + " WHERE PARENT='/" + CacheableLockManagerImpl.LOCKS + "'";
- }
-
- }
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement(queryStatement).execute();
- conn.commit();
- conn.close();
-
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.DB}, false);
- assertNotNull(result);
- assertTrue("Repository data is consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testValueStorage() throws Exception
+ public void testCheckIndex() throws Exception
{
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+ TesterRepositoryCheckController checkController =
+ new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- File f = this.createBLOBTempFile(20);
- InputStream is = new FileInputStream(f);
- try
- {
- Node n = root.addNode("node");
- n.setProperty("prop", is);
-
- root.save();
-
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.VALUE_STORAGE}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
- finally
- {
- is.close();
- f.delete();
- }
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testSearchIndex() throws Exception
+ public void testCheckAll() throws Exception
{
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+ TesterRepositoryCheckController checkController =
+ new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.LUCENE_INDEX}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkAll().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testAll() throws Exception
- {
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
-
- String result =
- checkController.checkAndRepair(new DataStorage[]{DataStorage.DB, DataStorage.VALUE_STORAGE,
- DataStorage.LUCENE_INDEX}, false);
-
-
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
-
/**
* Index contains documents that was already removed from DB.
*/
public void testIndexUsecaseWrongDocumentId() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, false, false);
-
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- session.save();
- session.logout();
-
- // repository is consistent
+ ManageableRepository repository = helper.createRepository(container, SINGLE_DB, CACHE_DISABLED);
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
-
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // Remove node from DB
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "ITEM DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "ITEM_PARENT").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ removeNodeInDB(repository, node);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
@@ -378,61 +202,14 @@
*/
public void testIndexUsecaseMultipleDocuments() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, false, false);
-
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- String nodeIdentifier = node.getIdentifier();
- session.save();
- session.logout();
-
- // repository is consistent
+ ManageableRepository repository = helper.createRepository(container, SINGLE_DB, CACHE_DISABLED);
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // Indexing one more document with same UUID
- List<SearchManager> searchManagers =
- repository.getWorkspaceContainer(repository.getConfiguration().getSystemWorkspaceName())
- .getComponentInstancesOfType(SearchManager.class);
-
- PlainChangesLog log = new PlainChangesLogImpl();
-
- NodeData data =
- new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testNode")),
- nodeIdentifier, -1, Constants.NT_UNSTRUCTURED, null, 0, null, new AccessControlList());
-
- TransientPropertyData primaryType =
- new TransientPropertyData(QPath.makeChildPath(data.getQPath(), Constants.JCR_PRIMARYTYPE),
- IdGenerator.generate(), -1, PropertyType.NAME, data.getIdentifier(), false, new TransientValueData(
- Constants.NT_UNSTRUCTURED));
-
- log.add(new ItemState(data, ItemState.ADDED, false, null));
- log.add(new ItemState(primaryType, ItemState.ADDED, false, null));
-
- SearchManager sm = null;
- for (SearchManager searchManager : searchManagers)
- {
- if (!(searchManager instanceof SystemSearchManager))
- {
- sm = searchManager;
- break;
- }
- }
-
- assertNotNull(sm);
- sm.onSaveItems(log);
-
- // repository is inconsistent
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ indexNode(repository, node, ItemState.ADDED);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
@@ -440,114 +217,36 @@
*/
public void testIndexUsecaseDocumentNotExists() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, false, false);
-
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- String nodeIdentifier = node.getIdentifier();
- session.save();
- session.logout();
-
- // repository is consistent
+ ManageableRepository repository = helper.createRepository(container, SINGLE_DB, CACHE_DISABLED);
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // Indexing one more document with same UUID
- List<SearchManager> searchManagers =
- repository.getWorkspaceContainer(repository.getConfiguration().getSystemWorkspaceName())
- .getComponentInstancesOfType(SearchManager.class);
-
- PlainChangesLog log = new PlainChangesLogImpl();
-
- NodeData data =
- new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testNode")),
- nodeIdentifier, -1, Constants.NT_UNSTRUCTURED, null, 0, null, new AccessControlList());
-
- TransientPropertyData primaryType =
- new TransientPropertyData(QPath.makeChildPath(data.getQPath(), Constants.JCR_PRIMARYTYPE),
- IdGenerator.generate(), -1, PropertyType.NAME, data.getIdentifier(), false, new TransientValueData(
- Constants.NT_UNSTRUCTURED));
-
- log.add(new ItemState(primaryType, ItemState.DELETED, false, null));
- log.add(new ItemState(data, ItemState.DELETED, false, null));
-
- SearchManager sm = null;
- for (SearchManager searchManager : searchManagers)
- {
- if (!(searchManager instanceof SystemSearchManager))
- {
- sm = searchManager;
- break;
- }
- }
-
- assertNotNull(sm);
- sm.onSaveItems(log);
-
- // repository is inconsistent
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ indexNode(repository, node, ItemState.DELETED);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
* Usecase: property doens't have have parent node.
*/
- public void testDBUsecasesTheParentIdIsIdOfThisNodeSingleDB() throws Exception
+ public void testDBUsecasesTheParentIdIsIdOfThisNode() throws Exception
{
- checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, false, false));
- checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, false, false));
- }
+ checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
- /**
- * Usecase: property doens't have have parent node.
- */
- public void testDBUsecasesTheParentIdIsIdOfThisNodeMultiDB() throws Exception
- {
- checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, true, false));
- checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, true, false));
+ checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
+ checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
private void checkDBUsecasesTheParentIdIsIdOfThisNode(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
- conn.prepareStatement(
- "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "ITEM SET PARENT_ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "' WHERE ID='" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
+ assingItsOwnParent(repository, (ItemImpl)node);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
@@ -557,105 +256,39 @@
private void checkDBUsecasesTheParentIdIsIdOfThisNode2(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ Node node = addTestNode(repository);
+ Property prop = addTestProperty(repository, node);
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
- conn.prepareStatement(
- "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "ITEM SET PARENT_ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "' WHERE ID='" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
+ assingItsOwnParent(repository, (ItemImpl)prop);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
-
}
/**
* Usecase: property doens't have have parent node.
*/
- public void testDBUsecasesSeveralVersionsOfSameItemSingleDB() throws Exception
+ public void testDBUsecasesSeveralVersionsOfSameItem() throws Exception
{
- checkSeveralVersionsOfSameItem(helper.createRepository(container, false, false));
+ checkSeveralVersionsOfSameItem(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkSeveralVersionsOfSameItem(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: property doens't have have parent node.
- */
- public void testDBUsecasesSeveralVersionsOfSameItemMultiDB() throws Exception
- {
- checkSeveralVersionsOfSameItem(helper.createRepository(container, true, false));
- }
-
private void checkSeveralVersionsOfSameItem(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- // add another item with new persisted version
- if (isMultiDb)
- {
- String propId = IdGenerator.generate();
- conn.prepareStatement(
- "INSERT INTO JCR_MITEM VALUES ('" + propId + "','" + prop.getParentIdentifier()
- + "','[]prop',1,2,1,NULL,1,FALSE)").execute();
- conn.prepareStatement("ALTER TABLE JCR_MVALUE DROP CONSTRAINT JCR_PK_MVALUE").execute();
- conn.prepareStatement("INSERT INTO JCR_MVALUE VALUES ('100','data','1','" + propId + "',NULL)").execute();
- }
- else
- {
- String propId = wsEntry.getName() + IdGenerator.generate();
- conn.prepareStatement(
- "INSERT INTO JCR_SITEM VALUES ('" + propId + "','" + wsEntry.getName() + prop.getParentIdentifier()
- + "','[]prop',1,'" + wsEntry.getName() + "',2,1,NULL,1,FALSE)").execute();
- conn.prepareStatement("ALTER TABLE JCR_SVALUE DROP CONSTRAINT JCR_PK_SVALUE").execute();
- conn.prepareStatement("INSERT INTO JCR_SVALUE VALUES ('100','data','1','" + propId + "',NULL)").execute();
- }
-
- conn.commit();
- conn.close();
-
+ insertPropertyRecord(repository, prop.getInternalIdentifier(), prop.getParentIdentifier(), prop.getName());
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
@@ -665,159 +298,68 @@
/**
* Usecase: property doens't have have parent node.
*/
- public void testDBUsecasesPropertyWithoutParentSingleDB() throws Exception
+ public void testDBUsecasesPropertyWithoutParent() throws Exception
{
- checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, false, false));
+ checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: property doens't have have parent node.
- */
- public void testDBUsecasesPropertyWithoutParentMultiDB() throws Exception
- {
- checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, true, false));
- }
-
private void checkDBUsecasesPropertyWithoutParent(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ insertPropertyRecord(repository, IdGenerator.generate(), IdGenerator.generate(), "testName");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "ITEM DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "ITEM_PARENT").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
* Usecase: Incorrect JCR_VALUE records.
*/
- public void testDBUsecasesIncorrectValueRecordsSingleDB() throws Exception
+ public void testDBUsecasesIncorrectValueRecords() throws Exception
{
- checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, false, false));
+ checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: Incorrect JCR_VALUE records.
- */
- public void testDBUsecasesIncorrectValueRecordsMultiDB() throws Exception
- {
- checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, true, false));
- }
-
private void checkDBUsecasesIncorrectValueRecords(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // change VALUE table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ updateValueRecord(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "VALUE SET STORAGE_DESC = 'unexisted-desc' WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
* Usecase: value records has no item record.
*/
- public void testDBUsecasesValueRecordHasNoItemRecordSingleDB() throws Exception
+ public void testDBUsecasesValueRecordHasNoItemRecord() throws Exception
{
- checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, false, false));
+ checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: value records has no item record.
- */
- public void testDBUsecasesValueRecordHasNoItemRecordMultiDB() throws Exception
- {
- checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, true, false));
- }
-
private void checkDBUsecasesValueRecordHasNoItemRecord(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // remove records from item table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "VALUE DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "VALUE_PROPERTY").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
+ removeItemRecord(repository, prop.getInternalIdentifier());
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
@@ -827,289 +369,437 @@
/**
* Usecase: properties that have not value record.
*/
- public void testDBUsecasesPropertiesHasNoValueRecordSingleDB() throws Exception
+ public void testDBUsecasesPropertiesHasNoValueRecord() throws Exception
{
- checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, false, false));
- checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, false, false));
- }
+ checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
- /**
- * Usecase: properties that have not value record.
- */
- public void testDBUsecasesPropertiesHasNoValueRecordMultiDB() throws Exception
- {
- checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, true, false));
- checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, false, false));
+ checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
+ checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
private void checkDBUsecasesPropertiesHasNoSingleValueRecord(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // remove records from value table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ removeValueRecord(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
}
private void checkDBUsecasesPropertiesHasEmptyMultiValueRecord(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", new String[]{});
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
+ Node node = addTestNode(repository);
+ node.setProperty("prop", new String[]{});
+ node.save();
- /**
- * Usecase: reference properties without reference records.
- */
- public void testDBUsecasesReferencePropertyWithoutReferenceRecordSingleDB() throws Exception
- {
- checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, false, false));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
* Usecase: reference properties without reference records.
*/
- public void testDBUsecasesReferencePropertyWithoutReferenceRecordMultiDB() throws Exception
+ public void testDBUsecasesReferencePropertyWithoutReferenceRecord() throws Exception
{
- checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, true, false));
+ checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, SINGLE_DB,
+ CACHE_DISABLED));
+ checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, MULTI_DB,
+ CACHE_DISABLED));
}
private void checkDBUsecasesReferencePropertyWithoutReferenceRecord(ManageableRepository repository)
throws Exception
{
- // create repository and add ref property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl refNode = (NodeImpl)session.getRootNode().addNode("refNode");
- refNode.addMixin("mix:referenceable");
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("refProp", refNode);
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ Node node2 = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)node2.setProperty("prop", node);
+ node2.save();
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // remove records from ref table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ removeReferenceRecord(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "REF WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ }
- conn.commit();
- conn.close();
+ /**
+ * Usecase when node doesn't have at primary type property.
+ */
+ public void testDBUsecasesNodeHasNoProperties() throws Exception
+ {
+ checkDBUsecasesNodeHasNotPrimaryTypeProperties(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesNodeHasNotPrimaryTypeProperties(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
+ }
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+ private void checkDBUsecasesNodeHasNotPrimaryTypeProperties(ManageableRepository repository) throws Exception
+ {
+ TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+
+ removePropertyInDB(repository, (PropertyImpl)node.getProperty("jcr:primaryType"));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
- * Usecase when node doesn't have at least one property.
+ * Usescase when STORAGE_DESC field in VALUE table is not empty but there is no file in the value storage.
*/
- public void testDBUsecasesNodeHasNoPropertiesSingleDB() throws Exception
+ public void testValueStorageUsecases() throws Exception
{
- checkDBUsecasesNodeHasNoProperties(helper.createRepository(container, false, false));
- checkDBUsecasesNodeHasPrimaryTypeProperties(helper.createRepository(container, false, false));
+ checkValueStorageUsecases(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkValueStorageUsecases(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase when node doesn't have at least one property.
- */
- public void testDBUsecasesNodeHasNoPropertiesMultiDB() throws Exception
+ private void checkValueStorageUsecases(ManageableRepository repository) throws Exception
{
- checkDBUsecasesNodeHasNoProperties(helper.createRepository(container, true, false));
- checkDBUsecasesNodeHasPrimaryTypeProperties(helper.createRepository(container, false, false));
+ TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)node.setProperty("prop", new FileInputStream(createBLOBTempFile(300)));
+ node.save();
+
+ assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+
+ removeFileFromVS(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkValueStorage()
+ .startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+
+ checkController.repairValueStorage("yes");
+ assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- private void checkDBUsecasesNodeHasNoProperties(ManageableRepository repository) throws Exception
+ private Node addTestNode(ManageableRepository repository) throws LoginException, NoSuchWorkspaceException,
+ RepositoryException
{
- // create repository and add node
SessionImpl session =
(SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
+
NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
+ node.addMixin("mix:referenceable");
session.save();
- PropertyIterator iter = node.getProperties();
+ return node;
+ }
- // repository is consistent
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ private Property addTestProperty(ManageableRepository repository, Node node) throws LoginException,
+ NoSuchWorkspaceException, RepositoryException
+ {
+ Property prop = node.setProperty("testProp", "value");
+ node.save();
+ return prop;
+ }
+ private void lockNode(Node node) throws LoginException, NoSuchWorkspaceException, RepositoryException
+ {
+ node.addMixin("mix:lockable");
+ node.save();
+
+ node.lock(false, false);
+ }
+
+ private void removeNodeInDB(ManageableRepository repository, Node node) throws SQLException,
+ RepositoryConfigurationException, NamingException, UnsupportedRepositoryOperationException, RepositoryException
+ {
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
- // remove all properties
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+
+ String nodeId = (isMultiDb ? "" : wsEntry.getName()) + node.getUUID();
+
Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- while (iter.hasNext())
+
+ ResultSet resultSet =
+ conn.prepareStatement("SELECT * FROM " + iTable + " WHERE PARENT_ID='" + nodeId + "'").executeQuery();
+ while (resultSet.next())
{
- PropertyImpl prop = (PropertyImpl)iter.nextProperty();
+ String propertyId = resultSet.getString(DBConstants.COLUMN_ID);
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "'").execute();
+ conn.prepareStatement("DELETE FROM " + vTable + " WHERE PROPERTY_ID = '" + propertyId + "'").execute();
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID = '" + propertyId + "'").execute();
}
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID='" + nodeId + "'").execute();
+
conn.commit();
conn.close();
+ }
- assertFalse(node.getProperties().hasNext());
+ private void removePropertyInDB(ManageableRepository repository, PropertyImpl property) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- session.logout();
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+
+ String propertyId = (isMultiDb ? "" : wsEntry.getName()) + property.getInternalIdentifier();
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DELETE FROM " + vTable + " WHERE PROPERTY_ID = '" + propertyId + "'").execute();
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID = '" + propertyId + "'").execute();
+
+ conn.commit();
+ conn.close();
}
- private void checkDBUsecasesNodeHasPrimaryTypeProperties(ManageableRepository repository) throws Exception
+ private void removeValueRecord(ManageableRepository repository, String propId) throws SQLException,
+ RepositoryConfigurationException, NamingException
{
- // create repository and add node
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- session.save();
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- PropertyIterator iter = node.getProperties();
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // repository is consistent
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DELETE FROM " + vTable + " WHERE PROPERTY_ID = '" + propId + "'").execute();
+ conn.prepareStatement(
+ "ALTER TABLE " + vTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "VALUE_PROPERTY").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void removeReferenceRecord(ManageableRepository repository, String propId) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+
boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // remove all properties
+ String rTable = "JCR_" + (isMultiDb ? "M" : "S") + "REF";
+
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DELETE FROM " + rTable + " WHERE PROPERTY_ID = '" + propId + "'").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void removeItemRecord(ManageableRepository repository, String propId) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
+
Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- while (iter.hasNext())
+
+ conn.prepareStatement(
+ "ALTER TABLE " + vTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "VALUE_PROPERTY").execute();
+ conn.prepareStatement(
+ "ALTER TABLE " + iTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID = '" + propId + "'").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void assingItsOwnParent(ManageableRepository repository, ItemImpl item) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+ String itemId = (isMultiDb ? "" : wsEntry.getName()) + item.getInternalIdentifier();
+
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+ conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT_NAME").execute();
+
+ conn.prepareStatement("UPDATE " + iTable + " SET PARENT_ID='" + itemId + "' WHERE ID='" + itemId + "'").execute();
+
+ conn.commit();
+ conn.close();
+
+ }
+
+ private void clearLockTable(ManageableRepository repository) throws RepositoryConfigurationException, SQLException,
+ NamingException
+ {
+ WorkspaceEntry workspaceEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ LockManagerEntry lockManagerEntry = workspaceEntry.getLockManager();
+
+ String sourceName = null;
+ String queryStatement = null;
+
+ if (helper.ispnCacheEnabled())
{
- PropertyImpl prop = (PropertyImpl)iter.nextProperty();
+ sourceName = lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.datasource");
- if (!prop.getName().equals("jcr:primaryType"))
+ queryStatement =
+ "DELETE FROM " + lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.table.name") + "_" + "L"
+ + workspaceEntry.getUniqueName().replace("_", "").replace("-", "_");
+ }
+ else
+ {
+ sourceName = lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_CL_DATASOURCE);
+
+ if (lockManagerEntry.getParameterBoolean("jbosscache-shareable"))
{
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
-
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ queryStatement =
+ "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
+ + " WHERE PARENT='/" + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "'";
}
+ else
+ {
+ queryStatement =
+ "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
+ + " WHERE PARENT='/" + CacheableLockManagerImpl.LOCKS + "'";
+ }
}
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement(queryStatement).execute();
conn.commit();
conn.close();
+ }
- assertTrue(node.getProperties().hasNext());
+ private void indexNode(ManageableRepository repository, Node node, int state)
+ throws UnsupportedRepositoryOperationException, RepositoryException
+ {
+ // Indexing one more document with same UUID
+ List<SearchManager> searchManagers =
+ repository.getWorkspaceContainer(repository.getConfiguration().getSystemWorkspaceName())
+ .getComponentInstancesOfType(SearchManager.class);
- session.logout();
+ PlainChangesLog log = new PlainChangesLogImpl();
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
+ NodeData data =
+ new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testNode")),
+ node.getUUID(), -1, Constants.NT_UNSTRUCTURED, null, 0, null, new AccessControlList());
- /**
- * Usescase when STORAGE_DESC field in JCR_SVALUE table is not empty but there is no file in the value storage.
- */
- public void testValueStorageUsecasesSingleDb() throws Exception
- {
- checkValueStorageUsecases(helper.createRepository(container, false, false));
+ TransientPropertyData primaryType =
+ new TransientPropertyData(QPath.makeChildPath(data.getQPath(), Constants.JCR_PRIMARYTYPE),
+ IdGenerator.generate(), -1, PropertyType.NAME, data.getIdentifier(), false, new TransientValueData(
+ Constants.NT_UNSTRUCTURED));
+
+ log.add(new ItemState(data, ItemState.ADDED, false, null));
+ log.add(new ItemState(primaryType, ItemState.ADDED, false, null));
+
+ for (SearchManager searchManager : searchManagers)
+ {
+ if (!(searchManager instanceof SystemSearchManager))
+ {
+ searchManager.onSaveItems(log);
+ break;
+ }
+ }
}
- /**
- * Usescase when STORAGE_DESC field in JCR_MVALUE table is not empty but there is no file in the value storage.
- */
- public void testValueStorageUsecasesMultiDb() throws Exception
+ private void insertPropertyRecord(ManageableRepository repository, String id, String parentId, String name)
+ throws RepositoryConfigurationException, SQLException, NamingException, RepositoryException
{
- checkValueStorageUsecases(helper.createRepository(container, true, false));
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ // add another item with new persisted version
+ String propId = (isMultiDb ? "" : wsEntry.getName()) + IdGenerator.generate();
+ parentId = (isMultiDb ? "" : wsEntry.getName()) + parentId;
+
+ conn.prepareStatement(
+ "ALTER TABLE " + iTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+
+ if (isMultiDb)
+ {
+ conn.prepareStatement(
+ "INSERT INTO " + iTable + " VALUES ('" + propId + "','" + parentId + "','[]" + name
+ + "',1,2,1,NULL,1,FALSE)").execute();
+ }
+ else
+ {
+ conn.prepareStatement(
+ "INSERT INTO " + iTable + " VALUES ('" + propId + "','" + parentId + "','[]" + name + "',1,'"
+ + wsEntry.getName() + "',2,1,NULL,1,FALSE)").execute();
+ }
+ conn.prepareStatement("INSERT INTO " + vTable + " VALUES ('10000','data','1','" + propId + "',NULL)").execute();
+
+ conn.commit();
+ conn.close();
}
- private void checkValueStorageUsecases(ManageableRepository repository) throws Exception
+ private void updateValueRecord(ManageableRepository repository, String propId)
+ throws RepositoryConfigurationException, SQLException, NamingException
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- InputStream in = new FileInputStream(createBLOBTempFile(300));
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("testProperty", in);
- session.save();
- in.close();
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
- session.logout();
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // repository is consistent
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkValueStorage().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
- // remove the file from the value storage
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+ conn.prepareStatement(
+ "UPDATE " + vTable + " SET STORAGE_DESC = 'unexisted-desc' WHERE PROPERTY_ID = '" + propId + "'").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void removeFileFromVS(ManageableRepository repository, String propId)
+ throws RepositoryConfigurationException
+ {
String vsPath =
repository.getConfiguration().getWorkspaceEntries().get(0).getContainer().getValueStorages().get(0)
.getParameterValue(FileValueStorage.PATH);
- File vsFile = new File(vsPath, prop.getInternalIdentifier() + "0");
+ File vsFile = new File(vsPath, propId + "0");
assertTrue(vsFile.exists());
assertTrue(vsFile.delete());
-
- assertTrue(checkController.checkValueStorage()
- .startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
- checkController.repairValueStorage("yes");
- assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
}
14 years, 1 month
exo-jcr SVN: r5743 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/storage/jdbc and 2 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2012-03-02 02:57:14 -0500 (Fri, 02 Mar 2012)
New Revision: 5743
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java
Removed:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
jcr/trunk/exo.jcr.component.core/src/test/resources/tsm-excludes.properties
Log:
EXOJCR-1762: auto-repair for DB inconsistency
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AbstractInconsistencyRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -18,6 +18,9 @@
*/
package org.exoplatform.services.jcr.impl.checker;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
@@ -41,6 +44,9 @@
protected final WorkspaceStorageConnectionFactory connFactory;
+ /**
+ * AbstractInconsistencyRepair constructor.
+ */
AbstractInconsistencyRepair(WorkspaceStorageConnectionFactory connFactory)
{
this.connFactory = connFactory;
@@ -60,7 +66,7 @@
throw new SQLException("Connection is instance of " + conn);
}
- repairInternally((JDBCStorageConnection)conn, resultSet);
+ repairRow((JDBCStorageConnection)conn, resultSet);
conn.commit();
}
@@ -76,7 +82,7 @@
}
}
- abstract void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException;
+ abstract void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException;
protected void rollback(WorkspaceStorageConnection conn)
{
@@ -97,7 +103,7 @@
}
}
- protected String exctractId(ResultSet resultSet) throws SQLException
+ protected String exctractId(ResultSet resultSet, String column) throws SQLException
{
String containerName = "";
try
@@ -108,6 +114,12 @@
{
}
- return resultSet.getString(DBConstants.COLUMN_ID).substring(containerName.length());
+ return resultSet.getString(column).substring(containerName.length());
}
+
+ protected QPathEntry extractName(ResultSet resultSet) throws SQLException, IllegalNameException
+ {
+ return new QPathEntry(InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME)),
+ resultSet.getInt(DBConstants.COLUMN_INDEX));
+ }
}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/AssignerRootAsParent.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-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.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: AssignRootAsParentRepair.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class AssignerRootAsParent extends AbstractInconsistencyRepair
-{
-
- public AssignerRootAsParent(WorkspaceStorageConnectionFactory connFactory)
- {
- super(connFactory);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- if (resultSet.getInt(DBConstants.COLUMN_CLASS) == 1)
- {
- repairNode(conn, resultSet);
- }
- else
- {
- repairProperty(conn, resultSet);
- }
- }
-
- private void repairProperty(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String propertyId = exctractId(resultSet);
- QPath path = QPath.parse(resultSet.getString(DBConstants.COLUMN_NAME));
-
- PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
-
- conn.delete(data);
- }
- catch (UnsupportedOperationException e)
- {
- throw new SQLException(e);
- }
- catch (InvalidItemStateException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-
- private void repairNode(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String nodeId = exctractId(resultSet);
- int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
- int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
- QPath path =
- new QPath(new QPathEntry[]{new QPathEntry(
- InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME)),
- resultSet.getInt(DBConstants.COLUMN_INDEX))});
-
- NodeData data =
- new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
-
- conn.rename(data);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalNameException e)
- {
- throw new SQLException(e);
- }
- }
-}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/DummyRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -33,6 +33,6 @@
*/
public void doRepair(ResultSet resultSet) throws SQLException
{
- // do nothing
+ throw new SQLException("Inconsistency can not be fixed automatically");
}
}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/EarlierVersionsRemover.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: EarlierVersionsRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class EarlierVersionsRemover extends AbstractInconsistencyRepair
+{
+
+ /**
+ * RemoveEarlierVersions constructor.
+ */
+ public EarlierVersionsRemover(WorkspaceStorageConnectionFactory connFactory)
+ {
+ super(connFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ PropertyData data = (PropertyData)conn.getItemData(exctractId(resultSet, DBConstants.COLUMN_ID));
+ int maxVersion = conn.getMaxPropertyVersion(data);
+
+ if (resultSet.getInt(DBConstants.COLUMN_VERSION) < maxVersion)
+ {
+ conn.delete(data);
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/InconsistencyRepair.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -28,7 +28,7 @@
public interface InconsistencyRepair
{
/**
- * Repair inconsistency based on resultSet.
+ * Repair inconsistency represented in row of resultSet.
*
* @param resultSet
* @throws SQLException
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/NodeRemover.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: NodeRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class NodeRemover extends AbstractInconsistencyRepair
+{
+ private final NodeTypeDataManager nodeTypeManager;
+
+ /**
+ * NodeRemover constructor.
+ */
+ public NodeRemover(WorkspaceStorageConnectionFactory connFactory, NodeTypeDataManager nodeTypeManager)
+ {
+ super(connFactory);
+ this.nodeTypeManager = nodeTypeManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String parentId = exctractId(resultSet, DBConstants.COLUMN_PARENTID);
+ InternalQName nodeName = InternalQName.parse(resultSet.getString(DBConstants.COLUMN_NAME));
+
+ NodeData parent = (NodeData)conn.getItemData(parentId);
+
+ NodeDefinitionData def =
+ nodeTypeManager.getChildNodeDefinition(nodeName, parent.getPrimaryTypeName(),
+ parent.getMixinTypeNames());
+
+ if (def == null || def.isResidualSet())
+ {
+ String nodeId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
+ int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
+ QPath path = QPath.makeChildPath(parent.getQPath(), extractName(resultSet));
+
+ NodeData data =
+ new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
+
+ deleteTree(conn, data);
+ }
+ else
+ {
+ throw new SQLException("Node is required by its parent.");
+ }
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+
+ private void deleteTree(JDBCStorageConnection conn, NodeData data) throws IllegalStateException,
+ RepositoryException
+ {
+ for (NodeData child : conn.getChildNodesData(data))
+ {
+ deleteTree(conn, child);
+ }
+
+ for (PropertyData prop : conn.getChildPropertiesData(data))
+ {
+ conn.delete(prop);
+ }
+
+ conn.delete(data);
+ }
+}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverEarlierVersions.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: RemoveEarlierVersions.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class RemoverEarlierVersions extends AbstractInconsistencyRepair
-{
-
- /**
- * RemoveEarlierVersions constructor.
- */
- public RemoverEarlierVersions(WorkspaceStorageConnectionFactory connFactory)
- {
- super(connFactory);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- PropertyData data = (PropertyData)conn.getItemData(exctractId(resultSet));
- int maxVersion = conn.getMaxPropertyVersion(data);
-
- if (resultSet.getInt(DBConstants.COLUMN_VERSION) < maxVersion)
- {
- conn.delete(data);
- }
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RemoverValueRecords.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2012 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.checker;
-
-import org.exoplatform.services.jcr.datamodel.IllegalPathException;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
- * @version $Id: RemoverValueRecords.java 34360 2009-07-22 23:58:59Z tolusha $
- */
-public class RemoverValueRecords extends AbstractInconsistencyRepair
-{
-
- private final String containerName;
-
- private final boolean multiDb;
-
- public RemoverValueRecords(WorkspaceStorageConnectionFactory connFactory, String containerName, boolean multiDb)
- {
- super(connFactory);
- this.containerName = containerName;
- this.multiDb = multiDb;
- }
-
- /**
- * {@inheritDoc}
- */
- void repairInternally(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
- {
- try
- {
- String propertyId = exctractId(resultSet);
- QPath path = QPath.parse("[]");
-
- PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
-
- conn.delete(data);
- }
- catch (IllegalPathException e)
- {
- throw new SQLException(e);
- }
- catch (UnsupportedOperationException e)
- {
- throw new SQLException(e);
- }
- catch (JCRInvalidItemStateException e)
- {
- // this is ok, since record is absent in ITEM table
- }
- catch (InvalidItemStateException e)
- {
- throw new SQLException(e);
- }
- catch (IllegalStateException e)
- {
- throw new SQLException(e);
- }
- catch (RepositoryException e)
- {
- throw new SQLException(e);
- }
- }
-
- protected String exctractId(ResultSet resultSet) throws SQLException
- {
- return resultSet.getString(DBConstants.COLUMN_VPROPERTY_ID).substring(multiDb ? 0 : containerName.length());
- }
-}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RepositoryCheckController.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.impl.AbstractRepositorySuspender;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainerChecker;
@@ -353,7 +354,9 @@
WorkspaceEntry wsEntry = (WorkspaceEntry)getComponent(WorkspaceEntry.class, wsName);
- return new JDBCWorkspaceDataContainerChecker(dataContainer, vsPlugin, wsEntry, lastReport);
+ NodeTypeDataManagerImpl nodeTypeManager = (NodeTypeDataManagerImpl)getComponent(NodeTypeDataManagerImpl.class, wsName);
+
+ return new JDBCWorkspaceDataContainerChecker(dataContainer, vsPlugin, wsEntry, nodeTypeManager, lastReport);
}
private Object getComponent(Class forClass, String wsName)
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/RootAsParentAssigner.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+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.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: AssignRootAsParentRepair.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class RootAsParentAssigner extends AbstractInconsistencyRepair
+{
+
+ public RootAsParentAssigner(WorkspaceStorageConnectionFactory connFactory)
+ {
+ super(connFactory);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ if (resultSet.getInt(DBConstants.COLUMN_CLASS) == 1)
+ {
+ assignRootAsParent(conn, resultSet);
+ }
+ else
+ {
+ deleteProperty(conn, resultSet);
+ }
+ }
+
+ private void deleteProperty(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String propertyId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ QPath path = QPath.parse(resultSet.getString(DBConstants.COLUMN_NAME));
+
+ PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
+
+ conn.delete(data);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+
+ private void assignRootAsParent(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String nodeId = exctractId(resultSet, DBConstants.COLUMN_ID);
+ int orderNum = resultSet.getInt(DBConstants.COLUMN_NORDERNUM);
+ int version = resultSet.getInt(DBConstants.COLUMN_VERSION);
+ QPath path = new QPath(new QPathEntry[]{extractName(resultSet)});
+
+ NodeData data = new TransientNodeData(path, nodeId, version, null, null, orderNum, Constants.ROOT_UUID, null);
+
+ conn.rename(data);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalNameException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/checker/ValueRecordsRemover.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2012 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.checker;
+
+import org.exoplatform.services.jcr.datamodel.IllegalPathException;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="abazko(a)exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: ValueRecordsRemover.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class ValueRecordsRemover extends AbstractInconsistencyRepair
+{
+
+ private final String containerName;
+
+ private final boolean multiDb;
+
+ /**
+ * ValueRecordsRemover constructor.
+ */
+ public ValueRecordsRemover(WorkspaceStorageConnectionFactory connFactory, String containerName, boolean multiDb)
+ {
+ super(connFactory);
+ this.containerName = containerName;
+ this.multiDb = multiDb;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ void repairRow(JDBCStorageConnection conn, ResultSet resultSet) throws SQLException
+ {
+ try
+ {
+ String propertyId = exctractId(resultSet, DBConstants.COLUMN_VPROPERTY_ID);
+ QPath path = QPath.parse("[]");
+
+ PropertyData data = new TransientPropertyData(path, propertyId, 0, 0, null, false, new ArrayList<ValueData>());
+
+ conn.delete(data);
+ }
+ catch (IllegalPathException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (UnsupportedOperationException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (JCRInvalidItemStateException e)
+ {
+ // this is ok, since record is absent in ITEM table
+ }
+ catch (InvalidItemStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (IllegalStateException e)
+ {
+ throw new SQLException(e);
+ }
+ catch (RepositoryException e)
+ {
+ throw new SQLException(e);
+ }
+ }
+
+ protected String exctractId(ResultSet resultSet, String column) throws SQLException
+ {
+ return resultSet.getString(column).substring(multiDb ? 0 : containerName.length());
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -23,15 +23,18 @@
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.checker.AssignerRootAsParent;
import org.exoplatform.services.jcr.impl.checker.DummyRepair;
+import org.exoplatform.services.jcr.impl.checker.EarlierVersionsRemover;
import org.exoplatform.services.jcr.impl.checker.InspectionQuery;
import org.exoplatform.services.jcr.impl.checker.InspectionQueryFilteredMultivaluedProperties;
import org.exoplatform.services.jcr.impl.checker.InspectionReport;
-import org.exoplatform.services.jcr.impl.checker.RemoverEarlierVersions;
-import org.exoplatform.services.jcr.impl.checker.RemoverValueRecords;
+import org.exoplatform.services.jcr.impl.checker.NodeRemover;
+import org.exoplatform.services.jcr.impl.checker.PropertyRemover;
+import org.exoplatform.services.jcr.impl.checker.ValueRecordsRemover;
+import org.exoplatform.services.jcr.impl.checker.RootAsParentAssigner;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandler;
import org.exoplatform.services.jcr.impl.core.lock.LockTableHandlerFactory;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
@@ -78,17 +81,21 @@
private LockTableHandler lockHandler;
+ private NodeTypeDataManagerImpl nodeTypeManager;
+
/**
* JDBCWorkspaceDataContainerChecker constructor.
*/
public JDBCWorkspaceDataContainerChecker(JDBCWorkspaceDataContainer jdbcDataContainer,
- ValueStoragePluginProvider vsPlugin, WorkspaceEntry workspaceEntry, InspectionReport report)
+ ValueStoragePluginProvider vsPlugin, WorkspaceEntry workspaceEntry, NodeTypeDataManagerImpl nodeTypeManager,
+ InspectionReport report)
{
this.jdbcDataContainer = jdbcDataContainer;
this.vsPlugin = vsPlugin;
this.workspaceEntry = workspaceEntry;
this.report = report;
this.lockHandler = LockTableHandlerFactory.getHandler(workspaceEntry);
+ this.nodeTypeManager = nodeTypeManager;
initInspectionQueries();
}
@@ -164,13 +171,19 @@
{
((JDBCStorageConnection)conn).deleteLockProperties(nodeId);
}
-
+ conn.commit();
logComment("Lock has been removed form ITEM table. Node UUID: " + nodeId);
}
- finally
+ catch (RepositoryException e)
{
- conn.close();
+ conn.rollback();
+ throw e;
}
+ catch (SQLException e)
+ {
+ conn.rollback();
+ throw e;
+ }
}
}
}
@@ -221,6 +234,7 @@
if (resultSet.next())
{
logDescription(query.getDescription());
+
do
{
logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, query.getFieldNames()));
@@ -233,12 +247,8 @@
}
catch (SQLException e)
{
- if (LOG.isTraceEnabled())
- {
- LOG.trace(e.getMessage(), e);
- }
+ logExceptionAndSetInconsistency("Inconsistency can not been fixed", e);
}
-
}
}
while (resultSet.next());
@@ -287,24 +297,26 @@
if (resultSet.next())
{
+ logDescription("ValueData not found inconsistency");
+
do
{
- String propertyId = removeWorkspacePrefix(resultSet.getString(DBConstants.COLUMN_VPROPERTY_ID));
- int orderNumber = resultSet.getInt(DBConstants.COLUMN_VORDERNUM);
String storageDesc = resultSet.getString(DBConstants.COLUMN_VSTORAGE_DESC);
ValueIOChannel channel = null;
try
{
channel = getIOChannel(storageDesc);
- doCheckAndRepairValueData(channel, resultSet, propertyId, orderNumber, autoRepair);
+ doCheckAndRepairValueData(channel, resultSet, autoRepair);
}
catch (IOException e)
{
- logDescription("Unexpected exception during checking");
- logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, vsInspectionQuery.getFieldNames()));
- logExceptionAndSetInconsistency(e.getMessage(), e);
+ logExceptionAndSetInconsistency("Unexpected exception during checking.", e);
}
+ catch (SQLException e)
+ {
+ logExceptionAndSetInconsistency("Unexpected exception during checking.", e);
+ }
finally
{
if (channel != null)
@@ -339,32 +351,37 @@
}
catch (ValueStorageNotFoundException e)
{
- logDescription("ValueStorage " + storageDesc + " not found");
- logExceptionAndSetInconsistency(e.getMessage(), e);
+ logExceptionAndSetInconsistency("ValueStorage " + storageDesc + " not found: " + e.getMessage(), e);
}
return channel;
}
- private void doCheckAndRepairValueData(ValueIOChannel channel, ResultSet resultSet, String propertyId,
- int orderNumber, boolean autoRepair) throws IOException
+ private void doCheckAndRepairValueData(ValueIOChannel channel, ResultSet resultSet, boolean autoRepair)
+ throws IOException, SQLException
{
+ String propertyId = removeWorkspacePrefix(resultSet.getString(DBConstants.COLUMN_VPROPERTY_ID));
+ int orderNumber = resultSet.getInt(DBConstants.COLUMN_VORDERNUM);
+
try
{
channel.checkValueData(propertyId, orderNumber);
}
catch (ValueDataNotFoundException e)
{
- String brokenObject = getBrokenObject(resultSet, vsInspectionQuery.getFieldNames());
+ logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, vsInspectionQuery.getFieldNames()));
- logDescription("ValueData not found");
- logBrokenObjectAndSetInconsistency(brokenObject);
- logExceptionAndSetInconsistency(e.getMessage(), e);
-
if (autoRepair)
{
- channel.repairValueData(propertyId, orderNumber);
- logComment("ValueData corresponding to " + brokenObject + " has been repaired. New empty file is created.");
+ try
+ {
+ channel.repairValueData(propertyId, orderNumber);
+ logComment("ValueData has been repaired. New empty file is created.");
+ }
+ catch (IOException e2)
+ {
+ logExceptionAndSetInconsistency("Can not repair value data: " + e.getMessage(), e);
+ }
}
}
}
@@ -469,7 +486,7 @@
: "select * from JCR_SITEM I where I.CONTAINER_NAME='" + jdbcDataContainer.containerName
+ "' and NOT EXISTS(select * from JCR_SITEM P where P.ID = I.PARENT_ID)", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME, DBConstants.COLUMN_CLASS},
- "Items that do not have parent nodes", new AssignerRootAsParent(jdbcDataContainer
+ "Items that do not have parent nodes", new RootAsParentAssigner(jdbcDataContainer
.getConnectionFactory())));
itemsInspectionQuery
@@ -480,7 +497,8 @@
+ jdbcDataContainer.containerName + "' and P.I_CLASS=2"
+ " and P.P_MULTIVALUED=? and NOT EXISTS( select * from JCR_SVALUE V where V.PROPERTY_ID=P.ID)",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
- "A node that has a single valued properties with nothing declared in the VALUE table.", new DummyRepair()));
+ "A node that has a single valued properties with nothing declared in the VALUE table.",
+ new PropertyRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MITEM N where N.I_CLASS=1 and NOT EXISTS "
@@ -491,7 +509,7 @@
+ "where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.NAME='[http://www.jcp.org/jcr/1.0]primaryType' "
+ "and P.CONTAINER_NAME='" + jdbcDataContainer.containerName + "')", new String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "A node that doesn't have primary type property",
- new DummyRepair()));
+ new NodeRemover(jdbcDataContainer.getConnectionFactory(), nodeTypeManager)));
itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P "
@@ -499,7 +517,7 @@
: "select * from JCR_SVALUE V where NOT EXISTS(select * from JCR_SITEM P "
+ "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)", new String[]{DBConstants.COLUMN_ID,
DBConstants.COLUMN_VPROPERTY_ID}, "All value records that has not related property record",
- new RemoverValueRecords(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerName,
+ new ValueRecordsRemover(jdbcDataContainer.getConnectionFactory(), jdbcDataContainer.containerName,
jdbcDataContainer.multiDb)));
// The differences in the queries by DB dialect.
@@ -537,7 +555,7 @@
: "select * from JCR_SITEM I where I.ID = I.PARENT_ID and I.CONTAINER_NAME='"
+ jdbcDataContainer.containerName + "' and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent.",
- new AssignerRootAsParent(jdbcDataContainer.getConnectionFactory())));
+ new RootAsParentAssigner(jdbcDataContainer.getConnectionFactory())));
itemsInspectionQuery
.add(new InspectionQuery(
@@ -552,7 +570,7 @@
+ " and I.VERSION != J.VERSION)",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME,
DBConstants.COLUMN_VERSION, DBConstants.COLUMN_CLASS, DBConstants.COLUMN_INDEX},
- "Several versions of same item.", new RemoverEarlierVersions(jdbcDataContainer.getConnectionFactory())));
+ "Several versions of same item.", new EarlierVersionsRemover(jdbcDataContainer.getConnectionFactory())));
itemsInspectionQuery.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MITEM P, JCR_MVALUE V where P.ID=V.PROPERTY_ID and P.P_TYPE=9 and NOT EXISTS "
@@ -561,6 +579,7 @@
+ jdbcDataContainer.containerName
+ "' and P.P_TYPE=9 and NOT EXISTS (select * from JCR_SREF R where P.ID=R.PROPERTY_ID)", new String[]{
DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME},
- "Reference properties without reference records", new DummyRepair()));
+ "Reference properties without reference records", new PropertyRemover(jdbcDataContainer
+ .getConnectionFactory(), nodeTypeManager)));
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2012-03-02 07:57:14 UTC (rev 5743)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.BaseStandaloneTest;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.config.LockManagerEntry;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.dataflow.ItemState;
@@ -30,7 +31,7 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.checker.RepositoryCheckController;
-import org.exoplatform.services.jcr.impl.checker.RepositoryCheckController.DataStorage;
+import org.exoplatform.services.jcr.impl.core.ItemImpl;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.PropertyImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -40,6 +41,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.storage.value.fs.FileValueStorage;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -47,14 +49,20 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.List;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
import javax.jcr.Node;
-import javax.jcr.PropertyIterator;
+import javax.jcr.Property;
import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.sql.DataSource;
/**
@@ -74,27 +82,18 @@
private static boolean CACHE_ENABLED = true;
+ private static boolean CACHE_DISABLED = false;
+
private final TesterConfigurationHelper helper = TesterConfigurationHelper.getInstance();
- /**
- * @see org.exoplatform.services.jcr.BaseStandaloneTest#getRepositoryName()
- */
- @Override
protected String getRepositoryName()
{
- String repName = System.getProperty("test.repository");
- if (repName == null)
- {
- throw new RuntimeException(
- "Test repository is undefined. Set test.repository system property "
- + "(For maven: in project.properties: maven.junit.sysproperties=test.repository\ntest.repository=<rep-name>)");
- }
- return repName;
-
+ return null;
}
public void tearDown() throws Exception
{
+ // remove generated reports
for (File file : new File(".").listFiles())
{
if (file.getName().startsWith("report"))
@@ -106,270 +105,96 @@
super.tearDown();
}
- public void testDB() throws Exception
+ public void testCheckDataBase() throws Exception
{
TesterRepositoryCheckController checkController =
new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.DB}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testConsistentLocksInDataBase() throws Exception
+ public void testLockUsecases() throws Exception
{
- checkConsistentLocksInDataBase(NOT_SHARED_CACHE, SINGLE_DB);
- checkConsistentLocksInDataBase(NOT_SHARED_CACHE, MULTI_DB);
- }
+ checkConsistentLocksInDataBase(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkConsistentLocksInDataBase(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkConsistentLocksInDataBase(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, SHARED_CACHE));
+ checkConsistentLocksInDataBase(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, SHARED_CACHE));
- public void testConsistentLocksInDataBaseSharedCache() throws Exception
- {
- checkConsistentLocksInDataBase(SHARED_CACHE, SINGLE_DB);
- checkConsistentLocksInDataBase(SHARED_CACHE, MULTI_DB);
+ checkInconsistentLocksInLockTable(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkInconsistentLocksInLockTable(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, NOT_SHARED_CACHE));
+ checkInconsistentLocksInLockTable(helper.createRepository(container, SINGLE_DB, CACHE_ENABLED, SHARED_CACHE));
+ checkInconsistentLocksInLockTable(helper.createRepository(container, MULTI_DB, CACHE_ENABLED, SHARED_CACHE));
}
- private void checkConsistentLocksInDataBase(boolean isCacheShared, boolean isMultiDb) throws Exception
+ private void checkConsistentLocksInDataBase(ManageableRepository repository) throws Exception
{
- ManageableRepository repository = helper.createRepository(container, isMultiDb, CACHE_ENABLED, isCacheShared);
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- node.addMixin("mix:lockable");
- session.save();
- node.lock(false, false);
-
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.DB}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
+ Node node = addTestNode(repository);
+ lockNode(node);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- public void testInconsistentLocksInDataBase() throws Exception
- {
- checkInconsistentLocksInItemTable(NOT_SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInItemTable(NOT_SHARED_CACHE, MULTI_DB);
+ removePropertyInDB(repository, (PropertyImpl)node.getProperty("jcr:lockIsDeep"));
+ removePropertyInDB(repository, (PropertyImpl)node.getProperty("jcr:lockOwner"));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- checkInconsistentLocksInLockTable(NOT_SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInLockTable(NOT_SHARED_CACHE, MULTI_DB);
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testInconsistentLocksInDataBaseWithSharedCache() throws Exception
+ private void checkInconsistentLocksInLockTable(ManageableRepository repository) throws Exception
{
- checkInconsistentLocksInItemTable(SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInItemTable(SHARED_CACHE, MULTI_DB);
-
- checkInconsistentLocksInLockTable(SHARED_CACHE, SINGLE_DB);
- checkInconsistentLocksInLockTable(SHARED_CACHE, MULTI_DB);
- }
-
- private void checkInconsistentLocksInItemTable(boolean cacheShared, boolean isMultiDb) throws Exception
- {
- ManageableRepository repository = helper.createRepository(container, isMultiDb, CACHE_ENABLED, cacheShared);
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- node.addMixin("mix:lockable");
- session.save();
- node.lock(false, false);
-
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- WorkspaceEntry workspaceEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- String sourceName = workspaceEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ Node node = addTestNode(repository);
+ lockNode(node);
- String multiDbQueryStatement =
- "DELETE FROM JCR_MITEM WHERE I_CLASS=2 "
- + "AND (NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')";
- String singleDbQueryStatement =
- "DELETE FROM JCR_SITEM WHERE CONTAINER_NAME='"
- + workspaceEntry.getName()
- + "' AND I_CLASS=2 AND (NAME='[http://www.jcp.org/jcr/1.0]lockOwner' OR NAME='[http://www.jcp.org/jcr/1.0]lockIsDeep')";
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- // remove constraint
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "ITEM DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "VALUE_PROPERTY").execute();
- // delete properties (this should cause inconsistency)
- conn.prepareStatement(isMultiDb ? multiDbQueryStatement : singleDbQueryStatement).execute();
-
- // remove constriant
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "VALUE DROP CONSTRAINT JCR_PK_" + (isMultiDb ? "M" : "S")
- + "VALUE").execute();
-
- // clean up properties value to avoid another (except needed) cause of inconsistency
- String lockOwnerPropertyId =
- (isMultiDb ? "" : workspaceEntry.getName())
- + ((PropertyImpl)node.getProperty("jcr:lockIsDeep")).getInternalIdentifier();
- String lockIsDeepPropertyId =
- (isMultiDb ? "" : workspaceEntry.getName())
- + ((PropertyImpl)node.getProperty("jcr:lockOwner")).getInternalIdentifier();
-
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '" + lockOwnerPropertyId
- + "' OR PROPERTY_ID = '" + lockIsDeepPropertyId + "'").execute();
- conn.commit();
- conn.close();
-
+ clearLockTable(repository);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
- assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- private void checkInconsistentLocksInLockTable(boolean cacheShared, boolean isMultiDb) throws Exception
+ public void testCheckValueStorage() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, isMultiDb, true, cacheShared);
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- node.addMixin("mix:lockable");
- session.save();
- node.lock(false, false);
+ TesterRepositoryCheckController checkController =
+ new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- WorkspaceEntry workspaceEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- LockManagerEntry lockManagerEntry = workspaceEntry.getLockManager();
-
- String sourceName = null;
- String queryStatement = null;
-
- if (helper.ispnCacheEnabled())
- {
- sourceName = lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.datasource");
-
- queryStatement =
- "DELETE FROM " + lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.table.name") + "_" + "L"
- + workspaceEntry.getUniqueName().replace("_", "").replace("-", "_");
- }
- else
- {
- sourceName = lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_CL_DATASOURCE);
-
- if (cacheShared)
- {
- queryStatement =
- "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
- + " WHERE PARENT='/" + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "'";
- }
- else
- {
- queryStatement =
- "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
- + " WHERE PARENT='/" + CacheableLockManagerImpl.LOCKS + "'";
- }
-
- }
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement(queryStatement).execute();
- conn.commit();
- conn.close();
-
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.DB}, false);
- assertNotNull(result);
- assertTrue("Repository data is consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testValueStorage() throws Exception
+ public void testCheckIndex() throws Exception
{
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+ TesterRepositoryCheckController checkController =
+ new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- File f = this.createBLOBTempFile(20);
- InputStream is = new FileInputStream(f);
- try
- {
- Node n = root.addNode("node");
- n.setProperty("prop", is);
-
- root.save();
-
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.VALUE_STORAGE}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
- finally
- {
- is.close();
- f.delete();
- }
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testSearchIndex() throws Exception
+ public void testCheckAll() throws Exception
{
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+ TesterRepositoryCheckController checkController =
+ new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
- String result = checkController.checkAndRepair(new DataStorage[]{DataStorage.LUCENE_INDEX}, false);
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkAll().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- public void testAll() throws Exception
- {
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
-
- String result =
- checkController.checkAndRepair(new DataStorage[]{DataStorage.DB, DataStorage.VALUE_STORAGE,
- DataStorage.LUCENE_INDEX}, false);
-
-
- assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
-
/**
* Index contains documents that was already removed from DB.
*/
public void testIndexUsecaseWrongDocumentId() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, false, false);
-
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- session.save();
- session.logout();
-
- // repository is consistent
+ ManageableRepository repository = helper.createRepository(container, SINGLE_DB, CACHE_DISABLED);
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
-
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // Remove node from DB
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "ITEM DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "ITEM_PARENT").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ removeNodeInDB(repository, node);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
@@ -377,60 +202,14 @@
*/
public void testIndexUsecaseMultipleDocuments() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, false, false);
-
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- session.save();
- session.logout();
-
- // repository is consistent
+ ManageableRepository repository = helper.createRepository(container, SINGLE_DB, CACHE_DISABLED);
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // Indexing one more document with same UUID
- List<SearchManager> searchManagers =
- repository.getWorkspaceContainer(repository.getConfiguration().getSystemWorkspaceName())
- .getComponentInstancesOfType(SearchManager.class);
-
- PlainChangesLog log = new PlainChangesLogImpl();
-
- NodeData data =
- new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testNode")),
- node.getIdentifier(), -1, Constants.NT_UNSTRUCTURED, null, 0, null, new AccessControlList());
-
- TransientPropertyData primaryType =
- new TransientPropertyData(QPath.makeChildPath(data.getQPath(), Constants.JCR_PRIMARYTYPE),
- IdGenerator.generate(), -1, PropertyType.NAME, data.getIdentifier(), false, new TransientValueData(
- Constants.NT_UNSTRUCTURED));
-
- log.add(new ItemState(data, ItemState.ADDED, false, null));
- log.add(new ItemState(primaryType, ItemState.ADDED, false, null));
-
- SearchManager sm = null;
- for (SearchManager searchManager : searchManagers)
- {
- if (!(searchManager instanceof SystemSearchManager))
- {
- sm = searchManager;
- break;
- }
- }
-
- assertNotNull(sm);
- sm.onSaveItems(log);
-
- // repository is inconsistent
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ indexNode(repository, node, ItemState.ADDED);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
@@ -438,114 +217,36 @@
*/
public void testIndexUsecaseDocumentNotExists() throws Exception
{
- ManageableRepository repository = helper.createRepository(container, false, false);
-
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- session.save();
- session.logout();
-
- // repository is consistent
+ ManageableRepository repository = helper.createRepository(container, SINGLE_DB, CACHE_DISABLED);
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // Indexing one more document with same UUID
- List<SearchManager> searchManagers =
- repository.getWorkspaceContainer(repository.getConfiguration().getSystemWorkspaceName())
- .getComponentInstancesOfType(SearchManager.class);
-
- PlainChangesLog log = new PlainChangesLogImpl();
-
- NodeData data =
- new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testNode")),
- node.getIdentifier(), -1, Constants.NT_UNSTRUCTURED, null, 0, null, new AccessControlList());
-
- TransientPropertyData primaryType =
- new TransientPropertyData(QPath.makeChildPath(data.getQPath(), Constants.JCR_PRIMARYTYPE),
- IdGenerator.generate(), -1, PropertyType.NAME, data.getIdentifier(), false, new TransientValueData(
- Constants.NT_UNSTRUCTURED));
-
- log.add(new ItemState(primaryType, ItemState.DELETED, false, null));
- log.add(new ItemState(data, ItemState.DELETED, false, null));
-
- SearchManager sm = null;
- for (SearchManager searchManager : searchManagers)
- {
- if (!(searchManager instanceof SystemSearchManager))
- {
- sm = searchManager;
- break;
- }
- }
-
- assertNotNull(sm);
- sm.onSaveItems(log);
-
- // repository is inconsistent
- assertTrue(checkController.checkIndex().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ indexNode(repository, node, ItemState.DELETED);
+ assertTrue(checkController.checkIndex().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
* Usecase: property doens't have have parent node.
*/
- public void testDBUsecasesTheParentIdIsIdOfThisNodeSingleDB() throws Exception
+ public void testDBUsecasesTheParentIdIsIdOfThisNode() throws Exception
{
- checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, false, false));
- checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, false, false));
- }
+ checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
- /**
- * Usecase: property doens't have have parent node.
- */
- public void testDBUsecasesTheParentIdIsIdOfThisNodeMultiDB() throws Exception
- {
- checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, true, false));
- checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, true, false));
+ checkDBUsecasesTheParentIdIsIdOfThisNode(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
+ checkDBUsecasesTheParentIdIsIdOfThisNode2(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
private void checkDBUsecasesTheParentIdIsIdOfThisNode(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
- conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT_NAME").execute();
- conn.prepareStatement(
- "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "ITEM SET PARENT_ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "' WHERE ID='" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
+ assingItsOwnParent(repository, (ItemImpl)node);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
@@ -555,106 +256,39 @@
private void checkDBUsecasesTheParentIdIsIdOfThisNode2(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ Node node = addTestNode(repository);
+ Property prop = addTestProperty(repository, node);
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
- conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT_NAME").execute();
- conn.prepareStatement(
- "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "ITEM SET PARENT_ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "' WHERE ID='" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
+ assingItsOwnParent(repository, (ItemImpl)prop);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
-
}
/**
* Usecase: property doens't have have parent node.
*/
- public void testDBUsecasesSeveralVersionsOfSameItemSingleDB() throws Exception
+ public void testDBUsecasesSeveralVersionsOfSameItem() throws Exception
{
- checkSeveralVersionsOfSameItem(helper.createRepository(container, false, false));
+ checkSeveralVersionsOfSameItem(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkSeveralVersionsOfSameItem(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: property doens't have have parent node.
- */
- public void testDBUsecasesSeveralVersionsOfSameItemMultiDB() throws Exception
- {
- checkSeveralVersionsOfSameItem(helper.createRepository(container, true, false));
- }
-
private void checkSeveralVersionsOfSameItem(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- // add another item with new persisted version
- if (isMultiDb)
- {
- String propId = IdGenerator.generate();
- conn.prepareStatement(
- "INSERT INTO JCR_MITEM VALUES ('" + propId + "','" + prop.getParentIdentifier()
- + "','[]prop',1,2,1,NULL,1,FALSE)").execute();
- conn.prepareStatement("ALTER TABLE JCR_MVALUE DROP CONSTRAINT JCR_PK_MVALUE").execute();
- conn.prepareStatement("INSERT INTO JCR_MVALUE VALUES ('100','data','1','" + propId + "',NULL)").execute();
- }
- else
- {
- String propId = wsEntry.getName() + IdGenerator.generate();
- conn.prepareStatement(
- "INSERT INTO JCR_SITEM VALUES ('" + propId + "','" + wsEntry.getName() + prop.getParentIdentifier()
- + "','[]prop',1,'" + wsEntry.getName() + "',2,1,NULL,1,FALSE)").execute();
- conn.prepareStatement("ALTER TABLE JCR_SVALUE DROP CONSTRAINT JCR_PK_SVALUE").execute();
- conn.prepareStatement("INSERT INTO JCR_SVALUE VALUES ('100','data','1','" + propId + "',NULL)").execute();
- }
-
- conn.commit();
- conn.close();
-
+ insertPropertyRecord(repository, prop.getInternalIdentifier(), prop.getParentIdentifier(), prop.getName());
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
@@ -664,159 +298,68 @@
/**
* Usecase: property doens't have have parent node.
*/
- public void testDBUsecasesPropertyWithoutParentSingleDB() throws Exception
+ public void testDBUsecasesPropertyWithoutParent() throws Exception
{
- checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, false, false));
+ checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: property doens't have have parent node.
- */
- public void testDBUsecasesPropertyWithoutParentMultiDB() throws Exception
- {
- checkDBUsecasesPropertyWithoutParent(helper.createRepository(container, true, false));
- }
-
private void checkDBUsecasesPropertyWithoutParent(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ insertPropertyRecord(repository, IdGenerator.generate(), IdGenerator.generate(), "testName");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
-
- // change ITEM table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
-
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "ITEM DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "ITEM_PARENT").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + node.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
* Usecase: Incorrect JCR_VALUE records.
*/
- public void testDBUsecasesIncorrectValueRecordsSingleDB() throws Exception
+ public void testDBUsecasesIncorrectValueRecords() throws Exception
{
- checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, false, false));
+ checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: Incorrect JCR_VALUE records.
- */
- public void testDBUsecasesIncorrectValueRecordsMultiDB() throws Exception
- {
- checkDBUsecasesIncorrectValueRecords(helper.createRepository(container, true, false));
- }
-
private void checkDBUsecasesIncorrectValueRecords(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // change VALUE table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ updateValueRecord(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "UPDATE JCR_" + (isMultiDb ? "M" : "S") + "VALUE SET STORAGE_DESC = 'unexisted-desc' WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
}
/**
* Usecase: value records has no item record.
*/
- public void testDBUsecasesValueRecordHasNoItemRecordSingleDB() throws Exception
+ public void testDBUsecasesValueRecordHasNoItemRecord() throws Exception
{
- checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, false, false));
+ checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase: value records has no item record.
- */
- public void testDBUsecasesValueRecordHasNoItemRecordMultiDB() throws Exception
- {
- checkDBUsecasesValueRecordHasNoItemRecord(helper.createRepository(container, true, false));
- }
-
private void checkDBUsecasesValueRecordHasNoItemRecord(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // remove records from item table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
-
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "ALTER TABLE JCR_" + (isMultiDb ? "M" : "S") + "VALUE DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S")
- + "VALUE_PROPERTY").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "'").execute();
-
- conn.commit();
- conn.close();
-
- // repository is inconsistent
+ removeItemRecord(repository, prop.getInternalIdentifier());
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.repairDataBase("yes");
@@ -826,289 +369,437 @@
/**
* Usecase: properties that have not value record.
*/
- public void testDBUsecasesPropertiesHasNoValueRecordSingleDB() throws Exception
+ public void testDBUsecasesPropertiesHasNoValueRecord() throws Exception
{
- checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, false, false));
- checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, false, false));
- }
+ checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
- /**
- * Usecase: properties that have not value record.
- */
- public void testDBUsecasesPropertiesHasNoValueRecordMultiDB() throws Exception
- {
- checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, true, false));
- checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, false, false));
+ checkDBUsecasesPropertiesHasNoSingleValueRecord(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
+ checkDBUsecasesPropertiesHasEmptyMultiValueRecord(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
private void checkDBUsecasesPropertiesHasNoSingleValueRecord(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", "test");
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)addTestProperty(repository, node);
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // remove records from value table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ removeValueRecord(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- conn.commit();
- conn.close();
-
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
}
private void checkDBUsecasesPropertiesHasEmptyMultiValueRecord(ManageableRepository repository) throws Exception
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("prop", new String[]{});
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
+ Node node = addTestNode(repository);
+ node.setProperty("prop", new String[]{});
+ node.save();
- /**
- * Usecase: reference properties without reference records.
- */
- public void testDBUsecasesReferencePropertyWithoutReferenceRecordSingleDB() throws Exception
- {
- checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, false, false));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
* Usecase: reference properties without reference records.
*/
- public void testDBUsecasesReferencePropertyWithoutReferenceRecordMultiDB() throws Exception
+ public void testDBUsecasesReferencePropertyWithoutReferenceRecord() throws Exception
{
- checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, true, false));
+ checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, SINGLE_DB,
+ CACHE_DISABLED));
+ checkDBUsecasesReferencePropertyWithoutReferenceRecord(helper.createRepository(container, MULTI_DB,
+ CACHE_DISABLED));
}
private void checkDBUsecasesReferencePropertyWithoutReferenceRecord(ManageableRepository repository)
throws Exception
{
- // create repository and add ref property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl refNode = (NodeImpl)session.getRootNode().addNode("refNode");
- refNode.addMixin("mix:referenceable");
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- PropertyImpl prop = (PropertyImpl)node.setProperty("refProp", refNode);
- session.save();
- session.logout();
-
- // repository is consistent
TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ Node node = addTestNode(repository);
+ Node node2 = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)node2.setProperty("prop", node);
+ node2.save();
- WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- // remove records from ref table
- String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ removeReferenceRecord(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
- Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "REF WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ }
- conn.commit();
- conn.close();
+ /**
+ * Usecase when node doesn't have at primary type property.
+ */
+ public void testDBUsecasesNodeHasNoProperties() throws Exception
+ {
+ checkDBUsecasesNodeHasNotPrimaryTypeProperties(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkDBUsecasesNodeHasNotPrimaryTypeProperties(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
+ }
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+ private void checkDBUsecasesNodeHasNotPrimaryTypeProperties(ManageableRepository repository) throws Exception
+ {
+ TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+ Node node = addTestNode(repository);
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+
+ removePropertyInDB(repository, (PropertyImpl)node.getProperty("jcr:primaryType"));
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+
+ checkController.repairDataBase("yes");
+ assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
- * Usecase when node doesn't have at least one property.
+ * Usescase when STORAGE_DESC field in VALUE table is not empty but there is no file in the value storage.
*/
- public void testDBUsecasesNodeHasNoPropertiesSingleDB() throws Exception
+ public void testValueStorageUsecases() throws Exception
{
- checkDBUsecasesNodeHasNoProperties(helper.createRepository(container, false, false));
- checkDBUsecasesNodeHasPrimaryTypeProperties(helper.createRepository(container, false, false));
+ checkValueStorageUsecases(helper.createRepository(container, SINGLE_DB, CACHE_DISABLED));
+ checkValueStorageUsecases(helper.createRepository(container, MULTI_DB, CACHE_DISABLED));
}
- /**
- * Usecase when node doesn't have at least one property.
- */
- public void testDBUsecasesNodeHasNoPropertiesMultiDB() throws Exception
+ private void checkValueStorageUsecases(ManageableRepository repository) throws Exception
{
- checkDBUsecasesNodeHasNoProperties(helper.createRepository(container, true, false));
- checkDBUsecasesNodeHasPrimaryTypeProperties(helper.createRepository(container, false, false));
+ TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
+
+ Node node = addTestNode(repository);
+ PropertyImpl prop = (PropertyImpl)node.setProperty("prop", new FileInputStream(createBLOBTempFile(300)));
+ node.save();
+
+ assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+
+ removeFileFromVS(repository, prop.getInternalIdentifier());
+ assertTrue(checkController.checkValueStorage()
+ .startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+
+ checkController.repairValueStorage("yes");
+ assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
- private void checkDBUsecasesNodeHasNoProperties(ManageableRepository repository) throws Exception
+ private Node addTestNode(ManageableRepository repository) throws LoginException, NoSuchWorkspaceException,
+ RepositoryException
{
- // create repository and add node
SessionImpl session =
(SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
+
NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
+ node.addMixin("mix:referenceable");
session.save();
- PropertyIterator iter = node.getProperties();
+ return node;
+ }
- // repository is consistent
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ private Property addTestProperty(ManageableRepository repository, Node node) throws LoginException,
+ NoSuchWorkspaceException, RepositoryException
+ {
+ Property prop = node.setProperty("testProp", "value");
+ node.save();
+ return prop;
+ }
+ private void lockNode(Node node) throws LoginException, NoSuchWorkspaceException, RepositoryException
+ {
+ node.addMixin("mix:lockable");
+ node.save();
+
+ node.lock(false, false);
+ }
+
+ private void removeNodeInDB(ManageableRepository repository, Node node) throws SQLException,
+ RepositoryConfigurationException, NamingException, UnsupportedRepositoryOperationException, RepositoryException
+ {
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
- // remove all properties
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+
+ String nodeId = (isMultiDb ? "" : wsEntry.getName()) + node.getUUID();
+
Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- while (iter.hasNext())
+
+ ResultSet resultSet =
+ conn.prepareStatement("SELECT * FROM " + iTable + " WHERE PARENT_ID='" + nodeId + "'").executeQuery();
+ while (resultSet.next())
{
- PropertyImpl prop = (PropertyImpl)iter.nextProperty();
+ String propertyId = resultSet.getString(DBConstants.COLUMN_ID);
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '" + (isMultiDb ? "" : wsEntry.getName())
- + prop.getInternalIdentifier() + "'").execute();
+ conn.prepareStatement("DELETE FROM " + vTable + " WHERE PROPERTY_ID = '" + propertyId + "'").execute();
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID = '" + propertyId + "'").execute();
}
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID='" + nodeId + "'").execute();
+
conn.commit();
conn.close();
+ }
- assertFalse(node.getProperties().hasNext());
+ private void removePropertyInDB(ManageableRepository repository, PropertyImpl property) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- session.logout();
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+
+ String propertyId = (isMultiDb ? "" : wsEntry.getName()) + property.getInternalIdentifier();
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DELETE FROM " + vTable + " WHERE PROPERTY_ID = '" + propertyId + "'").execute();
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID = '" + propertyId + "'").execute();
+
+ conn.commit();
+ conn.close();
}
- private void checkDBUsecasesNodeHasPrimaryTypeProperties(ManageableRepository repository) throws Exception
+ private void removeValueRecord(ManageableRepository repository, String propId) throws SQLException,
+ RepositoryConfigurationException, NamingException
{
- // create repository and add node
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- NodeImpl node = (NodeImpl)session.getRootNode().addNode("testNode");
- session.save();
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
- PropertyIterator iter = node.getProperties();
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // repository is consistent
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DELETE FROM " + vTable + " WHERE PROPERTY_ID = '" + propId + "'").execute();
+ conn.prepareStatement(
+ "ALTER TABLE " + vTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "VALUE_PROPERTY").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void removeReferenceRecord(ManageableRepository repository, String propId) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+
boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // remove all properties
+ String rTable = "JCR_" + (isMultiDb ? "M" : "S") + "REF";
+
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DELETE FROM " + rTable + " WHERE PROPERTY_ID = '" + propId + "'").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void removeItemRecord(ManageableRepository repository, String propId) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
+
Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
- while (iter.hasNext())
+
+ conn.prepareStatement(
+ "ALTER TABLE " + vTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "VALUE_PROPERTY").execute();
+ conn.prepareStatement(
+ "ALTER TABLE " + iTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+
+ conn.prepareStatement("DELETE FROM " + iTable + " WHERE ID = '" + propId + "'").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void assingItsOwnParent(ManageableRepository repository, ItemImpl item) throws SQLException,
+ RepositoryConfigurationException, NamingException
+ {
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+ String itemId = (isMultiDb ? "" : wsEntry.getName()) + item.getInternalIdentifier();
+
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+ conn.prepareStatement("DROP INDEX JCR_IDX_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT_NAME").execute();
+
+ conn.prepareStatement("UPDATE " + iTable + " SET PARENT_ID='" + itemId + "' WHERE ID='" + itemId + "'").execute();
+
+ conn.commit();
+ conn.close();
+
+ }
+
+ private void clearLockTable(ManageableRepository repository) throws RepositoryConfigurationException, SQLException,
+ NamingException
+ {
+ WorkspaceEntry workspaceEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ LockManagerEntry lockManagerEntry = workspaceEntry.getLockManager();
+
+ String sourceName = null;
+ String queryStatement = null;
+
+ if (helper.ispnCacheEnabled())
{
- PropertyImpl prop = (PropertyImpl)iter.nextProperty();
+ sourceName = lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.datasource");
- if (!prop.getName().equals("jcr:primaryType"))
- {
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "VALUE WHERE PROPERTY_ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ queryStatement =
+ "DELETE FROM " + lockManagerEntry.getParameterValue("infinispan-cl-cache.jdbc.table.name") + "_" + "L"
+ + workspaceEntry.getUniqueName().replace("_", "").replace("-", "_");
+ }
+ else
+ {
+ sourceName = lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_CL_DATASOURCE);
- conn.prepareStatement(
- "DELETE FROM JCR_" + (isMultiDb ? "M" : "S") + "ITEM WHERE ID = '"
- + (isMultiDb ? "" : wsEntry.getName()) + prop.getInternalIdentifier() + "'").execute();
+ if (lockManagerEntry.getParameterBoolean("jbosscache-shareable"))
+ {
+ queryStatement =
+ "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
+ + " WHERE PARENT='/" + workspaceEntry.getUniqueName() + "/" + CacheableLockManagerImpl.LOCKS + "'";
}
+ else
+ {
+ queryStatement =
+ "DELETE FROM " + lockManagerEntry.getParameterValue(CacheableLockManagerImpl.JBOSSCACHE_JDBC_TABLE_NAME)
+ + " WHERE PARENT='/" + CacheableLockManagerImpl.LOCKS + "'";
+ }
}
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ conn.prepareStatement(queryStatement).execute();
conn.commit();
conn.close();
+ }
- assertTrue(node.getProperties().hasNext());
+ private void indexNode(ManageableRepository repository, Node node, int state)
+ throws UnsupportedRepositoryOperationException, RepositoryException
+ {
+ // Indexing one more document with same UUID
+ List<SearchManager> searchManagers =
+ repository.getWorkspaceContainer(repository.getConfiguration().getSystemWorkspaceName())
+ .getComponentInstancesOfType(SearchManager.class);
- session.logout();
+ PlainChangesLog log = new PlainChangesLogImpl();
- // repository is inconsistent
- assertTrue(checkController.checkDataBase().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
- }
+ NodeData data =
+ new TransientNodeData(QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testNode")),
+ node.getUUID(), -1, Constants.NT_UNSTRUCTURED, null, 0, null, new AccessControlList());
- /**
- * Usescase when STORAGE_DESC field in JCR_SVALUE table is not empty but there is no file in the value storage.
- */
- public void testValueStorageUsecasesSingleDb() throws Exception
- {
- checkValueStorageUsecases(helper.createRepository(container, false, false));
+ TransientPropertyData primaryType =
+ new TransientPropertyData(QPath.makeChildPath(data.getQPath(), Constants.JCR_PRIMARYTYPE),
+ IdGenerator.generate(), -1, PropertyType.NAME, data.getIdentifier(), false, new TransientValueData(
+ Constants.NT_UNSTRUCTURED));
+
+ log.add(new ItemState(data, ItemState.ADDED, false, null));
+ log.add(new ItemState(primaryType, ItemState.ADDED, false, null));
+
+ for (SearchManager searchManager : searchManagers)
+ {
+ if (!(searchManager instanceof SystemSearchManager))
+ {
+ searchManager.onSaveItems(log);
+ break;
+ }
+ }
}
- /**
- * Usescase when STORAGE_DESC field in JCR_MVALUE table is not empty but there is no file in the value storage.
- */
- public void testValueStorageUsecasesMultiDb() throws Exception
+ private void insertPropertyRecord(ManageableRepository repository, String id, String parentId, String name)
+ throws RepositoryConfigurationException, SQLException, NamingException, RepositoryException
{
- checkValueStorageUsecases(helper.createRepository(container, true, false));
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
+
+ String iTable = "JCR_" + (isMultiDb ? "M" : "S") + "ITEM";
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+
+ // add another item with new persisted version
+ String propId = (isMultiDb ? "" : wsEntry.getName()) + IdGenerator.generate();
+ parentId = (isMultiDb ? "" : wsEntry.getName()) + parentId;
+
+ conn.prepareStatement(
+ "ALTER TABLE " + iTable + " DROP CONSTRAINT JCR_FK_" + (isMultiDb ? "M" : "S") + "ITEM_PARENT").execute();
+
+ if (isMultiDb)
+ {
+ conn.prepareStatement(
+ "INSERT INTO " + iTable + " VALUES ('" + propId + "','" + parentId + "','[]" + name
+ + "',1,2,1,NULL,1,FALSE)").execute();
+ }
+ else
+ {
+ conn.prepareStatement(
+ "INSERT INTO " + iTable + " VALUES ('" + propId + "','" + parentId + "','[]" + name + "',1,'"
+ + wsEntry.getName() + "',2,1,NULL,1,FALSE)").execute();
+ }
+ conn.prepareStatement("INSERT INTO " + vTable + " VALUES ('10000','data','1','" + propId + "',NULL)").execute();
+
+ conn.commit();
+ conn.close();
}
- private void checkValueStorageUsecases(ManageableRepository repository) throws Exception
+ private void updateValueRecord(ManageableRepository repository, String propId)
+ throws RepositoryConfigurationException, SQLException, NamingException
{
- // create repository and add property
- SessionImpl session =
- (SessionImpl)repository.login(credentials, repository.getConfiguration().getSystemWorkspaceName());
- InputStream in = new FileInputStream(createBLOBTempFile(300));
- PropertyImpl prop = (PropertyImpl)session.getRootNode().addNode("testNode").setProperty("testProperty", in);
- session.save();
- in.close();
+ WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
+ boolean isMultiDb = wsEntry.getContainer().getParameterBoolean(JDBCWorkspaceDataContainer.MULTIDB);
- session.logout();
+ String sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
- // repository is consistent
- TesterRepositoryCheckController checkController = new TesterRepositoryCheckController(repository);
- assertTrue(checkController.checkValueStorage().startsWith(
- RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
+ String vTable = "JCR_" + (isMultiDb ? "M" : "S") + "VALUE";
+ propId = (isMultiDb ? "" : wsEntry.getName()) + propId;
- // remove the file from the value storage
+ Connection conn = ((DataSource)new InitialContext().lookup(sourceName)).getConnection();
+ conn.prepareStatement(
+ "UPDATE " + vTable + " SET STORAGE_DESC = 'unexisted-desc' WHERE PROPERTY_ID = '" + propId + "'").execute();
+
+ conn.commit();
+ conn.close();
+ }
+
+ private void removeFileFromVS(ManageableRepository repository, String propId)
+ throws RepositoryConfigurationException
+ {
String vsPath =
repository.getConfiguration().getWorkspaceEntries().get(0).getContainer().getValueStorages().get(0)
.getParameterValue(FileValueStorage.PATH);
- File vsFile = new File(vsPath, prop.getInternalIdentifier() + "0");
+ File vsFile = new File(vsPath, propId + "0");
assertTrue(vsFile.exists());
assertTrue(vsFile.delete());
-
- assertTrue(checkController.checkValueStorage()
- .startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
-
- checkController.repairValueStorage("yes");
- assertTrue(checkController.checkValueStorage().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/tsm-excludes.properties
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/tsm-excludes.properties 2012-03-02 04:08:02 UTC (rev 5742)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/tsm-excludes.properties 2012-03-02 07:57:14 UTC (rev 5743)
@@ -42,3 +42,4 @@
org.exoplatform.services.jcr.impl.utils.io.TestDirectoryHelper.testCompressEmptyDirectory=compressDirectory
org.exoplatform.services.jcr.impl.utils.io.TestDirectoryHelper.testCompressDirectory=compressDirectory,uncompressDirectory
org.exoplatform.services.jcr.impl.utils.io.TestDirectoryHelper.testCompressFile=compressDirectory,uncompressDirectory
+org.exoplatform.services.jcr.impl.TestRepositoryCheckController.indexNode=onSaveItems
\ No newline at end of file
14 years, 1 month
exo-jcr SVN: r5742 - jcr/branches/1.12.x.
by do-not-reply@jboss.org
Author: mvacelet
Date: 2012-03-01 23:08:02 -0500 (Thu, 01 Mar 2012)
New Revision: 5742
Modified:
jcr/branches/1.12.x/pom.xml
Log:
[PLF-2955] Upgrade dependencies to next snapshots
Modified: jcr/branches/1.12.x/pom.xml
===================================================================
--- jcr/branches/1.12.x/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
+++ jcr/branches/1.12.x/pom.xml 2012-03-02 04:08:02 UTC (rev 5742)
@@ -42,9 +42,9 @@
<properties>
<exo.product.name>exo-jcr</exo.product.name>
<exo.product.specification>1.12</exo.product.specification>
- <org.exoplatform.kernel.version>2.2.12-GA</org.exoplatform.kernel.version>
- <org.exoplatform.core.version>2.3.12-GA</org.exoplatform.core.version>
- <org.exoplatform.ws.version>2.1.12-GA</org.exoplatform.ws.version>
+ <org.exoplatform.kernel.version>2.2.13-GA-SNAPSHOT</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.3.13-GA-SNAPSHOT</org.exoplatform.core.version>
+ <org.exoplatform.ws.version>2.1.13-GA-SNAPSHOT</org.exoplatform.ws.version>
<org.exoplatform.doc-style.version>2</org.exoplatform.doc-style.version>
<version.assembly.plugin>2.2.1</version.assembly.plugin>
</properties>
14 years, 1 month
exo-jcr SVN: r5741 - in jcr/branches/1.12.x: applications and 24 other directories.
by do-not-reply@jboss.org
Author: mvacelet
Date: 2012-03-01 22:52:44 -0500 (Thu, 01 Mar 2012)
New Revision: 5741
Modified:
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml
jcr/branches/1.12.x/applications/pom.xml
jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml
jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml
jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml
jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml
jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml
jcr/branches/1.12.x/exo.jcr.docs/pom.xml
jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml
jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml
jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml
jcr/branches/1.12.x/packaging/module/pom.xml
jcr/branches/1.12.x/pom.xml
Log:
[maven-release-plugin] [PLF-2955]prepare for next development iteration
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.applications.backupconsole</artifactId>
<name>eXo JCR :: Applications :: Backup Console</name>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.applications.backupconsole.dist</artifactId>
<name>eXo JCR :: Applications :: Backup Console Binary Distribution</name>
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.backupconsole</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.applications.browser</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.applications.config</artifactId>
<packaging>pom</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.applications.fckeditor</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.ear</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
<type>ear</type>
<scope>runtime</scope>
</dependency>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.ear</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
<type>ear</type>
<scope>runtime</scope>
</dependency>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.applications.rest</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
<relativePath>exo.jcr.applications.config</relativePath>
</parent>
Modified: jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.cluster.testclient</artifactId>
<name>eXo JCR :: Cluster :: Test Client</name>
Modified: jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.ear</artifactId>
<packaging>ear</packaging>
Modified: jcr/branches/1.12.x/applications/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/applications/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,12 +22,12 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
<name>eXo JCR :: Applications :: Reactor</name>
<packaging>pom</packaging>
Modified: jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.component.core</artifactId>
<name>eXo JCR :: Component :: Core Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.component.ext</artifactId>
<name>eXo JCR :: Component :: Extension Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.component.ftp</artifactId>
<name>eXo JCR :: Component :: FTP Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.component.statistics</artifactId>
<name>eXo JCR :: Component :: Statistics Provider</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.component.webdav</artifactId>
<name>eXo JCR :: Component :: Webdav Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.connectors.localadapter</artifactId>
<packaging>rar</packaging>
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.docs.developer</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.docs</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12.x/exo.jcr.docs/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.docs/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.framework.command</artifactId>
<name>eXo JCR :: Framework :: Command</name>
Modified: jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.framework.ftpclient</artifactId>
<name>eXo JCR :: Framework :: FTP Client</name>
Modified: jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>exo.jcr.framework.web</artifactId>
<name>eXo JCR :: Framework :: Web</name>
Modified: jcr/branches/1.12.x/packaging/module/pom.xml
===================================================================
--- jcr/branches/1.12.x/packaging/module/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/packaging/module/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -4,7 +4,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
</parent>
<artifactId>jcr.packaging.module</artifactId>
<packaging>pom</packaging>
Modified: jcr/branches/1.12.x/pom.xml
===================================================================
--- jcr/branches/1.12.x/pom.xml 2012-03-02 03:52:32 UTC (rev 5740)
+++ jcr/branches/1.12.x/pom.xml 2012-03-02 03:52:44 UTC (rev 5741)
@@ -29,14 +29,14 @@
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA</version>
+ <version>1.12.13-GA-SNAPSHOT</version>
<packaging>pom</packaging>
<name>eXo JCR</name>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/jcr/tags/1.12.12-GA</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/jcr/tags/1.12.12-GA</developerConnection>
- <url>http://fisheye.jboss.org/browse/exo-jcr/jcr/tags/1.12.12-GA</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/jcr/branches/1.12.x/</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/jcr/branches/1.12.x/</developerConnection>
+ <url>http://fisheye.jboss.org/browse/exo-jcr/jcr/branches/1.12.x</url>
</scm>
<properties>
14 years, 1 month
exo-jcr SVN: r5740 - jcr/tags.
by do-not-reply@jboss.org
Author: mvacelet
Date: 2012-03-01 22:52:32 -0500 (Thu, 01 Mar 2012)
New Revision: 5740
Added:
jcr/tags/1.12.12-GA/
Log:
[maven-release-plugin] [PLF-2955] copy for tag 1.12.12-GA
14 years, 1 month
exo-jcr SVN: r5739 - in jcr/branches/1.12.x: applications and 24 other directories.
by do-not-reply@jboss.org
Author: mvacelet
Date: 2012-03-01 22:52:24 -0500 (Thu, 01 Mar 2012)
New Revision: 5739
Modified:
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml
jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml
jcr/branches/1.12.x/applications/pom.xml
jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml
jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml
jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml
jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml
jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml
jcr/branches/1.12.x/exo.jcr.docs/pom.xml
jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml
jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml
jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml
jcr/branches/1.12.x/packaging/module/pom.xml
jcr/branches/1.12.x/pom.xml
Log:
[maven-release-plugin] [PLF-2955]prepare release 1.12.12-GA
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.applications.backupconsole</artifactId>
<name>eXo JCR :: Applications :: Backup Console</name>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.backupconsole.dist/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.applications.backupconsole.dist</artifactId>
<name>eXo JCR :: Applications :: Backup Console Binary Distribution</name>
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.backupconsole</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</dependency>
<dependency>
<groupId>org.exoplatform.jcr</groupId>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.browser/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.applications.browser</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.config/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.applications.config</artifactId>
<packaging>pom</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.fckeditor/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.applications.fckeditor</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.jboss/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.ear</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
<type>ear</type>
<scope>runtime</scope>
</dependency>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.jonas/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -40,7 +40,7 @@
<dependency>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.ear</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
<type>ear</type>
<scope>runtime</scope>
</dependency>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.rest/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.applications.rest</artifactId>
<packaging>war</packaging>
Modified: jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.applications.tomcat/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.applications.config</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
<relativePath>exo.jcr.applications.config</relativePath>
</parent>
Modified: jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.cluster.testclient/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.cluster.testclient</artifactId>
<name>eXo JCR :: Cluster :: Test Client</name>
Modified: jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/exo.jcr.ear/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.ear</artifactId>
<packaging>ear</packaging>
Modified: jcr/branches/1.12.x/applications/pom.xml
===================================================================
--- jcr/branches/1.12.x/applications/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/applications/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,12 +22,12 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jcr-applications-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
<name>eXo JCR :: Applications :: Reactor</name>
<packaging>pom</packaging>
Modified: jcr/branches/1.12.x/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.component.core/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.component.core</artifactId>
<name>eXo JCR :: Component :: Core Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.component.ext/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.component.ext</artifactId>
<name>eXo JCR :: Component :: Extension Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.component.ftp/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.component.ftp</artifactId>
<name>eXo JCR :: Component :: FTP Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.component.statistics/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.component.statistics</artifactId>
<name>eXo JCR :: Component :: Statistics Provider</name>
Modified: jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.component.webdav/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.component.webdav</artifactId>
<name>eXo JCR :: Component :: Webdav Service</name>
Modified: jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.connectors.localadapter/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.connectors.localadapter</artifactId>
<packaging>rar</packaging>
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/en/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.docs.developer</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.docs/exo.jcr.docs.developer/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>exo.jcr.docs</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12.x/exo.jcr.docs/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.docs/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.docs/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -22,7 +22,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.framework.command/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.framework.command</artifactId>
<name>eXo JCR :: Framework :: Command</name>
Modified: jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.framework.ftpclient/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.framework.ftpclient</artifactId>
<name>eXo JCR :: Framework :: FTP Client</name>
Modified: jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml
===================================================================
--- jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/exo.jcr.framework.web/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>exo.jcr.framework.web</artifactId>
<name>eXo JCR :: Framework :: Web</name>
Modified: jcr/branches/1.12.x/packaging/module/pom.xml
===================================================================
--- jcr/branches/1.12.x/packaging/module/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/packaging/module/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -4,7 +4,7 @@
<parent>
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
</parent>
<artifactId>jcr.packaging.module</artifactId>
<packaging>pom</packaging>
Modified: jcr/branches/1.12.x/pom.xml
===================================================================
--- jcr/branches/1.12.x/pom.xml 2012-03-02 03:47:20 UTC (rev 5738)
+++ jcr/branches/1.12.x/pom.xml 2012-03-02 03:52:24 UTC (rev 5739)
@@ -29,14 +29,14 @@
<groupId>org.exoplatform.jcr</groupId>
<artifactId>jcr-parent</artifactId>
- <version>1.12.12-GA-SNAPSHOT</version>
+ <version>1.12.12-GA</version>
<packaging>pom</packaging>
<name>eXo JCR</name>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/jcr/branches/1.12.x/</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/jcr/branches/1.12.x/</developerConnection>
- <url>http://fisheye.jboss.org/browse/exo-jcr/jcr/branches/1.12.x</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/jcr/tags/1.12.12-GA</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/jcr/tags/1.12.12-GA</developerConnection>
+ <url>http://fisheye.jboss.org/browse/exo-jcr/jcr/tags/1.12.12-GA</url>
</scm>
<properties>
14 years, 1 month