use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceImpl method deleteGroupingMemberByUuid.
// todo
// finds a user by a uuid and remove them from a grouping
@Override
public List<GroupingsServiceResult> deleteGroupingMemberByUuid(String ownerUsername, String groupingPath, String userToDeleteUuid) {
logger.info("deleteGroupingMemberByUuid; ownerUsername: " + ownerUsername + "; groupingPath: " + groupingPath + "; userToDelete: " + userToDeleteUuid + ";");
List<GroupingsServiceResult> gsrList = new ArrayList<>();
String action = ownerUsername + " deletes " + userToDeleteUuid + " from " + groupingPath;
String basis = groupingPath + BASIS;
String exclude = groupingPath + EXCLUDE;
String include = groupingPath + INCLUDE;
Person personToDelete = new Person(null, userToDeleteUuid, null);
boolean inBasis = mas.isMember(basis, personToDelete);
boolean inComposite = mas.isMember(groupingPath, personToDelete);
boolean inExclude = mas.isMember(exclude, personToDelete);
// if they are in the include group, get them out
gsrList.add(deleteGroupMemberByUuid(ownerUsername, include, userToDeleteUuid));
// make sure userToDelete is actually in the Grouping
if (inComposite) {
// if they are not in the include group, then they are in the basis, so add them to the exclude group
if (inBasis) {
gsrList.addAll(addGroupMemberByUuid(ownerUsername, exclude, userToDeleteUuid));
}
} else // since they are not in the Grouping, do nothing, but return SUCCESS
{
gsrList.add(hs.makeGroupingsServiceResult(SUCCESS + userToDeleteUuid + " was not in " + groupingPath, action));
}
// should not be in exclude if not in basis
if (!inBasis && inExclude) {
gsrList.add(deleteGroupMemberByUuid(ownerUsername, exclude, userToDeleteUuid));
}
return gsrList;
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupAttributeServiceImpl method changeGroupAttributeStatus.
// turns the attribute on or off in a group
public GroupingsServiceResult changeGroupAttributeStatus(String groupPath, String ownerUsername, String attributeName, boolean attributeOn) {
GroupingsServiceResult gsr;
String verb = "removed from ";
if (attributeOn) {
verb = "added to ";
}
String action = attributeName + " has been " + verb + groupPath + " by " + ownerUsername;
if (mas.isOwner(groupPath, ownerUsername) || mas.isAdmin(ownerUsername)) {
boolean hasAttribute = groupHasAttribute(groupPath, attributeName);
if (attributeOn) {
if (!hasAttribute) {
assignGroupAttributes(attributeName, OPERATION_ASSIGN_ATTRIBUTE, groupPath);
gsr = hs.makeGroupingsServiceResult(SUCCESS, action);
} else {
gsr = hs.makeGroupingsServiceResult(SUCCESS + ", " + attributeName + " already existed", action);
}
} else {
if (hasAttribute) {
assignGroupAttributes(attributeName, OPERATION_REMOVE_ATTRIBUTE, groupPath);
gsr = hs.makeGroupingsServiceResult(SUCCESS, action);
} else {
gsr = hs.makeGroupingsServiceResult(SUCCESS + ", " + attributeName + " did not exist", action);
}
}
} else {
gsr = hs.makeGroupingsServiceResult(FAILURE + ", " + ownerUsername + "does not have permission to set " + attributeName + " because " + ownerUsername + " does not own " + groupPath, action);
}
return gsr;
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupAttributeServiceImpl method changeOptOutStatus.
// turn the ability for users to opt-out of a grouping on or off
@Override
public List<GroupingsServiceResult> changeOptOutStatus(String groupingPath, String ownerUsername, boolean optOutOn) {
List<GroupingsServiceResult> results = new ArrayList<>();
if (mas.isOwner(groupingPath, ownerUsername) || mas.isAdmin(ownerUsername)) {
results.add(assignGrouperPrivilege(EVERY_ENTITY, PRIVILEGE_OPT_IN, groupingPath + EXCLUDE, optOutOn));
results.add(assignGrouperPrivilege(EVERY_ENTITY, PRIVILEGE_OPT_OUT, groupingPath + INCLUDE, optOutOn));
results.add(changeGroupAttributeStatus(groupingPath, ownerUsername, OPT_OUT, optOutOn));
} else {
GroupingsServiceResult failure = hs.makeGroupingsServiceResult(FAILURE + ", " + ownerUsername + " does not own " + groupingPath, "change opt out status for " + groupingPath + " to " + optOutOn);
results.add(failure);
}
return results;
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupAttributeServiceImpl method changeOptInStatus.
// turn the ability for users to opt-in to a grouping on or off
@Override
public List<GroupingsServiceResult> changeOptInStatus(String groupingPath, String ownerUsername, boolean optInOn) {
List<GroupingsServiceResult> results = new ArrayList<>();
if (mas.isOwner(groupingPath, ownerUsername) || mas.isAdmin(ownerUsername)) {
results.add(assignGrouperPrivilege(EVERY_ENTITY, PRIVILEGE_OPT_IN, groupingPath + INCLUDE, optInOn));
results.add(assignGrouperPrivilege(EVERY_ENTITY, PRIVILEGE_OPT_OUT, groupingPath + EXCLUDE, optInOn));
results.add(changeGroupAttributeStatus(groupingPath, ownerUsername, OPT_IN, optInOn));
} else {
GroupingsServiceResult failure = hs.makeGroupingsServiceResult(FAILURE + ", " + ownerUsername + " does not own " + groupingPath, "change opt in status for " + groupingPath + " to " + optInOn);
results.add(failure);
}
return results;
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method deleteAdminTest.
@Test
@WithMockUhUser(username = "admin")
public void deleteAdminTest() throws Exception {
given(membershipService.deleteAdmin("admin", "newAdmin")).willReturn(new GroupingsServiceResult("SUCCESS", "delete admin"));
mockMvc.perform(post("/api/groupings/newAdmin/deleteAdmin").with(csrf())).andExpect(status().isOk()).andExpect(jsonPath("resultCode").value("SUCCESS")).andExpect(jsonPath("action").value("delete admin"));
}
Aggregations