@Override public void link(final int subscription) { final Map<String, String> parameters = subscriptionResource.getParameters(subscription); // Validate the job settings validateGroup(parameters); // There is no additional step since the group is already created in // LDAP }
/** * Return users member of associated subscription. * * @param subscription * The subscription identifier used to get the related group and members. * @return The members of related groups of the subscription. */ public Collection<UserOrg> getMembers(final int subscription) { // Get current subscription parameters final Map<String, String> parameters = subscriptionResource.getParameters(subscription); final String group = parameters.get(IdentityResource.PARAMETER_GROUP); return userResource.findAllNotSecure(null, group); }
/** * Return the version of tool or <code>null</code> if not available/found. * * @param subscription * the subscription's identifier to use to locate the target instance. * @return the version of tool or <code>null</code> if not available/found. * @throws Exception * When version cannot be be retrieved. */ @GET @Path("version/{subscription:\\d+}") public String getVersion(@PathParam("subscription") final int subscription) throws Exception { // Return the version from the subscription parameters return getVersion(subscriptionResource.getParameters(subscription)); }
@Override public void delete(final int subscription, final boolean deleteRemoteData) { if (deleteRemoteData) { // Data are removed from the LDAP final Map<String, String> parameters = subscriptionResource.getParameters(subscription); final String group = parameters.get(IdentityResource.PARAMETER_GROUP); // Check the group exists, but is not required to continue the // process final GroupLdapRepository repository = getGroup(); final GroupOrg groupLdap = repository.findById(group); if (groupLdap != null) { // Perform the deletion repository.delete(groupLdap); } } }
@Override public void create(final int subscription) { final Map<String, String> parameters = subscriptionResource.getParameters(subscription); final String group = parameters.get(IdentityResource.PARAMETER_GROUP); final String parentGroup = parameters.get(IdentityResource.PARAMETER_PARENT_GROUP); final String ou = parameters.get(IdentityResource.PARAMETER_OU); final Project project = subscriptionRepository.findOne(subscription).getProject(); final String pkey = project.getPkey(); // Check the relationship between group, OU and project validateGroup(group, ou, pkey); // Check the relationship between group, and parent final String parentDn = validateAndCreateParent(group, parentGroup, ou, pkey); // Create the group inside the parent (OU or parent CN) final String groupDn = "cn=" + group + "," + parentDn; log.info("New Group CN would be created {} project {} and subscription {}", group, pkey); final GroupLdapRepository repository = getGroup(); final GroupOrg groupLdap = repository.create(groupDn, group); // Complete as needed the relationship between parent and this new group if (StringUtils.isNotBlank(parentGroup)) { // This group will be added as "uniqueMember" of its parent repository.addGroup(groupLdap, parentGroup); } // Associate the project to this group in the cache final CacheProjectGroup projectGroup = new CacheProjectGroup(); projectGroup.setProject(project); projectGroup.setGroup(repository.getCacheRepository().findOneExpected(groupLdap.getId())); cacheProjectGroupRepository.saveAndFlush(projectGroup); }
/** * Refresh given subscriptions and return their status. */ private SubscriptionStatusWithData refreshSubscription(final Subscription subscription) { final Map<String, String> parameters = getParameters(subscription.getId()); final SubscriptionStatusWithData statusWithData = nodeResource.checkSubscriptionStatus(subscription, parameters); statusWithData.setId(subscription.getId()); statusWithData.setProject(subscription.getProject().getId()); statusWithData.setParameters(parameterValueResource.getNonSecuredSubscriptionParameters(subscription.getId())); // Update the last event with fresh data eventResource.registerEvent(subscription, EventType.STATUS, statusWithData.getStatus().name()); // Return the fresh statuses return statusWithData; }