Example #1
0
  @Override
  public boolean rename(final Path src, final Path dst) throws IOException {
    // passing resolveLastComponet as false to catch renaming a mount point to
    // itself. We need to catch this as an internal operation and fail.
    InodeTree.ResolveResult<FileSystem> resSrc = fsState.resolve(getUriPath(src), false);

    if (resSrc.isInternalDir()) {
      throw readOnlyMountTable("rename", src);
    }

    InodeTree.ResolveResult<FileSystem> resDst = fsState.resolve(getUriPath(dst), false);
    if (resDst.isInternalDir()) {
      throw readOnlyMountTable("rename", dst);
    }
    /**
     * // Alternate 1: renames within same file system - valid but we disallow // Alternate 2: (as
     * described in next para - valid but we have disallowed it // // Note we compare the URIs. the
     * URIs include the link targets. // hence we allow renames across mount links as long as the
     * mount links // point to the same target. if (!resSrc.targetFileSystem.getUri().equals(
     * resDst.targetFileSystem.getUri())) { throw new IOException("Renames across Mount points not
     * supported"); }
     */

    //
    // Alternate 3 : renames ONLY within the the same mount links.
    //
    if (resSrc.targetFileSystem != resDst.targetFileSystem) {
      throw new IOException("Renames across Mount points not supported");
    }
    return resSrc.targetFileSystem.rename(resSrc.remainingPath, resDst.remainingPath);
  }
Example #2
0
 @Override
 public Path resolvePath(final Path f) throws IOException {
   final InodeTree.ResolveResult<FileSystem> res;
   res = fsState.resolve(getUriPath(f), true);
   if (res.isInternalDir()) {
     return f;
   }
   return res.targetFileSystem.resolvePath(res.remainingPath);
 }
Example #3
0
 @Override
 public boolean delete(final Path f, final boolean recursive)
     throws AccessControlException, FileNotFoundException, IOException {
   InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(f), true);
   // If internal dir or target is a mount link (ie remainingPath is Slash)
   if (res.isInternalDir() || res.remainingPath == InodeTree.SlashPath) {
     throw readOnlyMountTable("delete", f);
   }
   return res.targetFileSystem.delete(res.remainingPath, recursive);
 }
Example #4
0
  @Override
  public FileStatus[] listStatus(final Path f)
      throws AccessControlException, FileNotFoundException, IOException {
    InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(f), true);

    FileStatus[] statusLst = res.targetFileSystem.listStatus(res.remainingPath);
    if (!res.isInternalDir()) {
      // We need to change the name in the FileStatus as described in
      // {@link #getFileStatus }
      ChRootedFileSystem targetFs;
      targetFs = (ChRootedFileSystem) res.targetFileSystem;
      int i = 0;
      for (FileStatus status : statusLst) {
        String suffix = targetFs.stripOutRoot(status.getPath());
        statusLst[i++] =
            new ViewFsFileStatus(
                status,
                this.makeQualified(suffix.length() == 0 ? f : new Path(res.resolvedPath, suffix)));
      }
    }
    return statusLst;
  }
Example #5
0
 public Path getTrashCanLocation(final Path f) throws FileNotFoundException {
   final InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(f), true);
   return res.isInternalDir() ? null : res.targetFileSystem.getHomeDirectory();
 }