Package org.olat.core.util.coordinate

Examples of org.olat.core.util.coordinate.LockResultImpl


    final String asset = OresHelper.createStringRepresenting(ores, locksubkey);
   
    LockResult res = syncer.doInSync(ores, new SyncerCallback<LockResult>(){
      public LockResult execute() {
        ClusterLockManager cm = ClusterLockManager.getInstance();
        LockResultImpl lres;
        LockImpl li = cm.findLock(asset);
        if (li == null) { // fine, we can lock it
          li = cm.createLockImpl(asset, requestor);
          cm.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;
      }});
   
View Full Code Here


      // lock-holder
      lockOwner = ManagerFactory.getManager().loadIdentityByKey(lockOwnerKey);
    }
   
    LockEntry le = new LockEntry(derivedLockString, aqTime, lockOwner);
    lres = new LockResultImpl(success, le);
    return lres;
   
  }
View Full Code Here

      if (oldLockEntry == null || identity.getName().equals(oldLockEntry.getOwner().getName())) {
        // no one has the lock aquired yet - or user reacquired its own
        // lock (e.g. in case of browser crash or such)
        LockEntry lockEntry = new LockEntry(key, System.currentTimeMillis(), identity);
        locks.put(key, lockEntry);
        lockResult = new LockResultImpl(true, lockEntry);
        if (logDebug) {
          String msg;
          if (oldLockEntry == null) {
            msg = "identity '" + identity.getName() + "' acquired lock on " + key;
          } else {
            msg = "identity '" + identity.getName() + "' re-acquired lock on " + key;
          }
          log.audit(msg);
        }
      } else {
        // already locked
        lockResult = new LockResultImpl(false, oldLockEntry);
      }
    }
    return lockResult;
  }
View Full Code Here

TOP

Related Classes of org.olat.core.util.coordinate.LockResultImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.