Esempio n. 1
0
 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;
     }
   }
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
 private void backup(ZipOutputStream zipOutputStream, CollectRecord summary, int stepNumber) {
   Integer id = summary.getId();
   try {
     CollectRecord record = recordManager.load(survey, id, stepNumber);
     String entryFileName = buildEntryFileName(record, stepNumber);
     ZipEntry entry = new ZipEntry(entryFileName);
     zipOutputStream.putNextEntry(entry);
     OutputStreamWriter writer = new OutputStreamWriter(zipOutputStream);
     dataMarshaller.write(record, writer);
     zipOutputStream.closeEntry();
     zipOutputStream.flush();
   } catch (Exception e) {
     String message = "Error while backing up " + id + " " + e.getMessage();
     if (LOG.isErrorEnabled()) {
       LOG.error(message, e);
     }
     throw new RuntimeException(message, e);
   }
 }
Esempio n. 4
0
 private String buildEntryFileName(CollectRecord record, int stepNumber) {
   return stepNumber + File.separator + record.getId() + ".xml";
 }