Search in sources :

Example 1 with RecordLockedByActiveUserException

use of org.openforis.collect.persistence.RecordLockedByActiveUserException in project collect by openforis.

the class RecordLockManager method isLockAllowed.

public synchronized boolean isLockAllowed(User user, int recordId, String sessionId, boolean forceUnlock) throws RecordLockedException, MultipleEditException {
    RecordLock uLock = getLockBySessionId(sessionId);
    if (uLock != null) {
        throw new MultipleEditException("User is editing another record: " + uLock.getRecordId());
    }
    RecordLock lock = getLock(recordId);
    if (lock == null || (forceUnlock && isForceUnlockAllowed(user, lock))) {
        return true;
    } else if (lock.getUser().getId().equals(user.getId())) {
        throw new RecordLockedByActiveUserException(user.getUsername());
    } else {
        String lockingUserName = lock.getUser().getUsername();
        throw new RecordLockedException("Record already locked", lockingUserName);
    }
}
Also used : RecordLockedException(org.openforis.collect.persistence.RecordLockedException) RecordLock(org.openforis.collect.model.RecordLock) RecordLockedByActiveUserException(org.openforis.collect.persistence.RecordLockedByActiveUserException) MultipleEditException(org.openforis.collect.persistence.MultipleEditException)

Aggregations

RecordLock (org.openforis.collect.model.RecordLock)1 MultipleEditException (org.openforis.collect.persistence.MultipleEditException)1 RecordLockedByActiveUserException (org.openforis.collect.persistence.RecordLockedByActiveUserException)1 RecordLockedException (org.openforis.collect.persistence.RecordLockedException)1