/** * @see org.springframework.extensions.webscripts.ScriptContent#getPath() */ public String getPath() { return getBasePath() + '/' + this.scriptPath; }
public String[] getDescriptionDocumentPaths() { return getDocumentPathsByRegEx("/", ".*\\.desc\\.xml", true); }
/** * Returns the absolute path relative to the root of the store * given a particular document path. * * @param documentPath String * @return String */ protected String toAbsolutePath(String documentPath) { return getRootDir().getAbsolutePath() + File.separatorChar + documentPath; }
if (hasDocument(documentPath)) removeDocument(documentPath); File file = new File(toAbsolutePath(documentPath)); if (file.getParentFile().exists())
public boolean hasDocument(String documentPath) { File file = new File(toAbsolutePath(documentPath)); return (file != null && file.exists() && file.isFile()); }
public String[] getAllDocumentPaths() { List<String> list = new ArrayList<String>(256); // exhaustive traverse of absolute paths gatherAbsolutePaths(getRootDir().getAbsolutePath(), list); // convert to array String[] array = list.toArray(new String[list.size()]); // down shift to relative paths String absRootPath = getRootDir().getAbsolutePath() + File.separatorChar; int absRootPathLen = absRootPath.length(); for (int i = 0; i < array.length; i++) { array[i] = array[i].substring(absRootPathLen); // so as to be consistent with expected store syntax array[i] = array[i].replace("\\", "/"); } return array; }
String absParentPath = toAbsolutePath(path); int absParentPathLen = absParentPath.length() - 1; File f = new File(absParentPath); List<File> fileList = listPath(f, filter, traverseChildren);
private List<File> listPath(File path, FileFilter filter, boolean listChildren) { List<File> results = new ArrayList<File>(); listPath(path, filter, results, listChildren); return results; }
/** * @see freemarker.cache.TemplateLoader#findTemplateSource(java.lang.String) */ public Object findTemplateSource(String name) throws IOException { LocalFileSystemStoreTemplateSource source = null; if (hasDocument(name)) { source = new LocalFileSystemStoreTemplateSource(name); } return source; }
private long lastModified() { try { return LocalFileSystemStore.this.lastModified(templatePath); } catch (IOException e) { return -1; } }
protected void gatherAbsolutePaths(String absPath, List<String> list) { File file = new File(absPath); if (file.exists()) { if (file.isFile()) { list.add(absPath); } else if (file.isDirectory()) { // get all of the children String[] childDocumentPaths = file.list(); for (int i = 0; i < childDocumentPaths.length; i++) { String childAbsPath = absPath + File.separatorChar + childDocumentPaths[i]; gatherAbsolutePaths(childAbsPath, list); } } } }
public String getBasePath() { String fullPath = this.path; if (this.root != null) { if (!root.endsWith("/")) { root += "/"; } if (root.startsWith(".")) { // make relative to the web app real path fullPath = getRealPath(this.root.substring(1)) + this.path; } else { fullPath = this.root + this.path; } } return fullPath; }
if (hasDocument(documentPath)) removeDocument(documentPath); File file = new File(toAbsolutePath(documentPath)); if (file.getParentFile().exists())
private Reader getReader(String encoding) throws IOException { Reader reader = null; File f = new File(toAbsolutePath(templatePath)); if (f.exists()) { reader = new FileReader(f); } return reader; } }
public String[] getAllDocumentPaths() { List<String> list = new ArrayList<String>(256); // exhaustive traverse of absolute paths gatherAbsolutePaths(getRootDir().getAbsolutePath(), list); // convert to array String[] array = list.toArray(new String[list.size()]); // down shift to relative paths String absRootPath = getRootDir().getAbsolutePath() + File.separatorChar; int absRootPathLen = absRootPath.length(); for (int i = 0; i < array.length; i++) { array[i] = array[i].substring(absRootPathLen); // so as to be consistent with expected store syntax array[i] = array[i].replace("\\", "/"); } return array; }
String absParentPath = toAbsolutePath(path); int absParentPathLen = absParentPath.length() - 1; File f = new File(absParentPath); List<File> fileList = listPath(f, filter, traverseChildren);
private List<File> listPath(File path, FileFilter filter, boolean listChildren) { List<File> results = new ArrayList<File>(); listPath(path, filter, results, listChildren); return results; }
/** * @see freemarker.cache.TemplateLoader#findTemplateSource(java.lang.String) */ public Object findTemplateSource(String name) throws IOException { LocalFileSystemStoreTemplateSource source = null; if (hasDocument(name)) { source = new LocalFileSystemStoreTemplateSource(name); } return source; }
private long lastModified() { try { return LocalFileSystemStore.this.lastModified(templatePath); } catch (IOException e) { return -1; } }
protected void gatherAbsolutePaths(String absPath, List<String> list) { File file = new File(absPath); if (file.exists()) { if (file.isFile()) { list.add(absPath); } else if (file.isDirectory()) { // get all of the children String[] childDocumentPaths = file.list(); for (int i = 0; i < childDocumentPaths.length; i++) { String childAbsPath = absPath + File.separatorChar + childDocumentPaths[i]; gatherAbsolutePaths(childAbsPath, list); } } } }