Exemplo n.º 1
0
  // We cant wait for this because fedora transaction times out
  public void process(String url) {
    try {
      if (url == null || outputFolder == null) {
        logger.error("Missing source url or output folder.");
        return;
      }

      File targetFolder =
          new File(outputFolder, dataStore.createDeepPath(dataStore.getOnlyIdFromUrl(url)));
      if (targetFolder.exists()) {
        logger.debug("Image is already tiled, skipping.");
        return;
      }

      ZdoModel metadata = dataStore.get(url + "/fcr:metadata");

      if (metadata == null) {
        throw new IOException("Image metadata does not exist.");
      }

      ImageType type;
      switch (metadata.get(ZdoTerms.mimeType)) {
        case "image/jpeg":
          type = ImageType.JPEG;
          break;
        case "image/jp2":
          type = ImageType.JPEG2000;
          break;
        default:
          throw new IOException("Unsupported image format '{" + url + "}' detected.");
      }

      try (InputStream in = new URL(url).openStream()) {
        TiledImage image = tiler.tileImage(in, type);
        imageWriter.output(image, targetFolder);
      }

    } catch (final IOException e) {
      logger.error("Error processing JMS event!", e);
    }
  }
Exemplo n.º 2
0
  private void markAsUnpublished(ZdoModel model, ZdoModel kdrModel) throws IOException {
    if (ZdoGroup.ZDO.name().equals(model.get(ZdoTerms.group))) {
      model.replaceValueOfProperty(ZdoTerms.group, ZdoGroup.UNPUBLISHED.name());

      // Unlock kdr object
      kdrModel.decreaseLockCount();
      String pdfUrl = kdrModel.get(ZdoTerms.pdfUrl);
      String epubUrl = kdrModel.get(ZdoTerms.epubUrl);
      if (pdfUrl != null) {
        store.delete(pdfUrl);
        kdrModel.removeAllValuesOfProperty(ZdoTerms.pdfUrl);
      }
      if (epubUrl != null) {
        store.delete(epubUrl);
        kdrModel.removeAllValuesOfProperty(ZdoTerms.epubUrl);
      }

      // And unindex original published doc
      if (ZdoType.isRootCategory(model.get(ZdoTerms.zdoType))) {
        rootsToDelete.add(store.getOnlyIdFromUrl(model.getUrl()));
      }
    }
  }