/** * @return true if the path is the root * * @param path path string */ public static boolean isRoot(String path) { return isRoot(asPath(path)); } /**
private boolean deleteRes(DirRes<T> dirRes) { boolean removed = false; if (!dirRes.dir) { Resource<T> res = dirRes.res; removed = index.remove(res.getPath()) != null; Path parentPath = PathUtil.parentPath(res.getPath()); if (!PathUtil.isRoot(parentPath) && null != index.get(parentPath)) { DirRes<T> parentRes = index.get(parentPath); parentRes.dirList.remove(res.getPath()); //remove parent dir if empty dirRes = parentRes; } else { return removed; } } while (null != dirRes && dirRes.dir && dirRes.dirList.size() < 1) { index.remove(dirRes.getPath()); Path parentPath = PathUtil.parentPath(dirRes.getPath()); if (parentPath != null && !PathUtil.isRoot(parentPath)) { DirRes<T> parentRes = index.get(parentPath); parentRes.dirList.remove(dirRes.getPath()); dirRes = parentRes; } else { dirRes = null; } } return removed; }
private boolean isLocalRoot(Path path) { return PathUtil.isRoot(PathUtil.removePrefix(rootPath.getPath(), path.getPath())); }
/** * Configures storage plugins with the builder * * @param builder builder * @param index current prop index * @param configProps configuration properties */ private void configureStoragePlugin(TreeBuilder<ResourceMeta> builder, int index, Map<String, String> configProps) { String pref1 = getStorageConfigPrefix() + SEP + index; String pluginType = configProps.get(pref1 + SEP + TYPE); String path = configProps.get(pref1 + SEP + PATH); boolean removePathPrefix = Boolean.parseBoolean(configProps.get(pref1 + SEP + REMOVE_PATH_PREFIX)); Map<String, String> config = subPropertyMap(pref1 + SEP + CONFIG + SEP, configProps); config = expandConfig(config); Tree<ResourceMeta> resourceMetaTree = loadPlugin( pluginType, config, storagePluginProviderService ); if (index == 1 && PathUtil.isRoot(path)) { logger.debug("New base Storage[" + index + "]:" + path + " " + pluginType + ", config: " + config); builder.base(resourceMetaTree); } else { logger.debug("Subtree Storage[" + index + "]:" + path + " " + pluginType + ", config: " + config); builder.subTree(PathUtil.asPath(path.trim()), resourceMetaTree, !removePathPrefix); } }