示例#1
0
  public CacheFile findFilePath(CommonPath path, boolean isPreview) {
    // figure out which section we are looking in
    String sect = "www";

    if ("files".equals(path.getName(0)) || "galleries".equals(path.getName(0))) {
      sect = path.getName(0);
      path = path.subpath(1);
    }

    if (Logger.isDebug()) Logger.debug("find file path: " + path + " in " + sect);

    // =====================================================
    //  if request has an extension do specific file lookup
    // =====================================================

    // if we have an extension then we don't have to do the search below
    // never go up a level past a file (or folder) with an extension
    if (path.hasFileExtension()) return this.findSectionFile(sect, path.toString(), isPreview);

    // =====================================================
    //  if request does not have an extension look for files
    //  that might match this path or one of its parents
    //  using the special extensions
    // =====================================================

    if (Logger.isDebug()) Logger.debug("find file path dyn: " + path + " in " + sect);

    // we get here if we have no extension - thus we need to look for path match with specials
    int pdepth = path.getNameCount();

    // check file system
    while (pdepth > 0) {
      CommonPath ppath = path.subpath(0, pdepth);

      for (String ext : this.domain.getSpecialExtensions()) {
        CacheFile cfile = this.findSectionFile(sect, ppath.toString() + ext, isPreview);

        if (cfile != null) return cfile;
      }

      pdepth--;
    }

    OperationContext.get().errorTr(150007);
    return null;
  }
示例#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);
  }
示例#3
0
  public IOutputAdapter findFile(CommonPath path, boolean isPreview) {
    // =====================================================
    //  if request has an extension do specific file lookup
    // =====================================================

    if (Logger.isDebug()) Logger.debug("find file before ext check: " + path + " - " + isPreview);

    // if we have an extension then we don't have to do the search below
    // never go up a level past a file (or folder) with an extension
    if (path.hasFileExtension()) {
      CacheFile wpath = this.findFilePath(path, isPreview);

      if (wpath != null) return this.pathToAdapter(isPreview, path, wpath);

      // TODO not found file!!
      OperationContext.get().errorTr(150007);
      return null;
    }

    // =====================================================
    //  if request does not have an extension look for files
    //  that might match this path or one of its parents
    //  using the special extensions
    // =====================================================

    if (Logger.isDebug()) Logger.debug("find file before dyn check: " + path + " - " + isPreview);

    // we get here if we have no extension - thus we need to look for path match with specials
    int pdepth = path.getNameCount();

    // check path maps first - hopefully the request has been mapped at one of the levels
    while (pdepth > 0) {
      CommonPath ppath = path.subpath(0, pdepth);

      if (isPreview) {
        IOutputAdapter ioa = this.dynpreviewcache.get(ppath.toString());

        if (ioa != null) return ioa;
      }

      IOutputAdapter ioa = this.dyncache.get(ppath.toString());

      if (ioa != null) return ioa;

      pdepth--;
    }

    if (Logger.isDebug()) Logger.debug("find file not cached: " + path + " - " + isPreview);

    // if not in dyncache then look on file system
    CacheFile wpath = this.findFilePath(path, isPreview);

    if (wpath == null) {
      OperationContext.get().errorTr(150007);
      return null;
    }

    if (Logger.isDebug())
      Logger.debug("find file path: " + wpath + " - " + path + " - " + isPreview);

    return this.pathToAdapter(isPreview, path, wpath);
  }