Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.UserProfile


   public void testRemoveUserProfile() throws Exception
   {
      createUser(userName);
      createUserProfile(userName);
     
      UserProfile up = upHandler.removeUserProfile(userName, true);
      assertNotNull(up);
      assertEquals(up.getAttribute("key1"), "value1");
      assertEquals(up.getAttribute("key2"), "value2");
      assertNull(upHandler.findUserProfileByName("userP1"));

      // remove not existed profile. We are supposed to get "null" instead of Exception
      try
      {
View Full Code Here


   public void testSaveUserProfile() throws Exception
   {
      createUser(userName);
      createUserProfile(userName);

      UserProfile up = upHandler.findUserProfileByName(userName);
      up.setAttribute("key1", "value11");
      up.setAttribute("key2", null);
      upHandler.saveUserProfile(up, true);

      up = upHandler.findUserProfileByName(userName);
      assertEquals(up.getAttribute("key1"), "value11");
      assertNull(up.getAttribute("key2"));

      // try to save user profile for not existed user
      try
      {
         up = upHandler.createUserProfileInstance(newUserName);
View Full Code Here

        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

   /**
    * Create user with profile.
    */
   protected void createUserProfile(String userName) throws Exception
   {
      UserProfile up = upHandler.createUserProfileInstance(userName);
      Map<String, String> attributes = up.getUserInfoMap();
      attributes.put("key1", "value1");
      attributes.put("key2", "value2");
      upHandler.saveUserProfile(up, true);
   }
View Full Code Here

   public void testFindUserProfileByName() throws Exception
   {
      createUser(userName);
      createUserProfile(userName);

      UserProfile up = upHandler.findUserProfileByName(userName);
      assertNotNull(up);
      assertEquals(userName, up.getUserName());
      assertEquals("value1", up.getAttribute("key1"));
      assertEquals("value2", up.getAttribute("key2"));

      // try to find profile for not existed user. We are supposed to get "null" instead of Exception
      try
      {
         assertNull(upHandler.findUserProfileByName(newUserName));
View Full Code Here

   public void testRemoveUserProfile() throws Exception
   {
      createUser(userName);
      createUserProfile(userName);
     
      UserProfile up = upHandler.removeUserProfile(userName, true);
      assertNotNull(up);
      assertEquals(up.getAttribute("key1"), "value1");
      assertEquals(up.getAttribute("key2"), "value2");
      assertNull(upHandler.findUserProfileByName("userP1"));

      // remove not existed profile. We are supposed to get "null" instead of Exception
      try
      {
View Full Code Here

   public void testSaveUserProfile() throws Exception
   {
      createUser(userName);
      createUserProfile(userName);

      UserProfile up = upHandler.findUserProfileByName(userName);
      up.setAttribute("key1", "value11");
      up.setAttribute("key2", null);
      upHandler.saveUserProfile(up, true);

      up = upHandler.findUserProfileByName(userName);
      assertEquals(up.getAttribute("key1"), "value11");
      assertNull(up.getAttribute("key2"));

      // try to save user profile for not existed user
      try
      {
         up = upHandler.createUserProfileInstance(newUserName);
View Full Code Here

        this.oauthCodec = oauthCodec;
    }

    @Override
    public void preSave(UserProfile userProfile, boolean isNew) throws Exception {
        UserProfile foundUserProfile = userProfileHandler.findUserProfileByName(userProfile.getUserName());
        if(foundUserProfile == null) {
            foundUserProfile = userProfileHandler.createUserProfileInstance(userProfile.getUserName());
        }

        for (OAuthProviderType opt : oauthProviderTypeRegistry.getEnabledOAuthProviders()) {
            String oauthProviderUsername = userProfile.getAttribute(opt.getUserNameAttrName());
            String foundOauthProviderUsername = foundUserProfile.getAttribute(opt.getUserNameAttrName());

            // This means that oauthUsername has been changed. We may need to invalidate current accessToken as well
            if (!Safe.equals(oauthProviderUsername, foundOauthProviderUsername)) {
                OAuthProviderProcessor processor = opt.getOauthProviderProcessor();
                Object currentAccessToken = processor.getAccessTokenFromUserProfile(userProfile, oauthCodec);
View Full Code Here

    public void saveUserProfile(UserProfile profile, boolean broadcast) throws Exception {
        // We need to check if userProfile exists, because organization API is limited and it doesn't have separate methods for
        // "creation" and for "update" of user profile :/
        boolean isNew = true;
        if (broadcast) {
            UserProfile found = getProfile(profile.getUserName());
            isNew = found == null;
        }

        if (broadcast) {
            preSave(profile, isNew);
View Full Code Here

        }

    }

    public UserProfile removeUserProfile(String userName, boolean broadcast) throws Exception {
        UserProfile profile = getProfile(userName);

        if (profile != null) {
            try {
                if (broadcast) {
                    preDelete(profile);
View Full Code Here

TOP

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

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.