Search in sources :

Example 41 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsGetAttributeAssignmentsResultsForGroup.

@Override
public WsGetAttributeAssignmentsResults makeWsGetAttributeAssignmentsResultsForGroup(String assignType, String group) {
    WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults = new WsGetAttributeAssignmentsResults();
    Grouping grouping = groupingRepository.findByPath(group);
    if (grouping.isListservOn()) {
        wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, LISTSERV);
    }
    if (grouping.isOptInOn()) {
        wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, OPT_IN);
    }
    if (grouping.isOptOutOn()) {
        wsGetAttributeAssignmentsResults = addAssignmentResults(wsGetAttributeAssignmentsResults, OPT_OUT);
    }
    return wsGetAttributeAssignmentsResults;
}
Also used : WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) Grouping(edu.hawaii.its.api.type.Grouping)

Example 42 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method removeGroupsWithoutOptOut.

private WsGetAttributeAssignmentsResults removeGroupsWithoutOptOut(WsGetAttributeAssignmentsResults wsGetAttributeAssignmentsResults) {
    List<WsGroup> wsGroupList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsGroups());
    List<WsAttributeAssign> wsAttributeAssignList = Arrays.asList(wsGetAttributeAssignmentsResults.getWsAttributeAssigns());
    List<WsGroup> newWsGroupList = new ArrayList<>();
    List<WsAttributeAssign> newWsAttributeAssignList = new ArrayList<>();
    for (WsGroup wsGroup : wsGroupList) {
        Grouping grouping = groupingRepository.findByPath(wsGroup.getName());
        if (grouping.isOptOutOn()) {
            newWsGroupList.add(wsGroup);
        }
    }
    for (WsAttributeAssign wsAttributeAssign : wsAttributeAssignList) {
        Grouping grouping = groupingRepository.findByPath(wsAttributeAssign.getOwnerGroupName());
        if (grouping.isOptOutOn()) {
            newWsAttributeAssignList.add(wsAttributeAssign);
        }
    }
    wsGetAttributeAssignmentsResults.setWsAttributeAssigns(newWsAttributeAssignList.toArray(new WsAttributeAssign[newWsAttributeAssignList.size()]));
    wsGetAttributeAssignmentsResults.setWsGroups(newWsGroupList.toArray(new WsGroup[newWsGroupList.size()]));
    return wsGetAttributeAssignmentsResults;
}
Also used : ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) Grouping(edu.hawaii.its.api.type.Grouping)

Example 43 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsAssignAttributesResults.

@Override
public WsAssignAttributesResults makeWsAssignAttributesResults(String attributeAssignType, String attributeAssignOperation, String ownerGroupName, String attributeDefNameName, String attributeAssignValueOperation, WsAttributeAssignValue value) {
    WsAssignAttributesResults wsAssignAttributesResults = new WsAssignAttributesResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsAssignAttributesResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByPath(ownerGroupName);
    Boolean onOrrOff = null;
    if (attributeAssignOperation.equals(OPERATION_ASSIGN_ATTRIBUTE)) {
        onOrrOff = true;
    } else if (attributeAssignOperation.equals(OPERATION_REMOVE_ATTRIBUTE)) {
        onOrrOff = false;
    }
    if (onOrrOff != null) {
        if (attributeDefNameName.equals(LISTSERV)) {
            grouping.setListservOn(onOrrOff);
        } else if (attributeDefNameName.equals(OPT_IN)) {
            grouping.setOptInOn(onOrrOff);
        } else if (attributeDefNameName.equals(OPT_OUT)) {
            grouping.setOptOutOn(onOrrOff);
        }
    }
    return wsAssignAttributesResults;
}
Also used : WsAssignAttributesResults(edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping)

Example 44 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method groupingsToOptInto.

// returns the list of groupings that the user is allowed to opt-in to
public List<Grouping> groupingsToOptInto(String optInUsername, List<String> groupPaths) {
    logger.info("groupingsToOptInto; username: " + optInUsername + "; groupPaths : " + groupPaths + ";");
    List<String> trios = new ArrayList<>();
    List<String> opts = new ArrayList<>();
    List<String> excludes = groupPaths.stream().map(group -> group + EXCLUDE).collect(Collectors.toList());
    WsGetAttributeAssignmentsResults assignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO, OPT_IN);
    if (assignmentsResults.getWsAttributeAssigns() != null) {
        for (WsAttributeAssign assign : assignmentsResults.getWsAttributeAssigns()) {
            if (assign.getAttributeDefNameName() != null) {
                if (assign.getAttributeDefNameName().equals(TRIO)) {
                    trios.add(assign.getOwnerGroupName());
                } else if (assign.getAttributeDefNameName().equals(OPT_IN)) {
                    opts.add(assign.getOwnerGroupName());
                }
            }
        }
        // opts intersection trios
        opts.retainAll(trios);
        // excludes intersection opts
        excludes.retainAll(opts);
        // opts - (opts intersection groupPaths)
        opts.removeAll(groupPaths);
        // opts union excludes
        opts.addAll(excludes);
    }
    // get rid of duplicates
    List<String> groups = new ArrayList<>(new HashSet<>(opts));
    return helperService.makeGroupings(groups);
}
Also used : WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) Arrays(java.util.Arrays) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) WsAttributeDefName(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeDefName) Autowired(org.springframework.beans.factory.annotation.Autowired) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) WsSubject(edu.internet2.middleware.grouperClient.ws.beans.WsSubject) Service(org.springframework.stereotype.Service) Map(java.util.Map) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsStemLookup(edu.internet2.middleware.grouperClient.ws.beans.WsStemLookup) WsGetMembersResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetMembersResults) Grouping(edu.hawaii.its.api.type.Grouping) AdminListsHolder(edu.hawaii.its.api.type.AdminListsHolder) Person(edu.hawaii.its.api.type.Person) Collectors(java.util.stream.Collectors) List(java.util.List) WsGetGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResults) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) StemScope(edu.internet2.middleware.grouperClient.ws.StemScope) ArrayList(java.util.ArrayList) WsGetAttributeAssignmentsResults(edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults) WsAttributeAssign(edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)

Example 45 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingAssignmentServiceImpl method getGrouping.

// fetch a grouping from Grouper or the database
@Override
public Grouping getGrouping(String groupingPath, String ownerUsername) {
    logger.info("getGrouping; grouping: " + groupingPath + "; username: " + ownerUsername + ";");
    Grouping compositeGrouping = new Grouping();
    if (memberAttributeService.isOwner(groupingPath, ownerUsername) || memberAttributeService.isAdmin(ownerUsername)) {
        compositeGrouping = new Grouping(groupingPath);
        Group include = getMembers(ownerUsername, groupingPath + INCLUDE);
        Group exclude = getMembers(ownerUsername, groupingPath + EXCLUDE);
        Group basis = getMembers(ownerUsername, groupingPath + BASIS);
        Group composite = getMembers(ownerUsername, groupingPath);
        Group owners = getMembers(ownerUsername, groupingPath + OWNERS);
        compositeGrouping = setGroupingAttributes(compositeGrouping);
        compositeGrouping.setBasis(basis);
        compositeGrouping.setExclude(exclude);
        compositeGrouping.setInclude(include);
        compositeGrouping.setComposite(composite);
        compositeGrouping.setOwners(owners);
    }
    return compositeGrouping;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) Grouping(edu.hawaii.its.api.type.Grouping)

Aggregations

Grouping (edu.hawaii.its.api.type.Grouping)45 Test (org.junit.Test)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 ArrayList (java.util.ArrayList)14 Group (edu.hawaii.its.api.type.Group)13 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)11 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)11 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)9 Person (edu.hawaii.its.api.type.Person)8 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)6 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)6 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)5 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)5 WsAssignAttributesResults (edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults)3 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Membership (edu.hawaii.its.api.type.Membership)1 StemScope (edu.internet2.middleware.grouperClient.ws.StemScope)1 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)1