@SuppressWarnings("unchecked") public List<String> getListGroup() throws Exception { OrganizationService service = getApplicationComponent(OrganizationService.class); List<String> listGroup = new ArrayList<String>(); if (getCurrentGroup() == null) return null; Collection<Object> groups = service.getGroupHandler().findGroups(getCurrentGroup()); if (groups.size() > 0) { for (Object child : groups) { Group childGroup = (Group)child; listGroup.add(childGroup.getId()); } } return listGroup; }
public String[] getUserGroups(String username) throws Exception { String [] groupsList; if (username == RequestContext.getCurrentInstance().getRemoteUser()) { Set<String> groups = ConversationState.getCurrent().getIdentity().getGroups(); groupsList = groups.toArray(new String[groups.size()]); } else { Object[] objs = organization_.getGroupHandler().findGroupsOfUser(username).toArray(); groupsList = new String[objs.length]; for (int i = 0; i < objs.length; i++) { groupsList[i] = ((Group) objs[i]).getId(); } } return groupsList; }
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; }
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; }
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; }
groupId = data.getParentId() + "/" + data.getName(); if (organizationService.getGroupHandler().findGroupById(groupId) == null) { 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); } else { Group parentGroup = organizationService.getGroupHandler().findGroupById(parentId); organizationService.getGroupHandler().addChild(parentGroup, group, false);
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; }
/** * @see org.exoplatform.webui.core.UIComponent#processRender(org.exoplatform.webui.application.WebuiRequestContext) */ @Override public void processRender(WebuiRequestContext context) throws Exception { OrganizationService service = getApplicationComponent(OrganizationService.class); UITree tree = getChild(UITree.class); if (tree != null && tree.getSibbling() == null) { Collection<?> sibblingsGroup = service.getGroupHandler().findGroups(null); tree.setSibbling((List)sibblingsGroup); } Collection<?> collection = service.getMembershipTypeHandler().findMembershipTypes(); listMemberhip = new ArrayList<String>(5); for (Object obj : collection) { listMemberhip.add(((MembershipType)obj).getName()); } if(!listMemberhip.contains("*")) { listMemberhip.add("*"); } super.processRender(context); }
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); }
sibblingGroup = service.getGroupHandler().findGroups(null); tree.setSibbling((List)sibblingGroup); tree.setChildren(null); selectGroup_ = service.getGroupHandler().findGroupById(groupId); String parentGroupId = null; if (selectGroup_ != null) Group parentGroup = null; if (parentGroupId != null) parentGroup = service.getGroupHandler().findGroupById(parentGroupId); Collection childrenGroup = service.getGroupHandler().findGroups(selectGroup_); sibblingGroup = service.getGroupHandler().findGroups(parentGroup);
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; }
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; }
@SuppressWarnings("unchecked") public void onEvent(Event<GroupDAOImpl, Group> event) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("Remove all Child of Group: " + event.getData().getId()); } GroupHandler membershipHanler = service_.getGroupHandler(); List<Group> children = (List<Group>)membershipHanler.findGroups(event.getData()); for (Group child : children) { membershipHanler.removeGroup(child, true); } } }
public void execute(Event<UIUserSelector> event) throws Exception { UIUserSelector uiSelectUserForm = event.getSource(); String groupId = uiSelectUserForm.getSelectedGroup(); OrganizationService service = uiSelectUserForm.getApplicationComponent(OrganizationService.class); PageList users = PageList.EMPTY_LIST; if (groupId != null && groupId.trim().length() != 0) { if (service.getGroupHandler().findGroupById(groupId) != null) { users = uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId)); } } else { users = service.getUserHandler().findUsers(new Query()); } users.setPageSize(10); uiSelectUserForm.uiIterator_.setPageList(users); uiSelectUserForm.setKeyword(null); event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm); } }
public UIGroupSelector() throws Exception { UIBreadcumbs uiBreadcumbs = addChild(UIBreadcumbs.class, "BreadcumbGroupSelector", "BreadcumbGroupSelector"); UITree tree = addChild(UITree.class, "UITreeGroupSelector", "TreeGroupSelector"); OrganizationService service = getApplicationComponent(OrganizationService.class); Collection sibblingsGroup = service.getGroupHandler().findGroups(null); tree.setSibbling((List)sibblingsGroup); tree.setIcon("GroupAdminIcon"); tree.setSelectedIcon("PortalIcon"); tree.setBeanIdField("id"); //tree.setBeanLabelField("groupName"); tree.setBeanLabelField("label"); tree.setEscapeHTML(true); uiBreadcumbs.setBreadcumbsStyle("UIExplorerHistoryPath"); }
@SuppressWarnings("unchecked") public UIGroupSelector() throws Exception { UIBreadcumbs uiBreadcumbs = addChild(UIBreadcumbs.class, "BreadcumbGroupSelector", "BreadcumbGroupSelector"); UITree tree = addChild(UITree.class, "UITreeGroupSelector", "TreeGroupSelector"); OrganizationService service = getApplicationComponent(OrganizationService.class); Collection<?> sibblingsGroup = service.getGroupHandler().findGroups(null); tree.setSibbling((List)sibblingsGroup); tree.setIcon("GroupAdminIcon"); tree.setSelectedIcon("PortalIcon"); tree.setBeanIdField("id"); //tree.setBeanLabelField("groupName"); tree.setBeanLabelField("label"); tree.setEscapeHTML(true); uiBreadcumbs.setBreadcumbsStyle("UIExplorerHistoryPath"); }
public void save(OrganizationService service, boolean broadcast) throws Exception { GroupHandler groupHandler = service.getGroupHandler(); MembershipTypeHandler mtHandler = service.getMembershipTypeHandler(); User user = service.getUserHandler().findUserByName(user_); for (Membership membership : membership_) { if (user == null) user = service.getUserHandler().findUserByName(membership.getUserName()); Group group = groupHandler.findGroupById(membership.getGroupId()); MembershipType mt = mtHandler.findMembershipType(membership.getMembershipType()); if (service.getMembershipHandler() != null) { service.getMembershipHandler().linkMembership(user, group, mt, broadcast); } } }
public ListAccess<User> findUsersByGroupId(String groupId) throws Exception { if (LOG.isDebugEnabled()) LOG.debug("+++++++++++FIND USER BY GROUP_ID " + groupId); MembershipHandler membershipHandler = orgService.getMembershipHandler(); GroupHandler groupHandler = orgService.getGroupHandler(); Group group = groupHandler.findGroupById(groupId); if (group == null) { return new LazyListImpl(); } List<Membership> members = (List<Membership>)membershipHandler.findMembershipsByGroup(group); DBObjectQuery<UserImpl> dbQuery = new DBObjectQuery<UserImpl>(UserImpl.class); for (Membership member : members) { dbQuery.addEQ("USER_NAME", member.getUserName()); } return new JDBCListAccess<User>(this, dbQuery.toQueryUseOR(), dbQuery.toCountQueryUseOR()); }
/** * Add given user to our group with given membershipType. * * @param userId */ private void addUserToPlatformUsers(String userId) throws Exception { OrganizationService orgService = (OrganizationService) getContainer().getComponentInstanceOfType( OrganizationService.class); try { begin(orgService); User user = orgService.getUserHandler().findUserByName(userId); MembershipType memberType = orgService.getMembershipTypeHandler().findMembershipType(membershipType); Group platformUsersGroup = orgService.getGroupHandler().findGroupById(groupId); orgService.getMembershipHandler().linkMembership(user, platformUsersGroup, memberType, true); } catch (Exception e) { log.error("Failed to add user " + userId + " to group " + groupId + ".", e); // don't rethrow login exception in case of failure. // throw e; } finally { end(orgService); } }
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); } }