You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2025/09/24 11:00:10 UTC

(ranger) branch RANGER-5259_master created (now f6b3c8861)

This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a change to branch RANGER-5259_master
in repository https://gitbox.apache.org/repos/asf/ranger.git


      at f6b3c8861 RANGER-5259: Add REST API to delete stale entries of Plugin info

This branch includes the following new commits:

     new f6b3c8861 RANGER-5259: Add REST API to delete stale entries of Plugin info

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(ranger) 01/01: RANGER-5259: Add REST API to delete stale entries of Plugin info

Posted by pr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a commit to branch RANGER-5259_master
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit f6b3c88618254a37e9e8d2a4e95d3281be35343e
Author: Pradeep AgrawaL <pr...@apache.org>
AuthorDate: Wed Sep 24 15:14:48 2025 +0530

    RANGER-5259: Add REST API to delete stale entries of Plugin info
---
 .../main/java/org/apache/ranger/biz/AssetMgr.java  |  7 ++++
 .../java/org/apache/ranger/rest/ServiceREST.java   | 42 ++++++++++++++++++++++
 .../ranger/security/context/RangerAPIList.java     |  1 +
 .../ranger/security/context/RangerAPIMapping.java  |  1 +
 4 files changed, 51 insertions(+)

diff --git a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
index 919e2d656..b460d0762 100644
--- a/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
+++ b/security-admin/src/main/java/org/apache/ranger/biz/AssetMgr.java
@@ -1506,6 +1506,13 @@ private void doDeleteXXPluginInfo(RangerPluginInfo pluginInfo) {
         }
     }
 
+    public void doDeleteXXPluginInfo(Long id) {
+        XXPluginInfo xObj = rangerDaoManager.getXXPluginInfo().getById(id);
+        if (xObj != null) {
+            rangerDaoManager.getXXPluginInfo().remove(xObj.getId());
+        }
+    }
+
     private String getRemoteAddress(final HttpServletRequest request) {
         String ret = null;
 
diff --git a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
index dc7f90881..169f078af 100644
--- a/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
+++ b/security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java
@@ -2852,6 +2852,48 @@ public RangerPluginInfoList getPluginsInfo(@Context HttpServletRequest request)
         return ret;
     }
 
+    @DELETE
+    @Path("/plugins/info")
+    @Produces("application/json")
+    @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+    public void deletePluginsInfo(@Context HttpServletRequest request) {
+        LOG.debug("==> ServiceREST.deletePluginsInfo()");
+
+        RangerPluginInfoList ret    = null;
+        SearchFilter         filter = searchUtil.getSearchFilter(request, pluginInfoService.getSortFields());
+
+        try {
+            PList<RangerPluginInfo> paginatedPluginsInfo = pluginInfoService.searchRangerPluginInfo(filter);
+            if (paginatedPluginsInfo != null) {
+                for (RangerPluginInfo rangerPluginInfo : paginatedPluginsInfo.getList()) {
+                    if (rangerPluginInfo != null) {
+                        deletePluginsInfo(rangerPluginInfo.getId());
+                        LOG.debug("Deleted rangerPluginInfo:[{}]", rangerPluginInfo);
+                    }
+                }
+            }
+        } catch (WebApplicationException excp) {
+            throw excp;
+        } catch (Throwable excp) {
+            LOG.error("deletePluginsInfo() failed", excp);
+
+            throw restErrorUtil.createRESTException(excp.getMessage());
+        }
+
+        LOG.debug("<== ServiceREST.deletePluginsInfo()");
+    }
+
+    @DELETE
+    @Path("/plugins/info/{id}")
+    @PreAuthorize("hasRole('ROLE_SYS_ADMIN')")
+    public void deletePluginsInfo(@PathParam("id") Long id) {
+        LOG.debug("==> ServiceREST.deletePluginsInfo({})", id);
+
+        assetMgr.doDeleteXXPluginInfo(id);
+
+        LOG.debug("<== ServiceREST.deletePluginsInfo() - [id={}]", id);
+    }
+
     public void blockIfGdsService(String serviceName) {
         String serviceType = daoManager.getXXServiceDef().findServiceDefTypeByServiceName(serviceName);
 
diff --git a/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIList.java b/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIList.java
index 08fccdb7e..d489bb56d 100755
--- a/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIList.java
+++ b/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIList.java
@@ -87,6 +87,7 @@ public class RangerAPIList {
     public static final String GET_POLICY_VERSION_LIST         = "ServiceREST.getPolicyVersionList";
     public static final String GET_POLICY_FOR_VERSION_NO       = "ServiceREST.getPolicyForVersionNumber";
     public static final String GET_PLUGINS_INFO                = "ServiceREST.getPluginsInfo";
+    public static final String DELETE_PLUGINS_INFO             = "ServiceREST.deletePluginsInfo";
     public static final String GET_METRICS_BY_TYPE             = "ServiceREST.getMetricByType";
     public static final String DELETE_CLUSTER_SERVICES         = "ServiceREST.deleteClusterServices";
 
diff --git a/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIMapping.java b/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIMapping.java
index 115920720..1c4ee1183 100644
--- a/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIMapping.java
+++ b/security-admin/src/main/java/org/apache/ranger/security/context/RangerAPIMapping.java
@@ -376,6 +376,7 @@ private void mapAuditWithAPIs() {
         apiAssociatedWithAudit.add(RangerAPIList.GET_POLICY_FROM_EVENT_TIME);
         apiAssociatedWithAudit.add(RangerAPIList.GET_POLICY_VERSION_LIST);
         apiAssociatedWithAudit.add(RangerAPIList.GET_PLUGINS_INFO);
+        apiAssociatedWithAudit.add(RangerAPIList.DELETE_PLUGINS_INFO);
         apiAssociatedWithAudit.add(RangerAPIList.GET_SERVICE);
         apiAssociatedWithAudit.add(RangerAPIList.GET_SERVICE_BY_NAME);
         apiAssociatedWithAudit.add(RangerAPIList.GET_SERVICE_DEF);