Thursday, October 18, 2007

Fixing the Deprecated api exec for Lifecycles

A few months ago I came across a deprecated api that I was trying to use to uninstall a dm_policy or lifecycle. What I needed to do was uninstall the LC apply a new ACL to the LC object and install it. I searched EMC's dev discussions and found a few references to this, but no real solutions. I knew that the App Builder dealt with lifecycles, so I took a look at the DDS.jar files to see if there was something of interest. There was.

Here's the deprecate code I was trying to fix:

obj = (IDfSysObject)m_session.getObject(idObj);
m_objectId = idObj.toString();
// Uninstall this LifeCycle Object
m_session.apiExec("uninstall",m_objectId);
obj.setACLName(sAcl);
IDfACL idAclObj = (IDfACL)(m_session.getObject(getDocbaseObjectIDIfExists
("dm_acl WHERE ( object_name = '" + sAcl + "' )")));
sAclDomain = idAclObj.getDomain();
obj.setACLDomain(sAclDomain);
obj.save();
m_session.apiExec("install",m_objectId);

In the 5.3 DFC eclipse IDE, the "apiExec" was crossed out. I could compile the code, but the runtime environment needed to be very controlled. After digging into the DDS.jar file of the App Builder I fould a "policy" object which looked useful.

The following is the fixed code:

import java.beans.PropertyVetoException;
import com.documentum.policy.data.*;
try{
obj = (IDfSysObject)m_session.getObject(idObj);

m_objectId = idObj.toString();
// Uninstall this LifeCycle Object
IDfPolicy policy = new DfPolicy();
policy.setDocbaseContext(m_session);
try{
policy.open(new DfId(m_objectId), 1);
policy.uninstall();
obj.setACLName(sAcl);
IDfACL idAclObj = (IDfACL)(m_session.getObject
(getDocbaseObjectIDIfExists("dm_acl WHERE ( object_name = '" + sAcl +
"' )")));
sAclDomain = idAclObj.getDomain();
obj.setACLDomain(sAclDomain);
obj.save();
policy.validate();
policy.install();
}catch(IOException ioe){

}catch(PropertyVetoException pve){ }
}catch(DfException e) { }

1 comment:

DV.Ramesh said...

Hi John,
Nice blog with some real good stuff.

Best wishes,
Ramesh