Search in sources :

Example 11 with Group

use of org.apache.syncope.ext.scimv2.api.data.Group in project syncope by apache.

the class SCIMDataBinder method toGroupTO.

public GroupTO toGroupTO(final SCIMGroup group) {
    if (!GROUP_SCHEMAS.equals(group.getSchemas())) {
        throw new BadRequestException(ErrorType.invalidValue);
    }
    GroupTO groupTO = new GroupTO();
    groupTO.setRealm(SyncopeConstants.ROOT_REALM);
    groupTO.setKey(group.getId());
    groupTO.setName(group.getDisplayName());
    return groupTO;
}
Also used : BadRequestException(org.apache.syncope.ext.scimv2.api.BadRequestException) GroupTO(org.apache.syncope.common.lib.to.GroupTO)

Example 12 with Group

use of org.apache.syncope.ext.scimv2.api.data.Group in project syncope by apache.

the class SCIMDataBinder method toSCIMGroup.

public SCIMGroup toSCIMGroup(final GroupTO groupTO, final String location, final List<String> attributes, final List<String> excludedAttributes) {
    SCIMGroup group = new SCIMGroup(groupTO.getKey(), new Meta(Resource.Group, groupTO.getCreationDate(), groupTO.getLastChangeDate() == null ? groupTO.getCreationDate() : groupTO.getLastChangeDate(), groupTO.getETagValue(), location), output(attributes, excludedAttributes, "displayName", groupTO.getName()));
    MembershipCond membCond = new MembershipCond();
    membCond.setGroup(groupTO.getKey());
    SearchCond searchCond = SearchCond.getLeafCond(membCond);
    if (output(attributes, excludedAttributes, "members")) {
        int count = userLogic.search(searchCond, 1, 1, Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false).getLeft();
        for (int page = 1; page <= (count / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
            List<UserTO> users = userLogic.search(searchCond, page, AnyDAO.DEFAULT_PAGE_SIZE, Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false).getRight();
            users.forEach(userTO -> {
                group.getMembers().add(new Member(userTO.getKey(), StringUtils.substringBefore(location, "/Groups") + "/Users/" + userTO.getKey(), userTO.getUsername()));
            });
        }
    }
    return group;
}
Also used : Meta(org.apache.syncope.ext.scimv2.api.data.Meta) SCIMGroup(org.apache.syncope.ext.scimv2.api.data.SCIMGroup) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) UserTO(org.apache.syncope.common.lib.to.UserTO) MembershipCond(org.apache.syncope.core.persistence.api.dao.search.MembershipCond) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) Member(org.apache.syncope.ext.scimv2.api.data.Member)

Aggregations

SCIMGroup (org.apache.syncope.ext.scimv2.api.data.SCIMGroup)9 Member (org.apache.syncope.ext.scimv2.api.data.Member)7 Response (javax.ws.rs.core.Response)6 ListResponse (org.apache.syncope.ext.scimv2.api.data.ListResponse)6 GroupTO (org.apache.syncope.common.lib.to.GroupTO)5 BadRequestException (org.apache.syncope.ext.scimv2.api.BadRequestException)5 UserTO (org.apache.syncope.common.lib.to.UserTO)4 MembershipCond (org.apache.syncope.core.persistence.api.dao.search.MembershipCond)4 OrderByClause (org.apache.syncope.core.persistence.api.dao.search.OrderByClause)4 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)4 Meta (org.apache.syncope.ext.scimv2.api.data.Meta)4 SCIMUser (org.apache.syncope.ext.scimv2.api.data.SCIMUser)4 Test (org.junit.jupiter.api.Test)4 Arrays (java.util.Arrays)3 Collections (java.util.Collections)3 Set (java.util.Set)3 StringUtils (org.apache.commons.lang3.StringUtils)3 SyncopeConstants (org.apache.syncope.common.lib.SyncopeConstants)3 AnyDAO (org.apache.syncope.core.persistence.api.dao.AnyDAO)3 Group (org.apache.syncope.ext.scimv2.api.data.Group)3