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;
}
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;
}
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;
}
Aggregations