Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.OrganizationService


    public static class SaveActionListener extends EventListener<UIGroupMembershipForm> {
        public void execute(Event<UIGroupMembershipForm> event) throws Exception {
            UIGroupMembershipForm uiForm = event.getSource();
            UIUserInGroup userInGroup = uiForm.getParent();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            MembershipHandler memberShipHandler = service.getMembershipHandler();
            UIApplication uiApp = event.getRequestContext().getUIApplication();

            Group group = userInGroup.getSelectedGroup();
            MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(uiForm.getMembership());
            if (group == null) {
                uiApp.addMessage(new ApplicationMessage("UIGroupMembershipForm.msg.group-not-select", null));
                return;
            }

            // add new
            List<String> userNames = Arrays.asList(uiForm.getUserName().trim().split("\\s*,\\s*"));
            if (new HashSet<String>(userNames).size() != userNames.size()) {
                uiApp.addMessage(new ApplicationMessage("UIGroupMembershipForm.msg.duplicate-user", null));
                return;
            }

            // check user
            boolean check = false;
            String listNotExist = null;
            for (String username : userNames) {
                if (username == null || username.trim().length() == 0)
                    continue;
                User user = service.getUserHandler().findUserByName(username);
                if (user == null) {
                    check = true;
                    if (listNotExist == null)
                        listNotExist = username;
                    else
                        listNotExist += ", " + username;
                }
            }
            if (check) {
                ApplicationMessage msg = new ApplicationMessage("UIGroupMembershipForm.msg.user-not-exist",
                        new String[] { listNotExist });
                msg.setArgsLocalized(false);
                uiApp.addMessage(msg);
                return;
            }

            // check membership
            String listUserMembership = null;
            for (String username : userNames) {
                if (username == null || username.trim().length() == 0)
                    continue;
                Membership membership = memberShipHandler.findMembershipByUserGroupAndType(username, group.getId(),
                        membershipType.getName());
                if (membership != null) {
                    check = true;
                    if (listUserMembership == null)
                        listUserMembership = username;
                    else
                        listUserMembership += ", " + username;
                }
            }
            if (check) {
                uiApp.addMessage(new ApplicationMessage("UIGroupMembershipForm.msg.membership-exist", new String[] {
                        listUserMembership, group.getGroupName() }));
                return;
            }

            for (String username : userNames) {
                if (username == null || username.trim().length() == 0)
                    continue;
                User user = service.getUserHandler().findUserByName(username);
                memberShipHandler.linkMembership(user, group, membershipType, true);
            }
            userInGroup.refresh();
            uiForm.reset();
        }
View Full Code Here


    /** . */
    private static final Logger log = LoggerFactory.getLogger(GroupManagement.class);

    public static OrganizationService getOrganizationService() {
        ExoContainer container = ExoContainerContext.getCurrentContainer();
        OrganizationService orgService = (OrganizationService) container.getComponentInstanceOfType(OrganizationService.class);
        return orgService;
    }
View Full Code Here

    public static boolean isMembershipOfGroup(String username, String membership, String groupId) throws Exception {
        boolean ret = false;
        if (username == null)
            username = org.exoplatform.portal.webui.util.Util.getPortalRequestContext().getRemoteUser();
        OrganizationService orgService = getOrganizationService();
        Collection groups = orgService.getGroupHandler().findGroupByMembership(username, membership);
        for (Object group : groups) {
            if (((Group) group).getId().equals(groupId)) {
                ret = true;
                break;
            }
View Full Code Here

    public static class SaveActionListener extends EventListener<UIGroupEditMembershipForm> {
        public void execute(Event<UIGroupEditMembershipForm> event) throws Exception {
            UIGroupEditMembershipForm uiForm = event.getSource();
            UIApplication uiApp = event.getRequestContext().getUIApplication();
            UIPopupWindow uiPopup = uiForm.getParent();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);

            Membership formMembership = service.getMembershipHandler().findMembership(uiForm.membershipId);
            if (formMembership == null) {
                uiApp.addMessage(new ApplicationMessage("UIGroupEditMembershipForm.msg.membership-delete", null));
                uiPopup.setUIComponent(null);
                uiPopup.setShow(false);
                return;
            }
            String userName = formMembership.getUserName();
            Group group = service.getGroupHandler().findGroupById(uiForm.groupId);
            User user = service.getUserHandler().findUserByName(userName);
            MembershipHandler memberShipHandler = service.getMembershipHandler();
            String memberShipTypeStr = uiForm.getUIFormSelectBox(MEMBER_SHIP).getValue();
            MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(memberShipTypeStr);
            Membership membership = memberShipHandler.findMembershipByUserGroupAndType(userName, group.getId(),
                    membershipType.getName());
            if (membership != null) {
                uiApp.addMessage(new ApplicationMessage("UIGroupEditMembershipForm.msg.membership-exist", null));
                return;
View Full Code Here

    public static class SaveActionListener extends EventListener<UIGroupForm> {
        public void execute(Event<UIGroupForm> event) throws Exception {
            UIGroupForm uiGroupForm = event.getSource();
            UIGroupDetail uiGroupDetail = uiGroupForm.getParent();
            UIGroupManagement uiGroupManagement = uiGroupDetail.getParent();
            OrganizationService service = uiGroupForm.getApplicationComponent(OrganizationService.class);
            UIGroupExplorer uiGroupExplorer = uiGroupManagement.getChild(UIGroupExplorer.class);

            String currentGroupId = uiGroupForm.getGroupId();
            if (currentGroupId != null) {
                Group currentGroup = service.getGroupHandler().findGroupById(currentGroupId);

                if (currentGroup == null) {
                    Object[] args = { uiGroupForm.getUIStringInput(GROUP_NAME).getValue() };
                    UIApplication uiApp = event.getRequestContext().getUIApplication();
                    uiApp.addMessage(new ApplicationMessage("UIGroupForm.msg.group-not-exist", args));
                    uiGroupExplorer.changeGroup(null);
                    uiGroupDetail.getChild(UIGroupForm.class).setGroup(null);
                    uiGroupDetail.setRenderedChild(UIGroupInfo.class);
                    return;
                }

                uiGroupForm.invokeSetBindingBean(currentGroup);
                if (currentGroup.getLabel() == null || currentGroup.getLabel().trim().length() == 0) {
                    currentGroup.setLabel(currentGroup.getGroupName());
                }

                service.getGroupHandler().saveGroup(currentGroup, true);
                uiGroupForm.reset();
                uiGroupForm.setGroup(null);
                uiGroupExplorer.changeGroup(currentGroup.getId());
                uiGroupForm.setRenderSibling(UIGroupInfo.class);
                return;
            }

            // UIGroupExplorer uiGroupExplorer = uiGroupManagement.getChild(UIGroupExplorer.class) ;
            Group currentGroup = uiGroupExplorer.getCurrentGroup();
            if (currentGroup != null) {
                currentGroupId = currentGroup.getId();
            } else {
                currentGroupId = null;
            }
            String groupName = "/" + uiGroupForm.getUIStringInput(GROUP_NAME).getValue();

            GroupHandler groupHandler = service.getGroupHandler();

            if (currentGroupId != null) {
                groupName = currentGroupId + groupName;
            }

            Group newGroup = groupHandler.findGroupById(groupName);
            if (newGroup != null) {
                Object[] args = { groupName };
                UIApplication uiApp = event.getRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UIGroupForm.msg.group-exist", args));
                return;
            }
            newGroup = groupHandler.createGroupInstance();
            uiGroupForm.invokeSetBindingBean(newGroup);
            if (newGroup.getLabel() == null || newGroup.getLabel().trim().length() == 0) {
                newGroup.setLabel(newGroup.getGroupName());
            }
            String changeGroupId;
            if (currentGroupId == null) {
                groupHandler.addChild(null, newGroup, true);
                // uiGroupExplorer.changeGroup(groupName) ;
                changeGroupId = groupName;
            } else {
                Group parrentGroup = groupHandler.findGroupById(currentGroupId);
                groupHandler.addChild(parrentGroup, newGroup, true);
                // uiGroupExplorer.changeGroup(currentGroupId) ;
                changeGroupId = currentGroupId;
            }

            // change group
            String username = org.exoplatform.portal.webui.util.Util.getPortalRequestContext().getRemoteUser();
            User user = service.getUserHandler().findUserByName(username);
            MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(
                    GroupManagement.getUserACL().getAdminMSType());

            if (membershipType != null) {
                service.getMembershipHandler().linkMembership(user, newGroup, membershipType, true);
            }

            uiGroupExplorer.changeGroup(changeGroupId);
            uiGroupForm.reset();
            uiGroupForm.setGroup(null);
View Full Code Here

        setActions(new String[] { "Save", "Back" });
    }

    public void setUser(String userName) throws Exception {
        username_ = userName;
        OrganizationService service = getApplicationComponent(OrganizationService.class);
        User user = service.getUserHandler().findUserByName(userName);

        getChild(UIAccountEditInputSet.class).setValue(user);
        getChild(UIUserProfileInputSet.class).setUserProfile(userName);

        UIUserMembershipSelector uiMembershipSelector = getChild(UIUserMembershipSelector.class);
View Full Code Here

    }

    public static class SaveActionListener extends EventListener<UIUserInfo> {
        public void execute(Event<UIUserInfo> event) throws Exception {
            UIUserInfo uiUserInfo = event.getSource();
            OrganizationService service = uiUserInfo.getApplicationComponent(OrganizationService.class);
            boolean save = uiUserInfo.getChild(UIAccountEditInputSet.class).save(service);
            if (!save) {
                return;
            }
            uiUserInfo.getChild(UIUserProfileInputSet.class).save(service, uiUserInfo.getUserName(), false);

            if (uiUserInfo.getUserName().equals(event.getRequestContext().getRemoteUser())) {
                UserProfileHandler hanlder = service.getUserProfileHandler();
                UserProfile userProfile = hanlder.findUserProfileByName(event.getRequestContext().getRemoteUser());
                String language = userProfile.getAttribute(Constants.USER_LANGUAGE);

                UIPortalApplication uiApp = Util.getUIPortalApplication();
                if (language == null || language.trim().length() < 1)
View Full Code Here

    public static class DeleteUserActionListener extends EventListener<UIUserInGroup> {
        public void execute(Event<UIUserInGroup> event) throws Exception {
            UIUserInGroup uiUserInGroup = event.getSource();
            String id = event.getRequestContext().getRequestParameter(OBJECTID);
            OrganizationService service = uiUserInGroup.getApplicationComponent(OrganizationService.class);
            MembershipHandler handler = service.getMembershipHandler();
            handler.removeMembership(id, true);
            uiUserInGroup.refresh();
            event.getRequestContext().addUIComponentToUpdateByAjax(uiUserInGroup.getChild(UIGridUser.class));
        }
View Full Code Here

    public static class EditActionListener extends EventListener<UIUserInGroup> {
        public void execute(Event<UIUserInGroup> event) throws Exception {
            UIUserInGroup uiUserInGroup = event.getSource();
            String id = event.getRequestContext().getRequestParameter(OBJECTID);
            OrganizationService service = uiUserInGroup.getApplicationComponent(OrganizationService.class);
            MembershipHandler handler = service.getMembershipHandler();
            UIPopupWindow uiPopup = uiUserInGroup.getChild(UIPopupWindow.class);
            UIGroupEditMembershipForm uiEditMemberShip = uiUserInGroup.createUIComponent(UIGroupEditMembershipForm.class, null,
                    null);
            uiEditMemberShip.setValue(handler.findMembership(id), uiUserInGroup.getSelectedGroup());
            uiPopup.setUIComponent(uiEditMemberShip);
View Full Code Here

            }
            return null;
        }

        private MembershipUser toMembershipUser(Membership membership) throws Exception {
            OrganizationService service = getApplicationComponent(OrganizationService.class);
            String userName = membership.getUserName();
            UserHandler handler = service.getUserHandler();
            User user = handler.findUserByName(userName);
            if (user == null)
                return null;
            return new MembershipUser(user, membership.getMembershipType(), membership.getId());
        }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.organization.OrganizationService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.