13.2.6. Locking and Unlocking Objects

Engineering Knowledge Manager

Administration Guide | Chapter 13: EKM Client API | 13.2. Using the Library in Client Applications |

13.2.5. Checking Permissions |  | 13.2.7. Version Control
Prev |  | Next

### 13.2.6. Locking and Unlocking Objects

Since objects in the EKM repository can be accessed by any number of users, some users may wish to ensure they have exclusive control of an object before modifying it. One of the easiest ways to do this is to lock the object before modifying it. The library provides operations for both locking and unlocking objects so that the user can gain exclusive use of the object. When locking or unlocking an object, you must specify if any children of the object should be locked as well. The following shows examples of locking and unlocking an object:

Java

      ModelObject folder = dm.createFolder("/Data/My Data", "My Projects");
      if (dm.lock(folder.getPath(), true)) {
          try {
              // Modify the folder
          } finally {
              dm.unlock(folder.getPath(), true);
          }
      } else {
          System.err.println(“>>> Unable to lock the folder for exclusive use”);
      }

Python (Jython)

      folder = dm.createFolder("/Data/My Data", "My Projects")
      if dm.lock(folder.getPath(), True):
          try:
              # Modify the folder
          finally:
              dm.unlock(folder.getPath(), True)
      else:
          print “>>>> Unable to lock the folder for exclusive use”

Python (IronPython)

      folder = dm.CreateFolder("/Data/My Data", "My Projects")
      if dm.Lock(folder.getPath(), True):
          try:
              # Modify the folder
          finally:
              dm.Uunlock(folder.getPath(), True)
      else:
          print “>>>> Unable to lock the folder for exclusive use”

C#

      ModelObject folder = dm.CreateFolder("/Data/My Data", "My Projects");
      if (dm.Lock(folder.getPath(), true))
      {
          try
          {
              // Modify the folder
          }
          finally
          {
              dm.Unlock(folder.getPath(), true);
          }
      }
      else
          Console.WriteLine(“>>>> Unable to lock folder for exclusive use”);

Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Prev | Up / Contents | Next

Release 18.2 - © ANSYS, Inc. All rights reserved.