Skip to content

Commit b59f0d6

Browse files
Support export policies in a segmented manner
1 parent dc2ac1b commit b59f0d6

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,9 +4313,9 @@ private List<RangerPolicy> getRangerPoliciesInRange(List<RangerPolicy> policyLis
43134313
if (CollectionUtils.isNotEmpty(policyList)) {
43144314
int totalCount = policyList.size();
43154315
int startIndex = filter.getBeginIndex();
4316-
int pageSize = filter.getOffset();
4317-
int toIndex = Math.min(startIndex + pageSize, totalCount);
4318-
LOG.info("==>totalCount: {}, startIndex:{}, pageSize: {}, toIndex: {}" , totalCount, startIndex, pageSize, toIndex);
4316+
int offset = filter.getOffset();
4317+
int toIndex = Math.min(startIndex + offset, totalCount);
4318+
LOG.info("==>totalCount: {}, startIndex:{}, offsetSize: {}, toIndex: {}" , totalCount, startIndex, offset, toIndex);
43194319
String sortType = filter.getSortType();
43204320
String sortBy = filter.getSortBy();
43214321

@@ -4326,9 +4326,7 @@ private List<RangerPolicy> getRangerPoliciesInRange(List<RangerPolicy> policyLis
43264326
policyList.sort(this.getPolicyComparator(sortBy, sortType));
43274327
}
43284328
} else if (SearchFilter.POLICY_NAME.equalsIgnoreCase(sortBy)) {
4329-
if (SORT_ORDER.ASC.name().equalsIgnoreCase(sortType)) {
4330-
policyList.sort(this.getPolicyComparator(sortBy, sortType));
4331-
} else if (SORT_ORDER.DESC.name().equalsIgnoreCase(sortType)) {
4329+
if (SORT_ORDER.ASC.name().equalsIgnoreCase(sortType) || SORT_ORDER.DESC.name().equalsIgnoreCase(sortType)) {
43324330
policyList.sort(this.getPolicyComparator(sortBy, sortType));
43334331
} else {
43344332
LOG.info("Invalid or Unsupported sortType : {}", sortType);
@@ -4338,10 +4336,7 @@ private List<RangerPolicy> getRangerPoliciesInRange(List<RangerPolicy> policyLis
43384336
}
43394337
}
43404338

4341-
retList = new ArrayList<RangerPolicy>();
4342-
for (int i = startIndex; i < toIndex; i++) {
4343-
retList.add(policyList.get(i));
4344-
}
4339+
retList = new ArrayList<>(policyList.subList(startIndex, toIndex));
43454340

43464341
}
43474342
return retList;

0 commit comments

Comments
 (0)