public void releaseRecord() throws RecordUnlockedException { checkIsActiveRecordLocked(); SessionState sessionState = getSessionState(); CollectRecord activeRecord = sessionState.getActiveRecord(); if (activeRecord != null && activeRecord.getId() != null) { recordManager.releaseLock(activeRecord.getId()); } sessionState.setActiveRecord(null); }
public SessionState getSessionState() { SessionState sessionState = null; try { sessionState = (SessionState) getSessionAttribute(SessionState.SESSION_ATTRIBUTE_NAME); } catch (IllegalStateException e) { throw new InvalidSessionException(); } if (sessionState.getUser() == null) { sessionState.setUser(loadAuthenticatedUser()); } return sessionState; }
public void saveActiveDesignerSurvey() { try { SessionState sessionState = getSessionState(); CollectSurvey survey = getActiveDesignerSurvey(); boolean activeSurveyWork = sessionState.isActiveSurveyWork(); if (activeSurveyWork) { surveyManager.save(survey); } else { throw new IllegalArgumentException("Active designer survey should be a 'work' survey"); } } catch (SurveyStoreException e) { LOG.error("Error updating taxonomy related attributes.", e); } }
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; } } }
@Secured("ROLE_ADMIN") public DataImportStateProxy startSummaryCreation(boolean overwriteAll) throws DataImportExeption { if (dataImportProcess == null || !dataImportProcess.isRunning()) { SessionState sessionState = sessionManager.getSessionState(); File userImportFolder = new File(importDirectory, sessionState.getSessionId()); packagedFile = new File(userImportFolder, FILE_NAME); List<User> usersList = userManager.loadAll(); HashMap<String, User> users = new HashMap<String, User>(); for (User user : usersList) { users.put(user.getName(), user); } dataImportProcess = new DataImportProcess( surveyManager, recordManager, recordDao, users, packagedFile, overwriteAll); dataImportProcess.prepareToStartSummaryCreation(); ExecutorServiceUtil.executeInCachedPool(dataImportProcess); } DataImportState state = dataImportProcess.getState(); DataImportStateProxy proxy = new DataImportStateProxy(state); return proxy; }
public void setActiveSurvey(CollectSurvey survey) { SessionState sessionState = getSessionState(); sessionState.setActiveSurvey(survey); }
public void setActiveRecord(CollectRecord record) { SessionState sessionState = getSessionState(); sessionState.setActiveRecord(record); sessionState.keepActiveRecordAlive(); }
public CollectSurvey getActiveSurvey() { SessionState sessionState = getSessionState(); return sessionState.getActiveSurvey(); }
public CollectRecord getActiveRecord() { SessionState sessionState = getSessionState(); return sessionState.getActiveRecord(); }
public void setLocale(String string) { Locale locale = LocaleUtils.toLocale(string); SessionState sessionState = getSessionState(); sessionState.setLocale(locale); }
public void clearActiveRecord() { SessionState sessionState = getSessionState(); sessionState.setActiveRecord(null); }