Search in sources :

Example 1 with NodeStateEx

use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.

the class VersionManagerImpl method createConfiguration.

/**
 * {@inheritDoc}
 */
public Node createConfiguration(String absPath) throws RepositoryException {
    if (session.nodeExists(absPath)) {
        NodeStateEx state = getNodeState(absPath, ItemValidator.CHECK_LOCK | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE | ItemValidator.CHECK_HOLD, Permission.VERSION_MNGMT);
        // check versionable
        if (!checkVersionable(state)) {
            throw new UnsupportedRepositoryOperationException("Node not full versionable: " + absPath);
        }
        if (state.getPropertyValue(NameConstants.JCR_CONFIGURATION) != null) {
            String msg = "Node is already a configuration root: " + absPath;
            log.error(msg);
            throw new UnsupportedRepositoryOperationException(msg);
        }
        NodeId configId = createConfiguration(state);
        return session.getNodeById(configId);
    } else {
        String msg = "Create configuration node must exist: " + absPath;
        log.error(msg);
        throw new UnsupportedRepositoryOperationException(msg);
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NodeId(org.apache.jackrabbit.core.id.NodeId) NodeStateEx(org.apache.jackrabbit.core.version.NodeStateEx)

Example 2 with NodeStateEx

use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.

the class VersionManagerImpl method mergeOrUpdate.

/**
 * Combines merge and update method
 * @param state the state to merge or update
 * @param srcWorkspaceName source workspace name
 * @param failedIds list that will contain the failed ids.
 *        if <code>null</code> and update will be performed.
 * @param bestEffort best effort flag
 * @param isShallow is shallow flag
 * @throws RepositoryException if an error occurs
 */
private void mergeOrUpdate(NodeStateEx state, String srcWorkspaceName, List<ItemId> failedIds, boolean bestEffort, boolean isShallow) throws RepositoryException {
    // if same workspace, ignore
    if (!srcWorkspaceName.equals(session.getWorkspace().getName())) {
        // check authorization for specified workspace
        if (!session.getAccessManager().canAccess(srcWorkspaceName)) {
            String msg = "not authorized to access " + srcWorkspaceName;
            log.error(msg);
            throw new AccessDeniedException(msg);
        }
        // get root node of src workspace
        SessionImpl srcSession = null;
        try {
            // create session on other workspace for current subject
            // (may throw NoSuchWorkspaceException and AccessDeniedException)
            srcSession = ((RepositoryImpl) session.getRepository()).createSession(session.getSubject(), srcWorkspaceName);
            WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();
            NodeId rootNodeId = ((NodeImpl) srcSession.getRootNode()).getNodeId();
            NodeStateEx srcRoot = new NodeStateEx(srcWsp.getItemStateManager(), ntReg, rootNodeId);
            merge(state, srcRoot, failedIds, bestEffort, isShallow);
        } catch (ItemStateException e) {
            throw new RepositoryException(e);
        } finally {
            if (srcSession != null) {
                // we don't need the other session anymore, logout
                srcSession.logout();
            }
        }
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) NodeId(org.apache.jackrabbit.core.id.NodeId) RepositoryException(javax.jcr.RepositoryException) NodeStateEx(org.apache.jackrabbit.core.version.NodeStateEx) InvalidItemStateException(javax.jcr.InvalidItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 3 with NodeStateEx

use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.

the class VersionManagerImpl method cancelMerge.

/**
 * {@inheritDoc}
 */
public void cancelMerge(String absPath, Version version) throws RepositoryException {
    NodeStateEx state = getNodeState(absPath, ItemValidator.CHECK_LOCK | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE | ItemValidator.CHECK_HOLD, Permission.VERSION_MNGMT);
    finishMerge(state, version, true);
}
Also used : NodeStateEx(org.apache.jackrabbit.core.version.NodeStateEx)

Example 4 with NodeStateEx

use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.

the class VersionManagerImpl method doneMerge.

/**
 * {@inheritDoc}
 */
public void doneMerge(String absPath, Version version) throws RepositoryException {
    NodeStateEx state = getNodeState(absPath, ItemValidator.CHECK_LOCK | ItemValidator.CHECK_PENDING_CHANGES_ON_NODE | ItemValidator.CHECK_HOLD, Permission.VERSION_MNGMT);
    finishMerge(state, version, false);
}
Also used : NodeStateEx(org.apache.jackrabbit.core.version.NodeStateEx)

Example 5 with NodeStateEx

use of org.apache.jackrabbit.core.version.NodeStateEx in project jackrabbit by apache.

the class VersionManagerImpl method restore.

/**
 * Same as {@link #restore(String, String, boolean)} but to ensure
 * backward compatibility for Node.restore(Version, boolean).
 *
 * @param node the node to restore
 * @param version the version to restore
 * @param removeExisting the remove existing flag
 * @throws RepositoryException if an error occurs
 */
protected void restore(NodeImpl node, Version version, boolean removeExisting) throws RepositoryException {
    NodeStateEx state = getNodeState(node.getPath(), CHECK_PENDING_CHANGES | CHECK_LOCK | CHECK_HOLD, Permission.NONE);
    InternalVersion v = getVersion(version);
    restore(state, v, removeExisting);
}
Also used : NodeStateEx(org.apache.jackrabbit.core.version.NodeStateEx) InternalVersion(org.apache.jackrabbit.core.version.InternalVersion)

Aggregations

NodeStateEx (org.apache.jackrabbit.core.version.NodeStateEx)6 NodeId (org.apache.jackrabbit.core.id.NodeId)2 AccessDeniedException (javax.jcr.AccessDeniedException)1 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 RepositoryException (javax.jcr.RepositoryException)1 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)1 InternalVersion (org.apache.jackrabbit.core.version.InternalVersion)1