/** * Finds a group in a particular site, by group title * @param site the site * @param groupTitle the group title * @return the id of the group with the matching title, or empty string if not found */ public static String getSiteGroupByTitle(Site site, String groupTitle) { String groupId = ""; Collection<Group> siteGroups = site.getGroups(); if (groupTitle != null && siteGroups != null) { for (Group g : siteGroups) { if (g != null && groupTitle.equals(g.getTitle())) { groupId = g.getId(); break; } } } return groupId; } }
/** * Test a collection of Group object for the specified group reference * @param groups The collection (Group) of groups * @param groupRef The string group reference to find. * @return true if found, false if not. */ protected boolean groupCollectionContainsRefString(Collection<Group> groups, String groupRef) { for (Iterator<Group> i = groups.iterator(); i.hasNext();) { Group group = (Group) i.next(); if (group.getReference().equals(groupRef)) return true; } return false; }
/** * {@inheritDoc} */ public Collection getGroupsWithMemberHasRole(String userId, String role) { Collection siteGroups = getGroups(); ArrayList<String> siteGroupRefs = new ArrayList<String>(siteGroups.size()); for ( Iterator it=siteGroups.iterator(); it.hasNext(); ) siteGroupRefs.add( ((Group)it.next()).getReference() ); List groups = authzGroupService.getAuthzUserGroupIds(siteGroupRefs, userId); Collection<Group> rv = new Vector<Group>(); for (Iterator i = groups.iterator(); i.hasNext();) { Member m = null; Group g = getGroup( (String)i.next() ); if ( g != null ) m = g.getMember(userId); if ((m != null) && (m.isActive()) && (m.getRole().getId().equals(role))) rv.add(g); } return rv; }
/** * {@inheritDoc} */ public void deleteGroup(Group group) throws IllegalStateException { if (group.isLocked()) { throw new IllegalStateException("Error, cannot remove group: " + group.getId() + " because it is locked"); } // remove it m_groups.remove(group); // track so we can clean up related on commit m_deletedGroups.add(group); }
/** * {@inheritDoc} */ public Collection<String> getMembersInGroups(Set<String> groupIds) { @SuppressWarnings("unchecked") Collection<Group> siteGroups = getGroups(); HashSet<String> siteGroupRefs = new HashSet<String>(siteGroups.size()); for (Group group : siteGroups) { if (groupIds == null || // null groupIds includes all groups in the site groupIds.contains(group.getId())) { siteGroupRefs.add(group.getReference()); } } Collection<String> membersInGroups = authzGroupService.getAuthzUsersInGroups(siteGroupRefs); return membersInGroups; }
public CourseSectionImpl(Group group) { this.group = group; this.uuid = group.getReference(); this.course = new CourseImpl(group.getContainingSite()); this.title = group.getTitle(); this.description = group.getDescription(); this.isLocked = group.isLocked(Group.LockMode.ALL); this.isLockedForDeletion = group.isLocked(Group.LockMode.DELETE); ResourceProperties props = group.getProperties(); this.category = props.getProperty(CourseSectionImpl.CATEGORY); this.meetings = new ArrayList<Meeting>();
pageName = group.getId() + "/Home"; //$NON-NLS-1$ pageName = group.getReference() + "/"; //$NON-NLS-1$ pageName += "section/" + group.getTitle() + "/Home"; //$NON-NLS-1$ //$NON-NLS-2$ writer.write(group.getTitle()); writer.write("|"); //$NON-NLS-1$ writer.write(pageName);
private boolean isUserInAuthorizedGroup(String authorizedGroupId, Collection userGroups) { if (userGroups==null || userGroups.isEmpty() || authorizedGroupId==null || authorizedGroupId.equals("")) { return false; } Iterator userGroupsIter = userGroups.iterator(); while (userGroupsIter.hasNext()) { Group group = (Group) userGroupsIter.next(); if (group.getId().equals(authorizedGroupId)) { return true; } } return false; }
public List getStudentSectionMembershipNames(String gradebookUid, String studentUid) { List sectionNames = new ArrayList(); List sections = findStudentSectionMemberships(gradebookUid, studentUid); if (sections != null && !sections.isEmpty()) { Iterator sectionIter = sections.iterator(); while (sectionIter.hasNext()) { Group myGroup = (Group) sectionIter.next(); sectionNames.add(myGroup.getTitle()); } } return sectionNames; }
if (group.getTitle() == null || group.getTitle().trim().length() == 0) fields[0] = group.getId(); fields[1] = caseId(edit.getId()); fields[2] = group.getTitle(); fields[3] = group.getDescription(); m_sql.dbWrite(statement, fields); writeProperties("SAKAI_SITE_GROUP_PROPERTY", "GROUP_ID", group.getId(), "SITE_ID", caseId(edit.getId()), group.getProperties(), deleteAgain);
String gProp = grp.getProperties().getProperty(GROUP_PROP_SIGNUP_IGNORE); if (gProp != null && gProp.equals(Boolean.TRUE.toString())) { continue; sgrp.setGroupId(grp.getId()); sgrp.setTitle(grp.getTitle()); groupList.add(sgrp);
private Map<String, Set<String>> getUserGroups(String siteId, Collection<String> studentIds) { Map<String, Set<String>> userIdGroupIds = new HashMap<String, Set<String>>(); for (String studentId : studentIds) { userIdGroupIds.put(studentId, new HashSet<String>()); } try { Site site = siteService.getSite(siteId); for (Group g : site.getGroups()) { for (Member m : g.getMembers()) { String userId = m.getUserId(); if (userIdGroupIds.containsKey(userId)) { userIdGroupIds.get(userId).add(g.getId()); } } } } catch (IdUnusedException e) { if (log.isDebugEnabled()) { log.debug("Site not found when attempting to retrieve user groups: " + siteId); } } return userIdGroupIds; }
group.setTitle(GROUP_PREFIX + title); group.setDescription(description); group.getProperties().addProperty(GROUP_PROP_SITEINFO_VISIBLE, Boolean.TRUE.toString()); group.removeMembers(); return group.getId();
if(group.getTitle().startsWith(GROUP_PREFIX)){ group.setTitle(GROUP_PREFIX + newTitle); siteService.save(site); changed = true; else if(group.getTitle().contains(newTitle)){ log.error("synchGroupTitle failed for group: " + group.getTitle() + " and group: " + groupId, e); } finally { disableSecurityAdvisor(securityAdvisor);
String s1 = ((Group) o1).getTitle(); String s2 = ((Group) o2).getTitle(); result = compareString(s1, s2); } else if (m_criterion.equals(SiteConstants.SORTED_BY_GROUP_SIZE)) { int n1 = ((Group) o1).getMembers().size(); int n2 = ((Group) o2).getMembers().size(); result = (n1 > n2) ? 1 : -1; } else if (m_criterion.equals(SiteConstants.SORTED_BY_MEMBER_NAME)) {
ResourceProperties props = group.getProperties(); group.setTitle(title); group.setDescription(description); props.addProperty(CourseSectionImpl.CATEGORY, category); if(maxEnrollments == null) {
Map<String, Set<String>> groupIdUserIds = new HashMap<String, Set<String>>(); for (Group group : site.getGroups()) { String groupRef = group.getReference(); for (Member member : group.getMembers()) { if (member.getRole().isAllowed(SECURE_ADD_ASSIGNMENT_SUBMISSION)) { if (!groupIdUserIds.containsKey(groupRef)) {
sakaiGroup.getProperties().addProperty(sakaiGroup.GROUP_PROP_WSETUP_CREATED, Boolean.TRUE.toString()); sakaiGroup.setTitle(consumerGroupTitle); sakaiGroup.addMember(consumerGroupMember.userId, consumerGroupMember.role, true, false);
private boolean isCurrentUserFromGroup(final String gradebookUid, final String studentId) { boolean isFromGroup=false; try { final Site s = this.siteService.getSite(gradebookUid); final Group g = s.getGroup(studentId); isFromGroup = (g != null) && (g.getMember(this.authn.getUserUid()) != null); } catch (final Exception e) { // Id not found log.error("Error in isCurrentUserFromGroup: ", e); } return isFromGroup; }
site.getGroup(joinerGroupId).insertMember(user.getId(), site.getJoinerRole(), true, false); siteService.saveGroupMembership(site); } catch (IllegalStateException e) { log.error(".addJoinerToGroup: User with id {} cannot be inserted in group with id {} because the group is locked", user.getId(), site.getGroup(joinerGroupId).getId());