Esempio n. 1
0
  public void importSite(OperationCallback op) {
    // =============== COLLECT ==============
    XElement feed = op.getContext().getDomain().getSettings().find("Feed");

    if (feed != null) {
      // there are two special channels - Pages and Blocks
      for (XElement chan : feed.selectAll("Channel")) this.collectChannel(chan);
    }

    /* TODO need to update Stored Proc to handle Path instead of UUID as a key
    this.collectWWW();
    */

    if (op.hasErrors()) {
      op.error("Unable to import site, file collection failed");
      return;
    }

    // =============== PREP ==============
    this.prep();

    if (op.hasErrors()) {
      op.error("Unable to import site, file prep failed");
      return;
    }

    // =============== IMPORT ==============
    this.doImport(op);
  }
Esempio n. 2
0
  public void collectFeedFile(Path sfile) {
    XElement feed = OperationContext.get().getDomain().getSettings().find("Feed");

    if ((feed == null) || (sfile == null)) return;

    sfile = sfile.toAbsolutePath().normalize();

    DomainInfo di = OperationContext.get().getDomain();

    Path dmpath = di.getPath().toAbsolutePath().normalize();

    Path relpath = dmpath.relativize(sfile);

    if (relpath.getNameCount() < 3) return;

    // String wwwpathf1 = preview ? "/" + area +  "-preview/" + alias : "/" + area +  "/" + alias;
    // Path wwwsrc1 = di.resolvePath(wwwpathf1).toAbsolutePath().normalize();

    String area = "feed";
    String alias = relpath.getName(1).toString();
    String perpath = "";

    // there are two special channels - Pages and Blocks
    for (XElement chan : feed.selectAll("Channel")) {
      String calias = chan.getAttribute("Alias");

      if (calias == null) calias = chan.getAttribute("Name");

      if (calias.equals(alias)) {
        perpath = chan.getAttribute("Path", ""); // or empty string
        break;
      }
    }

    System.out.println("relpath: " + relpath);

    relpath = relpath.subpath(2, relpath.getNameCount());

    // System.out.println("abs: " + feedsrc1);

    // Path relpath = wwwsrc1.relativize(sfile);

    // System.out.println("rel: " + relpath);

    String cleanpath = relpath.toString();

    int pos = cleanpath.indexOf('.');

    if (pos != -1) cleanpath = cleanpath.substring(0, pos); // + ".dcf.xml";

    String innerpath = perpath + "/" + cleanpath;

    FileImporter imp = new FeedImporter();

    imp.setKey(innerpath);
    imp.setArea(area);
    imp.setAlias(alias);

    OperationContext.get().info("Indexing " + alias + " > " + innerpath);

    ImportWebsiteTool.this.feedpaths.put(innerpath, imp);

    String pubfeedpath = "/" + area + "/" + alias + "/" + cleanpath + ".dcf.xml";
    Path pubfeedsrc = di.resolvePath(pubfeedpath).normalize();

    if (Files.exists(pubfeedsrc)) {
      OperationContext.get().info("Indexing published " + alias + " > " + innerpath);
      imp.setFile(pubfeedsrc);
    }

    String prefeedpath = "/" + area + "-preview/" + alias + "/" + cleanpath + ".dcf.xml";
    Path prefeedsrc = di.resolvePath(prefeedpath).normalize();

    if (Files.exists(prefeedsrc)) {
      OperationContext.get().info("Indexing preview " + alias + " > " + innerpath);
      imp.setPreviewFile(prefeedsrc);
    }
  }
Esempio n. 3
0
  public void init(XElement config) {
    this.dictionary = null;
    this.locales.clear();

    // for a sub-site, may have additional dict to load
    if (this != this.domain.getRootSite()) {
      LocalFileStore pubfs = Hub.instance.getPublicFileStore();

      Path cpath =
          pubfs.resolvePath("/dcw/" + this.domain.getAlias() + "/sites/" + this.alias + "/config");

      if ((cpath != null) && Files.exists(cpath)) {
        // dictionary

        Path dicpath = cpath.resolve("dictionary.xml");

        if (Files.exists(dicpath)) {
          this.dictionary = new Dictionary();
          this.dictionary.setParent(this.domain.getDomainInfo().getDictionary());
          this.dictionary.load(dicpath);
        }
      }
    }

    if (config != null) {
      // this settings are only valid for sub sites
      if (this != this.domain.getRootSite()) {
        if (config.hasAttribute("Integration")) {
          try {
            this.integration = SiteIntegration.valueOf(config.getAttribute("Integration", "Files"));
          } catch (Exception x) {
            this.integration = SiteIntegration.Files;
          }
        }
      }

      if (config.hasAttribute("Locale")) {
        this.locale = config.getAttribute("Locale");

        this.localedef = this.getLocaleDefinition(this.locale);

        // add the list of locales supported for this site
        this.locales.put(this.locale, this.localedef);
      }

      // these settings are valid for root and sub sites

      for (XElement pel : config.selectAll("Locale")) {
        String lname = pel.getAttribute("Name");

        if (StringUtil.isEmpty(lname)) continue;

        LocaleDefinition def = this.getLocaleDefinition(lname);

        this.locales.put(lname, def);

        for (XElement del : pel.selectAll("Domain")) {
          String dname = del.getAttribute("Name");

          if (StringUtil.isEmpty(lname)) continue;

          this.domainlocales.put(dname, def);
        }
      }
    }
  }