Watch for deprecated methods in the G6 server API

We’re doing a G6 upgrade at one of our customer sites and we noticed that one of our PEIs (that used to set a user preference) was dying due to our use of APIs that worked in 5.0.4 but no longer work in G6.

(Just for the record, I guess I have a different idea of the meaning of deprecated when it comes to APIs. I thought that if you deprecate an API it means “please don’t use this as it might be removed in future versions of the API.” For BEA AquaLogic, I guess it means “this method just doesn’t work any more.”)

Here’s an example: AddPersonalSetting has been replaced by AddPreference.

public Redirect OnAfterLogin(Object userSession, ApplicationData applicationData)
{
IPTSession session = ((IPTSession)userSession);
session.GetMyPages().OpenPage(0 - userId)
.AddPersonalSetting("UserSettingName", "UserSettingValue");
}

Here’s the new G6 way to do this:

public Redirect OnAfterLogin(Object userSession, ApplicationData applicationData)
{
IPTSession session = ((IPTSession)userSession);
session.GetSessionInfo()
.AddPreference("UserSettingName", "UserSettingValue", 0);
}

3 Replies to “Watch for deprecated methods in the G6 server API”

  1. Chris,

    There is no API for the data in that table – you will need to write a DB script to convert the pref names that have the old page id in them.

    Jane

  2. Hi Jane,

    Thanks for setting the record straight. So the API is deprecated, but it still works as long as you don’t use the 0 – userId hack to get the user’s default MyPage.

    That makes sense given the conversion to pages as real IPTObjects.

    While we’re on that subject, I noticed that there is now a table called PTPAGEIDMAP with mappings from the old PageIds to the new page ObjectIds. This table appears to be populated with data only if you did an upgrade.

    We used to tell people back in 5.0.x that it was a good idea to append the PageId on to the end of the names of their portlet settings if they wanted to create page-level settings. Obviously these settings are now broken. Is there an API call (remote or native) that can map an old PageId to a new page ObjectId? Or do we need to run a database script to convert the setting names? (We’re leaning toward the latter.)

    Thanks!
    Chris

  3. This is actually incorrect – the API didn’t change, AddPersonalSetting is still available on IPTMyPortal interface.
    However, the fact that the user’s default mypage is always the negative of his/her user id has changed – and that was never a “supported” API, just a hack that happenned to work. (that change had to happen in order to support pages as objects feature)
    -JaneD

Leave a Reply