Check offset value have or not

offset-is-not-working
Nishan Sangeeth 1 year ago
parent 6344fc1469
commit 6973d7aa11

@ -697,26 +697,29 @@ public class UserManagementServiceImpl implements UserManagementService {
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME)); user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
userList.add(user); userList.add(user);
} }
if (offset==0) {
int toIndex = offset + limit; return Response.status(Response.Status.OK).entity(userList).build();
int listSize = userList.size(); } else {
int lastIndex = listSize - 1; int toIndex = offset + limit;
int listSize = userList.size();
List<UserInfo> offsetList; int lastIndex = listSize - 1;
if (offset <= lastIndex) {
if (toIndex <= listSize) { List<UserInfo> offsetList;
offsetList = userList.subList(offset, toIndex); if (offset <= lastIndex) {
if (toIndex <= listSize) {
offsetList = userList.subList(offset, toIndex);
} else {
offsetList = userList.subList(offset, listSize);
}
} else { } else {
offsetList = userList.subList(offset, listSize); offsetList = new ArrayList<>();
} }
} else { UserInfoList result = new UserInfoList();
offsetList = new ArrayList<>(); result.setList(offsetList);
} result.setCount(userList.size());
UserInfoList result = new UserInfoList();
result.setList(offsetList);
result.setCount(userList.size());
return Response.status(Response.Status.OK).entity(result).build(); return Response.status(Response.Status.OK).entity(result).build();
}
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving the list of users using the filter : " + filter; String msg = "Error occurred while retrieving the list of users using the filter : " + filter;
log.error(msg, e); log.error(msg, e);

Loading…
Cancel
Save