Search in sources :

Example 1 with WsAddMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceTest method makeWsAddMemberResultsTest.

@Test
public void makeWsAddMemberResultsTest() {
    WsAddMemberResults results;
    List<String> members = new ArrayList<>();
    members.add(users.get(0).getUsername());
    WsSubjectLookup lookup = gfsl.makeWsSubjectLookup(users.get(0).getUsername());
    results = gfsl.makeWsAddMemberResults(GROUPING_3_PATH, lookup, members);
    assertTrue(results.getResultMetadata().getResultCode().startsWith("SUCCESS"));
}
Also used : WsSubjectLookup(edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup) ArrayList(java.util.ArrayList) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with WsAddMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsAddMemberResults.

@Override
public WsAddMemberResults makeWsAddMemberResults(String group, WsSubjectLookup lookup, Person personToAdd) {
    Person newGroupMember;
    WsAddMemberResults wsAddMemberResults = new WsAddMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    wsAddMemberResults.setResultMetadata(wsResultMeta);
    Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
    if (personToAdd.getUsername() != null) {
        newGroupMember = personRepository.findByUsername(personToAdd.getUsername());
    } else {
        newGroupMember = personRepository.findByUuid(personToAdd.getUuid());
    }
    if (grouping == null) {
        Group groupToAddTo = groupRepository.findByPath(group);
        addMember(groupToAddTo, newGroupMember);
    } else {
        boolean inBasis = grouping.getBasis().isMember(newGroupMember);
        boolean inExclude = grouping.getExclude().isMember(newGroupMember);
        boolean inInclude = grouping.getInclude().isMember(newGroupMember);
        if (group.endsWith(OWNERS)) {
            addMember(grouping.getOwners(), newGroupMember);
        } else if (group.endsWith(EXCLUDE)) {
            if (inBasis) {
                addMember(grouping.getExclude(), newGroupMember);
            } else if (inInclude) {
                deleteMember(grouping.getInclude(), newGroupMember);
            }
        } else if (group.endsWith(INCLUDE)) {
            if (inExclude) {
                deleteMember(grouping.getExclude(), newGroupMember);
            } else if (!inBasis) {
                addMember(grouping.getInclude(), newGroupMember);
            }
        }
        grouping = groupingRepository.findByPath(grouping.getPath());
        Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
        groupRepository.save(composite);
    }
    return wsAddMemberResults;
}
Also used : WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) Group(edu.hawaii.its.api.type.Group) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) Grouping(edu.hawaii.its.api.type.Grouping) Person(edu.hawaii.its.api.type.Person) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)

Example 3 with WsAddMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImpl method makeWsAddMemberResults.

@Override
public WsAddMemberResults makeWsAddMemberResults(String group, WsSubjectLookup lookup, List<String> newMembers) {
    GcAddMember addMember = new GcAddMember();
    addMember.assignActAsSubject(lookup);
    addMember.assignGroupName(group);
    newMembers.forEach(addMember::addSubjectIdentifier);
    return addMember.execute();
}
Also used : GcAddMember(edu.internet2.middleware.grouperClient.api.GcAddMember)

Example 4 with WsAddMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GrouperFactoryServiceImplLocal method makeWsAddMemberResults.

@Override
public WsAddMemberResults makeWsAddMemberResults(String group, WsSubjectLookup lookup, List<String> newMembers) {
    WsAddMemberResults wsAddMemberResults = new WsAddMemberResults();
    WsResultMeta wsResultMeta = new WsResultMeta();
    wsResultMeta.setResultCode(SUCCESS);
    for (String username : newMembers) {
        WsResultMeta wsResultMetaData = makeWsAddMemberResults(group, lookup, username).getResultMetadata();
        if (wsResultMetaData.getResultCode().equals(FAILURE)) {
            wsResultMeta = wsResultMetaData;
        }
    }
    wsAddMemberResults.setResultMetadata(wsResultMeta);
    return wsAddMemberResults;
}
Also used : WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)

Example 5 with WsAddMemberResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class HelperServiceTest method makeGroupingsServiceResult.

@Test
public void makeGroupingsServiceResult() {
    String action = "add a member";
    String resultCode = "successfully added member";
    WsAddMemberResults gr = new WsAddMemberResults();
    WsResultMeta resultMeta = new WsResultMeta();
    resultMeta.setResultCode(resultCode);
    gr.setResultMetadata(resultMeta);
    GroupingsServiceResult gsr = helperService.makeGroupingsServiceResult(gr, action);
    assertEquals(action, gsr.getAction());
    assertEquals(resultCode, gsr.getResultCode());
}
Also used : GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) WsResultMeta(edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta) WsAddMemberResults(edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)7 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)3 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)3 WsSubjectLookup (edu.internet2.middleware.grouperClient.ws.beans.WsSubjectLookup)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Group (edu.hawaii.its.api.type.Group)1 Grouping (edu.hawaii.its.api.type.Grouping)1 Person (edu.hawaii.its.api.type.Person)1 GcAddMember (edu.internet2.middleware.grouperClient.api.GcAddMember)1 WsDeleteMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsDeleteMemberResults)1 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)1