org.rundeck.storage.conf.PrefixPathTree Maven / Gradle / Ivy
The newest version!
package org.rundeck.storage.conf;
import org.rundeck.storage.api.ContentMeta;
import org.rundeck.storage.api.Path;
import org.rundeck.storage.api.PathUtil;
import org.rundeck.storage.api.Tree;
/**
* SelectiveTree that Maps resources into a delegate, that appends a path prefix to requests.
*
* This provides a root tree mapped to a subpath in the delegate.
*
*
* - Input Path:
a/b
* - Path used for delegate:
${pathPrefix}/a/b
*
* @param
*/
public class PrefixPathTree
extends SubPathTree
implements SelectiveTree
{
public PrefixPathTree(final Tree delegate, final String pathPrefix) {
super(delegate, pathPrefix, false);
}
public PrefixPathTree(
final Tree delegate,
final Path rootPath
)
{
super(delegate, rootPath, false);
}
@Override
protected boolean isLocalRoot(final Path path) {
return PathUtil.isRoot(path);
}
@Override
protected String translatePathInternal(final String extpath) {
return PathUtil.appendPath(rootPath.getPath(), extpath);
}
@Override
protected String translatePathExternal(final String intpath) {
return PathUtil.removePrefix(rootPath.getPath(), intpath);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy