Set<Name> aggrNames = newCustomPrivs.get(name);
privilegeRegistry.registerDefinition(name, isAbstract, aggrNames);
// validate definition
PrivilegeDefinition definition = privilegeRegistry.get(name);
assertNotNull(definition);
assertEquals(name, definition.getName());
assertTrue(definition.isAbstract());
assertTrue(definition.getDeclaredAggregateNames().isEmpty());
assertEquals(aggrNames.size(), definition.getDeclaredAggregateNames().size());
for (Name n : aggrNames) {
assertTrue(definition.getDeclaredAggregateNames().contains(n));
}
Set<Name> allAgg = privilegeRegistry.get(NameConstants.JCR_ALL).getDeclaredAggregateNames();
assertTrue(allAgg.contains(name));
// re-read the filesystem resource and check if definition is correct
PrivilegeRegistry registry = new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs);
PrivilegeDefinition def = registry.get(name);
assertEquals(isAbstract, def.isAbstract());
assertEquals(aggrNames.size(), def.getDeclaredAggregateNames().size());
for (Name n : aggrNames) {
assertTrue(def.getDeclaredAggregateNames().contains(n));
}
assertPrivilege(privilegeRegistry, (SessionImpl) superuser, definition);
}
Map<Name, Set<Name>> newAggregates = new HashMap<Name, Set<Name>>();
// a new aggregate of custom privileges
newAggregates.put(resolver.getQName("newA2"), createNameSet(resolver.getQName("test:new"), resolver.getQName("new")));
// a new aggregate of custom and built-in privilege
newAggregates.put(resolver.getQName("newA1"), createNameSet(resolver.getQName("new"), NameConstants.JCR_READ));
// aggregating built-in privileges
newAggregates.put(resolver.getQName("aggrBuiltIn"), createNameSet(NameConstants.JCR_MODIFY_PROPERTIES, NameConstants.JCR_READ));
for (Name name : newAggregates.keySet()) {
boolean isAbstract = false;
Set<Name> aggrNames = newAggregates.get(name);
privilegeRegistry.registerDefinition(name, isAbstract, aggrNames);
PrivilegeDefinition definition = privilegeRegistry.get(name);
assertNotNull(definition);
assertEquals(name, definition.getName());
assertFalse(definition.isAbstract());
assertFalse(definition.getDeclaredAggregateNames().isEmpty());
assertEquals(aggrNames.size(), definition.getDeclaredAggregateNames().size());
for (Name n : aggrNames) {
assertTrue(definition.getDeclaredAggregateNames().contains(n));
}
Set<Name> allAgg = privilegeRegistry.get(NameConstants.JCR_ALL).getDeclaredAggregateNames();
assertTrue(allAgg.contains(name));
// re-read the filesystem resource and check if definition is correct
PrivilegeRegistry registry = new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs);
PrivilegeDefinition def = registry.get(name);
assertEquals(isAbstract, def.isAbstract());
assertEquals(isAbstract, def.isAbstract());
assertEquals(aggrNames.size(), def.getDeclaredAggregateNames().size());
for (Name n : aggrNames) {
assertTrue(def.getDeclaredAggregateNames().contains(n));
}
assertPrivilege(registry, (SessionImpl) superuser, def);
}
}