Search in sources :

Example 6 with ImmutablePrivilegeDefinition

use of org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition in project jackrabbit-oak by apache.

the class PrivilegeManagerImpl method registerPrivilege.

@Override
public Privilege registerPrivilege(String privilegeName, boolean isAbstract, String[] declaredAggregateNames) throws RepositoryException {
    if (root.hasPendingChanges()) {
        throw new InvalidItemStateException("Attempt to register a new privilege while there are pending changes.");
    }
    if (privilegeName == null || privilegeName.isEmpty()) {
        throw new RepositoryException("Invalid privilege name " + privilegeName);
    }
    PrivilegeDefinition definition = new ImmutablePrivilegeDefinition(getOakName(privilegeName), isAbstract, getOakNames(declaredAggregateNames));
    PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(getWriteRoot());
    writer.writeDefinition(definition);
    // refresh the current root to make sure the definition is visible
    root.refresh();
    return getPrivilege(definition);
}
Also used : InvalidItemStateException(javax.jcr.InvalidItemStateException) PrivilegeDefinition(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeDefinition) ImmutablePrivilegeDefinition(org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition) ImmutablePrivilegeDefinition(org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition) RepositoryException(javax.jcr.RepositoryException)

Aggregations

ImmutablePrivilegeDefinition (org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition)6 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)4 Test (org.junit.Test)4 RepositoryException (javax.jcr.RepositoryException)3 Root (org.apache.jackrabbit.oak.api.Root)2 PrivilegeDefinition (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeDefinition)2 LinkedHashMap (java.util.LinkedHashMap)1 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 Oak (org.apache.jackrabbit.oak.Oak)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)1