/** * for admin purposes only. Release a lockentry directly. Use 'releaseLock' as method to release a * lock. * * @param lock release this lockentry */ @Override public void releaseLockEntry(final LockEntry lockEntry) { final String asset = lockEntry.getKey(); final OLATPrincipal releaseRequestor = lockEntry.getOwner(); // cluster:: change to useage with syncer, but we don't have the // olatresourceable yet pessimisticLockManager.findOrPersistPLock(asset); final LockImpl li = clusterLockManager.findLock(asset); if (li == null) { // do nothing - since this lock may have been one that was cleared // when restarting the vm } else { // check that entry was previously locked by the same user that now // wants to release the lock. final OLATPrincipal ownwer = li.getOwner(); if (releaseRequestor.equals(ownwer)) { // delete the lock clusterLockManager.deleteLock(li); } else { throw new AssertException( "cannot release lock since the requestor of the release (" + releaseRequestor.getName() + ") is not the owner (" + ownwer.getName() + ") of the lock (" + asset + ")"); } } }
@Override public List<LockEntry> adminOnlyGetLockEntries() { final List<LockImpl> li = clusterLockManager.getAllLocks(); final List<LockEntry> res = new ArrayList<LockEntry>(li.size()); for (final LockImpl impl : li) { res.add(new LockEntry(impl.getAsset(), impl.getCreationDate().getTime(), impl.getOwner())); } return res; }