Search in sources :

Example 56 with GluuGroup

use of org.gluu.oxtrust.model.GluuGroup in project oxTrust by GluuFederation.

the class ServiceUtil method groupMembersAdder.

/**
 * Adds a person to a group
 *
 * @return void
 * @throws Exception
 */
public void groupMembersAdder(GluuCustomPerson gluuPerson, String dn) throws Exception {
    List<String> groups = gluuPerson.getMemberOf();
    for (String group : groups) {
        GluuGroup oneGroup = groupService.getGroupByDn(group);
        List<String> groupMembers = oneGroup.getMembers();
        if ((groupMembers != null && !groupMembers.isEmpty()) && !isMemberExist(groupMembers, dn)) {
            List<String> cleanGroupMembers = new ArrayList<String>();
            cleanGroupMembers.add(dn);
            for (String personDN : groupMembers) {
                cleanGroupMembers.add(personDN);
            }
            oneGroup.setMembers(cleanGroupMembers);
            groupService.updateGroup(oneGroup);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) GluuGroup(org.gluu.oxtrust.model.GluuGroup)

Aggregations

GluuGroup (org.gluu.oxtrust.model.GluuGroup)56 ArrayList (java.util.ArrayList)15 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)13 Produces (javax.ws.rs.Produces)11 Response (javax.ws.rs.core.Response)11 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)11 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)10 Operation (io.swagger.v3.oas.annotations.Operation)7 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)7 URI (java.net.URI)7 Path (javax.ws.rs.Path)7 ScimGroup (org.gluu.oxtrust.model.scim.ScimGroup)6 VirtualListViewResponse (org.xdi.ldap.model.VirtualListViewResponse)6 DefaultValue (javax.ws.rs.DefaultValue)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 Group (org.gluu.oxtrust.model.scim2.Group)5 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)4 Date (java.util.Date)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)4 Consumes (javax.ws.rs.Consumes)4