ihuzenko commented on a change in pull request #1692: DRILL-6562: Plugin
Management improvements
URL: https://github.com/apache/drill/pull/1692#discussion_r266468028
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
##########
@@ -137,31 +159,37 @@ public JsonResult enablePlugin(@PathParam("name") String
name, @PathParam("val")
}
@GET
- @Path("/storage/{name}/export")
+ @Path("/storage/{name}/export/{format}")
@Produces(MediaType.APPLICATION_JSON)
- public Response exportPlugin(@PathParam("name") String name) {
- Response.ResponseBuilder response =
Response.ok(getStoragePluginJSON(name));
- response.header("Content-Disposition",
String.format("attachment;filename=\"%s.json\"", name));
- return response.build();
+ public Response exportPlugin(@PathParam("name") String name,
@PathParam("format") String format) {
+ if (JSON_FILE_NAME.equalsIgnoreCase(format) ||
HOCON_FILE_NAME.equalsIgnoreCase(format)) {
+ PluginConfigWrapper storagePluginConfigs = getPluginConfig(name);
+ Response.ResponseBuilder response = Response.ok(storagePluginConfigs);
+ response.header("Content-Disposition",
String.format("attachment;filename=\"%s.%s\"", name, format));
+ return response.build();
+ }
+ logger.error("Unknown file type {} for Storage Plugin Config: {}", format,
name);
+ return Response.status(Response.Status.NOT_FOUND).build();
}
@DELETE
- @Path("/storage/{name}.json")
+ @Path("/storage/{name}.{format}")
@Produces(MediaType.APPLICATION_JSON)
- public JsonResult deletePluginJSON(@PathParam("name") String name) {
- PluginConfigWrapper plugin = getStoragePluginJSON(name);
- if (plugin.deleteFromStorage(storage)) {
- return message("success");
- } else {
- return message("error (unable to delete storage)");
+ public JsonResult deletePlugin(@PathParam("name") String name,
@PathParam("format") String format) {
+ if (JSON_FILE_NAME.equalsIgnoreCase(format) ||
HOCON_FILE_NAME.equalsIgnoreCase(format)) {
Review comment:
Note that similar simplification of nested ```if```'s possible in other
methods too. Please revisit other methods in the class.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services