/** * convert internal path to external * * @param intpath * * @return */ private String translatePathExternal(String intpath) { if (fullPath) { return intpath; } else { return PathUtil.appendPath(rootPath.getPath(), intpath); } }
/** * Append one path to another * * @param prefix prefix * @param subpath sub path * * @return sub path appended to the prefix */ public static Path appendPath(Path prefix, String subpath) { return asPath(appendPath(prefix.getPath(), subpath)); }
private DirRes<T> createParentPaths(Path path) { String[] split = path.getPath().split("/"); DirRes<T> current = root; Path currentPath = PathUtil.asPath(""); for (int i = 0; i < split.length - 1; i++) { currentPath = PathUtil.appendPath(currentPath, split[i]); if (!index.containsKey(currentPath)) { DirRes<T> newDir = new DirRes<T>(currentPath); newDir.dir = true; current.dirList.put(currentPath, newDir); index.put(currentPath, newDir); current = newDir; } else { current = index.get(currentPath); } } return current; }
/** * List all treeHandlers as directories which have the given path as a parent * @param path path * @return */ private Set<Resource<T>> listStackDirectory(Path path) { HashSet<Resource<T>> merge = new HashSet<Resource<T>>(); if (treeHandlerList.size() > 0) { for (SelectiveTree<T> treeHandler : treeHandlerList) { if (PathUtil.hasRoot(treeHandler.getSubPath(), path) && !PathUtil.equals( treeHandler.getSubPath(), path )) { String relativePath = PathUtil.removePrefix(path.getPath(), treeHandler.getSubPath().getPath()); String[] components = PathUtil.componentsFromPathString(relativePath); Path subpath = PathUtil.appendPath(path, components[0]); merge.add(new ResourceBase<T>(subpath, null, true)); } } } return merge; }