/** * 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; }
/** * Write user's activities */ private void writeNodeActivities(final Map<String, Activity> activities, final Writer writer, final Format df) throws IOException { for (final INamableBean<String> node : computations.getNodes()) { writer.write(';'); // Last connection, if available final Activity activity = activities.get(node.getId()); if (activity != null) { // There is an activity for this user and this node writer.write(df.format(activity.getLastConnection())); } } }
/** * 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; }
@Override public void serialize(final INamableBean<?> date, final JsonGenerator generator, final SerializerProvider provider) throws IOException { generator.writeString(date.getName()); }
/** * Write headers. */ private void writeNodeHeaders(final Writer writer) throws IOException { // Iterate over audited nodes for (final INamableBean<String> node : computations.getNodes()) { writer.write(";"); writer.write(node.getName()); } }