@Override public void checkPath(Path path) { myFs.checkPath(path); }
/** * 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); }
/** * * @param path * @return return full path including the chroot */ protected Path fullPath(final Path path) { super.checkPath(path); return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString) + path.toUri().getPath()); }
/** * Return the fully-qualified path of path f resolving the path * through any internal symlinks or mount point * @param p path to be resolved * @return fully qualified path * @throws FileNotFoundException, AccessControlException, IOException * UnresolvedLinkException if symbolic link on path cannot be resolved * internally */ public Path resolvePath(final Path p) throws FileNotFoundException, UnresolvedLinkException, AccessControlException, IOException { checkPath(p); return getFileStatus(p).getPath(); // default impl is to return the path }
/** * Get the path-part of a pathname. Checks that URI matches this file system * and that the path-part is a valid name. * * @param p path * * @return path-part of the Path p */ public String getUriPath(final Path p) { checkPath(p); String s = p.toUri().getPath(); if (!isValidName(s)) { throw new InvalidPathException("Path part " + s + " from URI " + p + " is not a valid filename."); } return s; }
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); }
/** * Get the file system of supplied path. * * @param absOrFqPath - absolute or fully qualified path * @return the file system of the path * * @throws UnsupportedFileSystemException If the file system for * <code>absOrFqPath</code> is not supported. * @throws IOException If the file system for <code>absOrFqPath</code> could * not be instantiated. */ protected AbstractFileSystem getFSofPath(final Path absOrFqPath) throws UnsupportedFileSystemException, IOException { absOrFqPath.checkNotSchemeWithRelative(); absOrFqPath.checkNotRelative(); try { // Is it the default FS for this FileContext? defaultFS.checkPath(absOrFqPath); return defaultFS; } catch (Exception e) { // it is different FileSystem return getAbstractFileSystem(ugi, absOrFqPath.toUri(), conf); } }
FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { checkPath(f); int bufferSize = -1; short replication = -1;
/** * * @param path * @return return full path including the chroot */ protected Path fullPath(final Path path) { super.checkPath(path); return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString) + path.toUri().getPath()); }
/** * 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); }
/** * * @param path * @return return full path including the chroot */ protected Path fullPath(final Path path) { super.checkPath(path); return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString) + path.toUri().getPath()); }
/** * * @param path * @return return full path including the chroot */ protected Path fullPath(final Path path) { super.checkPath(path); return new Path((chRootPathPart.isRoot() ? "" : chRootPathPartString) + path.toUri().getPath()); }
@Test public void testCheckPathWithTheSameNonDefaultPort() throws URISyntaxException { URI uri = new URI("dummy://dummy-host:" + OTHER_PORT); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT)); }
@Test public void testCheckPathWithDefaultPort() throws URISyntaxException { URI uri = new URI("dummy://dummy-host:" + DEFAULT_PORT); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host:" + DEFAULT_PORT)); }
@Test(expected=InvalidPathException.class) public void testCheckPathWithDifferentPorts() throws URISyntaxException { URI uri = new URI("dummy://dummy-host:" + DEFAULT_PORT); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT)); }
@Test public void testCheckPathWithNoPorts() throws URISyntaxException { URI uri = new URI("dummy://dummy-host"); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host")); }
@Test public void testCheckPathWithDefaultPort() throws URISyntaxException { URI uri = new URI("dummy://dummy-host:" + DEFAULT_PORT); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host:" + DEFAULT_PORT)); }
@Test(expected=InvalidPathException.class) public void testCheckPathWithDifferentPorts() throws URISyntaxException { URI uri = new URI("dummy://dummy-host:" + DEFAULT_PORT); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT)); }
@Test public void testCheckPathWithoutDefaultPorts() throws URISyntaxException, IOException { URI uri = new URI("dummy://dummy-host"); AbstractFileSystem afs = new DummyDelegateToFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host")); }
@Test public void testCheckPathWithNoPorts() throws URISyntaxException { URI uri = new URI("dummy://dummy-host"); AbstractFileSystem afs = new DummyFileSystem(uri); afs.checkPath(new Path("dummy://dummy-host")); }