Locking and Unlocking a KM Document
Use
When two users work simultaneously with the same document, you can lock and unlock the document by implementing code in the application service of your composite application.
Procedure
- Create a new application:
More information: Creating Composite Application Development Components
- Create an application service in your application:
More information: Creating Application Services
- Set dependency to DocContent, Document, and RelatedObject:
More information: Defining Application Service Dependencies
- To lock or unlock you document, import the following code in the implementation of the application service you have created:
/* You should provide an integer value that indicates the type of the locking and the scope of the locking lockType can be one of the following: 1 - Read Lock 2 - Write Lock lockScope can be one of the following: 1 - Shared Lock 2 - Exclusive Lock timeout should be an integer value, that indicates the timeout in milliseconds */ int lockType = 1; int lockScope = 2; int timeout = 100000; String token = docContentLocal.lockDocument( rid,lockType,lockScope,timeout); - To release a newly obtained lock or all locks, import the following code:
docContentLocal.unlockDocumentWithToken(rid, token); docContentLocal.unLockDocument(rid);
- To check whether a document is locked, import the following code:
docContentLocal.isDocumentLocked(rid));