Search in sources :

Example 76 with RepositoryException

use of javax.jcr.RepositoryException in project jackrabbit by apache.

the class WorkspaceImpl method internalClone.

/**
     * Handles a clone inside the same workspace, which is supported with
     * shareable nodes.
     *
     * @see {@link #clone()}
     *
     * @param srcAbsPath source path
     * @param destAbsPath destination path
     * @return the path of the node at its new position
     * @throws ConstraintViolationException
     * @throws AccessDeniedException
     * @throws VersionException
     * @throws PathNotFoundException
     * @throws ItemExistsException
     * @throws LockException
     * @throws RepositoryException
     */
private String internalClone(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    Path srcPath;
    try {
        srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + srcAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!srcPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + srcAbsPath);
    }
    Path destPath;
    try {
        destPath = context.getQPath(destAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + destAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!destPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + destAbsPath);
    }
    BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
    try {
        ops.edit();
    } catch (IllegalStateException e) {
        String msg = "unable to start edit operation";
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    boolean succeeded = false;
    try {
        ItemId id = ops.clone(srcPath, destPath);
        ops.update();
        succeeded = true;
        return context.getJCRPath(hierMgr.getPath(id));
    } finally {
        if (!succeeded) {
            // update operation failed, cancel all modifications
            ops.cancel();
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) RepositoryException(javax.jcr.RepositoryException) ItemId(org.apache.jackrabbit.core.id.ItemId)

Example 77 with RepositoryException

use of javax.jcr.RepositoryException in project jackrabbit by apache.

the class WorkspaceImpl method getQueryManager.

/**
     * {@inheritDoc}
     */
public synchronized QueryManager getQueryManager() throws RepositoryException {
    // check state of this instance
    sanityCheck();
    if (queryManager == null) {
        SearchManager searchManager;
        try {
            searchManager = context.getRepository().getSearchManager(wspConfig.getName());
            if (searchManager == null) {
                String msg = "no search manager configured for this workspace";
                log.debug(msg);
                throw new RepositoryException(msg);
            }
        } catch (NoSuchWorkspaceException nswe) {
            // should never get here
            String msg = "internal error: failed to instantiate query manager";
            log.debug(msg);
            throw new RepositoryException(msg, nswe);
        }
        queryManager = new QueryManagerImpl(context, searchManager);
    }
    return queryManager;
}
Also used : NoSuchWorkspaceException(javax.jcr.NoSuchWorkspaceException) RepositoryException(javax.jcr.RepositoryException) QueryManagerImpl(org.apache.jackrabbit.core.query.QueryManagerImpl)

Example 78 with RepositoryException

use of javax.jcr.RepositoryException in project jackrabbit by apache.

the class WorkspaceImpl method move.

/**
     * {@inheritDoc}
     */
public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    // check state of this instance
    sanityCheck();
    // intra-workspace move...
    Path srcPath;
    try {
        srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + srcAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!srcPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + srcAbsPath);
    }
    Path destPath;
    try {
        destPath = context.getQPath(destAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + destAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!destPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + destAbsPath);
    }
    BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
    try {
        ops.edit();
    } catch (IllegalStateException e) {
        String msg = "unable to start edit operation";
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    boolean succeeded = false;
    try {
        ops.move(srcPath, destPath);
        ops.update();
        succeeded = true;
    } finally {
        if (!succeeded) {
            // update operation failed, cancel all modifications
            ops.cancel();
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) RepositoryException(javax.jcr.RepositoryException)

Example 79 with RepositoryException

use of javax.jcr.RepositoryException in project jackrabbit by apache.

the class ClusterNode method process.

public void process(WorkspaceRecord record) {
    if (createWorkspaceListener == null) {
        String msg = "Create Workspace listener unavailable.";
        log.error(msg);
        return;
    }
    try {
        if (record.getActionType() == WorkspaceRecord.CREATE_WORKSPACE_ACTION_TYPE) {
            CreateWorkspaceAction action = record.getCreateWorkspaceAction();
            createWorkspaceListener.externalWorkspaceCreated(record.getWorkspace(), action.getInputSource());
        }
    } catch (RepositoryException e) {
        String msg = "Unable to create workspace: " + e.getMessage();
        log.error(msg);
    }
}
Also used : CreateWorkspaceAction(org.apache.jackrabbit.core.cluster.WorkspaceRecord.CreateWorkspaceAction) RepositoryException(javax.jcr.RepositoryException)

Example 80 with RepositoryException

use of javax.jcr.RepositoryException in project jackrabbit by apache.

the class ClusterNode method init.

/**
     * Initialize this cluster node (overridable).
     *
     * @throws ClusterException if an error occurs
     */
protected void init() throws ClusterException {
    ClusterConfig cc = clusterContext.getClusterConfig();
    clusterNodeId = cc.getId();
    syncDelay = cc.getSyncDelay();
    stopDelay = cc.getStopDelay();
    try {
        journal = cc.getJournal(clusterContext.getNamespaceResolver());
        instanceRevision = journal.getInstanceRevision();
        journal.register(this);
        producer = journal.getProducer(PRODUCER_ID);
    } catch (RepositoryException e) {
        throw new ClusterException("Cluster initialization failed: " + this, e);
    } catch (JournalException e) {
        throw new ClusterException("Journal initialization failed: " + this, e);
    }
}
Also used : JournalException(org.apache.jackrabbit.core.journal.JournalException) RepositoryException(javax.jcr.RepositoryException) ClusterConfig(org.apache.jackrabbit.core.config.ClusterConfig)

Aggregations

RepositoryException (javax.jcr.RepositoryException)1236 Node (javax.jcr.Node)289 Session (javax.jcr.Session)182 IOException (java.io.IOException)156 ArrayList (java.util.ArrayList)106 Name (org.apache.jackrabbit.spi.Name)94 DavException (org.apache.jackrabbit.webdav.DavException)90 Test (org.junit.Test)87 Value (javax.jcr.Value)80 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)76 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)72 Path (org.apache.jackrabbit.spi.Path)67 ItemNotFoundException (javax.jcr.ItemNotFoundException)65 PathNotFoundException (javax.jcr.PathNotFoundException)65 NodeId (org.apache.jackrabbit.core.id.NodeId)64 Property (javax.jcr.Property)61 HashMap (java.util.HashMap)53 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)53 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)52 InvalidItemStateException (javax.jcr.InvalidItemStateException)50