@Override public URI getUri() { return myFs.getUri(); }
public ChRootedFs(final AbstractFileSystem fs, final Path theRoot) throws URISyntaxException { super(fs.getUri(), fs.getUri().getScheme(), false, fs.getUriDefaultPort()); myFs = fs; myFs.checkPath(theRoot); chRootPathPart = new Path(myFs.getUriPath(theRoot)); chRootPathPartString = chRootPathPart.toUri().getPath(); /* * We are making URI include the chrootedPath: e.g. file:///chrootedPath. * This is questionable since Path#makeQualified(uri, path) ignores * the pathPart of a uri. Since this class is internal we can ignore * this issue but if we were to make it external then this needs * to be resolved. */ // Handle the two cases: // scheme:/// and scheme://authority/ myUri = new URI(myFs.getUri().toString() + (myFs.getUri().getAuthority() == null ? "" : Path.SEPARATOR) + chRootPathPart.toUri().getPath().substring(1)); super.checkPath(theRoot); }
/** * Return the current user's home directory in this file system. * The default implementation returns "/user/$USER/". * * @return current user's home directory. */ public Path getHomeDirectory() { return new Path("/user/"+System.getProperty("user.name")).makeQualified( getUri(), null); }
/** * Get a canonical name for this file system. * @return a URI string that uniquely identifies this file system */ public String getCanonicalServiceName() { return SecurityUtil.buildDTServiceName(getUri(), getUriDefaultPort()); }
/** * Make the path fully qualified if it is isn't. * A Fully-qualified path has scheme and authority specified and an absolute * path. * Use the default file system and working dir in this FileContext to qualify. * @param path * @return qualified path */ public Path makeQualified(final Path path) { return path.makeQualified(defaultFS.getUri(), getWorkingDirectory()); }
String thisScheme = this.getUri().getScheme(); String thisHost = this.getUri().getHost(); String thatHost = uri.getHost(); (thisHost == null && thatHost != null)) { throw new InvalidPathException("Wrong FS: " + path + ", expected: " + this.getUri()); int thisPort = this.getUri().getPort(); int thatPort = uri.getPort(); if (thatPort == -1) { // -1 => defaultPort of Uri scheme + this.getUri());
/** * Make the path fully qualified to this file system * @param path * @return the qualified path */ public Path makeQualified(Path path) { checkPath(path); return path.makeQualified(this.getUri(), null); }
/** * Get a canonical name for this file system. * @return a URI string that uniquely identifies this file system */ public String getCanonicalServiceName() { return SecurityUtil.buildDTServiceName(getUri(), getUriDefaultPort()); }
private String schemeFromPath(Path path) throws IOException { String scheme = path.toUri().getScheme(); if (scheme == null) { if (fs != null) { scheme = fs.getUri().getScheme(); } else { scheme = fc.getFSofPath(fc.fixRelativePart(path)). getUri().getScheme(); } } return scheme; }
private String authorityFromPath(Path path) throws IOException { String authority = path.toUri().getAuthority(); if (authority == null) { if (fs != null) { authority = fs.getUri().getAuthority(); } else { authority = fc.getFSofPath(fc.fixRelativePart(path)). getUri().getAuthority(); } } return authority ; }
/** * Constructor to be called by subclasses. * * @param uri for this file system. * @param supportedScheme the scheme supported by the implementor * @param authorityNeeded if true then theURI must have authority, if false * then the URI must have null authority. * * @throws URISyntaxException <code>uri</code> has syntax error */ public AbstractFileSystem(final URI uri, final String supportedScheme, final boolean authorityNeeded, final int defaultPort) throws URISyntaxException { myUri = getUri(uri, supportedScheme, authorityNeeded, defaultPort); statistics = getStatistics(uri); }
@Override public FileStatus next(final AbstractFileSystem fs, final Path p) throws IOException, UnresolvedLinkException { FileStatus fi = fs.getFileLinkStatus(p); if (fi.isSymlink()) { fi.setSymlink(FSLinkResolver.qualifySymlinkTarget(fs.getUri(), p, fi.getSymlink())); } return fi; } }.resolve(this, absF);
p = qualifySymlinkTarget(fs.getUri(), p, fs.getLinkTarget(p)); fs = fc.getFSofPath(p);
@Override public void renameInternal(final Path src, final Path dst, final boolean overwrite) throws IOException, UnresolvedLinkException { // passing resolveLastComponet as false to catch renaming a mount point // itself we need to catch this as an internal operation and fail. InodeTree.ResolveResult<AbstractFileSystem> resSrc = fsState.resolve(getUriPath(src), false); if (resSrc.isInternalDir()) { throw new AccessControlException( "Cannot Rename within internal dirs of mount table: src=" + src + " is readOnly"); } InodeTree.ResolveResult<AbstractFileSystem> resDst = fsState.resolve(getUriPath(dst), false); if (resDst.isInternalDir()) { throw new AccessControlException( "Cannot Rename within internal dirs of mount table: dest=" + dst + " is readOnly"); } //Alternate 1: renames within same file system URI srcUri = resSrc.targetFileSystem.getUri(); URI dstUri = resDst.targetFileSystem.getUri(); ViewFileSystem.verifyRenameStrategy(srcUri, dstUri, resSrc.targetFileSystem == resDst.targetFileSystem, renameStrategy); ChRootedFs srcFS = (ChRootedFs) resSrc.targetFileSystem; ChRootedFs dstFS = (ChRootedFs) resDst.targetFileSystem; srcFS.getMyFs().renameInternal(srcFS.fullPath(resSrc.remainingPath), dstFS.fullPath(resDst.remainingPath), overwrite); }
/** * Return the current user's home directory in this file system. * The default implementation returns "/user/$USER/". * * @return current user's home directory. */ public Path getHomeDirectory() { return new Path("/user/"+System.getProperty("user.name")).makeQualified( getUri(), null); }
/** * Return the current user's home directory in this file system. * The default implementation returns "/user/$USER/". * * @return current user's home directory. */ public Path getHomeDirectory() { return new Path("/user/"+System.getProperty("user.name")).makeQualified( getUri(), null); }
/** * Make the path fully qualified if it is isn't. * A Fully-qualified path has scheme and authority specified and an absolute * path. * Use the default file system and working dir in this FileContext to qualify. * @param path * @return qualified path */ public Path makeQualified(final Path path) { return path.makeQualified(defaultFS.getUri(), getWorkingDirectory()); }
private String authorityFromPath(Path path) throws IOException { String authority = path.toUri().getAuthority(); if (authority == null) { if (fs != null) { authority = fs.getUri().getAuthority(); } else { authority = fc.getFSofPath(fc.fixRelativePart(path)). getUri().getAuthority(); } } return authority ; }