use of org.olat.core.util.coordinate.LockEntry in project openolat by klemens.
the class ClusterLocker method adminOnlyGetLockEntries.
public List<LockEntry> adminOnlyGetLockEntries() {
List<LockImpl> li = clusterLockManager.getAllLocks();
List<LockEntry> res = new ArrayList<LockEntry>(li.size());
for (LockImpl impl : li) {
res.add(new LockEntry(impl.getAsset(), impl.getCreationDate().getTime(), impl.getOwner()));
}
return res;
}
use of org.olat.core.util.coordinate.LockEntry in project OpenOLAT by OpenOLAT.
the class ClusterLocker method adminOnlyGetLockEntries.
public List<LockEntry> adminOnlyGetLockEntries() {
List<LockImpl> li = clusterLockManager.getAllLocks();
List<LockEntry> res = new ArrayList<LockEntry>(li.size());
for (LockImpl impl : li) {
res.add(new LockEntry(impl.getAsset(), impl.getCreationDate().getTime(), impl.getOwner()));
}
return res;
}
use of org.olat.core.util.coordinate.LockEntry in project openolat by klemens.
the class ClusterLocker method acquireLock.
@Override
public LockResult acquireLock(final OLATResourceable ores, final Identity requestor, final String locksubkey) {
final String asset = OresHelper.createStringRepresenting(ores, locksubkey);
LockResult res = syncer.doInSync(ores, new SyncerCallback<LockResult>() {
@Override
public LockResult execute() {
LockResultImpl lres;
LockImpl li = clusterLockManager.findLock(asset);
if (li == null) {
// fine, we can lock it
li = clusterLockManager.createLockImpl(asset, requestor);
clusterLockManager.saveLock(li);
LockEntry le = new LockEntry(li.getAsset(), li.getCreationDate().getTime(), li.getOwner());
lres = new LockResultImpl(true, le);
} else {
// already locked by a user.
// if that user is us, we can reacquire it
LockEntry le = new LockEntry(li.getAsset(), li.getCreationDate().getTime(), li.getOwner());
if (requestor.getName().equals(li.getOwner().getName())) {
// that's us -> success (asset, owner is the same, and we leave creationdate to when the lock was originally acquired, not when it was reacquired.
lres = new LockResultImpl(true, le);
} else {
lres = new LockResultImpl(false, le);
}
}
return lres;
}
});
return res;
}
Aggregations