예제 #1
0
  @Override
  public void doProcess(
      PublishedChangeSet changeSet, Map<String, String> parameters, PublishingTarget target)
      throws PublishingException {
    String root = target.getParameter(FileUploadServlet.CONFIG_ROOT);
    String contentFolder = target.getParameter(FileUploadServlet.CONFIG_CONTENT_FOLDER);
    String siteId =
        (!StringUtils.isEmpty(siteName)) ? siteName : parameters.get(FileUploadServlet.PARAM_SITE);

    root += "/" + contentFolder;

    if (StringUtils.isNotBlank(siteId)) {
      root = root.replaceAll(FileUploadServlet.CONFIG_MULTI_TENANCY_VARIABLE, siteId);
    }

    List<String> createdFiles = changeSet.getCreatedFiles();
    List<String> updatedFiles = changeSet.getUpdatedFiles();
    List<String> deletedFiles = changeSet.getDeletedFiles();

    if (CollectionUtils.isNotEmpty(createdFiles)) {
      update(siteId, root, createdFiles, false);
    }
    if (CollectionUtils.isNotEmpty(updatedFiles)) {
      update(siteId, root, updatedFiles, false);
    }
    if (CollectionUtils.isNotEmpty(deletedFiles)) {
      update(siteId, root, deletedFiles, true);
    }

    searchService.commit();
  }
  @Override
  public void doProcess(
      final PublishedChangeSet changeSet,
      final Map<String, String> parameters,
      final PublishingTarget target)
      throws PublishingException {
    String root = target.getParameter(FileUploadServlet.CONFIG_ROOT);
    String contentFolder = target.getParameter(FileUploadServlet.CONFIG_CONTENT_FOLDER);
    String siteId = parameters.get(FileUploadServlet.PARAM_SITE);
    if (StringUtils.isEmpty(siteId)) {
      siteId = siteName;
    }

    root += "/" + contentFolder;
    if (org.springframework.util.StringUtils.hasText(siteId)) {
      root = root.replaceAll(FileUploadServlet.CONFIG_MULTI_TENANCY_VARIABLE, siteId);
    }

    List<String> createdFiles = changeSet.getCreatedFiles();
    List<String> updatedFiles = changeSet.getUpdatedFiles();
    List<String> deletedFiles = changeSet.getDeletedFiles();

    try {
      if (CollectionUtils.isNotEmpty(createdFiles)) {
        processFiles(siteId, root, createdFiles, false);
      }
      if (CollectionUtils.isNotEmpty(updatedFiles)) {
        processFiles(siteId, root, updatedFiles, false);
      }
      if (CollectionUtils.isNotEmpty(deletedFiles)) {
        processFiles(siteId, root, deletedFiles, true);
      }
    } catch (Exception exc) {
      logger.error("Error: ", exc);
      throw new PublishingException("Failed to complete postprocessing.", exc);
    }
  }