public String getId() { return group.getId(); } }
private List<LocalPath> getPath(List<LocalPath> list, String id) throws Exception { if (list == null) list = new ArrayList<LocalPath>(5); if (id == null) return list; OrganizationService service = getApplicationComponent(OrganizationService.class); Group group = service.getGroupHandler().findGroupById(id); if (group == null) return list; list.add(0, new LocalPath(group.getId(), group.getGroupName())); getPath(list, group.getParentId()); return list; }
private List<OrganizationConfig.Group> getAllGroups() throws Exception { List<OrganizationConfig.Group> allGroups = new ArrayList<OrganizationConfig.Group>(); try { @SuppressWarnings("unchecked") Collection<Group> groups = organizationService.getGroupHandler().getAllGroups(); for (Group group : groups) { OrganizationConfig.Group orgConfGroup = new OrganizationConfig.Group(); orgConfGroup.setDescription(group.getDescription()); orgConfGroup.setLabel(group.getLabel()); orgConfGroup.setName(group.getGroupName()); orgConfGroup.setParentId(group.getParentId()); allGroups.add(orgConfGroup); } } catch (Exception e) { LOG.error("Error when recovering of all groups ... ", e); return null; } return allGroups; }
/** * Create group from LDAP attributes. * * @param attrs {@link Attributes} * @return Group */ public final Group attributesToGroup(Attributes attrs) { if (attrs == null || attrs.size() == 0) return null; Group group = new GroupImpl(); group.setGroupName(getAttributeValueAsString(attrs, groupNameAttr)); group.setDescription(getAttributeValueAsString(attrs, ldapDescriptionAttr)); group.setLabel(getAttributeValueAsString(attrs, groupLabelAttr)); return group; }
String groupId = "/" + child.getGroupName(); GroupImpl childImpl = (GroupImpl)child; if (parent != null) Group parentGroup = findGroupById(parent.getId()); if (parentGroup == null) throw new InvalidNameException("Can't add node to not existed parent " + parent.getId()); groupId = parentGroup.getId() + "/" + child.getGroupName(); childImpl.setParentId(parentGroup.getId()); else if (child.getId() != null) groupId = child.getId(); if (o != null) Object[] args = {child.getGroupName()}; throw new UniqueObjectException("OrganizationService.unique-group-exception", args);
/** * Create LDAP attributes that represents group in LDAP context. * * @param group Group * @return LDAP attributes */ public final Attributes groupToAttributes(Group group) { BasicAttributes attrs = new BasicAttributes(); if (GROUP_LDAP_CLASSES == null) GROUP_LDAP_CLASSES = groupLDAPClasses.split(","); attrs.put(new ObjectClassAttribute(GROUP_LDAP_CLASSES)); attrs.put(groupNameAttr, group.getGroupName()); String desc = group.getDescription(); if (desc != null && desc.length() > 0) attrs.put(ldapDescriptionAttr, desc); String lbl = group.getLabel(); if (lbl != null && lbl.length() > 0) attrs.put(groupLabelAttr, lbl); return attrs; }
String filter = ldapAttrMapping.groupNameAttr + "=" + group.getGroupName(); String searchBase = this.createSubDN(group.getParentId()); SearchControls constraints = new SearchControls(); constraints.setSearchScope(SearchControls.ONELEVEL_SCOPE); throw new IllegalStateException("Group " + group.getGroupName() + " has at least one child group");
try { session = repositoryService.getCurrentRepository().getSystemSession(Util.WORKSPACE); if (group.getParentId() != null && !group.getParentId().isEmpty()) { try { Group parentGroup = organizationService.getGroupHandler().findGroupById(group.getParentId()); invokeListenersToSavedGroup(parentGroup, isNew); } catch (Exception e) { LOG.warn("\t\tError occurred while attempting to get parent of " + group.getId() + " Group. Listeners will not be applied on parent " + group.getParentId(), e); if (!isNew || !Util.hasGroupFolder(session, group.getId())) { LOG.info("Invoke " + group.getId() + " Group save listeners."); Collection<GroupEventListener> groupDAOListeners = groupDAOListeners_.values(); for (GroupEventListener groupEventListener : groupDAOListeners) { groupEventListener.preSave(group, isNew); } catch (Exception e) { LOG.warn("\t\t\tFailed to call preSave on " + group.getId() + " Group, listener = " + groupEventListener.getClass(), e); groupEventListener.postSave(group, isNew); } catch (Exception e) { LOG.warn("\t\t\tFailed to call postSave on " + group.getId() + " Group, listener = " + groupEventListener.getClass(), e); LOG.warn("\t\t\tFailed to call listeners for " + group.getId() + " Group.", e); } finally { if (session != null) {
static public String getGroupLabel(String groupId) throws Exception { WebuiRequestContext context = WebuiRequestContext.getCurrentInstance(); ExoContainer container = context.getApplication().getApplicationServiceContainer(); OrganizationService orgService = (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class); Group group = orgService.getGroupHandler().findGroupById(groupId); if(group == null){ return cachedGroupLabel; } String label = group.getLabel(); cachedGroupLabel = (label != null && label.trim().length() > 0 )? label : group.getGroupName(); return cachedGroupLabel; }
public void changeGroup(String groupId) throws Exception { OrganizationService service = getApplicationComponent(OrganizationService.class); UIBreadcumbs uiBreadcumb = getChild(UIBreadcumbs.class); uiBreadcumb.setPath(getPath(null, groupId)); UITree tree = getChild(UITree.class); Collection sibblingGroup; if (groupId == null) { sibblingGroup = service.getGroupHandler().findGroups(null); tree.setSibbling((List)sibblingGroup); tree.setChildren(null); tree.setSelected(null); selectedGroup = null; return; } selectedGroup = service.getGroupHandler().findGroupById(groupId); String parentGroupId = null; if (selectedGroup != null) parentGroupId = selectedGroup.getParentId(); Group parentGroup = null; if (parentGroupId != null) parentGroup = service.getGroupHandler().findGroupById(parentGroupId); Collection childrenGroup = service.getGroupHandler().findGroups(selectedGroup); sibblingGroup = service.getGroupHandler().findGroups(parentGroup); tree.setSibbling((List)sibblingGroup); tree.setChildren((List)childrenGroup); tree.setSelected(selectedGroup); tree.setParentSelected(parentGroup); }
public int compareTo(Object o) { if (!(o instanceof Group)) { return 0; } Group group = (Group) o; return groupName.compareTo(group.getGroupName()); } }
public String getLabel() { return group.getLabel(); }
static public String getGroupDescription(String groupId) throws Exception { WebuiRequestContext context = WebuiRequestContext.getCurrentInstance(); ExoContainer container = context.getApplication().getApplicationServiceContainer(); OrganizationService orgService = (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class); String description = ""; Group group = orgService.getGroupHandler().findGroupById(groupId); if (group != null) { description = group.getDescription(); } return description; }
public void onEvent(Event<UserDAOImpl, User> event) throws Exception { LOG.info("Create User Profile: " + event.getData().getUserName()); UserProfile profile = service_.getUserProfileHandler().createUserProfileInstance(event.getData().getUserName()); service_.getUserProfileHandler().saveUserProfile(profile, true); GroupHandler groupHandler = service_.getGroupHandler(); Group g = groupHandler.findGroupById("/user"); MembershipTypeHandler membershipTypeHandler = service_.getMembershipTypeHandler(); MembershipType memberType = membershipTypeHandler.findMembershipType("member"); if (g == null) { g = groupHandler.createGroupInstance(); g.setGroupName("user"); groupHandler.addChild(null, g, true); } if (memberType == null) { memberType = membershipTypeHandler.createMembershipTypeInstance(); memberType.setName("member"); membershipTypeHandler.createMembershipType(memberType, true); } MembershipHandler membershipHandler = service_.getMembershipHandler(); membershipHandler.linkMembership(event.getData(), g, memberType, true); } }
/** * {@inheritDoc} */ public Group removeGroup(Group group, boolean broadcast) throws Exception { if (broadcast) preDelete(group); Session session = service_.openSession(); if (session.get(group.getClass(), group.getId()) == null) { throw new InvalidNameException("Can not remove group " + group.getGroupName() + "record, because group does not exist."); } if (hasChildrenGroups(group)) { throw new IllegalStateException("Group " + group.getGroupName() + " has at least one child group"); } session.delete(group); MembershipDAOImpl.removeMembershipEntriesOfGroup(group, session); session.flush(); if (broadcast) postDelete(group); return group; }
String plGroupName = getPLIDMGroupName(group.getGroupName()); orgService.getConfiguration().getGroupType(group.getParentId())); } catch (Exception e) { handleException("Cannot obtain group: " + plGroupName + "; ", e); } finally { if(oneLevelChilds != null && oneLevelChilds.size() > 0) { throw new IllegalStateException("Group " + group.getGroupName() + " has at least one child group");
LOG.info(" Creating Group " + groupId); Group group = organizationService.getGroupHandler().createGroupInstance(); group.setGroupName(data.getName()); group.setDescription(data.getDescription()); group.setLabel(data.getLabel()); if (parentId == null || parentId.length() == 0) { organizationService.getGroupHandler().addChild(null, group, false);
String parentGroupId = null; if (selectGroup_ != null) parentGroupId = selectGroup_.getParentId(); Group parentGroup = null; if (parentGroupId != null)
LOG.debug("Remove all Membership by Group: " + group.getGroupName());