It's all about the answers!

Ask a question

How to retire a lifecycle asset using java api?

Manjiri Kamat (5132325) | asked Jan 28 '13, 11:26 p.m.
I have a lifecycle asset which is in the approved state.
In order to retire it using the java api i used the actions available on the asset.
After setting the action as retire it goes to the pre retired state,so i tried setting the same action again but that did not make any difference.

Code snippet used :
    for (RAMAction action : actions) {
                if (action.getName() != null
                        && RAMConfig.RETIRE_ACTION.equalsIgnoreCase(action
                                .getName())) {
                    session.put(asset, new RAMStatusMonitor());
                    session.put(asset, new RAMStatusMonitor());
Could you please tell me if this is not correct?

Manjiri Kamat commented Jan 28 '13, 11:43 p.m.

I just tried using RAMAction.RETIRE followed by RAMAction.Archive for the asset it did set the asset to retired.
I believe we should use this for a lifecycle asset and use the available action of the asset only when the asset is in pre retired to set it to retired.

Do let me know if my understanding is correct?

2 answers

permanent link
Rich Kulp (3.6k38) | answered Jan 29 '13, 10:41 a.m.
RAMAction.RETIRE and RAMAction.Archive are only valid for legacy assets. These do not work on lifecycle assets.

For lifecycle assets you have to use available actions. But after every put of an asset you need to get the available actions again since the set of available actions is different for every state of the asset. When you move into a new state, such as pre-retire there is a new set of available actions that you must use. The old set is now invalid.

permanent link
Gili Mendel (1.8k56) | answered Jan 30 '13, 8:05 a.m.
Typically this is the way you do it:

        RAMSession session = null;
        try {
            session = new RAMSession(RAM_URL, RAM_UID, RAM_PASSWD);
            RAMAsset asset = session.getAsset(new AssetIdentification(RAM_GUID, RAM_VER));
            if (asset == null) {
                System.out.println("Could not find Asset("+RAM_GUID+","+RAM_VER+")");
            RAMAction[] actions = asset.getAvailableActions();
            RAMAction action = null;
            for (int i = 0; i < actions.length; i++) {
                // Note taht RAMAction.RETIRE is a legacy action,
                // but its name and the name for the typical lifecycle is the same
                if (actions[i].getName().equals(RAMAction.RETIRE.getName()))
                    action = actions[i];
            if (action!=null) {
                System.out.println("Driving Action: "+action.getName());
                session.put(asset, new NullProgressMonitor());
                System.out.println(RAMAction.RETIRE+" is not available");
        catch (Throwable e) {
        finally {
          if (session != null)

Note also that there is a defect around driving a retire from API:  Java API to retire an asset (drive the Retire action) will not work properly (79583)

Check your ramDebug.log for exception ... if you get one when you drive this API and require this fix. Contact IBM's service and support.

Manjiri Kamat commented Jan 30 '13, 10:44 p.m.

Hi Gill,

Thanks for the reply.
I was able to get it working the way Rich suggested.
Could you please elaborate more on the defect that you mentioned as i could not get a clear picture of it from the description mentioned in the defect?


Rich Kulp commented Jan 31 '13, 9:43 a.m. | edited Jan 31 '13, 5:02 p.m.

There is a bug in the Retire didn't work for lifecycle assets. It threw an exception on the host.

Manjiri Kamat commented Feb 01 '13, 1:44 a.m.

Can you tell me what exception i should look for?

Gili Mendel commented Feb 01 '13, 9:05 a.m.

Drive the retire action, and to to the Administrator -> tools, and click on the ramDebug.log ... scroll down to the bottom.  See if you have a new "present" for ya.

Manjiri Kamat commented Feb 03 '13, 11:19 p.m.

There was no such thing in the logs after driving the retire action.
So does this mean we are good or do we still need the fix to be applied so that in future we don't encounter this problem?

Gili Mendel commented Feb 04 '13, 11:15 a.m.

If you have no exceptions in the log after driving the action, and asset indeed moves to the retire state; you are fine.

Manjiri Kamat commented Feb 06 '13, 12:12 a.m.

Thanks Gili.

showing 5 of 7 show 2 more comments

Your answer

Register or to post your answer.