Search in sources :

Example 1 with Group

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);
        }
    }
}
Also used : Group(org.orcid.jaxb.model.record_v2.Group) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) ArrayList(java.util.ArrayList)

Example 2 with Group

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;
}
Also used : Group(org.openstack4j.model.identity.v3.Group) GroupBuilder(org.openstack4j.model.identity.v3.builder.GroupBuilder) Map(java.util.Map)

Example 3 with 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);
}
Also used : Group(org.openstack4j.model.identity.v3.Group) Message(org.apache.camel.Message)

Example 4 with Group

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;
}
Also used : ArrayList(java.util.ArrayList) MemberRef(org.gluu.oxtrust.model.scim2.MemberRef) GluuGroup(org.gluu.oxtrust.model.GluuGroup)

Example 5 with Group

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;
}
Also used : Email(org.gluu.oxtrust.model.scim2.Email) Address(org.gluu.oxtrust.model.scim2.Address) Im(org.gluu.oxtrust.model.scim2.Im) Photo(org.gluu.oxtrust.model.scim2.Photo) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) X509Certificate(org.gluu.oxtrust.model.scim2.X509Certificate) Role(org.gluu.oxtrust.model.scim2.Role) Extension(org.gluu.oxtrust.model.scim2.Extension) PhoneNumber(org.gluu.oxtrust.model.scim2.PhoneNumber) GroupRef(org.gluu.oxtrust.model.scim2.GroupRef) Entitlement(org.gluu.oxtrust.model.scim2.Entitlement)

Aggregations

ArrayList (java.util.ArrayList)18 GluuGroup (org.gluu.oxtrust.model.GluuGroup)14 DefaultValue (javax.ws.rs.DefaultValue)13 HeaderParam (javax.ws.rs.HeaderParam)13 Produces (javax.ws.rs.Produces)13 Response (javax.ws.rs.core.Response)13 URI (java.net.URI)12 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)12 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)11 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)10 Path (javax.ws.rs.Path)8 Group (org.gluu.oxtrust.model.scim2.Group)8 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)8 Group (org.openstack4j.model.identity.v3.Group)8 Group (ucar.nc2.Group)8 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)7 Consumes (javax.ws.rs.Consumes)7 ListViewResponse (org.gluu.persist.model.ListViewResponse)7 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)6 SCIMException (org.gluu.oxtrust.model.exception.SCIMException)6