Package org.olat.core.util.coordinate

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


 
 
  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>(){
      public LockResult execute() {
        ClusterLockManager cm = ClusterLockManager.getInstance();
        LockResultImpl lres;
        LockImpl li = cm.findLock(asset);
        if (li == null) { // fine, we can lock it
View Full Code Here


    }
    return res;
  }
 
  public LockResult aquirePersistentLock(final OLATResourceable ores, final Identity ident, final String locksubkey) {
    LockResult res = syncer.doInSync(ores, new SyncerCallback<LockResult>(){
      public LockResult execute() {
        if (plm == null) { // lazy init because the impl is not defined in the core spring config
          plm = (PersistentLockManager) CoreSpringFactory.getBean(PersistentLockManager.class);
        }
        LockResult ares = plm.aquirePersistentLock(ores, ident, locksubkey);
        return ares;
      }
    });
    return res;
  }
View Full Code Here

   * @see org.olat.core.util.locks.PersistentLockManager#aquirePersistentLock(org.olat.core.id.OLATResourceable,
   *      org.olat.core.id.Identity, java.lang.String)
   */
  public LockResult aquirePersistentLock(OLATResourceable ores, Identity ident, String locksubkey) {
    //synchronisation is solved in the LockManager
    LockResult lres;
    PropertyManager pm = PropertyManager.getInstance();
    String derivedLockString = OresHelper.createStringRepresenting(ores, locksubkey);
    long aqTime;
    Identity lockOwner;
    boolean success;
View Full Code Here

    String repositorySoftkey = (String) moduleConfiguration.get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, true);
    if (CoordinatorManager.getCoordinator().getLocker().isLocked(re.getOlatResource(), null)){
      Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
      //so this resource is locked, let's find out who locked it
      LockResult lockResult = CoordinatorManager.getCoordinator().getLocker().acquireLock(re.getOlatResource(), ureq.getIdentity(), null);
      return MessageUIFactory.createInfoMessage(ureq, wControl, translator.translate("status.currently.locked.title"),
          translator.translate("status.currently.locked", new String[] {lockResult.getOwner().getName()}));
    }else{
      ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(re, OlatResourceableType.iq));
      return new IQDisplayController(moduleConfiguration, secCallback, ureq, wControl, callingResId, callingResDetail);
    }
  }
View Full Code Here

   */
  public LockResult acquireLock(OLATResourceable feed, Identity identity) {
    // OLATResourceable itemLock =
    // OresHelper.createOLATResourceableInstance("podcastlock_" +
    // feed.getResourceableId() + "_meta", item.getId())
    LockResult lockResult = CoordinatorManager.getCoordinator().getLocker().acquireLock(feed, identity, null);
    return lockResult;
  }
View Full Code Here

   *      org.olat.modules.webFeed.models.Item, org.olat.core.id.Identity)
   */
  public LockResult acquireLock(OLATResourceable feed, Item item, Identity identity) {
    String key = itemKey(item, feed);
    OLATResourceable itemResource = OresHelper.createOLATResourceableType(key);
    LockResult lockResult = CoordinatorManager.getCoordinator().getLocker().acquireLock(itemResource, identity, key);
    return lockResult;
  }
View Full Code Here

   * @param identity
   *            the identity who wishes to obtain the lock
   * @return the lockresult
   */
  private LockResult acquireLock(String key, Identity identity) {
    LockResult lockResult;
    boolean logDebug = log.isDebug();
    synchronized (locks) { //o_clusterOK by:fj, by definition we are in singleVM mode
      LockEntry oldLockEntry = locks.get(key);
      if (oldLockEntry == null || identity.getName().equals(oldLockEntry.getOwner().getName())) {
        // no one has the lock aquired yet - or user reacquired its own
View Full Code Here

   
    // ------------------ test the clusterlocker ----------------------   
    Locker cl = CoordinatorManager.getCoordinator().getLocker();
   
    // acquire
    LockResult res1 = cl.acquireLock(ores, ident, "abc");
    assertTrue(res1.isSuccess());
    DBFactory.getInstance().closeSession();
   
    // reacquire same identity (get from db)
    LockResult res11 = cl.acquireLock(ores, ident, "abc");
    long lock1Ac = res11.getLockAquiredTime();
    assertTrue(res11.isSuccess());
    DBFactory.getInstance().closeSession();

    // acquire by another identity must fail
    LockResult res2 = cl.acquireLock(ores, ident2, "abc");
    assertFalse(res2.isSuccess());
    DBFactory.getInstance().closeSession();

    // reacquire same identity
    LockResult res3 = cl.acquireLock(ores, ident, "abc");
    assertTrue(res3.isSuccess());
    DBFactory.getInstance().closeSession();

    // test the admin
    List<LockEntry> entries = cl.adminOnlyGetLockEntries();
    assertEquals(1, entries.size());
View Full Code Here

TOP

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

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.