Search in sources :

Example 1 with SetTree

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

the class AccessControlManagerImpl method setPolicy.

public void setPolicy(String absPath, AccessControlPolicy policy) throws RepositoryException {
    checkValidNodePath(absPath);
    checkValidPolicy(policy);
    checkAcccessControlItem(absPath);
    SetTree operation;
    NodeState aclNode = getAclNode(absPath);
    if (aclNode == null) {
        // policy node doesn't exist at absPath -> create one.
        Name name = (absPath == null) ? N_REPO_POLICY : N_POLICY;
        NodeState parent = null;
        Name mixinType = null;
        if (absPath == null) {
            parent = getRootNodeState();
            mixinType = NT_REP_REPO_ACCESS_CONTROLLABLE;
        } else {
            parent = getNodeState(absPath);
            mixinType = NT_REP_ACCESS_CONTROLLABLE;
        }
        setMixin(parent, mixinType);
        operation = SetTree.create(itemStateMgr, parent, name, NT_REP_ACL, null);
        aclNode = operation.getTreeState();
    } else {
        Iterator<NodeEntry> it = getNodeEntry(aclNode).getNodeEntries();
        while (it.hasNext()) {
            it.next().transientRemove();
        }
        operation = SetTree.create(aclNode);
    }
    // create the entry nodes
    for (AccessControlEntry entry : ((AccessControlListImpl) policy).getAccessControlEntries()) {
        createAceNode(operation, aclNode, entry);
    }
    itemStateMgr.execute(operation);
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) SetTree(org.apache.jackrabbit.jcr2spi.operation.SetTree) AccessControlEntry(javax.jcr.security.AccessControlEntry) Name(org.apache.jackrabbit.spi.Name)

Aggregations

AccessControlEntry (javax.jcr.security.AccessControlEntry)1 NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)1 SetTree (org.apache.jackrabbit.jcr2spi.operation.SetTree)1 NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)1 Name (org.apache.jackrabbit.spi.Name)1