Package org.exoplatform.webui.core

Examples of org.exoplatform.webui.core.UIApplication


        public void execute(Event<UIResetPassword> event) throws Exception {
            UIResetPassword uiForm = event.getSource();
            String newpassword = uiForm.getUIStringInput(NEW_PASSWORD).getValue();
            String confirmnewpassword = uiForm.getUIStringInput(CONFIRM_NEW_PASSWORD).getValue();
            WebuiRequestContext request = event.getRequestContext();
            UIApplication uiApp = request.getUIApplication();
            UIMaskWorkspace uiMaskWorkspace = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
            OrganizationService orgService = uiForm.getApplicationComponent(OrganizationService.class);
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);

            uiForm.reset();
            boolean setPassword = true;

            if (!newpassword.equals(confirmnewpassword)) {
                uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.password-is-not-match", null));
                setPassword = false;
            }

            Token token = tokenService.deleteToken(uiForm.getTokenId());
            if (token == null || token.isExpired()) {
                uiApp.addMessage(new ApplicationMessage("UIForgetPassword.msg.expration", null));
                setPassword = false;
            }

            if (setPassword) {
                try {
                    user_.setPassword(newpassword);
                    orgService.getUserHandler().saveUser(user_, true);
                    uiMaskWorkspace.createEvent("Close", Phase.DECODE, request).broadcast();
                    uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.change-password-successfully", null));
                } catch (Exception e) {
                    uiApp.addMessage(new ApplicationMessage("UIResetPassword.msg.change-password-fail", null, ApplicationMessage.ERROR));
                }
            }
            request.addUIComponentToUpdateByAjax(uiMaskWorkspace);
        }
View Full Code Here


    }

    @SuppressWarnings("unchecked")
    protected void processRequest(PortalRequestContext context, PortalApplication app) throws Exception {
        WebuiRequestContext.setCurrentInstance(context);
        UIApplication uiApp = app.getStateManager().restoreUIRootComponent(context);

        List<ApplicationLifecycle> lifecycles = app.getApplicationLifecycle();
        try {
            if (context.getUIApplication() != uiApp)
                context.setUIApplication(uiApp);
            for (ApplicationLifecycle lifecycle : lifecycles)
                lifecycle.onStartRequest(app, context);

            if (uiApp != null) {
                uiApp.processDecode(context);
            }

            if (!context.isResponseComplete() && !context.getProcessRender()) {
                startRequestPhaseLifecycle(app, context, lifecycles, Phase.ACTION);
                uiApp.processAction(context);
                endRequestPhaseLifecycle(app, context, lifecycles, Phase.ACTION);
            }

            if (!context.isResponseComplete()) {
                startRequestPhaseLifecycle(app, context, lifecycles, Phase.RENDER);
                uiApp.processRender(context);
                endRequestPhaseLifecycle(app, context, lifecycles, Phase.RENDER);
            }

            if (uiApp != null)
                uiApp.setLastAccessApplication(System.currentTimeMillis());

            // Store ui root
            app.getStateManager().storeUIRootComponent(context);
        } catch (StaleModelException staleModelEx) {
            // Minh Hoang TO:
View Full Code Here

    public static class SaveActionListener extends EventListener<UIAccountProfiles> {
        public void execute(Event<UIAccountProfiles> event) throws Exception {
            UIAccountProfiles uiForm = event.getSource();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIApplication uiApp = context.getUIApplication();

            ConversationState state = ConversationState.getCurrent();
            String userName = ((User) state.getAttribute(CacheUserProfileFilter.USER_PROFILE)).getUserName();
            User user = service.getUserHandler().findUserByName(userName);
            if (user != null) {
                String oldEmail = user.getEmail();
                String newEmail = uiForm.getUIStringInput("email").getValue();

                // Check if mail address is already used
                Query query = new Query();
                query.setEmail(newEmail);
                if (service.getUserHandler().findUsers(query).getAll().size() > 0 && !oldEmail.equals(newEmail)) {
                    // Be sure it keep old value
                    user.setEmail(oldEmail);
                    Object[] args = { userName };
                    uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args));
                    return;
                }
                user.setFirstName(uiForm.getUIStringInput("firstName").getValue());
                user.setLastName(uiForm.getUIStringInput("lastName").getValue());
                user.setDisplayName(uiForm.getUIStringInput("displayName").getValue());
                user.setEmail(newEmail);
                uiApp.addMessage(new ApplicationMessage("UIAccountProfiles.msg.update.success", null));
                try {
                    service.getUserHandler().saveUser(user, true);
                } catch (Exception e) {
                    uiApp.addMessage(new ApplicationMessage("UIAccountProfiles.msg.update.fail", null, ApplicationMessage.ERROR));
                    return;
                }

                state.setAttribute(CacheUserProfileFilter.USER_PROFILE, user);
                UIWorkingWorkspace uiWorkingWS = Util.getUIPortalApplication().getChild(UIWorkingWorkspace.class);
View Full Code Here

    public static class SaveActionListener extends EventListener<UIAccountChangePass> {
        public void execute(Event<UIAccountChangePass> event) throws Exception {
            UIAccountChangePass uiForm = event.getSource();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIApplication uiApp = context.getUIApplication();
            String username = Util.getPortalRequestContext().getRemoteUser();
            User user = service.getUserHandler().findUserByName(username);
            String currentPass = uiForm.getUIStringInput("currentpass").getValue();
            String newPass = uiForm.getUIStringInput("newpass").getValue();
            String confirmnewPass = uiForm.getUIStringInput("confirmnewpass").getValue();

            Authenticator authenticator = uiForm.getApplicationComponent(Authenticator.class);
            boolean authenticated;
            try {
                UsernameCredential usernameCred = new UsernameCredential(username);
                PasswordCredential passwordCred = new PasswordCredential(currentPass);
                authenticator.validateUser(new Credential[] { usernameCred, passwordCred });
                authenticated = true;
            } catch (Exception ex) {
                authenticated = false;
            }

            if (!authenticated) {
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.currentpassword-is-not-match", null, 1));
                uiForm.reset();
                event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
                return;
            }

            if (!newPass.equals(confirmnewPass)) {
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.password-is-not-match", null, 1));
                uiForm.reset();
                event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
                return;
            }
            try {
                user.setPassword(newPass);
                service.getUserHandler().saveUser(user, true);
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.change.pass.success", null));
                UIAccountSetting ui = uiForm.getParent();
                ui.getChild(UIAccountProfiles.class).setRendered(true);
                ui.getChild(UIAccountChangePass.class).setRendered(false);
                event.getRequestContext().addUIComponentToUpdateByAjax(ui);
            } catch (Exception e) {
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.change.pass.fail", null, ApplicationMessage.ERROR));

            }
            uiForm.reset();
            event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
            return;
View Full Code Here

            OrganizationService service = uiMembership.getApplicationComponent(OrganizationService.class);
            MembershipType mt = service.getMembershipTypeHandler().findMembershipType(name);

            if (mt == null) {
                UIApplication uiApp = event.getRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UIMembershipTypeForm.msg.MembershipNotExist", new String[] { name }));
                uiMembership.loadData();
                return;
            }

            if (mt.getDescription() == null) {
View Full Code Here

            UIMembershipManagement membership = uiMembership.getParent();
            UIMembershipTypeForm uiForm = membership.findFirstComponentOfType(UIMembershipTypeForm.class);

            String existMembershipTypeName = uiForm.getMembershipTypeName();
            if (existMembershipTypeName != null && existMembershipTypeName.equals(name)) {
                UIApplication uiApp = event.getRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UIMembershipList.msg.InUse", null));
                return;
            }

            // Check to see whether given membershiptype is mandatory or not
            UserACL acl = uiMembership.getApplicationComponent(UserACL.class);
            List<String> mandatories = acl.getMandatoryMSTypes();
            if (!mandatories.isEmpty() && mandatories.contains(name)) {
                UIApplication uiApp = event.getRequestContext().getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UIMembershipList.msg.DeleteMandatory", null));
                return;
            }

            OrganizationService service = uiMembership.getApplicationComponent(OrganizationService.class);
            MembershipType membershipType = service.getMembershipTypeHandler().findMembershipType(name);
View Full Code Here

            MembershipType mt = service.getMembershipTypeHandler().findMembershipType(msTypeName);

            if (uiForm.getMembershipTypeName() == null) {
                // For create new membershipType case
                if (mt != null) {
                    UIApplication uiApp = event.getRequestContext().getUIApplication();
                    uiApp.addMessage(new ApplicationMessage("UIMembershipTypeForm.msg.SameName", null));
                    return;
                }
                mt = service.getMembershipTypeHandler().createMembershipTypeInstance();
                uiForm.invokeSetBindingBean(mt);
                service.getMembershipTypeHandler().createMembershipType(mt, true);
                uiMembershipManagement.addOptions(mt);
            } else {
                // For edit a membershipType case
                if (mt == null) {
                    UIApplication uiApp = event.getRequestContext().getUIApplication();
                    uiApp.addMessage(new ApplicationMessage("UIMembershipTypeForm.msg.MembershipNotExist",
                            new String[] { msTypeName }));
                } else {
                    uiForm.invokeSetBindingBean(mt);
                    service.getMembershipTypeHandler().saveMembershipType(mt, true);
                }
View Full Code Here

        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) {
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;
            }
            memberShipHandler.removeMembership(uiForm.membershipId, true);
            memberShipHandler.linkMembership(user, group, membershipType, true);
View Full Code Here

            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) {
View Full Code Here

TOP

Related Classes of org.exoplatform.webui.core.UIApplication

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.