0

In an odd scenario where the creator of a document has explicitly removed all of the administrative groups thereby making the document effectively inaccessible, I am having to manually take control of the restricted document individually using the filenet enterprise manager before I can access the document (even when logged in as admin).

How can I possibly take ownership of a document programatically using either of the FileNet APIs available in version 3.5 APIs?

I am thinking on the lines of setting the owner, applying security template, marking set, etc. however haven't been able to find the right API for it and was wondering if someone has experienced this before and/or would like to share any ideas?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57

1 Answers1

0

Try this to change the owner and set permissions (java). You will need the appropriate permissions on the account you're using to connect to the objectstore and make changes. You will first need to connect to the objectstore. I'm not sure if you need to change the doc class/doc type and then add permissions but I've included this code as well. Please pick and choose what you need.

            // GUID = the unique document id value, os = the connection to your objectstore
        com.filenet.api.admin.ClassDefinition cf = null;
        cf = Factory.ClassDefinition.fetchInstance(os, DocumentClass, null);
        AccessPermissionList apl = cf.get_DefaultInstancePermissions();
        Document doc = Factory.Document.fetchInstance(os, new Id(GUID), null);
        
        //old permission list used to remove old permissions 
        com.filenet.api.admin.ClassDefinition cf_old = null;
        cf_old = Factory.ClassDefinition.fetchInstance(os, doc.getClassName(), null);
        AccessPermissionList apl_old = cf_old.get_DefaultInstancePermissions();
       
       // New DocClass if needed
        doc.changeClass("NewDocClass);
                    
        // set the new doc type if needed
        doc.getProperties().putValue("Your_Symbolic_DOC_TYPE_Name", "NewDocType");

        // Set the new Owner
        doc.set_Owner("NewOwner");
        
        // Wipe out old permissions
        Iterator<AccessPermission> ilist_old = apl_old.iterator();
        AccessPermissionList v_old = doc.get_Permissions();
        while (ilist_old.hasNext()) {
            AccessPermission ap_old = (AccessPermission)ilist_old.next();
            v_old.removeAll(apl_old);
        } 
        // save changes
        doc.save(RefreshMode.REFRESH);  

        // Add the new permissions
        Iterator<AccessPermission> ilist = apl.iterator();
        AccessPermissionList v = doc.get_Permissions();
        while (ilist.hasNext()) {
            AccessPermission ap = (AccessPermission)ilist.next();
            v.add(ap);    
        } 
        // save changes
        doc.save(RefreshMode.REFRESH);
devan777
  • 1
  • 1