This is an automated email from the ASF dual-hosted git repository. dzamo pushed a commit to branch 1.20 in repository https://gitbox.apache.org/repos/asf/drill.git
commit 3bb312f7bd5580d0c4b96adc1822c8ea37f361e4 Author: James Turton <9107319+jntur...@users.noreply.github.com> AuthorDate: Tue Nov 1 19:36:18 2022 +0200 DRILL-8348: Cannot delete disabled storage plugins (#2696) --- .../org/apache/drill/exec/server/rest/StorageResources.java | 11 ++++++----- exec/java-exec/src/main/resources/rest/storage/update.ftl | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java index 1dfdcfb263..a71fd395cb 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/StorageResources.java @@ -59,7 +59,6 @@ import org.apache.drill.common.logical.security.CredentialsProvider; import org.apache.drill.exec.oauth.PersistentTokenTable; import org.apache.drill.exec.oauth.TokenRegistry; import org.apache.drill.exec.server.rest.DrillRestServer.UserAuthEnabled; -import org.apache.drill.exec.store.AbstractStoragePlugin; import org.apache.drill.exec.store.StoragePluginRegistry; import org.apache.drill.exec.store.StoragePluginRegistry.PluginEncodingException; import org.apache.drill.exec.store.StoragePluginRegistry.PluginException; @@ -68,6 +67,7 @@ import org.apache.drill.exec.store.StoragePluginRegistry.PluginNotFoundException import org.apache.drill.exec.store.http.oauth.OAuthUtils; import org.apache.drill.exec.store.security.oauth.OAuthTokenCredentials; import org.eclipse.jetty.util.resource.Resource; +import org.apache.drill.exec.work.WorkManager; import org.glassfish.jersey.server.mvc.Viewable; import org.slf4j.Logger; @@ -88,6 +88,9 @@ public class StorageResources { @Inject StoragePluginRegistry storage; + @Inject + WorkManager workManager; + @Inject SecurityContext sc; @@ -217,8 +220,7 @@ public class StorageResources { Map<String, String> updatedTokens = OAuthUtils.getOAuthTokens(client, accessTokenRequest); // Add to token registry - TokenRegistry tokenRegistry = ((AbstractStoragePlugin) storage.getPlugin(name)) - .getContext() + TokenRegistry tokenRegistry = workManager.getContext() .getoAuthTokenProvider() .getOauthTokenRegistry(); @@ -296,8 +298,7 @@ public class StorageResources { @Produces(MediaType.APPLICATION_JSON) public Response deletePlugin(@PathParam("name") String name) { try { - TokenRegistry tokenRegistry = ((AbstractStoragePlugin) storage.getPlugin(name)) - .getContext() + TokenRegistry tokenRegistry = workManager.getContext() .getoAuthTokenProvider() .getOauthTokenRegistry(); diff --git a/exec/java-exec/src/main/resources/rest/storage/update.ftl b/exec/java-exec/src/main/resources/rest/storage/update.ftl index 972890d464..43a4bb7fb3 100644 --- a/exec/java-exec/src/main/resources/rest/storage/update.ftl +++ b/exec/java-exec/src/main/resources/rest/storage/update.ftl @@ -206,8 +206,14 @@ function deleteFunction() { showConfirmationDialog('"${model.getPlugin().getName()}"' + ' plugin will be deleted. Proceed?', function() { - $.get("/storage/" + encodeURIComponent("${model.getPlugin().getName()}") + "/delete", serverMessage).fail(function() { - serverMessage({ errorMessage: "Error while trying to delete." }) + $.ajax({ + url: '/storage/' + encodeURIComponent('${model.getPlugin().getName()}') + '.json', + method: 'DELETE', + contentType: 'application/json', + success: serverMessage, + error: function(request,msg,error) { + serverMessage({ errorMessage: 'Error while trying to delete.' }) + } }); }); }