Author: tolusha
Date: 2011-10-25 04:06:47 -0400 (Tue, 25 Oct 2011)
New Revision: 5084
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/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
Log:
EXOJCR-1471: fix query
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCheckController.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCheckController.java 2011-10-25
07:48:55 UTC (rev 5083)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCheckController.java 2011-10-25
08:06:47 UTC (rev 5084)
@@ -23,6 +23,7 @@
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
@@ -350,7 +351,8 @@
}
}
- private void checkDB(InspectionLog inspectionLog) throws RepositoryException,
IOException
+ private void checkDB(InspectionLog inspectionLog) throws RepositoryException,
IOException,
+ RepositoryConfigurationException
{
String[] wsNames = repository.getWorkspaceNames();
for (String wsName : wsNames)
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 2011-10-25
07:48:55 UTC (rev 5083)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2011-10-25
08:06:47 UTC (rev 5084)
@@ -133,14 +133,17 @@
? "select * from JCR_MITEM as N where N.I_CLASS=1 and NOT EXISTS
(select * from JCR_MITEM AS P where P.I_CLASS=2 and P.PARENT_ID=N.ID)"
: "select * from JCR_SITEM as N where N.CONTAINER_NAME='"
+ jdbcDataContainer.containerName
- + "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_SITEM
AS P where P.I_CLASS=2 and P.PARENT_ID=N.ID)",
+ + "' and N.I_CLASS=1 and NOT EXISTS (select * from JCR_SITEM
AS P where P.I_CLASS=2 and P.PARENT_ID=N.ID and P.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName + "')",
new String[]{DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID,
DBConstants.COLUMN_NAME},
"Nodes that do not have at least one property",
InspectionStatus.ERR));
queries
.add(new InspectionQuery(
jdbcDataContainer.multiDb
? "select * from JCR_MVALUE as V where NOT EXISTS(select * from
JCR_MITEM as P where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
- : "select * from JCR_SVALUE as V where NOT EXISTS(select * from
JCR_SITEM as P where P.CONTAINER_NAME='"
+ : "select V.* from JCR_SVALUE as V, JCR_SITEM as I where
V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName
+ + "' and NOT EXISTS(select * from JCR_SITEM as P where
P.CONTAINER_NAME='"
+ jdbcDataContainer.containerName + "' and 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 owner-property record",
InspectionStatus.ERR));
@@ -156,7 +159,9 @@
.add(new InspectionQuery(
jdbcDataContainer.multiDb
? "select * from JCR_MVALUE where (STORAGE_DESC is null and DATA is
null) or (STORAGE_DESC is not null and DATA is not null)"
- : "select * from JCR_SVALUE where (STORAGE_DESC is null and DATA is
null) or (STORAGE_DESC is not null and DATA is not null)",
+ : "select V.* from JCR_SVALUE as V, JCR_SITEM as I where
V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName
+ + "' AND ((STORAGE_DESC is null and DATA is null) or
(STORAGE_DESC is not null and DATA is not null))",
new String[]{DBConstants.COLUMN_ID}, "Incorrect JCR_VALUE records",
InspectionStatus.ERR));
queries
.add(new InspectionQuery(
@@ -170,7 +175,9 @@
// properties can refer to missing node. It is possible to perform this usecase via
JCR API with no exceptions
queries.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MREF AS R where NOT EXISTS(select * from JCR_MITEM AS
N where R.NODE_ID=N.ID)"
- : "select * from JCR_SREF AS R where NOT EXISTS(select * from JCR_SITEM AS
N where N.CONTAINER_NAME='"
+ : "select * from JCR_SREF AS R, JCR_SITEM as I where R.PROPERTY_ID = I.ID
and I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName
+ + "' and NOT EXISTS(select * from JCR_SITEM AS N where
N.CONTAINER_NAME='"
+ jdbcDataContainer.containerName + "' and R.NODE_ID=N.ID)",
new String[]{"NODE_ID", "PROPERTY_ID",
DBConstants.COLUMN_VORDERNUM},
"Reference records that linked to unexisted nodes. Can be normal for some
usecases.", InspectionStatus.WARN));
@@ -284,7 +291,7 @@
* @throws RepositoryException
* @throws IOException
*/
- public static void checkValueStorage(JDBCWorkspaceDataContainer jdbcDataContainer,
+ public static void checkValueStorage(final JDBCWorkspaceDataContainer
jdbcDataContainer,
ValueStoragePluginProvider vsPlugin, InspectionLog inspectionLog) throws
RepositoryException, IOException
{
final String valueRecordFormat = "ValueData[PROPERTY_ID=%s ORDER_NUM=%d
STORAGE_DESC=%s]";
@@ -295,9 +302,11 @@
try
{
st =
- connection.prepareStatement(jdbcDataContainer.multiDb
- ? "SELECT PROPERTY_ID, ORDER_NUM, STORAGE_DESC from JCR_MVALUE where
STORAGE_DESC is not null"
- : "SELECT PROPERTY_ID, ORDER_NUM, STORAGE_DESC from JCR_SVALUE where
STORAGE_DESC is not null");
+ connection
+ .prepareStatement(jdbcDataContainer.multiDb
+ ? "SELECT PROPERTY_ID, ORDER_NUM, STORAGE_DESC from JCR_MVALUE
where STORAGE_DESC is not null"
+ : "SELECT V.PROPERTY_ID, V.ORDER_NUM, V.STORAGE_DESC from
JCR_SVALUE as V, JCR_SITEM as I where I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName + "' and V.PROPERTY_ID =
I.ID and STORAGE_DESC is not null");
resultSet = st.executeQuery();
// traverse all values, written to value storage
@@ -338,7 +347,9 @@
{
public Object run() throws ValueDataNotFoundException, IOException
{
- vdChannel.checkValueData(propertyId, orderNumber);
+ vdChannel.checkValueData(
+ jdbcDataContainer.multiDb ? propertyId : propertyId
+ .substring(jdbcDataContainer.containerName.length()),
orderNumber);
return null;
}
});
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 2011-10-25
07:48:55 UTC (rev 5083)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2011-10-25
08:06:47 UTC (rev 5084)
@@ -73,8 +73,10 @@
public void testDB()
{
String result = checkController.checkRepositoryDataConsistency(new
DataStorage[]{DataStorage.DB});
- assertEquals("Repository data is consistent. See full report by path "
- + checkController.getLastLogFile().getAbsolutePath(), result);
+ assertTrue(result.equals("Repository data is consistent. See full report by
path "
+ + checkController.getLastLogFile().getAbsolutePath())
+ || result.equals("Repository data is consistent, except some warnings. See
full report by path "
+ + checkController.getLastLogFile().getAbsolutePath()));
}
public void testValueStorage() throws Exception
@@ -111,7 +113,9 @@
String result =
checkController.checkRepositoryDataConsistency(new DataStorage[]{DataStorage.DB,
DataStorage.VALUE_STORAGE,
DataStorage.LUCENE_INDEX});
- assertEquals("Repository data is consistent. See full report by path "
- + checkController.getLastLogFile().getAbsolutePath(), result);
+ assertTrue(result.equals("Repository data is consistent. See full report by
path "
+ + checkController.getLastLogFile().getAbsolutePath())
+ || result.equals("Repository data is consistent, except some warnings. See
full report by path "
+ + checkController.getLastLogFile().getAbsolutePath()));
}
}