fileInfo.setFileBlockInfos(getFileBlockInfoListInternal(inodePath)); } catch (InvalidPathException e) { throw new FileDoesNotExistException(e.getMessage(), e); resolution = mMountTable.resolve(uri); } catch (InvalidPathException e) { throw new FileDoesNotExistException(e.getMessage(), e);
/** * Tests {@link PathUtils#subtractPaths(String, String)} throws the right exception if an input * path is invalid or the second argument isn't a prefix of the first. */ @Test public void subtractPathsException() throws InvalidPathException { try { PathUtils.subtractPaths("", "/"); fail("\"\" should throw an InvalidPathException"); } catch (InvalidPathException e) { assertEquals(ExceptionMessage.PATH_INVALID.getMessage(""), e.getMessage()); } try { PathUtils.subtractPaths("/", "noslash"); fail("noslash should be an invalid path"); } catch (InvalidPathException e) { assertEquals(ExceptionMessage.PATH_INVALID.getMessage("noslash"), e.getMessage()); } try { PathUtils.subtractPaths("/a", "/not/a/prefix"); fail("subtractPaths should complain about the prefix not being a prefix"); } catch (RuntimeException e) { String expectedMessage = "Cannot subtract /not/a/prefix from /a because it is not a prefix"; assertEquals(expectedMessage, e.getMessage()); } }
return response; } catch (InvalidPathException e) { response.setInvalidPathException("Error: invalid path " + e.getMessage()); return response; } catch (AccessControlException e) {
fail("Should not have been able to delete the root"); } catch (InvalidPathException e) { assertEquals(ExceptionMessage.DELETE_ROOT_DIRECTORY.getMessage(), e.getMessage());
fail("Renaming to root should fail."); } catch (InvalidPathException e) { assertEquals(ExceptionMessage.RENAME_CANNOT_BE_TO_ROOT.getMessage(), e.getMessage()); fail("Should not be able to rename root"); } catch (InvalidPathException e) { assertEquals(ExceptionMessage.ROOT_CANNOT_BE_RENAMED.getMessage(), e.getMessage());
.getMessage("hdfs://localhost", "hdfs://localhost"), e.getMessage()); .getMessage("s3a://localhost", "s3a://localhost"), e.getMessage());
/** * Attempts to delete the file or directory with the specified path. * * @param cPath path to delete * @param recursive if true, will attempt to delete all children of the path * @return true if one or more files/directories were deleted; false otherwise * @throws IOException if the path failed to be deleted due to some constraint (ie. non empty * directory with recursive flag disabled) */ @Override public boolean delete(Path cPath, boolean recursive) throws IOException { LOG.info("delete({}, {})", cPath, recursive); if (mStatistics != null) { mStatistics.incrementWriteOps(1); } AlluxioURI path = new AlluxioURI(HadoopUtils.getPathWithoutScheme(cPath)); DeleteOptions options = DeleteOptions.defaults().setRecursive(recursive); try { mFileSystem.delete(path, options); return true; } catch (InvalidPathException e) { LOG.info("delete failed: {}", e.getMessage()); return false; } catch (FileDoesNotExistException e) { LOG.info("delete failed: {}", e.getMessage()); return false; } catch (AlluxioException e) { throw new IOException(e); } }
} catch (InvalidPathException e) { request.setAttribute("InvalidPathException", "Error: invalid path " + e.getMessage()); getServletContext().getRequestDispatcher("/browse.jsp").forward(request, response); } catch (AccessControlException e) {
.equals(e.getMessage())) { throw e;
LOG.warn("Failed to delete path from UFS: {}", e.getMessage());
fileInfo.setFileBlockInfos(getFileBlockInfoListInternal(inodePath)); } catch (InvalidPathException e) { throw new FileDoesNotExistException(e.getMessage(), e); resolution = mMountTable.resolve(uri); } catch (InvalidPathException e) { throw new FileDoesNotExistException(e.getMessage(), e);