Tabnine Logo
PathUtil
Code IndexAdd Tabnine to your IDE (free)

How to use
PathUtil
in
org.rundeck.storage.api

Best Java code snippets using org.rundeck.storage.api.PathUtil (Showing top 20 results out of 315)

origin: org.rundeck/rundeck-storage-conf

/**
 * @param delegate delegate tree
 * @param rootPath root path for the subtree
 * @param fullPath true if the root path should not be removed when accessing the delegate
 */
public SubPathTree(Tree<T> delegate, String rootPath, boolean fullPath) {
  this(delegate, PathUtil.asPath(rootPath), fullPath);
}
origin: org.rundeck/rundeck-storage-api

/**
 * @return true if the path is the root
 *
 * @param path path string
 */
public static boolean isRoot(String path) {
  return isRoot(asPath(path));
}
/**
origin: org.rundeck/rundeck-storage-api

/**
 * 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));
}
origin: org.rundeck/rundeck-storage-api

public static String removePrefix(String rootPath, String extpath) {
  if (!hasRoot(extpath, rootPath)) {
    return extpath;
  }
  return cleanPath(cleanPath(extpath).substring(cleanPath(rootPath).length()));
}
origin: org.rundeck/rundeck-storage-conf

/**
 * 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;
}
origin: org.rundeck/rundeck-storage-api

public static Path parentPath(Path path) {
  return asPath(parentPathString(path.getPath()));
}
origin: org.rundeck/rundeck-core

/**
 * Append a converter plugin to the tree builder
 *
 * @param builder    builder
 * @param pluginType converter plugin type
 * @param path       path
 * @param selector   metadata selector
 * @param config     plugin config data
 *
 * @return builder
 */
private TreeBuilder<ResourceMeta> buildConverterPlugin(TreeBuilder<ResourceMeta> builder, String pluginType,
                            String path, String selector, Map<String, String> config) {
  StorageConverterPlugin converterPlugin = loadPlugin(
      pluginType,
      config,
      storageConverterPluginProviderService
  );
  //convert tree under the subpath if specified, AND matching the selector if specified
  return builder.convert(
      new StorageConverterPluginAdapter(pluginType,converterPlugin),
      null != path ? PathUtil.asPath(path.trim()) : null,
      null != selector ? PathUtil.<ResourceMeta>resourceSelector(selector) : null
  );
}
origin: org.rundeck/rundeck-storage-data

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;
}
origin: org.rundeck/rundeck-storage-api

  @Override
  public boolean matchesPath(Path path) {
    return path.equals(rootPath) || PathUtil.hasRoot(path, rootPath);
  }
};
origin: org.rundeck/rundeck-storage-conf

private boolean isLocalRoot(Path path) {
  return PathUtil.isRoot(PathUtil.removePrefix(rootPath.getPath(), path.getPath()));
}
origin: org.rundeck/rundeck-storage-conf

/**
 * convert internal path to external
 *
 * @param intpath
 *
 * @return
 */
private String translatePathExternal(String intpath) {
  if (fullPath) {
    return intpath;
  } else {
    return PathUtil.appendPath(rootPath.getPath(), intpath);
  }
}
origin: org.rundeck/rundeck-storage-api

public static String pathName(String path) {
  String[] split = componentsFromPathString(path);
  if (split.length > 0) {
    return split[split.length - 1];
  }
  return null;
}
origin: org.rundeck/rundeck-storage-conf

/**
 * @param path parent path
 * @param tree tree with a subpath
 * @return true if the subpath is directly under the path
 */
public static boolean hasParentPath(Path path, SubPath tree) {
  return path.equals(PathUtil.parentPath(tree.getSubPath()));
}
origin: org.rundeck/rundeck-storage-conf

/**
 * Listen to events on selective resources of the tree
 *
 * @param listener listener
 * @param resourceSelector resource selector
 * @return builder
 */
private TreeBuilder<T> listen(Listener<T> listener, String resourceSelector) {
  return TreeBuilder.<T>builder(new ListenerTree<T>(build(), listener,
      PathUtil.<T>resourceSelector(resourceSelector)));
}
origin: org.rundeck/rundeck-storage-conf

public static boolean matchesPath(Path path, SelectiveTree<?> tree) {
  return path.equals(tree.getSubPath()) || PathUtil.hasRoot(path, tree.getSubPath());
}
origin: org.rundeck/rundeck-storage-api

/**
 * @param path path
 * @return path components
 */
public static String[] componentsFromPath(final Path path) {
  return componentsFromPathString(path.getPath());
}
origin: org.rundeck/rundeck-storage-data

public MemoryTree() {
  index.put(PathUtil.asPath(""), root);
}
origin: org.rundeck/rundeck-core

/**
 * 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);
  }
}
origin: org.rundeck/rundeck-storage-data

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;
}
origin: org.rundeck/rundeck-storage-api

/**
 * @return true if the given path starts with the given root
 *
 * @param path test path
 * @param root root
 *
 */
public static boolean hasRoot(Path path, Path root) {
  return hasRoot(path.getPath(), root.getPath());
}
org.rundeck.storage.apiPathUtil

Javadoc

Utility methods for paths

Most used methods

  • asPath
  • isRoot
  • appendPath
    Append one path to another
  • hasRoot
  • componentsFromPathString
  • parentPath
  • resourceSelector
    Return a ResourceSelector constructed using this selector syntax: key OP value [; key OP value]
  • allResourceSelector
    A resource selector which always matches
  • allpathSelector
  • cleanPath
    Clean the path string by removing leading and trailing slashes and removing duplicate slashes.
  • composeSelector
    compose two selectors
  • equals
  • composeSelector,
  • equals,
  • exactMetadataResourceSelector,
  • join,
  • parentPathString,
  • pathName,
  • pathStringFromComponents,
  • regexMetadataResourceSelector,
  • removePrefix,
  • subpathSelector

Popular in Java

  • Finding current android device location
  • addToBackStack (FragmentTransaction)
  • requestLocationUpdates (LocationManager)
  • getExternalFilesDir (Context)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now