use of org.gluu.oxtrust.model.scim2.Group in project ORCID-Source by ORCID.
the class Api2_0_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(GroupsContainer groupsContainerV2) {
if (groupsContainerV2.retrieveGroups() != null && !groupsContainerV2.retrieveGroups().isEmpty()) {
List<? extends Group> groupsRc1 = new ArrayList<>(groupsContainerV2.retrieveGroups());
List<org.orcid.jaxb.model.record_v2.Group> groupsV2 = new ArrayList<>(groupsContainerV2.retrieveGroups());
if (groupsRc1.get(0).getActivities() != null && !groupsRc1.get(0).getActivities().isEmpty()) {
LastModifiedDate latest = null;
for (Group group : groupsV2) {
calculateLastModified(group);
if (group.getLastModifiedDate() != null && group.getLastModifiedDate().after(latest)) {
latest = group.getLastModifiedDate();
}
}
groupsContainerV2.setLastModifiedDate(latest);
}
}
}
use of org.gluu.oxtrust.model.scim2.Group in project camel by apache.
the class GroupProducer method messageToGroup.
private Group messageToGroup(Message message) {
Group group = message.getBody(Group.class);
if (group == null) {
Map headers = message.getHeaders();
GroupBuilder builder = Builders.group();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DOMAIN_ID)) {
builder.domainId(message.getHeader(KeystoneConstants.DOMAIN_ID, String.class));
}
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
group = builder.build();
}
return group;
}
use of org.gluu.oxtrust.model.scim2.Group in project camel by apache.
the class GroupProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Group group = messageToGroup(msg);
final Group updatedGroup = osV3Client.identity().groups().update(group);
msg.setBody(updatedGroup);
}
use of org.gluu.oxtrust.model.scim2.Group in project oxTrust by GluuFederation.
the class CopyUtils2 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(Group 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) {
Set<MemberRef> members = source.getMembers();
List<String> listMembers = new ArrayList<String>();
for (MemberRef 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) {
Set<MemberRef> members = source.getMembers();
List<String> listMembers = new ArrayList<String>();
for (MemberRef member : members) {
listMembers.add(personService.getDnForPerson(member.getValue()));
}
destination.setMembers(listMembers);
}
/*GluuCustomPerson authUser = (GluuCustomPerson) identity.getSessionMap().get(OxTrustConstants.CURRENT_PERSON);
destination.setOwner(authUser.getDn());
log.trace(" authUser.getDn() : ", authUser.getDn());*/
destination.setStatus(GluuStatus.ACTIVE);
destination.setOrganization(organizationService.getDnForOrganization());
}
return destination;
}
use of org.gluu.oxtrust.model.scim2.Group in project oxTrust by GluuFederation.
the class PatchUtil method addPatch.
public GluuCustomPerson addPatch(User source, GluuCustomPerson destination) throws Exception {
if (source == null) {
return null;
}
if (destination == null) {
log.trace(" creating a new GluuCustomPerson instant ");
destination = new GluuCustomPerson();
}
log.trace(" setting schemas ");
destination.setSchemas(source.getSchemas());
personService.addCustomObjectClass(destination);
// getting emails
log.trace(" setting emails ");
if (source.getEmails() != null && source.getEmails().size() > 0) {
List<Email> emails = copyUtils2.getAttributeListValue(destination, Email.class, "oxTrustEmail");
if (emails == null) {
emails = new ArrayList<Email>();
}
emails.addAll(source.getEmails());
copyUtils2.setAttributeListValue(destination, emails, "oxTrustEmail");
}
// getting addresses
log.trace(" setting addresses ");
if (source.getAddresses() != null && source.getAddresses().size() > 0) {
List<Address> addresses = copyUtils2.getAttributeListValue(destination, Address.class, "oxTrustAddresses");
if (addresses == null) {
addresses = new ArrayList<Address>();
}
addresses.addAll(source.getAddresses());
copyUtils2.setAttributeListValue(destination, addresses, "oxTrustAddresses");
}
// getting phone numbers;
log.trace(" setting phoneNumbers ");
if (source.getPhoneNumbers() != null && source.getPhoneNumbers().size() > 0) {
List<PhoneNumber> phoneNumbers = copyUtils2.getAttributeListValue(destination, PhoneNumber.class, "oxTrustPhoneValue");
if (phoneNumbers == null) {
phoneNumbers = new ArrayList<PhoneNumber>();
}
phoneNumbers.addAll(source.getPhoneNumbers());
copyUtils2.setAttributeListValue(destination, phoneNumbers, "oxTrustPhoneValue");
}
// getting ims
log.trace(" setting ims ");
if (source.getIms() != null && source.getIms().size() > 0) {
List<Im> ims = copyUtils2.getAttributeListValue(destination, Im.class, "oxTrustImsValue");
if (ims == null) {
ims = new ArrayList<Im>();
}
ims.addAll(source.getIms());
copyUtils2.setAttributeListValue(destination, ims, "oxTrustImsValue");
}
// getting Photos
log.trace(" setting photos ");
if (source.getPhotos() != null && source.getPhotos().size() > 0) {
List<Photo> photos = copyUtils2.getAttributeListValue(destination, Photo.class, "oxTrustPhotos");
if (photos == null) {
photos = new ArrayList<Photo>();
}
photos.addAll(source.getPhotos());
copyUtils2.setAttributeListValue(destination, photos, "oxTrustPhotos");
}
// getting user groups
log.trace(" setting groups ");
if (source.getGroups() != null && source.getGroups().size() > 0) {
List<String> groupsList = destination.getMemberOf();
List<GroupRef> listGroups = source.getGroups();
for (GroupRef group : listGroups) {
String groupToAdd = groupService.getDnForGroup(group.getValue());
if (groupToAdd != null || !groupToAdd.trim().equalsIgnoreCase("")) {
groupsList.add(groupToAdd);
}
}
destination.setMemberOf(groupsList);
}
// getting roles
log.trace(" setting roles ");
if (source.getRoles() != null && source.getRoles().size() > 0) {
List<Role> roles = copyUtils2.getAttributeListValue(destination, Role.class, "oxTrustRole");
if (roles == null) {
roles = new ArrayList<Role>();
}
roles.addAll(source.getRoles());
copyUtils2.setAttributeListValue(destination, roles, "oxTrustRole");
}
// getting entitlements
log.trace(" setting entitlements ");
if (source.getEntitlements() != null && source.getEntitlements().size() > 0) {
List<Entitlement> entitlements = copyUtils2.getAttributeListValue(destination, Entitlement.class, "oxTrustEntitlements");
if (entitlements == null) {
entitlements = new ArrayList<Entitlement>();
}
entitlements.addAll(source.getEntitlements());
copyUtils2.setAttributeListValue(destination, entitlements, "oxTrustEntitlements");
}
// getting x509Certificates
log.trace(" setting certs ");
if (source.getX509Certificates() != null && source.getX509Certificates().size() > 0) {
List<X509Certificate> X509Certificates = copyUtils2.getAttributeListValue(destination, X509Certificate.class, "oxTrustx509Certificate");
if (X509Certificates == null) {
X509Certificates = new ArrayList<X509Certificate>();
}
X509Certificates.addAll(source.getX509Certificates());
copyUtils2.setAttributeListValue(destination, X509Certificates, "oxTrustx509Certificate");
}
log.trace(" setting extensions ");
if (source.getExtensions() != null && (source.getExtensions().size() > 0)) {
Map<String, Extension> destMap = destination.fetchExtensions();
if (destMap == null) {
destMap = new HashMap<String, Extension>();
}
destMap.putAll(source.getExtensions());
destination.setExtensions(destMap);
}
if (source.isActive() != null) {
copyUtils2.setGluuStatus(source, destination);
}
return destination;
}
Aggregations