AnsweredAssumed Answered

Script to remove control of a document from its creator?

Question asked by pdoggett on May 15, 2007
Latest reply on Oct 8, 2008 by ljjuarez
What I am trying to do is configure a space into which users can place documents but, once placed, the document ceases to be under the user's control (ie, is no longer editable or deletable by the owner).

I have tried the following, which comes very close:
if (document.isDocument) {
document.removePermission("FullControl","ROLE_OWNER");
document.setOwner("admin");
props = new Array(1);
props["cm:lockType"] = "READ_ONLY_LOCK";
props["cm:lockOwner"] = "admin";
document.addAspect("cm:lockable", props);
}

The 'removePermission' line appears to have no effect.  The creator of the document can still unlock (and hence edit, delete) the document.

I have tried
document.removePermission("Unlock","ROLE_OWNER");
but I suspect that I need something closer to
document.removePermission("Unlock","ROLE_CREATOR");

Is there a way to do this that does not require changing
model/permissionDefinitions.xml?

After the script has been run, the following is shown in the node browser:
Properties
cm:lockOwner == admin
cm:owner == admin
cm:creator == alfuser1
cm:description
cm:lockType = READ_ONLY_LOCK
cm:author == <empty>
cm:modifier == alfuser1

Aspects
cm:ownable
cm:auditable
cm:titled
cm:lockable
{http://www.alfresco.org/model/system/1.0}referenceable
cm:author

Cheers,
Philip

Outcomes