public IOutputAdapter pathToAdapter(boolean isPreview, CommonPath path, CacheFile cfile) { IOutputAdapter ioa = null; String filename = cfile.getPath(); HtmlMode hmode = this.domain.getHtmlMode(); if (filename.endsWith(".dcui.xml") || filename.endsWith(".dcuis.xml")) { DcuiOutputAdapter voa = new DcuiOutputAdapter(); (isPreview ? this.dynpreviewcache : this.dyncache).put(path.toString(), voa); ioa = voa; } else if (filename.endsWith(".shtml") || ((hmode == HtmlMode.Ssi) && filename.endsWith(".html"))) { ioa = new SsiOutputAdapter(); } else if (filename.endsWith(".gas")) { ioa = new GasOutputAdapter(); } // certain resource types cannot be delivered else if (filename.endsWith(".class")) { OperationContext.get().errorTr(150001); return null; } else { ioa = new StaticOutputAdapter(); } ioa.init(this, cfile, path, isPreview); return ioa; }
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; }
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); }