Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.UserProfileHandler


         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


         }
         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)
               return;
View Full Code Here

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

                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);

                if (newUserProfile == null) {
                    newUserProfile = orgService.getUserProfileHandler().createUserProfileInstance(newUser.getUserName());
                }
                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) {
View Full Code Here

                UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
                if(userProfile == null) {
                    userProfile = orgService.getUserProfileHandler().createUserProfileInstance(remoteUser);
                }
                userProfile.getUserInfoMap().put(Constants.USER_SKIN, skin);
                UserProfileHandler hanlder = orgService.getUserProfileHandler();
                hanlder.saveUserProfile(userProfile, true);
            }
        }
View Full Code Here

        }
    }

    @SuppressWarnings("deprecation")
    public boolean save(OrganizationService service, String user, boolean isnewUser) throws Exception {
        UserProfileHandler hanlder = service.getUserProfileHandler();
        UserProfile userProfile = hanlder.findUserProfileByName(user);

        if (userProfile == null) {
            userProfile = hanlder.createUserProfileInstance();
            userProfile.setUserName(user);
        }

        for (UIComponent set : getChildren()) {
            UIFormInputSet inputSet = (UIFormInputSet) set;
            for (UIComponent uiComp : inputSet.getChildren()) {
                UIFormStringInput uiInput = (UIFormStringInput) uiComp;
                // if(uiInput.getValue() == null || uiInput.getValue().length() < 1)
                // continue;
                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;
View Full Code Here

        "getUserProfileAttributes",
        " Trying to load user attributes for user with unique identifer '" + userUniqueIdentifier +"'.");
    // load the exo user profile attributes into a tenmporary hashmap
    HashMap exoProfileAttrs = new HashMap();
    HashMap userAttributes = new HashMap();
    UserProfileHandler userProfileHandler = service.getUserProfileHandler();
    if (userProfileHandler==null) {
      SpagoBITracer.warning(SpagoBIConstants.NAME_MODULE, SecurityProviderUtilities.class.getName(),
                        "getUserProfileAttributes", " UserProfileHandler null");
    } else {
      UserProfile exoUserProfile = null;
      try {
        exoUserProfile = userProfileHandler.findUserProfileByName(userUniqueIdentifier);
      } catch (Exception e) {
        SpagoBITracer.critical(SpagoBIConstants.NAME_MODULE, SecurityProviderUtilities.class.getName(),
                        "getUserProfileAttributes", " Error while recovering user profile by name '"
                        + userUniqueIdentifier + "'", e);
        return userAttributes;
View Full Code Here

         String remoteUser = event.getRequestContext().getRemoteUser();
         if (remoteUser != null)
         {
            UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
            userProfile.getUserInfoMap().put("user.language", language);
            UserProfileHandler hanlder = orgService.getUserProfileHandler();
            hanlder.saveUserProfile(userProfile, true);
         }
      }
View Full Code Here

    }

    @SuppressWarnings("deprecation")
    public void save(OrganizationService service, String user, boolean isnewUser) throws Exception {

        UserProfileHandler hanlder = service.getUserProfileHandler();
        UserProfile userProfile = hanlder.findUserProfileByName(user);

        if (userProfile == null) {
            userProfile = hanlder.createUserProfileInstance();
            userProfile.setUserName(user);
        }

        for (UIComponent set : getChildren()) {
            UIFormInputSet inputSet = (UIFormInputSet) set;
            for (UIComponent uiComp : inputSet.getChildren()) {
                UIFormStringInput uiInput = (UIFormStringInput) uiComp;
                // if(uiInput.getValue() == null || uiInput.getValue().length() < 1)
                // continue;
                userProfile.getUserInfoMap().put(uiInput.getName(), uiInput.getValue());
            }
        }

        hanlder.saveUserProfile(userProfile, true);

        Object[] args = { "UserProfile", user };
        WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
        UIApplication uiApp = context.getUIApplication();
View Full Code Here

    }

    @Override
    public <T extends AccessTokenContext> void updateOAuthAccessToken(OAuthProviderType<T> oauthProviderType, String username, T accessToken) {
        try {
            UserProfileHandler userProfileHandler = orgService.getUserProfileHandler();
            UserProfile userProfile = userProfileHandler.findUserProfileByName(username);

            OAuthProviderProcessor<T> oauthProviderProcessor = oauthProviderType.getOauthProviderProcessor();
            oauthProviderProcessor.saveAccessTokenAttributesToUserProfile(userProfile, this, accessToken);

            userProfileHandler.saveUserProfile(userProfile, true);
        } catch (OAuthException oauthEx) {
            throw oauthEx;
        } catch (Exception e) {
            throw new OAuthException(OAuthExceptionCode.PERSISTENCE_ERROR, e);
        }
View Full Code Here

TOP

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

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.