use of org.gluu.oxtrust.model.PersonAttribute in project oxTrust by GluuFederation.
the class CopyUtils2 method copy.
/**
* Copy data from Person object to GluuCustomPerson object
*
* @param source
* @param destination
* @return
* @throws Exception
*/
public GluuCustomPerson copy(Person source, GluuCustomPerson destination, List<GluuAttribute> attributes, GluuUserRole role, boolean isUpdate) {
if (source == null || !isValidData(source, isUpdate)) {
return null;
}
if (destination == null) {
destination = new GluuCustomPerson();
}
if (source.getPersonAttrList() != null) {
for (PersonAttribute personAttr : source.getPersonAttrList()) {
GluuAttribute attribute = getAttribute(attributes, personAttr.getName());
if (attribute == null || attribute.getEditType() == null || !containsRole(attribute.getEditType(), role))
continue;
destination.setAttribute(personAttr.getName(), personAttr.getValue());
}
}
if (!isUpdate) {
destination.setUid(source.getUserId());
destination.setUserPassword(source.getPassword());
destination.setGivenName(source.getFirstName());
destination.setDisplayName(source.getDisplayName());
destination.setSurname(source.getLastName());
destination.setMail(source.getEmail());
destination.setCommonName(source.getFirstName() + " " + source.getDisplayName());
} else {
if (!isEmpty(source.getFirstName()))
destination.setGivenName(source.getFirstName());
if (!isEmpty(source.getDisplayName()))
destination.setDisplayName(source.getDisplayName());
if (!isEmpty(source.getLastName()))
destination.setSurname(source.getLastName());
if (!isEmpty(source.getEmail()))
destination.setMail(source.getEmail());
if (!isEmpty(source.getFirstName()) && !isEmpty(source.getDisplayName()))
destination.setCommonName(source.getFirstName() + " " + source.getDisplayName());
}
return destination;
}
use of org.gluu.oxtrust.model.PersonAttribute in project oxTrust by GluuFederation.
the class CopyUtils2 method copy.
/**
* Copy data from GluuCustomPerson object to Person object
*
* @param source
* @param destination
* @return
* @throws Exception
*/
public Person copy(GluuCustomPerson source, Person destination, List<GluuAttribute> attributes) {
if (source == null) {
return null;
}
if (destination == null) {
destination = new Person();
}
destination.setInum(source.getInum());
destination.setIname(source.getIname());
destination.setUserId(source.getUid());
destination.setFirstName(source.getGivenName());
destination.setDisplayName(source.getDisplayName());
destination.setLastName(source.getSurname());
destination.setEmail(source.getMail());
destination.setPassword(source.getUserPassword());
destination.setCommonName(source.getGivenName() + " " + source.getDisplayName());
List<PersonAttribute> personAttrList = new ArrayList<PersonAttribute>();
for (GluuAttribute attribute : attributes) {
PersonAttribute personAttr = new PersonAttribute(attribute.getName(), source.getAttribute(attribute.getName()), attribute.getDisplayName());
personAttrList.add(personAttr);
}
destination.setPersonAttrList(personAttrList);
return destination;
}
Aggregations