[
https://issues.apache.org/jira/browse/RANGER-3500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17610773#comment-17610773
]
Xuze Yang commented on RANGER-3500:
-----------------------------------
The changes are as following:
1. Add sortBy and sortType to searchFilter
2. Support sorting by sortType("desc" means in decreasing order, otherwise in
increasing order)
3. Delete a redundant line of code(In AbstractPredicateUtil#static filed)
When the ranger web ui calls the getServicePolicies(), the sortBy and sortType
parameters are not passed by default, the change is consistent with the
previous return logic.
The patch is updated based on ranger-2.3.0.
Please find attached patch and review PR as per your convenience. Thanks.
CC: [~madhan] [~kirbyzhou] [~kulkabhay] [~rmani] [~bpatel]
> Ranger policy list doesn't support sorting by field
> ---------------------------------------------------
>
> Key: RANGER-3500
> URL: https://issues.apache.org/jira/browse/RANGER-3500
> Project: Ranger
> Issue Type: Bug
> Components: admin
> Affects Versions: 2.1.0
> Reporter: Xuze Yang
> Assignee: Xuze Yang
> Priority: Major
> Attachments:
> 0001-RANGER-3500-Ranger-policy-list-doesn-t-support-sorti.patch,
> 0002-RANGER-3500-Ranger-policy-list-doesn-t-support-sorti.patch
>
>
> When getting the ranger policy list, we may want to sort the returned policy
> list according to certain fields, such as policyId, policyName and etc. But
> case shows that adding the parameters sortBy and sortType to the url has no
> effect (eg:
> [http://192.168.0.12:6080/service/plugins/]policies/service/2?sortBy=policyName&sortType=desc&serviceName=default-Hdfs).
> I look through the source code and find that code supports sorting by
> fields, but due to some code bugs, it did not really take effect.
> The main reason for the problem is that when the SearchFilter is copied
> deeply, only the params is copied, the sortBy and sortType attributes is
> omitted. The code show as follows:
> {code:java}
> // ServiceDBStore # getServicePolicies()
> Map<String, String> paramsCopy = new HashMap<>(filter.getParams());
> SearchFilter searchFilter = new SearchFilter(paramsCopy); {code}
>
> {code:java}
> // SearchFilter.java
> private Map<String, String> params;
> private int startIndex;
> private int maxRows = Integer.MAX_VALUE;
> private boolean getCount = true;
> private String sortBy;
> private String sortType;
> public SearchFilter(Map<String, String> values) {
> setParams(values);
> }
> public void setParams(Map<String, String> params) {
> this.params = params;
> } {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)