/** Unlock the VFS lock only */
  @Override
  public boolean unlock(VFSItem item, Identity identity, Roles roles) {
    if (item instanceof MetaTagged) {
      MetaInfoFileImpl info = (MetaInfoFileImpl) ((MetaTagged) item).getMetaInfo();
      if (info == null) return false;

      info.setLockedBy(null);
      info.setLockedDate(null);
      info.setLocked(false);
      info.write();

      boolean unlocked = false;
      File file = extractFile(item);
      if (file != null && fileLocks.containsKey(file)) {
        LockInfo lock = fileLocks.get(file);
        if (lock.isWebDAVLock()) {
          lock.setVfsLock(false);
        } else {
          if (lock.getWebPath() != null) {
            // LOCK resourceLocks.remove(lock.getWebPath());
          }
          fileLocks.remove(file);
          unlocked = true;
        }
      } else {
        unlocked = true;
      }
      return unlocked;
    }
    return false;
  }
 private Long getMetaLockedBy(VFSItem item) {
   MetaInfoFileImpl info = getMetaInfo(item);
   Long lockedBy = null;
   if (info != null) {
     if (!info.isLocked()) {
       return null;
     }
     lockedBy = info.getLockedBy();
   }
   return lockedBy;
 }
  @Override
  public boolean lock(VFSItem item, Identity identity, Roles roles) {
    if (item instanceof MetaTagged) {
      MetaInfoFileImpl info = (MetaInfoFileImpl) ((MetaTagged) item).getMetaInfo();
      info.setLockedBy(identity.getKey());
      info.setLockedDate(new Date());
      info.setLocked(true);
      info.write();

      File file = extractFile(item);
      if (file != null && fileLocks.containsKey(file)) {
        LockInfo lock = fileLocks.get(file);
        if (lock != null) {
          lock.setVfsLock(true);
        }
      }

      return true;
    }
    return false;
  }
 /**
  * Return a lock info base on the VFS lock
  *
  * @param resource
  * @return
  */
 public LockInfo getVFSLock(WebResource resource) {
   VFSItem item = extractItem(resource);
   MetaInfoFileImpl info = getMetaInfo(item);
   if (info != null && info.isLocked()) {
     File file = extractFile(item);
     LockInfo lock = null;
     if (fileLocks.containsKey(file)) {
       lock = fileLocks.get(file);
       if (lock != null) {
         lock.setVfsLock(true);
       }
     }
     if (lock == null) {
       lock = new LockInfo(info.getLockedBy(), false, true);
       lock.setWebResource(resource);
       lock.setCreationDate(info.getLockedDate());
       lock.setOwner(Settings.getServerContextPathURI() + "/Identity/" + info.getLockedBy());
       lock.setDepth(1);
       lock.addToken(generateLockToken(lock, info.getLockedBy()));
       fileLocks.put(file, lock);
     }
     return lock;
   }
   return null;
 }
  @Override
  public LockInfo getLock(VFSItem item) {
    File file = extractFile(item);
    if (file != null && fileLocks.containsKey(file)) {
      LockInfo lock = fileLocks.get(file);
      if (lock != null) {
        return lock;
      }
    }

    MetaInfoFileImpl info = getMetaInfo(item);
    if (info != null && info.isLocked()) {
      LockInfo lock = new LockInfo(info.getLockedBy(), false, true);
      lock.setCreationDate(info.getLockedDate());
      lock.setOwner(Settings.getServerContextPathURI() + "/Identity/" + info.getLockedBy());
      lock.setDepth(1);
      lock.addToken(generateLockToken(lock, info.getLockedBy()));
      fileLocks.put(file, lock);
      return lock;
    }
    return null;
  }