use of org.openforis.collect.persistence.RecordUnlockedException in project collect by openforis.
the class SessionManager method invalidateSession.
public void invalidateSession() {
try {
releaseRecord();
} catch (RecordUnlockedException e) {
// do nothing
}
GraniteContext graniteContext = GraniteContext.getCurrentInstance();
if (graniteContext != null && graniteContext instanceof HttpGraniteContext) {
HttpGraniteContext httpGraniteContext = (HttpGraniteContext) graniteContext;
HttpServletRequest request = httpGraniteContext.getRequest();
HttpSession session = request.getSession();
session.invalidate();
}
}
use of org.openforis.collect.persistence.RecordUnlockedException in project collect by openforis.
the class RecordLockManager method checkIsLocked.
public synchronized boolean checkIsLocked(int recordId, User user, String sessionId) throws RecordUnlockedException {
RecordLock lock = getLock(recordId);
String lockUserName = null;
if (lock != null) {
String lockSessionId = lock.getSessionId();
int lockRecordId = lock.getRecordId();
User lUser = lock.getUser();
if (recordId == lockRecordId && (lUser == user || lUser.getId().equals(user.getId())) && lockSessionId.equals(sessionId)) {
lock.keepAlive();
return true;
} else {
User lockUser = lock.getUser();
lockUserName = lockUser.getUsername();
}
}
throw new RecordUnlockedException(lockUserName);
}
use of org.openforis.collect.persistence.RecordUnlockedException in project collect by openforis.
the class SessionManager method checkIsActiveRecordLocked.
public void checkIsActiveRecordLocked() throws RecordUnlockedException {
SessionState sessionState = getSessionState();
CollectRecord record = sessionState.getActiveRecord();
if (record == null) {
throw new RecordUnlockedException();
} else if (record.getId() != null) {
User user = sessionState.getUser();
String lockId = sessionState.getSessionId();
try {
recordManager.checkIsLocked(record.getId(), user, lockId);
sessionState.keepActiveRecordAlive();
} catch (RecordUnlockedException e) {
clearActiveRecord();
throw e;
}
}
}
Aggregations