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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations