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:
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”);
}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”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”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”);