use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsDeleteMemberResults.
@Override
public WsDeleteMemberResults makeWsDeleteMemberResults(String group, WsSubjectLookup lookup, Person personToDelete) {
WsDeleteMemberResults wsDeleteMemberResults = new WsDeleteMemberResults();
WsResultMeta wsResultMeta = new WsResultMeta();
wsResultMeta.setResultCode(SUCCESS);
wsDeleteMemberResults.setResultMetadata(wsResultMeta);
Grouping grouping = groupingRepository.findByIncludePathOrExcludePathOrCompositePathOrOwnersPath(group, group, group, group);
if (personToDelete.getUsername() != null) {
personToDelete = personRepository.findByUsername(personToDelete.getUsername());
} else if (personToDelete.getUuid() != null) {
personToDelete = personRepository.findByUuid(personToDelete.getUuid());
}
if (grouping == null) {
Group groupToDeleteFrom = groupRepository.findByPath(group);
deleteMember(groupToDeleteFrom, personToDelete);
} else {
if (group.endsWith(OWNERS)) {
deleteMember(grouping.getOwners(), personToDelete);
} else if (group.endsWith(EXCLUDE)) {
deleteMember(grouping.getExclude(), personToDelete);
} else if (group.endsWith(INCLUDE)) {
deleteMember(grouping.getInclude(), personToDelete);
}
grouping = groupingRepository.findByPath(grouping.getPath());
grouping = groupingRepository.findByPath(grouping.getPath());
Group composite = buildComposite(grouping.getInclude(), grouping.getExclude(), grouping.getBasis(), grouping.getPath());
groupRepository.save(composite);
}
return wsDeleteMemberResults;
}
use of edu.hawaii.its.api.type.Group 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;
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingsRestControllerTest method grouping.
// Test data.
private Grouping grouping() {
Grouping grouping = new Grouping("test:ing:me:bob");
Group basisGroup = new Group();
basisGroup.addMember(new Person("b0-name", "b0-uuid", "b0-username"));
basisGroup.addMember(new Person("b1-name", "b1-uuid", "b1-username"));
basisGroup.addMember(new Person("b2-name", "b2-uuid", "b2-username"));
grouping.setBasis(basisGroup);
Group exclude = new Group();
exclude.addMember(new Person("e0-name", "e0-uuid", "e0-username"));
grouping.setExclude(exclude);
Group include = new Group();
include.addMember(new Person("i0-name", "i0-uuid", "i0-username"));
include.addMember(new Person("i1-name", "i1-uuid", "i1-username"));
grouping.setInclude(include);
Group owners = new Group();
owners.addMember(new Person("o0-name", "o0-uuid", "o0-username"));
owners.addMember(new Person("o1-name", "o1-uuid", "o1-username"));
owners.addMember(new Person("o2-name", "o2-uuid", "o2-username"));
owners.addMember(new Person("o3-name", "o3-uuid", "o3-username"));
grouping.setOwners(owners);
grouping.setListservOn(true);
return grouping;
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupRepositoryTest method setup.
@Before
public void setup() {
for (int i = 0; i < 10; i++) {
persons[i] = new Person("name" + i, "uuid" + i, "username" + i);
personRepository.save(persons[i]);
}
for (int i = 0; i < 5; i++) {
memberLists.add(new ArrayList<>());
}
memberLists.get(1).add(persons[0]);
memberLists.get(1).add(persons[1]);
memberLists.get(2).add(persons[2]);
memberLists.get(2).add(persons[3]);
memberLists.get(2).add(persons[4]);
memberLists.get(3).add(persons[5]);
memberLists.get(3).add(persons[6]);
memberLists.get(3).add(persons[7]);
memberLists.get(3).add(persons[8]);
memberLists.get(4).add(persons[0]);
memberLists.get(4).add(persons[1]);
memberLists.get(4).add(persons[2]);
memberLists.get(4).add(persons[3]);
memberLists.get(4).add(persons[4]);
memberLists.get(4).add(persons[5]);
memberLists.get(4).add(persons[6]);
memberLists.get(4).add(persons[7]);
memberLists.get(4).add(persons[8]);
memberLists.get(4).add(persons[9]);
for (int i = 0; i < 5; i++) {
groups[i] = new Group("path:to:group" + i, memberLists.get(i));
groupRepository.save(groups[i]);
}
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class DatabaseSetup method buildComposite.
// /////////////////////////////////////////////////////////
// helper methods
// /////////////////////////////////////////////////////////
private Group buildComposite(Group include, Group exclude, Group basis, String path) {
Group basisPlusInclude = addIncludedMembers(include, basis);
Group compositeGroup = removeExcludedMembers(basisPlusInclude, exclude);
compositeGroup.setPath(path);
return compositeGroup;
}
Aggregations