Search in sources :

Example 21 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class ItemImpl method remove.

/**
     * @see javax.jcr.Item#remove()
     */
public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException {
    checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
    checkStatus();
    // validation checks are performed within remove operation
    Operation rm = Remove.create(getItemState());
    session.getSessionItemStateManager().execute(rm);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 22 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class NodeImpl method update.

/**
     * @see Node#update(String)
     */
public void update(String srcWorkspaceName) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
    checkIsWritable();
    checkSessionHasPendingChanges();
    // if same workspace, ignore
    if (session.getWorkspace().getName().equals(srcWorkspaceName)) {
        return;
    }
    // a check if the specified source workspace is accessible
    try {
        getCorrespondingNodePath(srcWorkspaceName);
    } catch (ItemNotFoundException e) {
        // no corresponding node exists -> method has not effect
        return;
    }
    Operation op = Update.create(getNodeState(), srcWorkspaceName);
    ((WorkspaceImpl) session.getWorkspace()).getUpdatableItemStateManager().execute(op);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 23 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class NodeImpl method setPrimaryType.

/**
     * @see javax.jcr.Node#setPrimaryType(String)
     */
public void setPrimaryType(String nodeTypeName) throws RepositoryException {
    checkStatus();
    if (getNodeState().isRoot()) {
        String msg = "The primary type of the root node may not be changed.";
        log.debug(msg);
        throw new RepositoryException(msg);
    }
    Name ntName = getQName(nodeTypeName);
    if (ntName.equals(getPrimaryNodeTypeName())) {
        log.debug("Changing the primary type has no effect: '" + nodeTypeName + "' already is the primary node type.");
        return;
    }
    NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
    NodeType nt = ntMgr.getNodeType(ntName);
    if (nt.isMixin() || nt.isAbstract()) {
        throw new ConstraintViolationException("Cannot change the primary type: '" + nodeTypeName + "' is a mixin type or abstract.");
    }
    // perform the operation
    Operation op = SetPrimaryType.create(getNodeState(), ntName);
    session.getSessionItemStateManager().execute(op);
}
Also used : NodeType(javax.jcr.nodetype.NodeType) EffectiveNodeType(org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType) ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException) RepositoryException(javax.jcr.RepositoryException) NodeTypeManagerImpl(org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeManagerImpl) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) Name(org.apache.jackrabbit.spi.Name)

Example 24 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class AccessControlManagerImpl method addProperty.

private void addProperty(SetTree treeOperation, NodeState parent, Name propName, int propType, QValue[] values) throws RepositoryException {
    QPropertyDefinition definition = definitionProvider.getQPropertyDefinition(parent.getAllNodeTypeNames(), propName, propType);
    Operation ap = treeOperation.addChildProperty(parent, propName, propType, values, definition);
    itemStateMgr.execute(ap);
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 25 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class WorkspaceImpl method copy.

/**
     * @see javax.jcr.Workspace#copy(String, String, String)
     */
public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    session.checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
    session.checkIsAlive();
    // check workspace name
    if (getName().equals(srcWorkspace)) {
        // same as current workspace, delegate to within workspace copy method
        copy(srcAbsPath, destAbsPath);
        return;
    }
    // make sure the specified workspace is visible for the current session.
    session.checkAccessibleWorkspace(srcWorkspace);
    Path srcPath = session.getQPath(srcAbsPath);
    Path destPath = session.getQPath(destAbsPath);
    // copy (i.e. pull) subtree at srcAbsPath from srcWorkspace
    // to 'this' workspace at destAbsPath
    SessionImpl srcSession = null;
    try {
        // create session on other workspace for current subject
        // (may throw NoSuchWorkspaceException and AccessDeniedException)
        srcSession = session.switchWorkspace(srcWorkspace);
        WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();
        // do cross-workspace copy
        Operation op = Copy.create(srcPath, destPath, srcWsp.getName(), srcWsp, this);
        getUpdatableItemStateManager().execute(op);
    } finally {
        if (srcSession != null) {
            // we don't need the other session anymore, logout
            srcSession.logout();
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Aggregations

Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)32 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)6 Path (org.apache.jackrabbit.spi.Path)6 Name (org.apache.jackrabbit.spi.Name)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 RepositoryException (javax.jcr.RepositoryException)4 AddNode (org.apache.jackrabbit.jcr2spi.operation.AddNode)3 NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)3 PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)3 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)3 ItemExistsException (javax.jcr.ItemExistsException)2 HierarchyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)2 EffectiveNodeType (org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType)2 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)2 QValue (org.apache.jackrabbit.spi.QValue)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 Node (javax.jcr.Node)1