Beispiel #1
0
  public Path getPath() {
    LocalFileStore fs = Hub.instance.getPublicFileStore();

    if (fs == null) return null;

    return fs.getFilePath().resolve("dcw/" + this.getAlias());
  }
Beispiel #2
0
  public CacheFile resolveCachePath(String path) {
    LocalFileStore fs = Hub.instance.getPublicFileStore();

    if (fs == null) return null;

    if (StringUtil.isEmpty(path)) return fs.cacheResolvePath("dcw/" + this.getAlias());

    if (path.charAt(0) == '/') return fs.cacheResolvePath("dcw/" + this.getAlias() + path);

    return fs.cacheResolvePath("dcw/" + this.getAlias() + "/" + path);
  }
Beispiel #3
0
  public CacheFile findSectionFile(String section, String path, boolean isPreview) {
    if (Logger.isDebug()) Logger.debug("find section file: " + path + " in " + section);

    LocalFileStore pubfs = Hub.instance.getPublicFileStore();
    LocalFileStore prifs = Hub.instance.getPrivateFileStore();

    // for a sub-site, check first in the site folder

    if (this != this.domain.getRootSite()) {
      if (Logger.isDebug())
        Logger.debug("find section file, check site: " + path + " in " + section);

      if (prifs != null) {
        if (isPreview) {
          CacheFile cfile =
              prifs.cacheResolvePath(
                  "/dcw/"
                      + this.domain.getAlias()
                      + "/sites/"
                      + this.alias
                      + "/"
                      + section
                      + "-preview"
                      + path);

          if (cfile != null) return cfile;
        }

        CacheFile cfile =
            prifs.cacheResolvePath(
                "/dcw/" + this.domain.getAlias() + "/sites/" + this.alias + "/" + section + path);

        if (cfile != null) return cfile;
      }

      if (pubfs != null) {
        if (isPreview) {
          CacheFile cfile =
              pubfs.cacheResolvePath(
                  "/dcw/"
                      + this.domain.getAlias()
                      + "/sites/"
                      + this.alias
                      + "/"
                      + section
                      + "-preview"
                      + path);

          if (cfile != null) return cfile;
        }

        CacheFile cfile =
            pubfs.cacheResolvePath(
                "/dcw/" + this.domain.getAlias() + "/sites/" + this.alias + "/" + section + path);

        if (cfile != null) return cfile;
      }

      // if not shared then jump right to modules for resource
      if (!this.isSharedSection(section))
        return Hub.instance
            .getResources()
            .getPackages()
            .cacheLookupPath(this.domain.getPackagelist(), "/" + section + path);
    }

    // now check the root site folders

    // TODO Each site's special files (dcui, dcf, html, shtml, gas) are completely separate -
    // supplemental files like js, css, imgs, etc may be integrated depending on site settings.

    if (Logger.isDebug()) Logger.debug("find section file, check root: " + path + " in " + section);

    if (prifs != null) {
      if (isPreview) {
        CacheFile cfile =
            prifs.cacheResolvePath(
                "/dcw/" + this.domain.getAlias() + "/" + section + "-preview" + path);

        if (cfile != null) return cfile;
      }

      CacheFile cfile =
          prifs.cacheResolvePath("/dcw/" + this.domain.getAlias() + "/" + section + path);

      if (cfile != null) return cfile;
    }

    if (pubfs != null) {
      if (isPreview) {
        CacheFile cfile =
            pubfs.cacheResolvePath(
                "/dcw/" + this.domain.getAlias() + "/" + section + "-preview" + path);

        if (cfile != null) return cfile;
      }

      CacheFile cfile =
          pubfs.cacheResolvePath("/dcw/" + this.domain.getAlias() + "/" + section + path);

      if (cfile != null) return cfile;
    }

    if (Logger.isDebug()) Logger.debug("find section check packages: " + path + " in " + section);

    return Hub.instance
        .getResources()
        .getPackages()
        .cacheLookupPath(this.domain.getPackagelist(), "/" + section + path);
  }
Beispiel #4
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);
        }
      }
    }
  }