コード例 #1
0
  public Object step(int step) {
    helper.assertStep(step);
    try {
      MDC.put("fileset", logFilename);
      log.debug("Step " + step);
      Job j = activity.getChild();
      if (j == null) {
        throw helper.cancel(new ERR(), null, "null-job");
      } else if (!(j instanceof MetadataImportJob)) {
        throw helper.cancel(new ERR(), null, "unexpected-job-type", "job-type", j.ice_id());
      }

      if (step == 0) {
        return importMetadata((MetadataImportJob) j);
      } else if (step == 1) {
        return pixelData(null); // (ThumbnailGenerationJob) j);
      } else if (step == 2) {
        return generateThumbnails(null); // (PixelDataJob) j); Nulls image
      } else if (step == 3) {
        // TODO: indexing and scripting here as well.
        store.launchProcessing();
        return null;
      } else if (step == 4) {
        return objects;
      } else {
        throw helper.cancel(new ERR(), null, "bad-step", "step", "" + step);
      }
    } catch (MissingLibraryException mle) {
      notifyObservers(new ErrorHandler.MISSING_LIBRARY(fileName, mle, usedFiles, format));
      throw helper.cancel(new ERR(), mle, "import-missing-library", "filename", fileName);
    } catch (UnsupportedCompressionException uce) {
      // Handling as UNKNOWN_FORMAT for 4.3.0
      notifyObservers(new ErrorHandler.UNKNOWN_FORMAT(fileName, uce, this));
      throw helper.cancel(new ERR(), uce, "import-unknown-format", "filename", fileName);
    } catch (UnknownFormatException ufe) {
      notifyObservers(new ErrorHandler.UNKNOWN_FORMAT(fileName, ufe, this));
      throw helper.cancel(new ERR(), ufe, "import-unknown-format", "filename", fileName);
    } catch (IOException io) {
      notifyObservers(new ErrorHandler.FILE_EXCEPTION(fileName, io, usedFiles, format));
      throw helper.cancel(new ERR(), io, "import-file-exception", "filename", fileName);
    } catch (FormatException fe) {
      notifyObservers(new ErrorHandler.FILE_EXCEPTION(fileName, fe, usedFiles, format));
      throw helper.cancel(new ERR(), fe, "import-file-exception", "filename", fileName);
    } catch (Cancel c) {
      throw c;
    } catch (Throwable t) {
      notifyObservers(
          new ErrorHandler.INTERNAL_EXCEPTION(
              fileName, new RuntimeException(t), usedFiles, format));
      throw helper.cancel(new ERR(), t, "import-request-failure");
    } finally {
      try {
        long size = logPath.size();
        store.updateFileSize(logFile, size);
      } catch (Throwable t) {
        throw helper.cancel(new ERR(), t, "update-log-file-size");
      }
      MDC.clear();
    }
  }