Uploaded image for project: 'GateIn Portal'
  1. GateIn Portal
  2. GTNPORTAL-3013

UserProfileDAOImpl not distinguishing creating and updating user profile when firing preSave/postSave events

    Details

      Description

      org.exoplatform.services.organization.idm.UserProfileDAOImpl; the following is a code excerpt of the file included in the community version of the Maven artefact org.exoplatform.portal:exo.portal.component.identity:3.3.0-GA

      // void createUserProfileEntry(UserProfile up, IdentitySession session) throws Exception
      //

      { // UserProfileData upd = new UserProfileData(); // upd.setUserProfile(up); // session.save(upd); // session.flush(); // cache_.remove(up.getUserName()); // }

      public void saveUserProfile(UserProfile profile, boolean broadcast) throws Exception
      {

      if (broadcast)

      { preSave(profile, true); }

      setProfile(profile.getUserName(), profile);

      if (broadcast)

      { postSave(profile, true); }

      }

      As you can see, the preSave() method is always called with "true". However, saveUserProfile() is the only available method for persisting UserProfile objects. From the commented-out createUserProfileEntry() method, I draw the conclusion that at some point, there was a distinction between methods to call for new and existing UserProfiles (just as there is for Users in the UserDAOImpl in the same package - there are a createUser() and a saveUser()).

      Where all this breaks down is in the listeners; upon saving the UserProfile, I want to send either a save or an update message over JMS to a SOA-P application that transforms the message and forwards it to a mainframe application that needs to know about user creation and modification. I need to pick the correct message format, but as it turns out, I can't use the isNew parameter to reliably determine which one to choose.

      I have tried to work around the problem by creating the UserProfile first and the User second, and sync from the User Listener, since the User preSave() does receive a correct value for isNew; however, Hibernate won't let me: new UserProfiles can not be saved if the User they are associated with does not yet exist in the database; they are a dependent entity.

      Can you provide a version of the Identity Component that can distinguish between updating and saving UserProfile objects, or a suitable workaround to that end?

      Version-Release number of selected component (if applicable):
      EPP 5
      JPP 6

      How reproducible:
      always

      Steps to Reproduce:
      please see attached customer case

      Actual results:
      true as the parameter even with update

      Expected results:
      true/false depending on create or update

      Additional info:

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mposolda Marek Posolda
                Reporter:
                mposolda Marek Posolda
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: