If you try to create a copy of an ACL template (which has alias references) using the method saveAsNew(), you will receive an error like this:
2011-12-02 11:53:01,138 ERROR [main] com.mycompany.documentum.job.method - [DM_ACL_E_USER_NOT_EXIST]error: "The owner_name or accessor_name '%alias' given in the ACL 'myACL' does not exist."
DfException:: THREAD: main; MSG: [DM_ACL_E_USER_NOT_EXIST]error: "The owner_name or accessor_name '%alias' given in the ACL 'myACL' does not exist."; ERRORCODE: 100; NEXT: null
This is caused by a bug in DFC method saveAsNew() of DfACL - it does not copy the value of attribute acl_class, which defines the ACL type (template, regular, etc.)
So you have to make a clone with custom code, something like this:
public IDfACL cloneACL(IDfACL acl, String name) throws DfException {
IDfACL copy = (IDfACL) acl.getSession().newObject("dm_acl");
copy.setObjectName(acl.getObjectName());
copy.setDescription(acl.getDescription());
copy.setString("owner_name", acl.getString("owner_name"));
copy.setACLClass(acl.getACLClass());
for (int i = 0; i < acl.getAttrCount(); i++) {
if (acl.getAttr(i).isRepeating()) {
String attrName = acl.getAttr(i).getName();
for (int j = 0; j < acl.getValueCount(attrName); j++) {
copy.setRepeatingValue(attrName, j, acl.getRepeatingValue(attrName, j));
}
}
}
copy.save();
return copy;
}