示例#1
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);
  }
示例#2
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);
  }