When you work with folders in FileNet and managing documents within, it can make sense to inherit the security of the folder to the documents that are filed in. For that the “SecurityFolder” property was introduced and could be used on the docuemnts classes. In the next chapter I will guide you how to setup an event action that will automatic set the SecurityFolder property to your documents, so that you can use this for creation update or change actions.
The following JavaScript code is solely provided as a sample without any expressed or implied warranty. It is used to create an asynchronous Event Action that is tied to a Subscription that triggers on the Checkin event or Creation event. When a document is checked in, the script retrieves the list of properties, specifically the FoldersFiledIn property. If there are multiple folders, only the first one is retrieved. It then sets the value of the Security Folder property to the folder retrieved. Messages are also printed to SystemOut.log when the operation succeeds or fails to locate a folder or if it encounters an exception. When the SecurityFolder property is set to a certain folder, any security at the folder level that is set to propagate to childen objects, will propagate to the respective documents with the Source field indicating ‘Inherited’ as opposed to ‘Direct’.
importPackage(java.lang);
importClass(Packages.com.filenet.api.engine.EventActionHandler);
importClass(Packages.com.filenet.api.util.Id);
importPackage(Packages.com.filenet.api.events);
importPackage(Packages.com.filenet.api.property);
importPackage(Packages.com.filenet.api.security);
importPackage(Packages.com.filenet.api.core);
importPackage(Packages.com.filenet.api.constants);
importClass(java.lang.System);
function onEvent(event, subId)
{
try {
var oDoc, oProps, oRCR, oFolders, oFol, iter
oDoc = Factory.Document.fetchInstance(event.getObjectStore(),event.get_SourceObjectId() ,null);
oProps = oDoc.getProperties();
oFolders = oProps.getIndependentObjectSetValue("FoldersFiledIn");
iter = oFolders.iterator();
if (oFolders.isEmpty()) {
System.out.println("Skipped Security Folder Document = " + oProps.getIdValue("ID").toString());
}
else {
oFol= iter.next();
oProps.putObjectValue ("SecurityFolder",oFol);
oDoc.save (RefreshMode.REFRESH);
System.out.println("Set SecurityFolder Document = " + oProps.getIdValue("ID").toString() + " , Folder = " + oFol.get_FolderName());
}
}
catch (e) {
System.out.println("Failed SecurityFolder Document = " + oProps.getIdValue("ID").toString());
throw new RuntimeException(e);
}
}
Go to the Administrative Console for Content Platform Engine and create the new event action.
Now create a subscription to launch the event action whenever a document is checked-in or created in your required document class.
Be sure that the subscription runs asynchronously and the checkin and creation event are selected.
Now we create a new folder to test the security inheritance.
Now we set the required permissions on the folders security tab.
Keep in mind that only permission user/groups are inherited where the apply level is a child level
When you now add a document to the folder you will see that the security of the folder in inherited to the document.
Now you can see the inherited permissions on the documents security tab.
And the SecurityFolder property is set to the folder filed in.