use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GrouperFactoryServiceImplLocal method makeWsGetMembersResults.
@Override
public WsGetMembersResults makeWsGetMembersResults(String subjectAttributeName, WsSubjectLookup lookup, String groupName) {
WsGetMembersResults wsGetMembersResults = new WsGetMembersResults();
String[] attributeNames = new String[] { UID_KEY, UUID_KEY, LAST_NAME_KEY, COMPOSITE_NAME_KEY, FIRST_NAME_KEY };
wsGetMembersResults.setSubjectAttributeNames(attributeNames);
WsGetMembersResult wsGetMembersResult = new WsGetMembersResult();
WsSubject[] subjects;
Group group = groupRepository.findByPath(groupName);
List<Person> members = group.getMembers();
List<WsSubject> subjectList = new ArrayList<>();
for (Person person : members) {
WsSubject subject = new WsSubject();
subject.setId(person.getUuid());
subject.setName(person.getName());
// has to be the same order as attributeNames array
subject.setAttributeValues(new String[] { person.getUsername(), person.getUuid(), person.getLastName(), person.getName(), person.getFirstName() });
subjectList.add(subject);
}
subjects = subjectList.toArray(new WsSubject[subjectList.size()]);
wsGetMembersResult.setWsSubjects(subjects);
wsGetMembersResults.setResults(new WsGetMembersResult[] { wsGetMembersResult });
return wsGetMembersResults;
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method getMembers.
// returns a group from grouper or the database
@Override
public Group getMembers(String ownerUsername, String groupPath) {
logger.info("getMembers; user: " + ownerUsername + "; group: " + groupPath + ";");
WsSubjectLookup lookup = grouperFS.makeWsSubjectLookup(ownerUsername);
WsGetMembersResults members = grouperFS.makeWsGetMembersResults(SUBJECT_ATTRIBUTE_NAME_UID, lookup, groupPath);
// todo should we use EmptyGroup?
Group groupMembers = new Group();
if (members.getResults() != null) {
groupMembers = makeGroup(members);
}
return groupMembers;
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method makeGroup.
// makes a group filled with members from membersResults
@Override
public Group makeGroup(WsGetMembersResults membersResults) {
Group group = new Group();
try {
WsSubject[] subjects = membersResults.getResults()[0].getWsSubjects();
String[] attributeNames = membersResults.getSubjectAttributeNames();
if (subjects.length > 0) {
for (WsSubject subject : subjects) {
if (subject != null) {
group.addMember(makePerson(subject, attributeNames));
}
}
}
} catch (NullPointerException npe) {
return new Group();
}
return group;
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method groupingsToOptInto.
// returns the list of groupings that the user is allowed to opt-in to
public List<Grouping> groupingsToOptInto(String optInUsername, List<String> groupPaths) {
logger.info("groupingsToOptInto; username: " + optInUsername + "; groupPaths : " + groupPaths + ";");
List<String> trios = new ArrayList<>();
List<String> opts = new ArrayList<>();
List<String> excludes = groupPaths.stream().map(group -> group + EXCLUDE).collect(Collectors.toList());
WsGetAttributeAssignmentsResults assignmentsResults = grouperFS.makeWsGetAttributeAssignmentsResultsTrio(ASSIGN_TYPE_GROUP, TRIO, OPT_IN);
if (assignmentsResults.getWsAttributeAssigns() != null) {
for (WsAttributeAssign assign : assignmentsResults.getWsAttributeAssigns()) {
if (assign.getAttributeDefNameName() != null) {
if (assign.getAttributeDefNameName().equals(TRIO)) {
trios.add(assign.getOwnerGroupName());
} else if (assign.getAttributeDefNameName().equals(OPT_IN)) {
opts.add(assign.getOwnerGroupName());
}
}
}
// opts intersection trios
opts.retainAll(trios);
// excludes intersection opts
excludes.retainAll(opts);
// opts - (opts intersection groupPaths)
opts.removeAll(groupPaths);
// opts union excludes
opts.addAll(excludes);
}
// get rid of duplicates
List<String> groups = new ArrayList<>(new HashSet<>(opts));
return helperService.makeGroupings(groups);
}
use of edu.hawaii.its.api.type.Group in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupingAssignmentServiceImpl method getGrouping.
// fetch a grouping from Grouper or the database
@Override
public Grouping getGrouping(String groupingPath, String ownerUsername) {
logger.info("getGrouping; grouping: " + groupingPath + "; username: " + ownerUsername + ";");
Grouping compositeGrouping = new Grouping();
if (memberAttributeService.isOwner(groupingPath, ownerUsername) || memberAttributeService.isAdmin(ownerUsername)) {
compositeGrouping = new Grouping(groupingPath);
Group include = getMembers(ownerUsername, groupingPath + INCLUDE);
Group exclude = getMembers(ownerUsername, groupingPath + EXCLUDE);
Group basis = getMembers(ownerUsername, groupingPath + BASIS);
Group composite = getMembers(ownerUsername, groupingPath);
Group owners = getMembers(ownerUsername, groupingPath + OWNERS);
compositeGrouping = setGroupingAttributes(compositeGrouping);
compositeGrouping.setBasis(basis);
compositeGrouping.setExclude(exclude);
compositeGrouping.setInclude(include);
compositeGrouping.setComposite(composite);
compositeGrouping.setOwners(owners);
}
return compositeGrouping;
}
Aggregations