Search in sources :

Example 6 with MetaInfoFileImpl

use of org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl in project openolat by klemens.

the class VFSLockManagerImpl method getLock.

@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;
}
Also used : MetaInfoFileImpl(org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl) File(java.io.File)

Example 7 with MetaInfoFileImpl

use of org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl in project OpenOLAT by OpenOLAT.

the class VFSLockManagerImpl method lock.

@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;
}
Also used : MetaInfoFileImpl(org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) File(java.io.File) Date(java.util.Date)

Example 8 with MetaInfoFileImpl

use of org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl in project OpenOLAT by OpenOLAT.

the class VFSLockManagerImpl method getMetaLockedBy.

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;
}
Also used : MetaInfoFileImpl(org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl)

Example 9 with MetaInfoFileImpl

use of org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl in project openolat by klemens.

the class VFSLockManagerImpl method getMetaLockedBy.

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;
}
Also used : MetaInfoFileImpl(org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl)

Example 10 with MetaInfoFileImpl

use of org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl in project openolat by klemens.

the class VFSLockManagerImpl method unlock.

/**
 * 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;
}
Also used : MetaInfoFileImpl(org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) File(java.io.File)

Aggregations

MetaInfoFileImpl (org.olat.core.commons.modules.bc.meta.MetaInfoFileImpl)10 File (java.io.File)8 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)4 Date (java.util.Date)2 VFSItem (org.olat.core.util.vfs.VFSItem)2