Search in sources :

Example 1 with ConsistencyChecker

use of org.apache.jackrabbit.core.persistence.check.ConsistencyChecker in project jackrabbit by apache.

the class TestHelper method checkConsistency.

/**
     * Runs a consistency check on the workspace used by the specified session.
     *
     * @param session the Session accessing the workspace to be checked
     * @param runFix whether to attempt fixup
     * @param lostNFoundId node to which to attach orphaned nodes (or <code>null</code>)
     * @throws RepositoryException if an error occurs while getting the
     * workspace with the given name.
     * @throws NotExecutableException if the {@link PersistenceManager} does
     * not implement {@link ConsistencyChecker}, or if the associated
     * {@link Repository} is not a {@link RepositoryImpl}.
     */
public static ConsistencyReport checkConsistency(Session session, boolean runFix, String lostNFoundId) throws NotExecutableException, RepositoryException {
    Repository r = session.getRepository();
    if (!(r instanceof RepositoryImpl)) {
        throw new NotExecutableException();
    } else {
        RepositoryImpl ri = (RepositoryImpl) r;
        PersistenceManager pm = ri.getWorkspaceInfo(session.getWorkspace().getName()).getPersistenceManager();
        if (!(pm instanceof ConsistencyChecker)) {
            throw new NotExecutableException();
        } else {
            return ((ConsistencyChecker) pm).check(null, true, runFix, lostNFoundId, null);
        }
    }
}
Also used : Repository(javax.jcr.Repository) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PersistenceManager(org.apache.jackrabbit.core.persistence.PersistenceManager) ConsistencyChecker(org.apache.jackrabbit.core.persistence.check.ConsistencyChecker)

Example 2 with ConsistencyChecker

use of org.apache.jackrabbit.core.persistence.check.ConsistencyChecker in project jackrabbit by apache.

the class TestHelper method checkVersionStoreConsistency.

/**
     * Runs a consistency check on the versioning store used by the specified session.
     *
     * @param session the Session accessing the workspace to be checked
     * @param runFix whether to attempt fixup
     * @param lostNFoundId node to which to attach orphaned nodes (or <code>null</code>)
     * @throws RepositoryException
     * @throws NotExecutableException if the {@link PersistenceManager} does
     * not implement {@link ConsistencyChecker}, or if the associated
     * {@link Repository} is not a {@link RepositoryImpl}.
     */
public static ConsistencyReport checkVersionStoreConsistency(Session session, boolean runFix, String lostNFoundId) throws NotExecutableException, RepositoryException {
    Repository r = session.getRepository();
    if (!(r instanceof RepositoryImpl)) {
        throw new NotExecutableException();
    } else {
        RepositoryImpl ri = (RepositoryImpl) r;
        PersistenceManager pm = ri.getRepositoryContext().getInternalVersionManager().getPersistenceManager();
        if (!(pm instanceof ConsistencyChecker)) {
            throw new NotExecutableException();
        } else {
            return ((ConsistencyChecker) pm).check(null, true, runFix, lostNFoundId, null);
        }
    }
}
Also used : Repository(javax.jcr.Repository) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PersistenceManager(org.apache.jackrabbit.core.persistence.PersistenceManager) ConsistencyChecker(org.apache.jackrabbit.core.persistence.check.ConsistencyChecker)

Aggregations

Repository (javax.jcr.Repository)2 PersistenceManager (org.apache.jackrabbit.core.persistence.PersistenceManager)2 ConsistencyChecker (org.apache.jackrabbit.core.persistence.check.ConsistencyChecker)2 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)2