@Override public void addManagedRepository(String repositoryId) throws NoSuchRepositoryException, ConfigurationException, IOException, NoSuchAuthorizationManagerException, NoSuchRoleException { final Repository repository; try { // Call verifies that the repository exists repository = this.repositoryRegistry.getRepository(repositoryId); } catch (NoSuchRepositoryException e) { throw new NoSuchRepositoryException( "Cannot manage repository that doesn't exist: " + repositoryId, e); } groupManagementPluginConfiguration.addManagedRepository(repositoryId); // Go through and add all privs/roles needed for the new repository for every existing managed // groupId final ManagedRepository managedRepository = this.createManagedRepository(repository); final ManagedGroupIds managedGroupIds = getManagedGroupIds(); for (final ManagedGroupId managedGroupId : managedGroupIds.getManagedGroupIds()) { this.addRepositoryForGroupId(managedGroupId.getGroupId(), managedRepository); } this.nexusConfiguration.saveConfiguration(); }
@Override public ManagedGroupIds getManagedGroupIds() { final ManagedGroupIds managedGroupIds = new ManagedGroupIds(); for (final Target target : this.targetRegistry.getTargetsForContentClass(M2_CONTENT_CLASS)) { final String id = target.getId(); if (id.startsWith(GIDM_ID_PREFIX)) { final String groupId = id.substring(GIDM_ID_PREFIX.length()); final ManagedGroupId managedGroupId = createManagedGroupId(groupId); managedGroupIds.addManagedGroupId(managedGroupId); } } return managedGroupIds; }
@Override public void removeManagedRepository(String repositoryId) throws NoSuchRepositoryException, NoSuchPrivilegeException, NoSuchAuthorizationManagerException, IOException { final ManagedRepository repository = this.getAsManagedRepository(repositoryId); groupManagementPluginConfiguration.removeManagedRepository(repositoryId); final ManagedGroupIds managedGroupIds = getManagedGroupIds(); for (final ManagedGroupId managedGroupId : managedGroupIds.getManagedGroupIds()) { this.removeRepositoryForGroupId(managedGroupId.getGroupId(), repository); } this.nexusConfiguration.saveConfiguration(); }