예제 #1
0
 private void processImportRequest(ImportRequest request) throws Exception {
   ImportResult result = request.getResult();
   try {
     result.setStatusMessage("Processing CSV data");
     result.setDomain(request.getDomain());
     importLogger.saveImportResult(result);
     if (request.getDomain().equals(Task.PROVIDER_STRING)) {
       List<Task> tasks =
           admin.importProviders(request.getCsvData(), request.getFieldList(), result);
       result.setStatusMessage("Saving changes to database for providers");
       handleTaskList(tasks, result, request);
     } else if (request.getDomain().equals(Task.ORGANISATION_STRING)) {
       List<Task> tasks =
           admin.importOrganisations(request.getCsvData(), request.getFieldList(), result);
       result.setStatusMessage("Saving changes to database for organisations");
       handleTaskList(tasks, result, request);
     }
     result.setStatusMessage("Complete");
     result.setEndDate(new Date());
     importLogger.saveImportResult(result);
     entitySearcher.rebuildSearchindex();
   } catch (Exception e) {
     logger.error("Error processing import", e);
     result.setStatusMessage("Failed");
     result.setException(e);
     result.setErrorMessage(e.getMessage());
     importLogger.saveImportResult(result);
     throw e;
   }
 }
예제 #2
0
 private void handleTaskList(List<Task> tasks, ImportResult result, ImportRequest request)
     throws Exception {
   importLogger.saveImportResult(result);
   boolean flushAndClear = false;
   for (int i = 0; i < tasks.size(); i++) {
     flushAndClear = false;
     if (i != 0 && i % 25 == 0) {
       flushAndClear = true;
     }
     Task task = tasks.get(i);
     controller.handleTask(
         task, request.getUser(), request.getIp(), request.getSessionId(), flushAndClear);
     result.setProcessed(result.getProcessed() + 1);
     importLogger.saveImportResult(result);
   }
 }
예제 #3
0
  public void onMessage(Message message) {
    try {
      logger.info("onMessage called");
      ObjectMessage objectMessage = (ObjectMessage) message;
      ImportRequest request = (ImportRequest) objectMessage.getObject();

      ImportResult dbResult = importLogger.getImportResult(request.getResult().getJobId());
      if (dbResult.getStatusMessage() == null || dbResult.getStatusMessage().length() == 0) {
        processImportRequest(request);
      } else {
        logger.info("Message already failed! Skipping message");
      }
    } catch (JMSException e) {
      logger.error("Error processing message", e);
      context.setRollbackOnly();
    } catch (Exception e) {
      logger.info("onMessage caught exception");
      context.setRollbackOnly();
    }
  }