Search in sources :

Example 1 with ScimGroupMembers

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

the class CopyUtils method copy.

/**
	 * Copy data from GluuGroup object to ScimGroup object
	 * 
	 * @param source
	 * @param destination
	 * @return
	 * @throws Exception
	 */
public ScimGroup copy(GluuGroup source, ScimGroup destination) throws Exception {
    if (source == null) {
        return null;
    }
    if (destination == null) {
        destination = new ScimGroup();
    }
    List<String> schemas = new ArrayList<String>();
    schemas.add(Constants.SCIM1_CORE_SCHEMA_ID);
    destination.setSchemas(schemas);
    destination.setDisplayName(source.getDisplayName());
    destination.setId(source.getInum());
    if (source.getMembers() != null) {
        if (source.getMembers().size() != 0) {
            List<ScimGroupMembers> members = new ArrayList<ScimGroupMembers>();
            List<String> membersList = source.getMembers();
            for (String oneMember : membersList) {
                ScimGroupMembers member = new ScimGroupMembers();
                GluuCustomPerson person = personService.getPersonByDn(oneMember);
                member.setValue(person.getInum());
                member.setDisplay(person.getDisplayName());
                members.add(member);
            }
            destination.setMembers(members);
        }
    }
    return destination;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimGroupMembers(org.gluu.oxtrust.model.scim.ScimGroupMembers) ArrayList(java.util.ArrayList) ScimGroup(org.gluu.oxtrust.model.scim.ScimGroup)

Example 2 with ScimGroupMembers

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

the class CopyUtils method copy.

/**
	 * Copy data from ScimGroup object to GluuGroupn object
	 * 
	 * @param source
	 * @param destination
	 * @param isUpdate
	 * @return
	 * @throws IOException
	 * @throws JsonMappingException
	 * @throws JsonGenerationException
	 * @throws Exception
	 */
public GluuGroup copy(ScimGroup source, GluuGroup destination, boolean isUpdate) throws Exception {
    if (source == null || !isValidData(source, isUpdate)) {
        return null;
    }
    if (destination == null) {
        log.trace(" creating a new GluuGroup instant ");
        destination = new GluuGroup();
    }
    if (isUpdate) {
        if (source.getDisplayName() != null && source.getDisplayName().length() > 0) {
            destination.setDisplayName(source.getDisplayName());
        }
        if (source.getMembers() != null && source.getMembers().size() > 0) {
            List<ScimGroupMembers> members = source.getMembers();
            List<String> listMembers = new ArrayList<String>();
            for (ScimGroupMembers member : members) {
                listMembers.add(personService.getDnForPerson(member.getValue()));
            }
            destination.setMembers(listMembers);
        }
    } else {
        log.trace(" creating a new GroupService instant ");
        log.trace(" source.getDisplayName() : ", source.getDisplayName());
        if (groupService.getGroupByDisplayName(source.getDisplayName()) != null) {
            log.trace(" groupService1.getGroupByDisplayName(source.getDisplayName() != null : ");
            return null;
        }
        if (source.getDisplayName() != null && source.getDisplayName().length() > 0) {
            destination.setDisplayName(source.getDisplayName());
        }
        log.trace(" source.getMembers() : ", source.getMembers());
        log.trace(" source.getMembers().size() : ", source.getMembers().size());
        if (source.getMembers() != null && source.getMembers().size() > 0) {
            List<ScimGroupMembers> members = source.getMembers();
            List<String> listMembers = new ArrayList<String>();
            for (ScimGroupMembers member : members) {
                listMembers.add(personService.getDnForPerson(member.getValue()));
            }
            destination.setMembers(listMembers);
        }
        destination.setStatus(GluuStatus.ACTIVE);
        destination.setOrganization(organizationService.getDnForOrganization());
    }
    return destination;
}
Also used : ScimGroupMembers(org.gluu.oxtrust.model.scim.ScimGroupMembers) ArrayList(java.util.ArrayList) GluuGroup(org.gluu.oxtrust.model.GluuGroup)

Example 3 with ScimGroupMembers

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

the class CopyUtils2 method copy.

public GluuGroup copy(ScimGroup source, GluuGroup destination, List<GluuGroup> attributes) throws Exception {
    if (source == null) {
        return null;
    }
    if (destination == null) {
        destination = new GluuGroup();
    }
    destination.setInum(source.getId());
    destination.setDisplayName(source.getDisplayName());
    List<ScimGroupMembers> mapMembers = source.getMembers();
    List<String> listMembers = new ArrayList<String>();
    for (String dn : listMembers) {
        GluuCustomPerson gluuPerson = personService.getPersonByDn(dn);
        ScimGroupMembers member = new ScimGroupMembers();
        member.setDisplay(gluuPerson.getDisplayName());
        member.setValue(gluuPerson.getInum());
        mapMembers.add(member);
    }
    destination.setMembers(listMembers);
    return destination;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimGroupMembers(org.gluu.oxtrust.model.scim.ScimGroupMembers) ArrayList(java.util.ArrayList) GluuGroup(org.gluu.oxtrust.model.GluuGroup)

Aggregations

ArrayList (java.util.ArrayList)3 ScimGroupMembers (org.gluu.oxtrust.model.scim.ScimGroupMembers)3 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)2 GluuGroup (org.gluu.oxtrust.model.GluuGroup)2 ScimGroup (org.gluu.oxtrust.model.scim.ScimGroup)1