use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method deleteAdminTest.
@Test
public void deleteAdminTest() {
GroupingsServiceResult gsr;
// usernameToDelete is not a superuser
String usernameToDelete = users.get(9).getUsername();
try {
// user is not super user
gsr = membershipService.deleteAdmin(usernameToDelete, ADMIN_USER);
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
assertTrue(gsr.getResultCode().startsWith(FAILURE));
// user is super user usernameToDelete is not superuser
gsr = membershipService.deleteAdmin(ADMIN_USER, usernameToDelete);
assertEquals(SUCCESS, gsr.getResultCode());
// make usernameToDelete a superuser
membershipService.addAdmin(ADMIN_USER, usernameToDelete);
assertTrue(memberAttributeService.isAdmin(usernameToDelete));
// user is super user usernameToDelete is not superuser
gsr = membershipService.deleteAdmin(ADMIN_USER, usernameToDelete);
assertEquals(SUCCESS, gsr.getResultCode());
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupAttributeService method changeListServeStatusTest.
@Test
public void changeListServeStatusTest() {
GroupingsServiceResult groupingsServiceResult;
assertTrue(memberAttributeService.isOwner(GROUPING, username[0]));
assertTrue(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], true);
assertTrue(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], false);
assertFalse(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], false);
assertFalse(groupAttributeService.hasListserv(GROUPING));
assertFalse(memberAttributeService.isOwner(GROUPING, username[1]));
try {
groupingsServiceResult = groupAttributeService.changeListservStatus(GROUPING, username[1], true);
} catch (GroupingsServiceResultException gsre) {
groupingsServiceResult = gsre.getGsr();
}
assertTrue(groupingsServiceResult.getResultCode().startsWith(FAILURE));
assertFalse(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], true);
assertTrue(groupAttributeService.hasListserv(GROUPING));
try {
groupingsServiceResult = groupAttributeService.changeListservStatus(GROUPING, username[1], false);
} catch (GroupingsServiceResultException gsre) {
groupingsServiceResult = gsre.getGsr();
}
assertTrue(groupingsServiceResult.getResultCode().startsWith(FAILURE));
assertTrue(groupAttributeService.hasListserv(GROUPING));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestMembershipService method addRemoveSelfOptedTest.
@Test
public void addRemoveSelfOptedTest() {
// username[2] is not in the include, but not self opted
assertTrue(memberAttributeService.isMember(GROUPING_INCLUDE, username[2]));
assertFalse(memberAttributeService.isSelfOpted(GROUPING_INCLUDE, username[2]));
// add the self opted attribute for username[2]'s membership for the include group
membershipService.addSelfOpted(GROUPING_INCLUDE, username[2]);
// username[2] should now be self opted
assertTrue(memberAttributeService.isSelfOpted(GROUPING_INCLUDE, username[2]));
// remove the self opted attribute for username[2]'s membership from the include group
membershipService.removeSelfOpted(GROUPING_INCLUDE, username[2]);
// username[2] should no longer be self opted into the include
assertFalse(memberAttributeService.isSelfOpted(GROUPING_INCLUDE, username[2]));
// try to add self opted attribute when not in the group
GroupingsServiceResult groupingsServiceResult;
try {
groupingsServiceResult = membershipService.addSelfOpted(GROUPING_EXCLUDE, username[2]);
} catch (GroupingsServiceResultException gsre) {
groupingsServiceResult = gsre.getGsr();
}
assertTrue(groupingsServiceResult.getResultCode().startsWith(FAILURE));
assertFalse(memberAttributeService.isSelfOpted(GROUPING_EXCLUDE, username[2]));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingFactoryServiceImpl method addGrouping.
@Override
public // todo change basis to a String
List<GroupingsServiceResult> addGrouping(String adminUsername, String groupingPath, List<String> basis, List<String> include, List<String> exclude, List<String> owners) {
List<GroupingsServiceResult> addGroupingResults = new ArrayList<>();
String action = adminUsername + " is adding a Grouping: " + groupingPath;
// make sure that adminUsername is actually an admin
if (!memberAttributeService.isAdmin(adminUsername)) {
GroupingsServiceResult gsr = helperService.makeGroupingsServiceResult(FAILURE + ": " + adminUsername + " does not have permission to add this grouping", action);
addGroupingResults.add(gsr);
return addGroupingResults;
}
// make sure that there is not already a group there
if (!pathIsEmpty(adminUsername, groupingPath)) {
GroupingsServiceResult gsr = helperService.makeGroupingsServiceResult(FAILURE + ": a group already exists at " + groupingPath, action);
addGroupingResults.add(gsr);
return addGroupingResults;
}
Map<String, List<String>> memberLists = new HashMap<>();
memberLists.put("", new ArrayList<>());
memberLists.put(BASIS_PLUS_INCLUDE, new ArrayList<>());
memberLists.put(BASIS, new ArrayList<>());
memberLists.put(INCLUDE, include);
memberLists.put(EXCLUDE, exclude);
memberLists.put(OWNERS, owners);
// a stem the same as a folder
// create main stem
grouperFactoryService.makeWsStemSaveResults(adminUsername, groupingPath);
// create basis stem
grouperFactoryService.makeWsStemSaveResults(adminUsername, groupingPath + BASIS);
for (Map.Entry<String, List<String>> entry : memberLists.entrySet()) {
String groupPath = groupingPath + entry.getKey();
// make the groups in grouper
addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.addEmptyGroup(adminUsername, groupPath), action));
// add members to the groups
addGroupingResults.addAll(membershipService.addGroupMembersByUsername(adminUsername, groupPath, entry.getValue()));
if (groupingPath.equals(groupPath)) {
// todo create is-trio attribute
}
// todo this needs to be created not updated
// update the last modified values of those groups
addGroupingResults.add(membershipService.updateLastModified(groupPath));
}
WsSubjectLookup lookup = grouperFactoryService.makeWsSubjectLookup(adminUsername);
WsStemLookup stemLookup = grouperFactoryService.makeWsStemLookup(STEM);
String basisUid = getGroupId(groupingPath + BASIS);
String includeUid = getGroupId(groupingPath + INCLUDE);
String excludeUid = getGroupId(groupingPath + EXCLUDE);
String basisPlusIncludeUid = getGroupId(groupingPath + BASIS_PLUS_INCLUDE);
// add memberships for BASIS_PLUS_INCLUDE (basis group and include group)
addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.makeWsAddMemberResultsGroup(groupingPath + BASIS_PLUS_INCLUDE, lookup, basisUid), "add " + groupingPath + BASIS + " to " + groupingPath + BASIS_PLUS_INCLUDE));
addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.makeWsAddMemberResultsGroup(groupingPath + BASIS_PLUS_INCLUDE, lookup, includeUid), "add " + groupingPath + INCLUDE + " to " + groupingPath + BASIS_PLUS_INCLUDE));
// add members for the composite (basisPlusInclude group complement exclude group)
addGroupingResults.add(helperService.makeGroupingsServiceResult(grouperFactoryService.makeWsAddMemberResultsGroup(groupingPath, lookup, basisPlusIncludeUid), "add " + groupingPath + BASIS_PLUS_INCLUDE + " to " + groupingPath));
// todo do a complement
// add the isTrio attribute to the grouping
grouperFactoryService.makeWsAssignAttributesResultsForGroup(lookup, ASSIGN_TYPE_GROUP, OPERATION_ASSIGN_ATTRIBUTE, TRIO, groupingPath);
return addGroupingResults;
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class HelperServiceImpl method makeGroupingsServiceResult.
// makes a groupingsServiceResult with the result code from the metadataHolder and the action string
@Override
public GroupingsServiceResult makeGroupingsServiceResult(ResultMetadataHolder resultMetadataHolder, String action) {
GroupingsServiceResult groupingsServiceResult = new GroupingsServiceResult();
groupingsServiceResult.setAction(action);
groupingsServiceResult.setResultCode(resultMetadataHolder.getResultMetadata().getResultCode());
if (groupingsServiceResult.getResultCode().startsWith(FAILURE)) {
throw new GroupingsServiceResultException(groupingsServiceResult);
}
return groupingsServiceResult;
}
Aggregations