use of org.openforis.collect.persistence.MultipleEditException in project collect by openforis.
the class DataService method checkoutRecord.
@Secured(ENTRY_LIMITED)
public RecordProxy checkoutRecord(int id, Integer stepNumber, boolean forceUnlock) throws RecordPersistenceException, RecordIndexException {
SessionState sessionState = sessionManager.getSessionState();
if (sessionState.isActiveRecordBeingEdited()) {
throw new MultipleEditException();
}
final CollectSurvey survey = sessionState.getActiveSurvey();
User user = sessionState.getUser();
Step step = stepNumber == null ? null : Step.valueOf(stepNumber);
CollectRecord record = step == null ? recordManager.checkout(survey, user, id, sessionState.getSessionId(), forceUnlock) : recordManager.checkout(survey, user, id, step, sessionState.getSessionId(), forceUnlock);
sessionManager.setActiveRecord(record);
prepareRecordIndexing();
return toProxy(record);
}
use of org.openforis.collect.persistence.MultipleEditException 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);
}
}
use of org.openforis.collect.persistence.MultipleEditException in project collect by openforis.
the class DataService method createRecord.
@Secured(ENTRY)
public RecordProxy createRecord(String rootEntityName, String versionName, Step recordStep) throws RecordPersistenceException, RecordIndexException {
SessionState sessionState = sessionManager.getSessionState();
if (sessionState.isActiveRecordBeingEdited()) {
throw new MultipleEditException();
}
CollectSurvey activeSurvey = sessionState.getActiveSurvey();
User user = sessionState.getUser();
CollectRecord record = recordManager.instantiateRecord(activeSurvey, rootEntityName, user, versionName, recordStep);
NodeChangeSet changeSet = recordManager.initializeRecord(record);
List<RecordEvent> events = new EventProducer().produceFor(changeSet, user.getUsername());
sessionManager.onEvents(events);
sessionManager.setActiveRecord(record);
prepareRecordIndexing();
RecordProxy recordProxy = new RecordProxy(record, getProxyContext(), true);
return recordProxy;
}
Aggregations