Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.OrganizationService


        res.addCookie(cookie);
    }

    private void saveLocaleToUserProfile(PortalRequestContext context, Locale loc, String user) {
        ExoContainer container = context.getApplication().getApplicationServiceContainer();
        OrganizationService svc = (OrganizationService) container.getComponentInstanceOfType(OrganizationService.class);

        // Don't rely on UserProfileLifecycle loaded UserProfile when doing
        // an update to avoid a potential overwrite of other changes
        UserProfile userProfile = loadUserProfile(container, context);
        if (userProfile != null) {
            userProfile.getUserInfoMap().put(Constants.USER_LANGUAGE, LocaleContextInfo.getLocaleAsString(loc));
            try {
                svc.getUserProfileHandler().saveUserProfile(userProfile, false);
            } catch (Exception ignored) {
                log.error("IGNORED: Failed to save profile for user: " + user, ignored);
                userProfile = null;
            }
        }
View Full Code Here


                return;
            uiApp.setSkin(skin);
            String remoteUser = rContext.getRemoteUser();

            // Save the skin selection to the User Profile
            OrganizationService orgService = event.getSource().getApplicationComponent(OrganizationService.class);
            if (remoteUser != null) {
                UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
                userProfile.getUserInfoMap().put(Constants.USER_SKIN, skin);
                UserProfileHandler hanlder = orgService.getUserProfileHandler();
                hanlder.saveUserProfile(userProfile, true);
            }
        }
View Full Code Here

                requestContext.getUIApplication().addMessage(new ApplicationMessage("UIForgetPassword.msg.expration", null));
                requestContext.addUIComponentToUpdateByAjax(uiPortal.getParent());
                return;
            }

            OrganizationService orgSrc = uiPortal.getApplicationComponent(OrganizationService.class);
            // get user
            User user = orgSrc.getUserHandler().findUserByName(token.getPayload().getUsername());
            if (user == null) {
                requestContext.getUIApplication().addMessage(new ApplicationMessage("UIForgetPassword.msg.user-delete", null));
                return;
            }
View Full Code Here

        return portalLocale;
    }

    private Locale getUserProfileLocale(ExoContainer container, String user) {
        UserProfile userProfile = null;
        OrganizationService svc = (OrganizationService) container.getComponentInstanceOfType(OrganizationService.class);

        if (user != null) {
            try {
                beginContext(svc);
                userProfile = svc.getUserProfileHandler().findUserProfileByName(user);
            } catch (Exception ignored) {
                log.error("IGNORED: Failed to load UserProfile for username: " + user, ignored);
            } finally {
                try {
                    endContext(svc);
View Full Code Here

     */
    public void reloadPortalProperties() throws Exception {
        PortalRequestContext context = Util.getPortalRequestContext();
        String user = context.getRemoteUser();
        String portalSkin = null;
        OrganizationService orgService = getApplicationComponent(OrganizationService.class);

        if (user != null) {
            UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(user);
            if (userProfile != null) {
                portalSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
            } else {
                if (log.isWarnEnabled())
                    log.warn("Could not load user profile for " + user + ". Using default portal locale.");
View Full Code Here

                UIApplication uiApp = context.getUIApplication();
                UIRegisterForm uiRegisterForm = event.getSource();
                PortalRequestContext portalRequestContext = Util.getPortalRequestContext();

                // Save OAuth username as part of user profile of new user
                OrganizationService orgService = uiRegisterForm.getApplicationComponent(OrganizationService.class);
                UserProfileHandler profileHandler = orgService.getUserProfileHandler();
                UserProfile newUserProfile = profileHandler.findUserProfileByName(newUser.getUserName());

                AuthenticationRegistry authRegistry = uiRegisterForm.getApplicationComponent(AuthenticationRegistry.class);
                HttpServletRequest httpRequest = portalRequestContext.getRequest();
                OAuthPrincipal oauthPrincipal = (OAuthPrincipal)authRegistry.getAttributeOfClient(httpRequest, OAuthConstants.ATTRIBUTE_AUTHENTICATED_OAUTH_PRINCIPAL);

                newUserProfile.setAttribute(oauthPrincipal.getOauthProviderType().getUserNameAttrName(), oauthPrincipal.getUserName());
                try {
                    profileHandler.saveUserProfile(newUserProfile, true);
                } catch (OAuthException gtnOAuthException) {
                    // Show warning message if user with this facebookUsername (or googleUsername) already exists
                    // NOTE: It could happen only in case of parallel registration of same oauth user from more browser windows
                    if (gtnOAuthException.getExceptionCode() == OAuthExceptionCode.DUPLICATE_OAUTH_PROVIDER_USERNAME) {

                        // Drop new user
                        orgService.getUserHandler().removeUser(newUser.getUserName(), true);

                        // Clear previous message about successful creation of user because we dropped him. Add message about duplicate oauth username
                        Object[] args = new Object[] {gtnOAuthException.getExceptionAttribute(OAuthConstants.EXCEPTION_OAUTH_PROVIDER_USERNAME),
                                gtnOAuthException.getExceptionAttribute(OAuthConstants.EXCEPTION_OAUTH_PROVIDER_NAME)};
                        ApplicationMessage appMessage = new ApplicationMessage("UIAccountSocial.msg.failed-registration", args, ApplicationMessage.WARNING);
View Full Code Here

    public static class SubscribeActionListener extends EventListener<UIRegisterForm> {
        @Override
        public void execute(Event<UIRegisterForm> event) throws Exception {
            UIRegisterForm registerForm = event.getSource();
            OrganizationService orgService = registerForm.getApplicationComponent(OrganizationService.class);
            UserHandler userHandler = orgService.getUserHandler();
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIRegisterInputSet registerInput = registerForm.getChild(UIRegisterInputSet.class);

            if (registerInput.save(userHandler, context)) {
                // TODO: Add Account Activating feature
View Full Code Here

            }
        }

        private void saveLocaleToUserProfile(PortalRequestContext context) throws Exception {
            ExoContainer container = context.getApplication().getApplicationServiceContainer();
            OrganizationService svc = (OrganizationService) container.getComponentInstanceOfType(OrganizationService.class);

            // Don't rely on UserProfileLifecycle loaded UserProfile when doing
            // an update to avoid a potential overwrite of other changes
            UserProfile userProfile = svc.getUserProfileHandler().findUserProfileByName(context.getRemoteUser());
            if (userProfile != null && userProfile.getUserInfoMap() != null) {
                // Only save if user's locale has not been set
                String currLocale = userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
                if (currLocale == null || currLocale.trim().equals("")) {
                    userProfile.getUserInfoMap().put(Constants.USER_LANGUAGE,
                            LocaleContextInfo.getLocaleAsString(context.getLocale()));
                    svc.getUserProfileHandler().saveUserProfile(userProfile, false);
                }
            }
        }
View Full Code Here

        static final String LISTENER_NAME = "CheckUsernameAvailability";

        @Override
        public void execute(Event<UIRegisterForm> event) throws Exception {
            UIRegisterForm registerForm = event.getSource();
            OrganizationService orgService = registerForm.getApplicationComponent(OrganizationService.class);
            UIRegisterInputSet registerInput = registerForm.getChild(UIRegisterInputSet.class);
            UIFormStringInput userNameInput = registerInput.getUIStringInput(UIRegisterInputSet.USER_NAME);
            List<Validator> validators = userNameInput.getValidators();
            for (Validator validator : validators) {
                try {
View Full Code Here

    public void loadGroups() throws Exception {

        PortalRequestContext pContext = Util.getPortalRequestContext();
        UserPortalConfigService dataService = getApplicationComponent(UserPortalConfigService.class);
        UserACL userACL = getApplicationComponent(UserACL.class);
        OrganizationService orgService = getApplicationComponent(OrganizationService.class);
        final List<String> listGroup = new ArrayList<String>();

        // get all group that user has permission
        if (userACL.isUserInGroup(userACL.getAdminGroups()) && !userACL.getSuperUser().equals(pContext.getRemoteUser())) {
            Collection<?> temp = orgService.getGroupHandler().findGroupsOfUser(pContext.getRemoteUser());
            if (temp != null) {
                for (Object group : temp) {
                    Group m = (Group) group;
                    String groupId = m.getId().trim();
                    listGroup.add(groupId);
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.