Invalid isNew argument in UserProfile Listener pre / post Save description in EPP 5.2.2 / JPP 6.0.0

Solution Verified - Updated -

Issue

For integration to our backend, we have several Listeners registered to the events of creating and updating these User and UserProfile objects, i.e. classes extending org.exoplatform.services.organization.UserEventListener and org.exoplatform.services.organization.UserProfileEventListener. These are then registered in a conf/portal/configuration.xml

This works, in the sense that the preSave() methods of the respective Listeners get called when a User or UserProfile gets saved. However, the signature of these methods includes a boolean parameter "isNew", which, in the case of UserProfile objects, is ALWAYS true, even if it is an update of an existing UserProfile object.

The cause for this appears to lie in org.exoplatform.services.organization.idm.UserProfileDAOImpl;

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

      if (broadcast)
      {
         preSave(profile, true);
      }

      setProfile(profile.getUserName(), profile);

      if (broadcast)
      {
         postSave(profile, true);
      }

   }

As can be seen in above code snippet, the preSave() method is always called with "true". However, saveUserProfile() is the only available method for persisting UserProfile objects. We need a way to distinguish between new UserProfile creation, and update events of existing UserProfiles in our listeners.

Environment

  • Red Hat JBoss Portal
    • 5.2.2
    • 6.0.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content