/** Logic shared when adding new managed GroupIds and Repositories. */ protected void addRepositoryForGroupId( String groupId, ManagedRepository repository, Target managedTarget, AuthorizationManager authorizationManager, Set<String> deployerPrivs, Set<String> readOnlyPrivs, Map<String, Privilege> existingPrivs) throws InvalidConfigurationException { final Logger logger = this.getLogger(); for (final String method : PRIVILEGE_METHODS) { final String name = createPrivilegeName(repository, groupId, method); // Check for existing priv before creating a new one Privilege priv = existingPrivs.get(name); if (priv == null) { priv = new Privilege(); logger.info("Creating new privilege: " + name); } else { logger.info("Updating existing privilege: " + name); } priv.setName(name); priv.setDescription(priv.getName()); priv.setType(TargetPrivilegeDescriptor.TYPE); priv.addProperty(ApplicationPrivilegeMethodPropertyDescriptor.ID, method); priv.addProperty(TargetPrivilegeRepositoryTargetPropertyDescriptor.ID, managedTarget.getId()); priv.addProperty(TargetPrivilegeRepositoryPropertyDescriptor.ID, repository.getId()); // Store, capturing updated reference priv = authorizationManager.addPrivilege(priv); // Build up the priv lists if (DEPLOYER_METHODS.contains(method)) { deployerPrivs.add(priv.getId()); } if (READONLY_METHODS.contains(method)) { readOnlyPrivs.add(priv.getId()); } } }
protected void removeRepositoryForGroupId( String groupId, ManagedRepository repository, AuthorizationManager authorizationManager, Map<String, Privilege> existingPrivs) throws NoSuchPrivilegeException { final Logger logger = getLogger(); for (final String method : PRIVILEGE_METHODS) { final String name = createPrivilegeName(repository, groupId, method); final Privilege priv = existingPrivs.remove(name); if (priv != null) { authorizationManager.deletePrivilege(priv.getId()); logger.info("Deleted privilege: " + priv.getName()); } } }