Package org.exoplatform.webui.core

Examples of org.exoplatform.webui.core.UIApplication


                userProfile.getUserInfoMap().put(uiInput.getName(), uiInput.getValue());
            }
        }

        WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
        UIApplication uiApp = context.getUIApplication();

        try {
            hanlder.saveUserProfile(userProfile, true);
        } catch (OAuthException gtnOauthOAuthException) {
            // Show warning message if user with this facebookUsername (or googleUsername) already exists
            if (gtnOauthOAuthException.getExceptionCode() == OAuthExceptionCode.DUPLICATE_OAUTH_PROVIDER_USERNAME) {
                addOAuthExceptionMessage(context, gtnOauthOAuthException, uiApp);
                return false;
            } else {
                throw gtnOauthOAuthException;
            }
        }

        Object[] args = { "UserProfile", user_ };
        if (isnewUser) {
            uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.successful.create.user", args));
            return true;
        }
        uiApp.addMessage(new ApplicationMessage("UIUserProfileInputSet.msg.sucsesful.update.userprofile", args));
        return true;
    }
View Full Code Here


    public static class SearchUserActionListener extends EventListener<UIAccountForm> {
        public void execute(Event<UIAccountForm> event) throws Exception {
            UIAccountForm uiForm = event.getSource();
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIApplication uiApp = context.getUIApplication();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            UIFormStringInput usernameInput = uiForm.getChild(UIAccountInputSet.class).getUIStringInput(
                    UIAccountInputSet.USERNAME);
            for (Validator validator : usernameInput.getValidators()) {
                try {
                    validator.validate(usernameInput);
                } catch (MessageException e) {
                    uiApp.addMessage(e.getDetailMessage());
                    return;
                }
            }

            String userName = usernameInput.getValue();
            if (service.getUserHandler().findUserByName(userName) != null) {
                uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-exist", null, ApplicationMessage.WARNING));
                return;
            }
            uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-not-exist", null, ApplicationMessage.INFO));
        }
View Full Code Here

        getUIStringInput(USERNAME).setReadOnly(true);
    }

    public boolean save(OrganizationService service, boolean newUser) throws Exception {
        WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
        UIApplication uiApp = context.getUIApplication();
        String pass1x = getUIStringInput(PASSWORD1X).getValue();
        String pass2x = getUIStringInput(PASSWORD2X).getValue();
        if (!pass1x.equals(pass2x)) {
            uiApp.addMessage(new ApplicationMessage("UIAccountForm.msg.password-is-not-match", null, ApplicationMessage.ERROR));
            return false;
        }
        String username = getUIStringInput(USERNAME).getValue();
        if (newUser) {
            User user = service.getUserHandler().createUserInstance(username);
            invokeSetBindingField(user);
            // user.setPassword(Util.encodeMD5(pass1x)) ;
            if (service.getUserHandler().findUserByName(user.getUserName()) != null) {
                Object[] args = { user.getUserName() };
                uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-exist", args, ApplicationMessage.ERROR));
                return false;
            }

            Query query = new Query();
            query.setEmail(getUIStringInput("email").getValue());
            if (service.getUserHandler().findUsers(query).getAll().size() > 0) {
                Object[] args = { user.getUserName() };
                uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args, ApplicationMessage.ERROR));
                return false;
            }

            service.getUserHandler().createUser(user, true);
            reset();
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));
                service.getUserHandler().saveUser(user, true);

                state.setAttribute(CacheUserProfileFilter.USER_PROFILE, user);
                UIWorkingWorkspace uiWorkingWS = Util.getUIPortalApplication().getChild(UIWorkingWorkspace.class);
                uiWorkingWS.updatePortletsByName("UserInfoPortlet");
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;
            }
            user.setPassword(newPass);
            uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.change.pass.success", null));
            service.getUserHandler().saveUser(user, true);
            uiForm.reset();
            event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
            UIAccountSetting ui = uiForm.getParent();
            ui.getChild(UIAccountProfiles.class).setRendered(true);
View Full Code Here

        String key = getKey(context);
        if (session != null) {
            appState = (ApplicationState) session.getAttribute(APPLICATION_ATTRIBUTE_PREFIX + key);
        }

        UIApplication uiapp = null;
        if (appState != null) {
            if (log.isDebugEnabled()) {
                log.debug("Found application " + key + " :" + appState.getApplication());
            }
            if (Safe.equals(context.getRemoteUser(), appState.getUserName())) {
View Full Code Here

        return uiapp;
    }

    @Override
    public void storeUIRootComponent(final WebuiRequestContext context) throws Exception {
        UIApplication uiapp = context.getUIApplication();

        //
        if (uiapp != null) {
            HttpSession session = getSession(context);
View Full Code Here

            UIAccountSocial uiForm = event.getSource();

            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            PortalRequestContext prContext = Util.getPortalRequestContext();
            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) {
                UserProfile userProfile = (UserProfile)prContext.getAttribute(UserProfileLifecycle.USER_PROFILE_ATTRIBUTE_NAME);

                String unlinkProviderKey = prContext.getRequestParameter(PARAM_PROVIDER_FOR_UNLINK);
                OAuthProviderType<AccessTokenContext> oauthProviderTypeToUnlink = uiForm.getApplicationComponent(OAuthProviderTypeRegistry.class).getOAuthProvider(unlinkProviderKey, AccessTokenContext.class);

                // Obtain current accessToken
                AccessTokenContext accessToken = uiForm.getApplicationComponent(SocialNetworkService.class).getOAuthAccessToken(oauthProviderTypeToUnlink, userName);

                // Unlink social account in userProfile (AccessTokenInvalidationListener will automatically remove accessToken)
                if (oauthProviderTypeToUnlink != null) {
                    userProfile.setAttribute(oauthProviderTypeToUnlink.getUserNameAttrName(), null);
                } else {
                    log.warn("Social account field to unlink not found");
                }
                service.getUserProfileHandler().saveUserProfile(userProfile, true);

                // Revoke accessToken remotely
                if (accessToken != null) {
                    try {
                        oauthProviderTypeToUnlink.getOauthProviderProcessor().revokeToken(accessToken);
                    } catch (OAuthException oe) {
                        if (OAuthExceptionCode.TOKEN_REVOCATION_FAILED.equals(oe.getExceptionCode())) {
                            Throwable t = oe.getCause() != null ? oe.getCause() : oe;
                            ApplicationMessage appMessage = new ApplicationMessage("UIAccountSocial.msg.failed-revoke", null, ApplicationMessage.WARNING);
                            appMessage.setArgsLocalized(false);
                            uiApp.addMessage(appMessage);
                            log.warn("Revocation of accessToken failed for user " + userName + ". Details: " + t.getClass() + ": " + t.getMessage());
                        } else {
                            throw oe;
                        }
                    }
                }

                Object[] args = { oauthProviderTypeToUnlink.getFriendlyName(), userName};
                ApplicationMessage appMessage = new ApplicationMessage("UIAccountSocial.msg.successful-unlink", args);
                appMessage.setArgsLocalized(false);
                uiApp.addMessage(appMessage);

                prContext.setAttribute(UserProfileLifecycle.USER_PROFILE_ATTRIBUTE_NAME, userProfile);
                uiForm.updateUIFields();
                prContext.addUIComponentToUpdateByAjax(uiForm);
View Full Code Here

      {
         for (ApplicationLifecycle<RequestContext> lifecycle : getApplicationLifecycle())
         {
            lifecycle.onStartRequest(this, context);
         }
         UIApplication uiApp = getStateManager().restoreUIRootComponent(context);
         context.setUIApplication(uiApp);
         uiApp.processDecode(context);
         if (!context.isResponseComplete() && !context.getProcessRender())
         {
            uiApp.processAction(context);
         }
      }
      finally
      {
         context.setProcessAction(true);
View Full Code Here

      {
         for (ApplicationLifecycle<RequestContext> lifecycle : getApplicationLifecycle())
         {
            lifecycle.onStartRequest(this, context);
         }
         UIApplication uiApp = getStateManager().restoreUIRootComponent(context);
         context.setUIApplication(uiApp);
         javax.portlet.Event portletEvent = req.getEvent();
         context.setAttribute(PORTLET_EVENT_VALUE, portletEvent.getValue());
         Event<UIComponent> uiEvent = uiApp.createEvent(portletEvent.getName(), Phase.PROCESS, context);
         uiEvent.broadcast();
      }
      finally
      {
         WebuiRequestContext.setCurrentInstance(parentAppRequestContext);
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.