示例#1
0
  public ImageProcessingResult importImages(
      final String article_obj_id,
      final String image_archive_name,
      final String image_item_type,
      final boolean copyAsPrint) {

    logger.info("Import Images executing......sequence issue resolution111111111");

    logger.info("Article Obj ID : " + article_obj_id);
    logger.info("Image Archive ID : " + image_archive_name);
    logger.info("Image Item Type : " + image_item_type);
    logger.info("Copy As Print : " + copyAsPrint);

    try {

      setArticleId(article_obj_id);
      setImageType(image_item_type);
      setZipId(image_archive_name);

      this.copyWebImagesAsPrint = copyAsPrint;

      this.idfSession = getSession();

      boolean isSuccess = processImages();

      if (isSuccess) {

        result.setProcessingStatus(ImageProcessingResult.PROCESSING_STATUS_SUCCESS);
        result.setStrErrorMessage("All images validated and imported successfully");

        return result;
      } else {

        result.setStrErrorMessage(archive.getErrorMessage());
        result.setProcessingStatus(ImageProcessingResult.PROCESSING_STATUS_FAILED);

        if (result.getStrErrorMessage().equals("")) {
          result.setStrErrorMessage("Unknown Error occured");
        }

        return result;
      }

    } catch (Exception e) {

      logger.error("Exception occured while processing images : " + archive.getErrorMessage());

      result.setProcessingStatus(ImageProcessingResult.PROCESSING_STATUS_FAILED);
      result.setStrErrorMessage(archive.getErrorMessage());

      if (result.getStrErrorMessage().equals("")) {
        result.setStrErrorMessage("Unknown Error occured");
      }

      e.printStackTrace();

      return result;

    } finally {
      archive.destroyArchive();
      archive.closeZip();
    }
  }
示例#2
0
  private boolean processImages() throws Exception {

    boolean isSuccess = false;

    logger.debug("processing zip images ");

    isSuccess = archive.initArchiveObj(idfSession, getZipId(), getArticleId());

    if (!isSuccess) {
      return false;
    }

    archive.loadFiles();

    logger.debug(
        "Images loaded successfull in ZipEntry, Image count : " + archive.getNumberOfImages());

    archive.validate();

    logger.debug(
        "Received image validation completed, All images valid : " + archive.isAllZipImagesValid());

    boolean isAllZipImagesNameValid = false;
    boolean isPrintImagesValid = false;

    if (archive.isAllZipImagesValid() == false) {
      logger.error("All images are not valid... Error: " + archive.getErrorMessage());

      isAllZipImagesNameValid = false;
      // return false;
    } else {
      isAllZipImagesNameValid = true;
    }

    if (IConstants.ITEM_TYPE_PRINT_IMAGE.equals(getImageType())) {

      logger.debug("Validating print images against article Web images");

      isPrintImagesValid = archive.validatePrintImagesAgainstWeb();

      if (isPrintImagesValid == false) {
        logger.error("Images received in zip are not compared to Web images");
        return false;
      }
    }

    if (isAllZipImagesNameValid == false) {
      logger.error("Images received in zip are not valid due to name or extension");
      return false;
    }

    logger.debug("All images are valid...starting import in article folder.......");

    archive.loadContents();

    logger.debug("All images content extracted from zip, starting images import in Article ");

    boolean keepFiles = false;
    if (IConstants.ITEM_TYPE_WEB_IMAGE.equals(getImageType()) && (copyWebImagesAsPrint == true)) {
      keepFiles = true;
    }

    logger.debug("KeepFile : " + keepFiles);

    ArticleImageHandler importer = new ArticleImageHandler();
    isSuccess =
        importer.uploadImages(
            idfSession, getArticleId(), archive.getImages(), getImageType(), keepFiles);
    logger.debug("upload Web images completed");

    if (copyWebImagesAsPrint) {
      logger.debug("Copying Web images as Print images");
      isSuccess =
          importer.uploadImages(
              idfSession,
              getArticleId(),
              archive.getImages(),
              IConstants.ITEM_TYPE_PRINT_IMAGE,
              false);
      logger.debug("Web images copied as Print images");
    }

    if (!isSuccess) {
      logger.error("image import process failed ");
      result.setStrErrorMessage("image import process failed");
      return false;
    }

    return true;
  }