示例#1
0
 /**
  * populate channel information
  *
  * @param configTO
  */
 private List<PublishingChannel> getChannels(
     String site, PublishingChannelGroupConfigTO configTO) {
   SiteService siteService = getSiteService();
   if (configTO.getChannels() != null) {
     List<PublishingChannel> channels = new ArrayList<PublishingChannel>();
     for (PublishingChannelConfigTO channelConfig : configTO.getChannels()) {
       DeploymentEndpointConfigTO endpointConfigTO =
           siteService.getDeploymentEndpoint(site, channelConfig.getName());
       if (endpointConfigTO != null) {
         PublishingChannel channel = new PublishingChannel();
         logger.debug(
             "[IMPORT] populating channel: "
                 + channelConfig.getName()
                 + ", id: "
                 + channel.getId());
         channel.setName(channelConfig.getName());
         String server = endpointConfigTO.getServerUrl();
         channel.setPassword(endpointConfigTO.getPassword());
         channel.setTarget(endpointConfigTO.getTarget());
         channel.setPublishMetadata(endpointConfigTO.isSendMetadata());
         try {
           URL channelUrl = new URL(server);
           channel.setUrl(channelUrl.toString());
         } catch (MalformedURLException e) {
           logger.error("[IMPORT] " + channelConfig.getName() + " has an invalid target URL.", e);
         }
         channels.add(channel);
       }
     }
     return channels;
   } else {
     return null;
   }
 }
示例#2
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.");
    }
  }