I would like to set all documents to "Lock" setting when users upload a document.
So I created a script at the respective folder where I use the following lines:
The Document Name change works and the Keywords work,
BUT the doc.setLocked(true); does not work.
Why is this? and How can I set Locked to true by default when uploading documents?
Thanks in advance - Govinda
So I created a script at the respective folder where I use the following lines:
Code: Select all
import javax.jcr.*;
import com.openkm.core.*;
import com.openkm.bean.*;
import com.openkm.module.base.*;
import com.openkm.bean.Document;
if (eventType.equals("CREATE_DOCUMENT")) {
String token = JcrSessionManager.getInstance().getSystemToken();
Session session = JcrSessionManager.getInstance().get(token);
Node rootNode = session.getRootNode().getNode(Repository.ROOT);
String docName = com.openkm.util.FileUtils.getName(eventNode.getPath());
String parentDir = com.openkm.util.FileUtils.getParent(eventNode.getPath());
Node myNode = session.getNode(parentDir + "/" + docName);
Document doc = BaseDocumentModule.getProperties(session, myNode);
doc.setLocked(true);
myNode.setProperty(Document.NAME, "Name1.xls");
String[] keywords = {"one", "two"};
myNode.setProperty(Property.KEYWORDS, keywords);
myNode.save();
rootNode.save();
}The Document Name change works and the Keywords work,
BUT the doc.setLocked(true); does not work.
Why is this? and How can I set Locked to true by default when uploading documents?
Thanks in advance - Govinda
