[exo-jcr-commits] exo-jcr SVN: r5661 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/query and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Feb 17 06:54:14 EST 2012
Author: tolusha
Date: 2012-02-17 06:54:13 -0500 (Fri, 17 Feb 2012)
New Revision: 5661
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionReport.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TesterRepositoryCheckController.java
Removed:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLog.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLogWriter.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/AbstractRepositorySuspender.java
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/core/query/QueryHandler.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQueryFilteredMultivaluedProperties.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/api/core/query/lucene/SlowQueryHandler.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestInspectionLogFile.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java
Log:
EXOJCR-1755: refactoring RepositoryCheckController
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/AbstractRepositorySuspender.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/AbstractRepositorySuspender.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/AbstractRepositorySuspender.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl;
+import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
@@ -33,7 +34,7 @@
/**
* The current repository.
*/
- private final ManageableRepository repository;
+ protected final ManageableRepository repository;
/**
* AbstractRepositorySuspender constructor.
@@ -49,12 +50,8 @@
*/
protected void suspendRepository() throws RepositoryException
{
- // Need privileges to manage repository.
- SecurityManager security = System.getSecurityManager();
- if (security != null)
- {
- security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
- }
+ SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
+
repository.setState(ManageableRepository.SUSPENDED);
}
@@ -64,11 +61,8 @@
protected void resumeRepository() throws RepositoryException
{
// Need privileges to manage repository.
- SecurityManager security = System.getSecurityManager();
- if (security != null)
- {
- security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
- }
+ SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
+
repository.setState(ManageableRepository.ONLINE);
}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLog.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLog.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2011 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;
-
-import java.io.IOException;
-
-/**
- * Interface of inspection log. It provides general methods for logging consistency issues.
- *
- * @author <a href="mailto:skarpenko at exoplatform.com">Sergiy Karpenko</a>
- * @version $Id: exo-jboss-codetemplates.xml 34360 4.10.2011 skarpenko $
- *
- */
-public interface InspectionLog
-{
- // represents broken object state
- public enum InspectionStatus {
- ERR("Error"), WARN("Warning"), REINDEX("Reindex");
- final String text;
-
- InspectionStatus(String text)
- {
- this.text = text;
- }
-
- public String toString()
- {
- return text;
- }
- }
-
- /**
- * @return true, if inconsistency was found
- */
- boolean hasInconsistency();
-
- /**
- * @return true, if inconsistency or warning was found
- */
- boolean hasWarnings();
-
- /**
- * Adds comment to log
- */
- void logComment(String message) throws IOException;
-
- /**
- * Adds description to log
- */
- void logInspectionDescription(String description) throws IOException;
-
- /**
- * Adds detailed event to log, with issue found
- */
- void logBrokenObjectInfo(String brokenObjectDesc, String comment, InspectionStatus status) throws IOException;
-
- /**
- * Adds exception with full trace to the log
- */
- void logException(String message, Exception ex) throws IOException;
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLogWriter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLogWriter.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionLogWriter.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2011 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;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Text-based inspection log implementation. It uses any compatible Writer instance for output.
- *
- * @author <a href="mailto:skarpenko at exoplatform.com">Sergiy Karpenko</a>
- * @version $Id: exo-jboss-codetemplates.xml 34360 6.10.2011 skarpenko $
- *
- */
-public class InspectionLogWriter implements InspectionLog
-{
- private static final String LINE_COMMENT = "//";
-
- private static final String LINE_DELIMITER = "\n";
-
- private static final String WSP = " ";
-
- private final Writer out;
-
- private final Set<InspectionStatus> statusSet = new HashSet<InspectionStatus>();
-
- public InspectionLogWriter(Writer out)
- {
- this.out = out;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasInconsistency()
- {
- return statusSet.contains(InspectionStatus.ERR) || statusSet.contains(InspectionStatus.REINDEX);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasWarnings()
- {
- return statusSet.contains(InspectionStatus.WARN);
- }
-
- /**
- * {@inheritDoc}
- */
- public void logComment(String message) throws IOException
- {
- writeLine(message);
- out.flush();
- }
-
- /**
- * {@inheritDoc}
- */
- public void logInspectionDescription(String description) throws IOException
- {
- writeLine(description);
- out.flush();
- }
-
- /**
- * {@inheritDoc}
- */
- public void logBrokenObjectInfo(String brokenObjectDesc, String comment, InspectionStatus status) throws IOException
- {
- statusSet.add(status);
-
- out.write(status.toString());
- out.write(WSP);
- out.write(brokenObjectDesc);
- out.write(WSP);
- out.write(comment);
- out.write(LINE_DELIMITER);
- out.flush();
- }
-
- public void logException(String message, Exception ex) throws IOException
- {
- statusSet.add(InspectionStatus.ERR);
-
- writeLine(message);
- writeStackTrace(ex);
- out.flush();
- }
-
- private void writeLine(String message) throws IOException
- {
- out.write(LINE_COMMENT);
- out.write(message);
- out.write(LINE_DELIMITER);
- }
-
- private void writeStackTrace(Throwable e) throws IOException
- {
- writeLine(e.getMessage());
- writeLine(e.toString());
- StackTraceElement[] trace = e.getStackTrace();
- for (int i = 0; i < trace.length; i++)
- {
- writeLine("\tat " + trace[i]);
- }
-
- Throwable ourCause = e.getCause();
- if (ourCause != null)
- {
- writeLine("Cause:");
- writeStackTrace(ourCause);
- }
- }
-}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionReport.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionReport.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/InspectionReport.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2011 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;
+
+import org.exoplatform.commons.utils.SecurityHelper;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.security.PrivilegedExceptionAction;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Text-based inspection log implementation.
+ *
+ * @author <a href="mailto:skarpenko at exoplatform.com">Sergiy Karpenko</a>
+ * @version $Id: InspectionReport.java 34360 6.10.2011 skarpenko $
+ */
+public class InspectionReport
+{
+ private static final String COMMENT = "//";
+
+ private static final String DELIMITER = "\n";
+
+ private static final String WHITE_SPACE = " ";
+
+ private Writer writer;
+
+ private boolean reportHasInconsistency;
+
+ private String reportPath;
+
+ /**
+ * InspectionReport constructor.
+ */
+ public InspectionReport(String forRepository) throws IOException
+ {
+ final File reportFile =
+ new File("report-" + forRepository + "-" + new SimpleDateFormat("dd-MMM-yy-HH-mm").format(new Date()) + ".txt");
+
+ SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
+ {
+ public Void run() throws IOException
+ {
+ reportPath = reportFile.getAbsolutePath();
+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(reportFile)));
+
+ return null;
+ }
+ });
+
+ }
+
+ /**
+ * Indicates if report has inconsistency info or not.
+ */
+ public boolean hasInconsistency()
+ {
+ return reportHasInconsistency;
+ }
+
+ /**
+ * Adds comment to log.
+ */
+ public void logComment(String message) throws IOException
+ {
+ writeLine(message);
+ writer.flush();
+ }
+
+ /**
+ * Adds description to log.
+ */
+ public void logDescription(String description) throws IOException
+ {
+ writeLine(description);
+ writer.flush();
+ }
+
+ /**
+ * Adds detailed event to log.
+ */
+ public void logBrokenObjectAndSetInconsistency(String brokenObjectDesc, String comment) throws IOException
+ {
+ setInconsistency();
+
+ writer.write(brokenObjectDesc);
+ writer.write(WHITE_SPACE);
+ writer.write(comment);
+ writer.write(DELIMITER);
+ writer.flush();
+ }
+
+ /**
+ * Adds exception with full stack trace.
+ */
+ public void logExceptionAndSetInconsistency(String message, Throwable e) throws IOException
+ {
+ setInconsistency();
+
+ writeLine(message);
+ writeStackTrace(e);
+ writer.flush();
+ }
+
+ /**
+ * Closes report and frees all allocated resources.
+ */
+ public void close() throws IOException
+ {
+ writer.close();
+ }
+
+ /**
+ * Returns the absolute path to report file.
+ */
+ public String getReportPath()
+ {
+ return reportPath;
+ }
+
+ private void setInconsistency()
+ {
+ reportHasInconsistency = true;
+ }
+
+ private void writeLine(String message) throws IOException
+ {
+ writer.write(COMMENT);
+ writer.write(message);
+ writer.write(DELIMITER);
+ writer.flush();
+ }
+
+ private void writeStackTrace(Throwable e) throws IOException
+ {
+ writeLine(e.getMessage());
+ writeLine(e.toString());
+ StackTraceElement[] trace = e.getStackTrace();
+ for (int i = 0; i < trace.length; i++)
+ {
+ writeLine("\tat " + trace[i]);
+ }
+
+ Throwable ourCause = e.getCause();
+ if (ourCause != null)
+ {
+ writeLine("Cause:");
+ writeStackTrace(ourCause);
+ }
+ }
+}
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 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryCheckController.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -18,7 +18,6 @@
*/
package org.exoplatform.services.jcr.impl;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.jmx.annotations.NameTemplate;
@@ -33,13 +32,7 @@
import org.exoplatform.services.log.Log;
import org.picocontainer.Startable;
-import java.io.BufferedWriter;
-import java.io.File;
import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import javax.jcr.RepositoryException;
@@ -52,7 +45,7 @@
* </ul>
*
* @author <a href="mailto:skarpenko at exoplatform.com">Sergiy Karpenko</a>
- * @version $Id: exo-jboss-codetemplates.xml 34360 3.10.2011 skarpenko $
+ * @version $Id: RepositoryCheckController.java 34360 3.10.2011 skarpenko $
*/
@Managed
@NameTemplate(@Property(key = "service", value = "RepositoryCheckController"))
@@ -61,20 +54,25 @@
/**
* Logger.
*/
- protected static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RepositorySuspendController");
+ protected static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RepositoryCheckController");
- protected static final String FILE_NAME = "report";
+ public static final String REPORT_CONSISTENT_MESSAGE = "Repository data is consistent";
+ public static final String REPORT_NOT_CONSISTENT_MESSAGE = "Repository data is NOT consistent";
+
+ public static final String EXCEPTION_DURING_CHECKING_MESSAGE = "Exception occured during consistency checking";
+
+ /**
+ * The list of available storages for checking.
+ */
protected enum DataStorage {
DB, VALUE_STORAGE, LUCENE_INDEX
};
- private File inspectionLogFile = null;
-
/**
- * The current repository.
+ * Store the results of last checking.
*/
- private final ManageableRepository repository;
+ protected InspectionReport lastReport;
/**
* RepositoryCheckController constructor.
@@ -82,7 +80,6 @@
public RepositoryCheckController(ManageableRepository repository)
{
super(repository);
- this.repository = repository;
}
/**
@@ -126,221 +123,197 @@
return checkRepositoryDataConsistency(new DataStorage[]{DataStorage.LUCENE_INDEX});
}
- protected String checkRepositoryDataConsistency(DataStorage[] checkData)
+ protected String checkRepositoryDataConsistency(DataStorage[] storages)
{
- inspectionLogFile = null;
try
{
- if (getRepositoryState() == ManageableRepository.SUSPENDED)
- {
- return "Can not check data consistency. Repository is already suspended.";
- }
+ createNewReport();
+ }
+ catch (IOException e)
+ {
+ return getExceptionDuringCheckingMessage(e);
+ }
- Writer reportWriter = null;
- try
- {
- try
- {
- suspendRepository();
- }
- catch (RepositoryException e)
- {
- return "Can not check data consistency. Repository was not suspended. Error: " + e.getMessage();
- }
+ try
+ {
+ suspendRepository();
+
+ return doCheck(storages);
+ }
+ catch (RepositoryException e)
+ {
+ return getExceptionDuringCheckingMessage(e);
+ }
+ finally
+ {
+ resumeRepository();
+ closeReport();
+ }
+ }
- // DO CHECK
- inspectionLogFile =
- new File(FILE_NAME + "-" + repository.getConfiguration().getName() + "-"
- + new SimpleDateFormat("dd-MMM-yy-HH-mm").format(new Date()) + ".txt");
- if (!PrivilegedFileHelper.exists(inspectionLogFile)
- && !PrivilegedFileHelper.createNewFile(inspectionLogFile))
- {
- LOG.error("Inspection log file was not created. "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile));
- return "Can not check data consistency. Inspection log file was not created. "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected void resumeRepository()
+ {
+ try
+ {
+ super.resumeRepository();
+ }
+ catch (RepositoryException e)
+ {
+ LOG.error("Can not resume repository. Error: " + e.getMessage(), e);
+ }
+ }
- reportWriter =
- new BufferedWriter(new OutputStreamWriter(PrivilegedFileHelper.fileOutputStream(inspectionLogFile)));
- InspectionLog report = new InspectionLogWriter(reportWriter);
- for (DataStorage cd : checkData)
- {
- switch (cd)
- {
- case DB :
- try
- {
- checkDB(report);
- }
- catch (RepositoryException e)
- {
- report.logException("RepositoryException occures during DB consistency check.", e);
- return "RepositoryException occures during DB consistency check. Error: " + e.getMessage()
- + ". See log here: " + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- catch (IOException e)
- {
- report.logException("IOException occures during DB consistency check.", e);
- return "IOException occures during DB consistency check. Error: " + e.getMessage()
- + ". See log here: " + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- break;
- case VALUE_STORAGE :
- try
- {
- checkVS(report);
- }
- catch (RepositoryException e)
- {
- report.logException("RepositoryException occures during ValueStorage consistency check.", e);
- return "RepositoryException occures during ValueStorage consistency check. Error: "
- + e.getMessage() + ". See log here: "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- catch (IOException e)
- {
- report.logException("IOException occures during ValueStorage consistency check.", e);
- return "IOException occures during ValueStorage consistency check. Error: " + e.getMessage()
- + ". See log here: " + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- break;
- case LUCENE_INDEX :
- try
- {
- checkLuceneIndex(report);
- }
- catch (RepositoryException e)
- {
- report.logException("RepositoryException occures during SearchIndex consistency check.", e);
- return "RepositoryException occures during SearchIndex consistency check. Error: "
- + e.getMessage() + ". See log here: "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- catch (IOException e)
- {
- report.logException("IOException occures during SearchIndex consistency check.", e);
- return "IOException occures during SearchIndex consistency check. Error: " + e.getMessage()
- + ". See log here: " + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- break;
- }
- }
-
- if (report.hasInconsistency())
- {
- report.logComment("Repository data is NOT consistent.");
- return "Repository data is inconsistent. See full report by path "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- else if (report.hasWarnings())
- {
- report.logComment("Repository data is consistent, except some warnings.");
- return "Repository data is consistent, except some warnings. See full report by path "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- else
- {
- report.logComment("Repository data is consistent");
- return "Repository data is consistent. See full report by path "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile);
- }
- }
- finally
+ private String doCheck(DataStorage[] storages)
+ {
+ try
+ {
+ for (DataStorage storage : storages)
{
- if (reportWriter != null)
+ switch (storage)
{
- try
- {
- reportWriter.flush();
- reportWriter.close();
- }
- catch (IOException e)
- {
- LOG.error("Can not close file " + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile), e);
- }
- }
+ case DB :
+ checkDataBase();
+ break;
- //resume repository
- try
- {
- resumeRepository();
+ case VALUE_STORAGE :
+ checkValueStorage();
+ break;
+
+ case LUCENE_INDEX :
+ checkLuceneIndex();
+ break;
}
- catch (RepositoryException e)
- {
- LOG.error("Can not resume repository. Error: " + e.getMessage(), e);
- }
- if (getRepositoryState() != ManageableRepository.ONLINE)
- {
- LOG.error("Repository was not resumed and now it is OFFLINE");
- }
}
+
+ return logAndGetCheckingResultMessage();
}
catch (Throwable e)
{
+ return logAndGetExceptionDuringCheckingMessage(e);
+ }
+ }
+
+ private String logAndGetCheckingResultMessage()
+ {
+ if (lastReport.hasInconsistency())
+ {
+ logComment(REPORT_NOT_CONSISTENT_MESSAGE);
+ return REPORT_NOT_CONSISTENT_MESSAGE + getPathToReportMessage();
+ }
+ else
+ {
+ logComment(REPORT_CONSISTENT_MESSAGE);
+ return REPORT_CONSISTENT_MESSAGE + getPathToReportMessage();
+ }
+ }
+
+ private String logAndGetExceptionDuringCheckingMessage(Throwable e)
+ {
+ logExceptionAndSetInconsistency(EXCEPTION_DURING_CHECKING_MESSAGE, e);
+ return getExceptionDuringCheckingMessage(e) + getPathToReportMessage();
+ }
+
+ private String getExceptionDuringCheckingMessage(Throwable e)
+ {
+ return EXCEPTION_DURING_CHECKING_MESSAGE + ": " + e.getMessage();
+ }
+
+ private void logComment(String message)
+ {
+ try
+ {
+ lastReport.logComment(message);
+ }
+ catch (IOException e)
+ {
LOG.error(e.getMessage(), e);
- return "Exception thrown during repository data validation: "
- + e
- + (inspectionLogFile != null ? " See log by path "
- + PrivilegedFileHelper.getAbsolutePath(inspectionLogFile) : "");
}
}
- private void checkDB(InspectionLog inspectionLog) throws RepositoryException, IOException,
+ private void logExceptionAndSetInconsistency(String message, Throwable e)
+ {
+ try
+ {
+ lastReport.logExceptionAndSetInconsistency(message, e);
+ }
+ catch (IOException e1)
+ {
+ LOG.error(e1.getMessage(), e1);
+ }
+ }
+
+ private void createNewReport() throws IOException
+ {
+ lastReport = new InspectionReport(repository.getConfiguration().getName());
+ }
+
+ private void closeReport()
+ {
+ try
+ {
+ lastReport.close();
+ }
+ catch (IOException e)
+ {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+
+ private void checkDataBase() throws RepositoryException, IOException,
RepositoryConfigurationException
{
- String[] wsNames = repository.getWorkspaceNames();
- for (String wsName : wsNames)
+ for (String wsName : repository.getWorkspaceNames())
{
- inspectionLog.logComment("Check DB consistency. Workspace " + wsName);
+ logComment("Check DB consistency. Workspace " + wsName);
+
JDBCWorkspaceDataContainer dataContainer =
- (JDBCWorkspaceDataContainer)repository.getWorkspaceContainer(wsName).getComponent(
- JDBCWorkspaceDataContainer.class);
- JDBCWorkspaceDataContainerChecker.checkDB(dataContainer, inspectionLog);
+ (JDBCWorkspaceDataContainer)getComponent(JDBCWorkspaceDataContainer.class, wsName);
+
+ JDBCWorkspaceDataContainerChecker.checkDataBase(dataContainer, lastReport);
}
}
- private void checkVS(InspectionLog inspectionLog) throws RepositoryException, IOException
+ private void checkValueStorage() throws RepositoryException, IOException
{
- String[] wsNames = repository.getWorkspaceNames();
- for (String wsName : wsNames)
+ for (String wsName : repository.getWorkspaceNames())
{
- inspectionLog.logComment("Check ValueStorage consistency. Workspace " + wsName);
+ logComment("Check ValueStorage consistency. Workspace " + wsName);
JDBCWorkspaceDataContainer dataContainer =
- (JDBCWorkspaceDataContainer)repository.getWorkspaceContainer(wsName).getComponent(
- JDBCWorkspaceDataContainer.class);
-
+ (JDBCWorkspaceDataContainer)getComponent(JDBCWorkspaceDataContainer.class, wsName);
ValueStoragePluginProvider vsPlugin =
- (ValueStoragePluginProvider)repository.getWorkspaceContainer(wsName).getComponent(
- ValueStoragePluginProvider.class);
+ (ValueStoragePluginProvider)getComponent(ValueStoragePluginProvider.class, wsName);
- JDBCWorkspaceDataContainerChecker.checkValueStorage(dataContainer, vsPlugin, inspectionLog);
+ JDBCWorkspaceDataContainerChecker.checkValueStorage(dataContainer, vsPlugin, lastReport);
}
}
- private void checkLuceneIndex(InspectionLog inspectionLog) throws RepositoryException, IOException
+ private void checkLuceneIndex() throws RepositoryException, IOException
{
- final String[] wsNames = repository.getWorkspaceNames();
final String systemWS = repository.getConfiguration().getSystemWorkspaceName();
- for (String wsName : wsNames)
+ for (String wsName : repository.getWorkspaceNames())
{
- inspectionLog.logComment("Check SearchIndex consistency. Workspace " + wsName);
- SearchManager searchManager =
- (SearchManager)repository.getWorkspaceContainer(wsName).getComponent(SearchManager.class);
- searchManager.checkIndex(inspectionLog, systemWS.equals(wsName));
+ logComment("Check SearchIndex consistency. Workspace " + wsName);
+
+ SearchManager searchManager = (SearchManager)getComponent(SearchManager.class, wsName);
+
+ searchManager.checkIndex(lastReport, systemWS.equals(wsName));
}
}
- /**
- * For test purposes.
- * @return
- */
- protected File getLastLogFile()
+ private Object getComponent(Class forClass, String wsName)
{
- return inspectionLogFile;
+ return repository.getWorkspaceContainer(wsName).getComponent(forClass);
}
+ private String getPathToReportMessage()
+ {
+ return ". See full report by path " + lastReport.getReportPath();
+ }
+
/**
* {@inheritDoc}
*/
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandler.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandler.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryHandler.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -20,7 +20,7 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.impl.InspectionLog;
+import org.exoplatform.services.jcr.impl.InspectionReport;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.query.lucene.ChangesHolder;
@@ -231,10 +231,10 @@
*
* @param itemStateManager
* @param isSystem
- * @param inspectionLog
+ * @param report
* @throws RepositoryException
* @throws IOException
*/
- void checkIndex(ItemDataConsumer itemStateManager, boolean isSystem, InspectionLog inspectionLog)
+ void checkIndex(ItemDataConsumer itemStateManager, boolean isSystem, InspectionReport report)
throws RepositoryException, IOException;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -49,7 +49,7 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.InspectionLog;
+import org.exoplatform.services.jcr.impl.InspectionReport;
import org.exoplatform.services.jcr.impl.backup.BackupException;
import org.exoplatform.services.jcr.impl.backup.Backupable;
import org.exoplatform.services.jcr.impl.backup.DataRestore;
@@ -400,7 +400,7 @@
* according jcr-node. If index is suspended then it will be temporary resumed, while check is running
* and suspended afterwards.
*/
- public void checkIndex(final InspectionLog inspectionLog, final boolean isSystem) throws RepositoryException,
+ public void checkIndex(final InspectionReport report, final boolean isSystem) throws RepositoryException,
IOException
{
if (isSuspended)
@@ -420,7 +420,7 @@
}
resume();
- handler.checkIndex(itemMgr, isSystem, inspectionLog);
+ handler.checkIndex(itemMgr, isSystem, report);
return null;
}
catch (ResumeException e)
@@ -466,7 +466,7 @@
else
{
// simply run checkIndex, if not suspended
- handler.checkIndex(itemMgr, isSystem, inspectionLog);
+ handler.checkIndex(itemMgr, isSystem, report);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -51,8 +51,7 @@
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.InspectionLog;
-import org.exoplatform.services.jcr.impl.InspectionLog.InspectionStatus;
+import org.exoplatform.services.jcr.impl.InspectionReport;
import org.exoplatform.services.jcr.impl.backup.ResumeException;
import org.exoplatform.services.jcr.impl.backup.SuspendException;
import org.exoplatform.services.jcr.impl.backup.Suspendable;
@@ -869,7 +868,7 @@
/**
* {@inheritDoc}
*/
- public void checkIndex(ItemDataConsumer itemStateManager, boolean isSystem, final InspectionLog inspectionLog)
+ public void checkIndex(ItemDataConsumer itemStateManager, boolean isSystem, final InspectionReport report)
throws RepositoryException, IOException
{
@@ -920,12 +919,12 @@
if (docs.next())
{
//multiple entries
- inspectionLog.logBrokenObjectInfo("ID=" + uuid, "Multiple entires.", InspectionStatus.REINDEX);
+ report.logBrokenObjectAndSetInconsistency("ID=" + uuid, "Multiple entires.");
}
}
else
{
- inspectionLog.logBrokenObjectInfo("ID=" + uuid, "Not indexed.", InspectionStatus.REINDEX);
+ report.logBrokenObjectAndSetInconsistency("ID=" + uuid, "Not indexed.");
}
}
catch (IOException e)
@@ -983,8 +982,7 @@
String uuid = d.get(FieldNames.UUID);
if (!documentUUIDs.contains(uuid))
{
- inspectionLog.logBrokenObjectInfo("ID=" + uuid, "Document corresponds to removed node.",
- InspectionStatus.REINDEX);
+ report.logBrokenObjectAndSetInconsistency("ID=" + uuid, "Document corresponds to removed node.");
}
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQuery.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQuery.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc;
-import org.exoplatform.services.jcr.impl.InspectionLog.InspectionStatus;
-
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -49,17 +47,11 @@
*/
public String[] fieldNames;
- /**
- * Corruption status. Is it critical - <b>ERR</b>, or not - <b>WARN</b>.
- */
- public InspectionStatus status;
-
- public InspectionQuery(String statement, String[] fieldNames, String headerMessage, InspectionStatus status)
+ public InspectionQuery(String statement, String[] fieldNames, String headerMessage)
{
this.statement = statement;
this.description = headerMessage;
this.fieldNames = fieldNames;
- this.status = status;
}
public String getStatement()
@@ -77,11 +69,6 @@
return fieldNames;
}
- public InspectionStatus getStatus()
- {
- return status;
- }
-
/**
* Creates a PreparedStatement object for sending parameterized SQL statements to the database.
*
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQueryFilteredMultivaluedProperties.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQueryFilteredMultivaluedProperties.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/InspectionQueryFilteredMultivaluedProperties.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jdbc;
-import org.exoplatform.services.jcr.impl.InspectionLog.InspectionStatus;
-
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -34,9 +32,9 @@
/**
* {@inheritDoc}
*/
- public InspectionQueryFilteredMultivaluedProperties(String statement, String[] fieldNames, String headerMessage, InspectionStatus status)
+ public InspectionQueryFilteredMultivaluedProperties(String statement, String[] fieldNames, String headerMessage)
{
- super(statement, fieldNames, headerMessage, status);
+ super(statement, fieldNames, headerMessage);
}
/**
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-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainerChecker.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -20,8 +20,7 @@
import org.exoplatform.commons.utils.SecurityHelper;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.InspectionLog;
-import org.exoplatform.services.jcr.impl.InspectionLog.InspectionStatus;
+import org.exoplatform.services.jcr.impl.InspectionReport;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
@@ -61,7 +60,7 @@
* @throws RepositoryException
* @throws IOException
*/
- public static void checkDB(JDBCWorkspaceDataContainer jdbcDataContainer, InspectionLog inspectionLog)
+ public static void checkDataBase(JDBCWorkspaceDataContainer jdbcDataContainer, InspectionReport report)
throws RepositoryException, IOException
{
Set<InspectionQuery> queries = new HashSet<InspectionQuery>();
@@ -72,8 +71,8 @@
: "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", InspectionStatus.ERR));
-
+ "Items that do not have parent nodes"));
+
queries.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MITEM N where N.I_CLASS=1 and NOT EXISTS "
+ "(select * from JCR_MITEM P where P.I_CLASS=2 and P.PARENT_ID=N.ID "
@@ -83,17 +82,15 @@
+ "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},
- "Nodes that do not have at least one jcr:primaryType property", InspectionStatus.ERR));
-
- queries
- .add(new InspectionQuery(jdbcDataContainer.multiDb
- ? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P "
- + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
- : "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 owner-property record",
- InspectionStatus.ERR));
+ "Nodes that do not have at least one jcr:primaryType property"));
+ queries.add(new InspectionQuery(jdbcDataContainer.multiDb
+ ? "select * from JCR_MVALUE V where NOT EXISTS(select * from JCR_MITEM P "
+ + "where V.PROPERTY_ID = P.ID and P.I_CLASS=2)"
+ : "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 owner-property record"));
+
queries
.add(new InspectionQueryFilteredMultivaluedProperties(
jdbcDataContainer.multiDb
@@ -103,8 +100,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},
- "All properties that have not value record.", InspectionStatus.ERR));
-
+ "All properties that have not value record."));
+
// The differences in the queries by DB dialect.
// Oracle doesn't work correct with default query because empty value stored as null value.
String statement;
@@ -121,22 +118,23 @@
else if (jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLE)
|| jdbcDataContainer.dbDialect.equalsIgnoreCase(DBConstants.DB_DIALECT_ORACLEOCI))
{
- statement = jdbcDataContainer.multiDb
- ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA is not null)"
- : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
- + jdbcDataContainer.containerName
- + "' AND (STORAGE_DESC is not null and DATA is not null)";
- } else {
statement =
jdbcDataContainer.multiDb
+ ? "select * from JCR_MVALUE where (STORAGE_DESC is not null and DATA is not null)"
+ : "select V.* from JCR_SVALUE V, JCR_SITEM I where V.PROPERTY_ID = I.ID and I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName + "' AND (STORAGE_DESC is not null and DATA is not null)";
+ }
+ else
+ {
+ statement =
+ 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 V.* from JCR_SVALUE V, JCR_SITEM 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))";
}
- queries.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID}, "Incorrect JCR_VALUE records",
- InspectionStatus.ERR));
+ queries.add(new InspectionQuery(statement, new String[]{DBConstants.COLUMN_ID}, "Incorrect JCR_VALUE records"));
queries
.add(new InspectionQueryFilteredMultivaluedProperties(
@@ -147,15 +145,14 @@
+ jdbcDataContainer.containerName
+ "' and P.P_TYPE=9 and P.P_MULTIVALUED=? 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", InspectionStatus.ERR));
+ "Reference properties without reference records"));
// an item is its own parent.
queries.add(new InspectionQuery(jdbcDataContainer.multiDb
? "select * from JCR_MITEM I where I.ID = I.PARENT_ID and I.NAME <> '" + Constants.ROOT_PARENT_NAME + "'"
: "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.",
- InspectionStatus.ERR));
+ DBConstants.COLUMN_ID, DBConstants.COLUMN_PARENTID, DBConstants.COLUMN_NAME}, "An item is its own parent."));
// Several versions of same item
queries
@@ -164,14 +161,15 @@
? "select * from JCR_MITEM I where EXISTS (select * from JCR_MITEM J"
+ " WHERE I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
+ " and I.VERSION != J.VERSION)"
- : "select * from JCR_SITEM I where I.CONTAINER_NAME='" + jdbcDataContainer.containerName + "' and"
+ : "select * from JCR_SITEM I where I.CONTAINER_NAME='"
+ + jdbcDataContainer.containerName
+ + "' and"
+ " EXISTS (select * from JCR_SITEM J WHERE I.CONTAINER_NAME = J.CONTAINER_NAME and"
+ " I.PARENT_ID = J.PARENT_ID AND I.NAME = J.NAME and I.I_INDEX = J.I_INDEX and I.I_CLASS = J.I_CLASS"
+ " 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.",
- InspectionStatus.ERR));
+ 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."));
// using existing DataSource to get a JDBC Connection.
Connection jdbcConn = jdbcDataContainer.getConnectionFactory().getJdbcConnection();
@@ -192,7 +190,7 @@
if (resultSet.next())
{
// but if result not empty, then inconsistency takes place
- inspectionLog.logInspectionDescription(query.getDescription());
+ report.logDescription(query.getDescription());
do
{
StringBuilder record = new StringBuilder();
@@ -211,8 +209,8 @@
}
record.append(' ');
}
- // log inconsistency issue.
- inspectionLog.logBrokenObjectInfo(record.toString(), "", query.getStatus());
+
+ report.logBrokenObjectAndSetInconsistency(record.toString(), "");
}
while (resultSet.next());
}
@@ -247,8 +245,7 @@
}
catch (SQLException e)
{
- // log unexpected exceptions to log
- inspectionLog.logException("Exception during DB inspection.", e);
+ report.logExceptionAndSetInconsistency("Exception during DB inspection.", e);
}
finally
{
@@ -284,7 +281,7 @@
* @throws IOException
*/
public static void checkValueStorage(final JDBCWorkspaceDataContainer jdbcDataContainer,
- ValueStoragePluginProvider vsPlugin, InspectionLog inspectionLog) throws RepositoryException, IOException
+ ValueStoragePluginProvider vsPlugin, InspectionReport report) throws RepositoryException, IOException
{
final String valueRecordFormat = "ValueData[PROPERTY_ID=%s ORDER_NUM=%d STORAGE_DESC=%s]";
@@ -324,9 +321,8 @@
}
catch (ValueStorageNotFoundException e)
{
- inspectionLog.logBrokenObjectInfo("ValueStorage " + storageDesc + " not found. "
- + String.format(valueRecordFormat, propertyId, orderNumber, storageDesc), e.getMessage(),
- InspectionStatus.ERR);
+ report.logBrokenObjectAndSetInconsistency("ValueStorage " + storageDesc + " not found. "
+ + String.format(valueRecordFormat, propertyId, orderNumber, storageDesc), e.getMessage());
continue;
}
}
@@ -352,13 +348,13 @@
Throwable ex = e.getCause();
if (ex instanceof ValueDataNotFoundException)
{
- inspectionLog.logBrokenObjectInfo(String.format(valueRecordFormat, propertyId, orderNumber,
- storageDesc)
- + " not found.", ex.getMessage(), InspectionStatus.ERR);
+ report.logBrokenObjectAndSetInconsistency(
+ String.format(valueRecordFormat, propertyId, orderNumber, storageDesc) + " not found.",
+ ex.getMessage());
}
else if (ex instanceof IOException)
{
- inspectionLog.logException(ex.getMessage(), (IOException)ex);
+ report.logExceptionAndSetInconsistency(ex.getMessage(), ex);
}
else
{
@@ -371,8 +367,7 @@
}
catch (SQLException e)
{
- // log unexpceted exception
- inspectionLog.logException("Exception during ValueStorage inspection.", e);
+ report.logExceptionAndSetInconsistency("Exception during ValueStorage inspection.", e);
}
finally
{
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/SlowQueryHandler.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/SlowQueryHandler.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/api/core/query/lucene/SlowQueryHandler.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -19,7 +19,7 @@
import org.apache.lucene.search.Query;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.impl.InspectionLog;
+import org.exoplatform.services.jcr.impl.InspectionReport;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.query.AbstractQueryHandler;
@@ -130,7 +130,8 @@
* @see org.exoplatform.services.jcr.impl.core.query.QueryHandler#checkIndex(org.exoplatform.services.jcr.dataflow.ItemDataConsumer, boolean, InspectionLog)
*/
@Override
- public void checkIndex(ItemDataConsumer itemStateManager, boolean isSystem, InspectionLog inspectionLog) throws RepositoryException,
+ public void checkIndex(ItemDataConsumer itemStateManager, boolean isSystem, InspectionReport inspectionLog)
+ throws RepositoryException,
IOException
{
// do nothing
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestInspectionLogFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestInspectionLogFile.java 2012-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestInspectionLogFile.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -20,15 +20,10 @@
import junit.framework.TestCase;
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
-import org.exoplatform.services.jcr.impl.InspectionLog.InspectionStatus;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
-import java.io.OutputStreamWriter;
import java.io.Reader;
-import java.io.Writer;
/**
* @author <a href="mailto:skarpenko at exoplatform.com">Sergiy Karpenko</a>
@@ -38,31 +33,29 @@
public class TestInspectionLogFile extends TestCase
{
- private File f;
+ private InspectionReport report;
- private Writer writer;
-
public void setUp() throws Exception
{
super.setUp();
- f = File.createTempFile("testlog", "suf");
- writer = new OutputStreamWriter(PrivilegedFileHelper.fileOutputStream(f));
+
+ report = new InspectionReport("test");
}
public void tearDown() throws Exception
{
- writer.close();
- f.delete();
+ report.close();
+ getFileFromReport().delete();
+
super.tearDown();
}
public void testLogComment() throws Exception
{
- InspectionLog report = new InspectionLogWriter(writer);
report.logComment("test message");
// read file;
- Reader reader = new FileReader(f);
+ Reader reader = new FileReader(getFileFromReport());
BufferedReader br = new BufferedReader(reader);
String s = br.readLine();
br.close();
@@ -72,11 +65,10 @@
public void testLogInspectionDescription() throws Exception
{
- InspectionLog report = new InspectionLogWriter(writer);
- report.logInspectionDescription("description");
+ report.logDescription("description");
// read file;
- Reader reader = new FileReader(f);
+ Reader reader = new FileReader(getFileFromReport());
BufferedReader br = new BufferedReader(reader);
String s = br.readLine();
br.close();
@@ -86,16 +78,15 @@
public void testLogBrokenObjectInfo() throws Exception
{
- InspectionLog report = new InspectionLogWriter(writer);
- report.logBrokenObjectInfo("broken object descr", "message", InspectionStatus.REINDEX);
+ report.logBrokenObjectAndSetInconsistency("broken object descr", "message");
// read file;
- Reader reader = new FileReader(f);
+ Reader reader = new FileReader(getFileFromReport());
BufferedReader br = new BufferedReader(reader);
String s = br.readLine();
br.close();
- assertEquals("Reindex broken object descr message", s);
+ assertEquals("broken object descr message", s);
assertTrue(report.hasInconsistency());
}
@@ -103,11 +94,10 @@
{
Exception e = new Exception("Exception message.");
- InspectionLog report = new InspectionLogWriter(writer);
- report.logException("message", e);
+ report.logExceptionAndSetInconsistency("message", e);
// read file;
- Reader reader = new FileReader(f);
+ Reader reader = new FileReader(getFileFromReport());
BufferedReader br = new BufferedReader(reader);
String s = br.readLine();
assertEquals("//message", s);
@@ -119,4 +109,9 @@
assertTrue(report.hasInconsistency());
}
+ private File getFileFromReport()
+ {
+ return new File(report.getReportPath());
+ }
+
}
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-02-17 09:35:53 UTC (rev 5660)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TestRepositoryCheckController.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -62,7 +62,7 @@
public class TestRepositoryCheckController extends BaseStandaloneTest
{
- private RepositoryCheckController checkController;
+ private TesterRepositoryCheckController checkController;
private final TesterConfigurationHelper helper = TesterConfigurationHelper.getInstance();
@@ -90,19 +90,17 @@
public void testDB() throws Exception
{
- checkController =
- new RepositoryCheckController(repositoryService.getRepository("db1"));
+ checkController = new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
String result = checkController.checkRepositoryDataConsistency(new DataStorage[]{DataStorage.DB});
assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result, result
- .startsWith("Repository data is consistent"));
+ assertTrue("Repository data is not consistent, result: " + result,
+ result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
public void testValueStorage() throws Exception
{
- checkController =
- new RepositoryCheckController(repositoryService.getRepository("db1"));
+ checkController = new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
File f = this.createBLOBTempFile(20);
InputStream is = new FileInputStream(f);
@@ -115,8 +113,8 @@
String result = checkController.checkRepositoryDataConsistency(new DataStorage[]{DataStorage.VALUE_STORAGE});
assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result, result
- .startsWith("Repository data is consistent"));
+ assertTrue("Repository data is not consistent, result: " + result,
+ result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
finally
{
@@ -127,17 +125,17 @@
public void testSearchIndex() throws Exception
{
- checkController = new RepositoryCheckController(repositoryService.getRepository("db1"));
+ checkController = new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
String result = checkController.checkRepositoryDataConsistency(new DataStorage[]{DataStorage.LUCENE_INDEX});
assertNotNull(result);
- assertTrue("Repository data is not consistent, result: " + result, result
- .startsWith("Repository data is consistent"));
+ assertTrue("Repository data is not consistent, result: " + result,
+ result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
public void testAll() throws Exception
{
- checkController = new RepositoryCheckController(repositoryService.getRepository("db1"));
+ checkController = new TesterRepositoryCheckController(repositoryService.getRepository("db1"));
String result =
checkController.checkRepositoryDataConsistency(new DataStorage[]{DataStorage.DB, DataStorage.VALUE_STORAGE,
@@ -146,7 +144,7 @@
assertNotNull(result);
assertTrue("Repository data is not consistent, result: " + result,
- result.startsWith("Repository data is consistent"));
+ result.startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
}
/**
@@ -155,7 +153,7 @@
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());
@@ -164,8 +162,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -185,9 +184,10 @@
conn.commit();
conn.close();
-
+
// repository is inconsistent
- assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -206,8 +206,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -246,7 +247,8 @@
sm.onSaveItems(log);
// repository is inconsistent
- assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -265,8 +267,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -305,7 +308,8 @@
sm.onSaveItems(log);
// repository is inconsistent
- assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositorySearchIndexConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -336,8 +340,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -359,7 +364,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -390,8 +396,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -426,7 +433,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -457,8 +465,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -480,7 +489,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -512,8 +522,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -531,7 +542,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -545,8 +557,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -564,7 +577,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -594,8 +608,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -616,7 +631,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -648,8 +664,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -667,7 +684,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -681,8 +699,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -716,8 +735,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -735,7 +755,8 @@
conn.close();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -767,10 +788,10 @@
PropertyIterator iter = node.getProperties();
-
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -800,7 +821,8 @@
session.logout();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -815,8 +837,9 @@
PropertyIterator iter = node.getProperties();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
WorkspaceEntry wsEntry = repository.getConfiguration().getWorkspaceEntries().get(0);
@@ -850,7 +873,8 @@
session.logout();
// repository is inconsistent
- assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith("Repository data is consistent"));
+ assertTrue(checkController.checkRepositoryDataBaseConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
@@ -883,8 +907,9 @@
session.logout();
// repository is consistent
- checkController = new RepositoryCheckController(repository);
- assertTrue(checkController.checkRepositoryValueStorageConsistency().startsWith("Repository data is consistent"));
+ checkController = new TesterRepositoryCheckController(repository);
+ assertTrue(checkController.checkRepositoryValueStorageConsistency().startsWith(
+ RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
// remove the file from the value storage
@@ -897,7 +922,8 @@
assertTrue(vsFile.delete());
// repository is inconsistent
- assertTrue(checkController.checkRepositoryValueStorageConsistency().startsWith("Repository data is inconsistent"));
+ assertTrue(checkController.checkRepositoryValueStorageConsistency().startsWith(
+ RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
checkController.getLastLogFile().delete();
}
}
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TesterRepositoryCheckController.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TesterRepositoryCheckController.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/TesterRepositoryCheckController.java 2012-02-17 11:54:13 UTC (rev 5661)
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+import org.exoplatform.services.jcr.core.ManageableRepository;
+
+import java.io.File;
+
+/**
+ * For testing purpose. Returns last log file to have possibility to delete.
+ *
+ * @author <a href="abazko at exoplatform.com">Anatoliy Bazko</a>
+ * @version $Id: TesterRepositoryCheckController.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class TesterRepositoryCheckController extends RepositoryCheckController
+{
+ public TesterRepositoryCheckController(ManageableRepository repository)
+ {
+ super(repository);
+ }
+
+ public File getLastLogFile()
+ {
+ return new File(lastReport.getReportPath());
+ }
+}
More information about the exo-jcr-commits
mailing list