-
Notifications
You must be signed in to change notification settings - Fork 1k
RANGER-5259: Add REST API to delete stale entries of Plugin info #683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a info level log here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do in the next patch. |
||
} | ||
} 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to expose ithis method via REST, given There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This REST is designed keeping in the mind that option can be exposed in future on the RANGER UI to delete the selected row. Currently there is no option in the UI to delete the stale entries. if the concern is that such REST APIs should not be there then there are many such APIs which exists in ranger. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. I suggest to introduce this API when we add UI for this. |
||
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); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving this method to AdminREST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done.