Search in sources :

Example 6 with PersistenceManager

use of org.apache.jackrabbit.core.persistence.PersistenceManager 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 7 with PersistenceManager

use of org.apache.jackrabbit.core.persistence.PersistenceManager 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

PersistenceManager (org.apache.jackrabbit.core.persistence.PersistenceManager)7 Repository (javax.jcr.Repository)3 IterablePersistenceManager (org.apache.jackrabbit.core.persistence.IterablePersistenceManager)3 RepositoryException (javax.jcr.RepositoryException)2 NodeId (org.apache.jackrabbit.core.id.NodeId)2 ConsistencyChecker (org.apache.jackrabbit.core.persistence.check.ConsistencyChecker)2 InternalVersionManagerImpl (org.apache.jackrabbit.core.version.InternalVersionManagerImpl)2 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 AccessDeniedException (javax.jcr.AccessDeniedException)1 LoginException (javax.jcr.LoginException)1 NoSuchWorkspaceException (javax.jcr.NoSuchWorkspaceException)1 Node (javax.jcr.Node)1 Session (javax.jcr.Session)1 RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)1 ClusterException (org.apache.jackrabbit.core.cluster.ClusterException)1 RepositoryConfig (org.apache.jackrabbit.core.config.RepositoryConfig)1 WorkspaceConfig (org.apache.jackrabbit.core.config.WorkspaceConfig)1