Ejemplo n.º 1
0
  protected void checkRequest(boolean addedNewRecords, Request newRequest) {
    try {
      if (!addedNewRecords) {
        Repox2Sip repox2sip = RepoxContextUtil.getRepoxManager().getDataManager().getRepox2sip();
        List<Request> requestList = repox2sip.getDataSetRequests(this.getIdDb());

        Collections.sort(requestList, new DateSorter());
        for (Request request : requestList) {
          if (request.getStatus().equals(RequestStatus.IMPORT_COMPLETED)) {
            Long myId = request.getId();
            repox2sip.addMetadataRecords(
                newRequest.getId(), repox2sip.getRequestMetadataRecords(myId));
            break;
          }
        }
      }
    } catch (Repox2SipException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }
Ejemplo n.º 2
0
  /**
   * Add MDRecord to database
   *
   * @param request
   * @param ingestedRecords
   */
  protected void addMdRecord2Database(Request request, List<RecordRepox> ingestedRecords) {
    try {
      Repox2Sip repox2Sip = RepoxContextUtil.getRepoxManager().getDataManager().getRepox2sip();
      List<MetadataRecord> allMetadataRecords = new ArrayList<MetadataRecord>();
      for (RecordRepox rp : ingestedRecords) {
        allMetadataRecords.add(rp.createRecordSip());
        // rp.addRecord2DataBase(request.getId(), repox2Sip);
      }
      repox2Sip.addMetadataRecords(request.getId(), allMetadataRecords);

    } catch (Repox2SipException e) {
      log.error("Could not add MetadataRecord to Data Base", e);
      e.printStackTrace();
    }
  }
Ejemplo n.º 3
0
  public Task.Status startIngest(String taskId, boolean fullIngest) {
    Repox2Sip repox2sip = RepoxContextUtil.getRepoxManager().getDataManager().getRepox2sip();
    Request request = new Request();
    File logFile = getLogFile(taskId);
    Task.Status exitStatus = Task.Status.OK;

    try {
      if (RepoxContextUtil.getRepoxManager()
          .getConfiguration()
          .getUseSipDataBase()
          .equals("true")) {
        // REPOX2SIP Create request
        DataSet dataSet = repox2sip.getDataSet(this.getIdDb());
        request.setDataSet(dataSet);
        request.setStatus(RequestStatus.UNDER_CONSTRUCTION);
        request.setCreationDate(new Date());
        request = setRequestName(request);
        repox2sip.addRequest(request);
      }

      stopExecution = false;

      StringUtil.simpleLog(
          "Starting to import from Data Source with id " + id, this.getClass(), logFile);
      lastUpdate = getSynchronizationDate();
      Date now = new Date();

      exitStatus = ingestRecords(request, logFile, fullIngest);

      if (RepoxContextUtil.getRepoxManager()
          .getConfiguration()
          .getUseSipDataBase()
          .equals("true")) {
        // REPOX2SIP Change request status
        request.setStatus(getCorrespondentRequestStatus(exitStatus));
        repox2sip.updateRequest(request);
      }

      lastUpdate = now;
      if (exitStatus.isSuccessful()) {
        signalSynchronizationFinished(lastUpdate);
      }

      StringUtil.simpleLog(
          "Finished importing from Data Source with id "
              + id
              + ". Exit status: "
              + exitStatus.toString(),
          this.getClass(),
          logFile);
      sendEmail(exitStatus, logFile);
      request.setStatus(RequestStatus.IMPORT_COMPLETED);
    } catch (TemplateException e) {
      log.error(e.getMessage(), e);
      StringUtil.simpleLog(
          "TemplateException: ERROR importing from Data Source with id "
              + id
              + ": "
              + e.getMessage(),
          this.getClass(),
          logFile);
      request.setStatus(RequestStatus.ABORTED);
    } catch (Repox2SipException e) {
      log.error(e.getMessage(), e);
      StringUtil.simpleLog(
          "Repox2SipException: ERROR importing from Data Source with id "
              + id
              + ": "
              + e.getMessage(),
          this.getClass(),
          logFile);
      request.setStatus(RequestStatus.ABORTED);
    } catch (MessagingException e) {
      log.error(e.getMessage(), e);
      StringUtil.simpleLog(
          "MessagingException: ERROR importing from Data Source with id "
              + id
              + ": "
              + e.getMessage(),
          this.getClass(),
          logFile);
      request.setStatus(RequestStatus.ABORTED);
    } catch (IOException e) {
      log.error(e.getMessage(), e);
      StringUtil.simpleLog(
          "IOException: ERROR importing from Data Source with id " + id + ": " + e.getMessage(),
          this.getClass(),
          logFile);
      request.setStatus(RequestStatus.ABORTED);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      StringUtil.simpleLog(
          "ERROR importing from Data Source with id " + id + ": " + e.getMessage(),
          this.getClass(),
          logFile);
      request.setStatus(RequestStatus.ABORTED);
    }

    return exitStatus;
  }