Updating a user’s WebCenter Profile programmatically

There are many details stored in a user’s profile and sometimes it needs to be controlled what is updated and how. This means that using the standard edit capability in the WebCenter profile screen isn’t possible.

To get around this you can create a custom taskflow that that permits and validates the changes to the profile. The challenge that I found when working on this was how to get the user’s profile, update it and get WebCenter to invalidate the cached profile object that it had stored.

Whilst hunting through the APIs I found a WCUserProfile class that looked like it fitted my needs and also it had a save(); method on the object. I had a go at retrieving the profile and updating it then calling save(); and it worked.

  private void updateAndSaveUserProfileChanges(String username) throws ProfileException {
    WCUserProfile userProfile = this.userProfileManager.getProfileForUpdate(username);

Note that getProfileForUpdate was used to get the WCUserProfile object, there is another getProfile command without the update. I opted for the getProfileForUpdate because I was updating it but the JavaDoc wasn’t too helpful I found.

The one thing I haven’t solved with this change is the About screen in WebCenter still has cached content in the user’s session. Logging out and back in clears this and the About page in the User’s Profile then shows the updated information.

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s