use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceImpl method addGroupingMemberByUuid.
// find a user by a uuid and add them to a grouping
@Override
public List<GroupingsServiceResult> addGroupingMemberByUuid(String username, String groupingPath, String userToAddUuid) {
logger.info("addGroupingMemberByUuid; user: " + username + "; grouping: " + groupingPath + "; userToAdd: " + userToAddUuid + ";");
List<GroupingsServiceResult> gsrs = new ArrayList<>();
String action = "add user to " + groupingPath;
String basis = groupingPath + BASIS;
String exclude = groupingPath + EXCLUDE;
String include = groupingPath + INCLUDE;
Person personToAdd = new Person(null, userToAddUuid, null);
boolean inBasis = mas.isMember(basis, personToAdd);
boolean inComposite = mas.isMember(groupingPath, personToAdd);
boolean inInclude = mas.isMember(include, personToAdd);
// check to see if they are already in the grouping
if (!inComposite) {
// get them out of the exclude
gsrs.add(deleteGroupMemberByUuid(username, exclude, userToAddUuid));
// only add them to the include if they are not in the basis
if (!inBasis) {
gsrs.addAll(addGroupMemberByUuid(username, include, userToAddUuid));
} else {
gsrs.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + userToAddUuid + " was in " + basis, action));
}
} else {
gsrs.add(hs.makeGroupingsServiceResult(SUCCESS + ": " + userToAddUuid + " was already in " + groupingPath, action));
}
// should only be in one or the other
if (inBasis && inInclude) {
gsrs.add(deleteGroupMemberByUuid(username, include, userToAddUuid));
}
return gsrs;
}
use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceImpl method deleteGroupMemberByUuid.
@Override
public GroupingsServiceResult deleteGroupMemberByUuid(String ownerUsername, String groupPath, String userToDeleteUuid) {
logger.info("deleteGroupMemberByUuid; user: " + ownerUsername + "; group: " + groupPath + "; userToDelete: " + userToDeleteUuid + ";");
String action = "delete " + userToDeleteUuid + " from " + groupPath;
Person personToDelete = new Person(null, userToDeleteUuid, null);
String composite = hs.parentGroupingPath(groupPath);
if (mas.isOwner(composite, ownerUsername) || mas.isSuperuser(ownerUsername)) {
WsSubjectLookup user = grouperFS.makeWsSubjectLookup(ownerUsername);
if (groupPath.endsWith(EXCLUDE) || groupPath.endsWith(INCLUDE) || groupPath.endsWith(OWNERS)) {
if (mas.isMember(groupPath, personToDelete)) {
WsDeleteMemberResults deleteMemberResults = grouperFS.makeWsDeleteMemberResults(groupPath, user, personToDelete);
updateLastModified(composite);
updateLastModified(groupPath);
return hs.makeGroupingsServiceResult(deleteMemberResults, action);
}
return hs.makeGroupingsServiceResult(SUCCESS + ": " + ownerUsername + " was not in " + groupPath, action);
}
return hs.makeGroupingsServiceResult(FAILURE + ": " + ownerUsername + " may only delete from exclude, include or owner group", action);
}
return hs.makeGroupingsServiceResult(FAILURE + ": " + ownerUsername + " does not have permission to edit " + groupPath, action);
}
Aggregations