aielchiieva commented on a change in pull request #1692: DRILL-6562: Plugin 
Management improvements
URL: https://github.com/apache/drill/pull/1692#discussion_r267361287
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java
 ##########
 @@ -147,49 +131,42 @@ public Viewable getPlugin(@PathParam("name") String 
name) {
   public JsonResult enablePlugin(@PathParam("name") String name, 
@PathParam("val") Boolean enable) {
     PluginConfigWrapper plugin = getPluginConfig(name);
     try {
-      if (plugin.setEnabledInStorage(storage, enable)) {
-        return message("success");
-      } else {
-        return message("error (plugin does not exist)");
-      }
+      return plugin.setEnabledInStorage(storage, enable)
+          ? message("success")
+          : message("error (plugin does not exist)");
     } catch (ExecutionSetupException e) {
-      logger.debug("Error in enabling storage name: " + name + " flag: " + 
enable);
-      return message("error (unable to enable/ disable storage)");
+      logger.debug("Error in enabling storage name: {} flag: {}",  name, 
enable);
+      return message("error (unable to enable / disable storage)");
     }
   }
 
   @GET
   @Path("/storage/{name}/export/{format}")
   @Produces(MediaType.APPLICATION_JSON)
   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();
+    return isSupported(format)
+        ? Response.ok(getPluginConfig(name))
+            .header(HttpHeaders.CONTENT_DISPOSITION, 
String.format("attachment;filename=\"%s.%s\"", name, format))
+            .build()
+        : Response.status(Response.Status.NOT_FOUND.getStatusCode(),
+               String.format("Unknown file type %s for Storage Plugin Config: 
%s", format, name))
+            .build();
   }
 
   @DELETE
   @Path("/storage/{name}.{format}")
   @Produces(MediaType.APPLICATION_JSON)
   public JsonResult deletePlugin(@PathParam("name") String name, 
@PathParam("format") String format) {
-    if (JSON_FILE_NAME.equalsIgnoreCase(format) || 
HOCON_FILE_NAME.equalsIgnoreCase(format)) {
-      PluginConfigWrapper plugin = getPluginConfig(name);
-      if (plugin.deleteFromStorage(storage)) {
-        return message("Success");
-      }
-    }
-    return message("Error (unable to delete %s.%s storage plugin)", name, 
format);
+    return isSupported(format) && 
getPluginConfig(name).deleteFromStorage(storage)
+        ? message("Success")
+        : message("Error (unable to delete %s.%s storage plugin)", name, 
format);
 
 Review comment:
   Please give an example of error message, not quite sure how this will look 
like: `%s.%s `

----------------------------------------------------------------
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

Reply via email to