use of org.apache.jackrabbit.webdav.lock.ActiveLock in project jackrabbit by apache.
the class TxLockManagerImpl method getLock.
/**
* @param lockToken
* @param resource
* @return
*/
private ActiveLock getLock(String lockToken, Scope scope, DavResource resource) {
if (!(resource instanceof TransactionResource)) {
log.warn("TransactionResource expected");
return null;
}
ActiveLock lock = null;
Transaction tx = null;
TransactionMap m = map;
// check if main-map contains that txId
if (m.containsKey(lockToken)) {
tx = m.get(lockToken);
} else {
// look through all the nested tx-maps (i.e. global txs) for the given txId
Iterator<Transaction> it = m.values().iterator();
while (it.hasNext() && tx == null) {
Transaction txMap = it.next();
if (!txMap.isLocal()) {
m = (TransactionMap) txMap;
if (m.containsKey(lockToken)) {
tx = ((TransactionMap) txMap).get(lockToken);
}
}
}
}
if (tx != null) {
if (tx.getLock().isExpired()) {
removeExpired(tx, m, (TransactionResource) resource);
} else if (tx.appliesToResource(resource) && (scope == null || tx.getLock().getScope().equals(scope))) {
lock = tx.getLock();
}
}
return lock;
}
use of org.apache.jackrabbit.webdav.lock.ActiveLock in project jackrabbit by apache.
the class AbstractResource method getLocks.
/**
* @see DavResource#getLocks()
* todo improve....
*/
@Override
public ActiveLock[] getLocks() {
List<ActiveLock> locks = new ArrayList<ActiveLock>();
// tx locks
ActiveLock l = getLock(TransactionConstants.TRANSACTION, TransactionConstants.LOCAL);
if (l != null) {
locks.add(l);
}
l = getLock(TransactionConstants.TRANSACTION, TransactionConstants.GLOBAL);
if (l != null) {
locks.add(l);
}
// write lock (either exclusive or session-scoped).
l = getLock(Type.WRITE, Scope.EXCLUSIVE);
if (l != null) {
locks.add(l);
} else {
l = getLock(Type.WRITE, ItemResourceConstants.EXCLUSIVE_SESSION);
if (l != null) {
locks.add(l);
}
}
return locks.toArray(new ActiveLock[locks.size()]);
}
Aggregations