/** * Search the LDAP Customers matching to the given criteria and for type "Project". Node identifier is ignored for * now. Node is ignored. * * @param criteria * the search criteria. * @return LDAP Customers matching the criteria. * @see ContainerScope#TYPE_PROJECT */ @GET @Path("customer/{node}/{criteria}") @Consumes(MediaType.APPLICATION_JSON) public Collection<INamableBean<String>> findCustomersByName(@PathParam("criteria") final String criteria) { final Set<INamableBean<String>> result = new TreeSet<>(); final String criteriaClean = Normalizer.normalize(criteria); final ContainerScope findByName = containerScopeResource.findByName(ContainerScope.TYPE_PROJECT); final Collection<String> allCustomers = projectCustomerLdapRepository.findAll(findByName.getDn()); // Check type and criteria allCustomers.stream().filter(customer -> customer.contains(criteriaClean)).forEach(customer -> { // Return the nice name final INamableBean<String> bean = new NamedBean<>(); // Return the nice name bean.setName(customer); bean.setId(customer); result.add(bean); }); return result; }
/** * Copy a bean to another one. * * @param <T> * Bean type. * @param from * the source bean. * @param to * the target bean. */ public static <T extends Serializable> void copy(final INamableBean<T> from, final INamableBean<T> to) { to.setId(from.getId()); to.setName(from.getName()); }
/** * Validate the group settings. * * @param parameters * the administration parameters. * @return real group name. */ protected INamableBean<String> validateGroup(final Map<String, String> parameters) { // Get group configuration final String group = parameters.get(IdentityResource.PARAMETER_GROUP); final ContainerWithScopeVo groupLdap = groupLdapResource.findByName(group); // Check the group exists if (groupLdap == null) { throw new ValidationJsonException(IdentityResource.PARAMETER_GROUP, BusinessException.KEY_UNKNOW_ID, group); } // Check the group has type TYPE_PROJECT if (!ContainerScope.TYPE_PROJECT.equals(groupLdap.getScope())) { // Invalid type throw new ValidationJsonException(IdentityResource.PARAMETER_GROUP, "group-type", group); } // Return the nice name final INamableBean<String> result = new NamedBean<>(); result.setName(groupLdap.getName()); result.setId(group); return result; }