예제 #1
0
 /**
  * create files from a list
  *
  * @param site
  * @param importedPaths
  * @param importedFullPaths
  * @param nodes
  * @param fileRoot
  * @param targetRoot the target location root
  * @param parentPath the target location to import to
  * @param overWrite
  * @param channels
  * @param user
  */
 protected void createFiles(
     String site,
     Set<String> importedPaths,
     List<String> importedFullPaths,
     List<Node> nodes,
     String fileRoot,
     String targetRoot,
     String parentPath,
     boolean overWrite,
     List<PublishingChannel> channels,
     String user) {
   logger.info(
       "[IMPORT] createFiles: fileRoot ["
           + fileRoot
           + "] parentFullPath ["
           + parentPath
           + "] overwrite["
           + overWrite
           + "]");
   if (nodes != null) {
     for (Node node : nodes) {
       String name = node.valueOf("@name");
       String value = node.valueOf("@over-write");
       boolean fileOverwrite =
           (StringUtils.isEmpty(value)) ? overWrite : ContentFormatUtils.getBooleanValue(value);
       if (!StringUtils.isEmpty(name)) {
         writeContentInTransaction(
             site,
             importedPaths,
             importedFullPaths,
             fileRoot,
             targetRoot,
             parentPath,
             name,
             fileOverwrite,
             channels,
             user);
       }
     }
   }
 }
예제 #2
0
  /**
   * create folders
   *
   * @param site site name
   * @param importedPaths a list of imported files
   * @param importedFullPaths
   * @param nodes nodes representing folders
   * @param fileRoot the root location of files/folders being imported
   * @param targetRoot the target location root
   * @param parentPath the target location to import to
   * @param overWrite overwrite contents?
   * @param channels
   * @param user
   */
  @SuppressWarnings("unchecked")
  private void createFolders(
      String site,
      Set<String> importedPaths,
      List<String> importedFullPaths,
      List<Node> nodes,
      String fileRoot,
      String targetRoot,
      String parentPath,
      boolean overWrite,
      List<PublishingChannel> channels,
      String user) {
    logger.info(
        "[IMPORT] createFolders : site["
            + site
            + "] "
            + "] fileRoot ["
            + fileRoot
            + "] targetRoot [ "
            + targetRoot
            + "] parentPath ["
            + parentPath
            + "] overwrite["
            + overWrite
            + "]");

    if (nodes != null) {
      for (Node node : nodes) {
        String name = node.valueOf("@name");
        String value = node.valueOf("@over-write");
        boolean folderOverWrite =
            (StringUtils.isEmpty(value)) ? overWrite : ContentFormatUtils.getBooleanValue(value);
        if (!StringUtils.isEmpty(name)) {
          String currentFilePath = fileRoot + "/" + name;
          String currentPath = parentPath + "/" + name;
          // check if the parent node exists and create the folder if
          // not
          boolean folderExists = contentService.contentExists(site, currentPath);
          if (!folderExists) {
            contentService.createFolder(site, parentPath, name);
          }
          boolean importAll = ContentFormatUtils.getBooleanValue(node.valueOf("@import-all"));
          if (importAll) {
            importRootFileList(
                site,
                importedPaths,
                importedFullPaths,
                fileRoot + "/" + name,
                targetRoot,
                currentPath,
                folderOverWrite,
                channels,
                user);

          } else {
            // create child folders
            List<Node> childFolders = node.selectNodes("folder");
            createFolders(
                site,
                importedPaths,
                importedFullPaths,
                childFolders,
                currentFilePath,
                targetRoot,
                currentPath,
                folderOverWrite,
                channels,
                user);
            // create child fiimportedPathsles
            List<Node> childFiles = node.selectNodes("file");
            createFiles(
                site,
                importedPaths,
                importedFullPaths,
                childFiles,
                currentFilePath,
                targetRoot,
                currentPath,
                folderOverWrite,
                channels,
                user);
          }
        }
      }
    }
  }
예제 #3
0
  private void importFromConfigNode(
      final String site,
      String publishChannelGroup,
      final Node node,
      final String fileRoot,
      final String targetRoot,
      boolean publish,
      int chunkSize,
      int delayInterval,
      int delayLength) {
    if (!inProgress) {
      inProgress = true;
      if (delayInterval > 0) pauseEanbeld = true;
      this.currentDelayInterval = delayInterval * 1000;
      this.currentDelayLength = delayLength * 1000;
      final Set<String> importedPaths = new HashSet<String>();
      final List<String> importedFullPaths = new ArrayList<String>();
      logger.info(
          "[IMPORT] started importing in "
              + site
              + ", pause enabled: "
              + pauseEanbeld
              + ", delay interval: "
              + this.currentDelayInterval
              + ", delay length: "
              + this.currentDelayLength);

      boolean overWrite = ContentFormatUtils.getBooleanValue(node.valueOf("@over-write"));
      final List<Node> folderNodes = node.selectNodes("folder");
      if (publish) {
        PublishingChannelGroupConfigTO configTO =
            siteService.getPublishingChannelGroupConfigs(site).get(publishChannelGroup);
        String user = securityService.getCurrentUser();
        List<PublishingChannel> channels = getChannels(site, configTO);
        logger.debug(
            "[IMPORT] publishing user: "******", publishing channel config: "
                + configTO.getName());

        this.nextStop = System.currentTimeMillis() + this.currentDelayInterval;
        createFolders(
            site,
            importedPaths,
            importedFullPaths,
            folderNodes,
            fileRoot,
            targetRoot,
            "",
            overWrite,
            channels,
            user);
        logger.info(
            "Starting Publish of Imported Files (Total "
                + importedFullPaths.size()
                + " On chunkSize of "
                + chunkSize
                + " )");
        publish(site, publishChannelGroup, targetRoot, importedFullPaths, chunkSize);
      } else {
        this.nextStop = System.currentTimeMillis() + this.currentDelayInterval;
        createFolders(
            site,
            importedPaths,
            importedFullPaths,
            folderNodes,
            fileRoot,
            targetRoot,
            "",
            overWrite,
            null,
            null);
      }
      inProgress = false;
    } else {
      logger.info("[IMPORT] an import process is currently running.");
    }
  }