use of edu.hawaii.its.api.type.Person 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.Person in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceImpl method addGroupMemberByUsername.
// finds a user by a username and adds that user to the group
@Override
public List<GroupingsServiceResult> addGroupMemberByUsername(String ownerUsername, String groupPath, String userToAddUsername) {
logger.info("addGroupMemberByUsername; user: " + ownerUsername + "; groupPath: " + groupPath + "; userToAdd: " + userToAddUsername + ";");
Person personToAdd = new Person(null, null, userToAddUsername);
return addMemberHelper(ownerUsername, groupPath, personToAdd);
}
use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method addIncludedMembers.
private Group addIncludedMembers(Group include, Group basis) {
Group unionGroup = new Group();
List<Person> unionList = new ArrayList<>();
unionList.addAll(include.getMembers());
unionList.addAll(basis.getMembers());
// remove duplicates
Set<Person> s = new TreeSet<>();
s.addAll(unionList);
unionGroup.setMembers(Arrays.asList(s.toArray(new Person[s.size()])));
return unionGroup;
}
use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method removeExcludedMembers.
private Group removeExcludedMembers(Group basisPlusInclude, Group exclude) {
Group basisPlusIncludeMinusExcludeGroup = new Group();
ArrayList<Person> newBasisPlusInclude = new ArrayList<>();
newBasisPlusInclude.addAll(basisPlusInclude.getMembers());
newBasisPlusInclude.removeAll(exclude.getMembers());
basisPlusIncludeMinusExcludeGroup.setMembers(newBasisPlusInclude);
return basisPlusIncludeMinusExcludeGroup;
}
use of edu.hawaii.its.api.type.Person in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsHasMemberResults.
@Override
public WsHasMemberResults makeWsHasMemberResults(String group, Person person) {
WsHasMemberResults wsHasMemberResults = new WsHasMemberResults();
WsHasMemberResult wsHasMemberResult = new WsHasMemberResult();
WsResultMeta wsResultMeta = new WsResultMeta();
wsHasMemberResult.setResultMetadata(wsResultMeta);
wsHasMemberResults.setResults(new WsHasMemberResult[] { wsHasMemberResult });
wsResultMeta.setResultCode("not member");
Group groupToCheck = groupRepository.findByPath(group);
// first try username
if (person.getUsername() != null) {
person = personRepository.findByUsername(person.getUsername());
if (groupToCheck.isMember(person)) {
wsResultMeta.setResultCode(IS_MEMBER);
}
// if username is null, try uuid
} else if (person.getUuid() != null) {
Person person0 = personRepository.findByUuid(person.getUuid());
if (groupToCheck.isMember(person0)) {
wsResultMeta.setResultCode(IS_MEMBER);
}
}
return wsHasMemberResults;
}
Aggregations