Skip to content

Commit

Permalink
Merge pull request #15 from slaclab/SDC-72_Cleanup_stacktrace
Browse files Browse the repository at this point in the history
[SDC-72] Cleanup Stacktrace
  • Loading branch information
brianv0 authored Mar 29, 2017
2 parents 098eefd + 34e720f commit 2cbb1de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Response getChildren( @DefaultValue("100000") @QueryParam("max") int max,
} catch (NoSuchFileException ex){
throw new RestException(ex,404, "File doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (NotDirectoryException ex){
throw new RestException(ex,404,"File exists, but Path is not a container");
} catch (IOException ex){
Expand Down Expand Up @@ -152,7 +152,7 @@ public Response createContainer(MultivaluedMap<String, String> formParams) throw
} catch (NoSuchFileException ex){
throw new RestException(ex ,404, "Parent file doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (NotDirectoryException ex){
throw new RestException(ex, 404, "File exists, but Path is not a container");
} catch (IOException ex){
Expand Down Expand Up @@ -186,7 +186,7 @@ public Response createContainerJson(DatasetContainer container) throws IOExcepti
} catch (NoSuchFileException ex){
throw new RestException(ex ,404, "Parent file doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (NotDirectoryException ex){
throw new RestException(ex, 404, "File exists, but Path is not a container");
} catch (IOException ex){
Expand Down Expand Up @@ -232,7 +232,7 @@ public Response deleteContainer() throws IOException{
} catch (NoSuchFileException ex){
throw new RestException(ex, 404, "Directory doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Response getDataset(@PathParam("id") String path,
// TODO: Check exception
throw new RestException(ex, 400 , "The target is not a dataset", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
Expand Down Expand Up @@ -199,7 +199,7 @@ public Response createDataset(java.nio.file.Path datasetPath, DatasetModel reqDs
} catch (NoSuchFileException ex){
throw new RestException(ex, 404, "Parent file doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (NotDirectoryException ex){
throw new RestException(ex, 404, "File exists, but Path is not a container");
} catch (IOException ex){
Expand Down Expand Up @@ -294,7 +294,7 @@ private Response handleFileAlreadyExists(FileAlreadyExistsException ex, java.nio
locationHeader.put("Location", newUriBuilder.build());
throw new RestException(ex, 409, "A Location Already exists for that site", null, locationHeader);
}
throw new RestException(ex, 409);
throw new RestException(ex, 409, ex.getMessage(), ex.getCause().getMessage());
}

@PATCH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public Response getHead(@DefaultValue("false") @QueryParam("refresh") boolean re
} catch (IllegalArgumentException ex){
throw new RestException(ex, 400 , "Unable to correctly process view", ex.getMessage());
} catch (NoSuchFileException ex){
throw new RestException(ex,404 , "File doesn't exist", ex.getMessage());
throw new RestException(ex, 404 , "File doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
Expand Down Expand Up @@ -177,9 +177,9 @@ public Response getBean(String path, HashMap<String,List<String>> matrixParams,
} catch (NoSuchFileException ex){
throw new RestException(ex,404 , "File doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Response getAclOrPermissions(@DefaultValue("") @QueryParam("subject") Str
} catch (NoSuchFileException ex){
throw new RestException(ex,404 , "File doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
Expand All @@ -104,7 +104,7 @@ public Response setAcl(List<AclEntryProxy> proxyAcl){
} catch (NoSuchFileException ex){
throw new RestException(ex,404 , "File doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
Expand Down Expand Up @@ -135,7 +135,7 @@ public Response mergeAcl(List<AclEntryProxy> proxyAcl){
} catch (NoSuchFileException ex){
throw new RestException(ex,404 , "File doesn't exist", ex.getMessage());
} catch (AccessDeniedException ex){
throw new RestException(ex, 403);
throw new RestException(ex, 403, ex.getMessage());
} catch (IOException ex){
Logger.getLogger(PermissionsResource.class.getName()).log(Level.WARNING, "Unknown exception", ex);
throw new RestException(ex, 500);
Expand Down
20 changes: 7 additions & 13 deletions vfs/src/main/java/org/srs/vfs/AbstractFsProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,12 @@ public FileStore getFileStore(Path path) throws IOException{
}

public static enum AfsException {
ACCESS_DENIED(AccessDeniedException.class),
NO_SUCH_FILE(NoSuchFileException.class),
NOT_DIRECTORY(NotDirectoryException.class),
DIRECTORY_NOT_EMPTY(DirectoryNotEmptyException.class),
FILE_EXISTS(FileAlreadyExistsException.class),
GENERIC(FileSystemException.class);

private final Class<? extends FileSystemException> exceptionClass;

private AfsException(Class<? extends FileSystemException> exceptionClass){
this.exceptionClass = exceptionClass;
}
ACCESS_DENIED,
NO_SUCH_FILE,
NOT_DIRECTORY,
DIRECTORY_NOT_EMPTY,
FILE_EXISTS,
GENERIC;

/*
TODO: Untested and unused
Expand Down Expand Up @@ -140,7 +134,7 @@ public String getReason(){
public String getMessage(){
return msg;
}

}

private static class ContainerNotEmptyException extends DirectoryNotEmptyException {
Expand Down

0 comments on commit 2cbb1de

Please sign in to comment.