Modify application retrieval API

As per the API designing best practices, added offset and limit query parameters for application getting API.
feature/appm-store/pbac
lasanthaDLPDS 7 years ago
parent 71aa6762ac
commit 976d0ad60d

@ -66,8 +66,6 @@ import java.util.Date;
public class ApplicationManagerImpl implements ApplicationManager {
private static final Log log = LogFactory.getLog(ApplicationManagerImpl.class);
private static final int DEFAULT_LIMIT = 20;
private static final int DEFAULT_OFFSET = 10;
private DeviceTypeDAO deviceTypeDAO;
private VisibilityDAO visibilityDAO;
private ApplicationDAO applicationDAO;
@ -843,12 +841,6 @@ public class ApplicationManagerImpl implements ApplicationManager {
private Filter validateFilter(Filter filter) {
if (filter != null) {
if (filter.getLimit() == 0) {
filter.setLimit(DEFAULT_LIMIT);
}
if (filter.getOffset() == 0) {
filter.setOffset(DEFAULT_OFFSET);
}
if (!SortingOrder.ASC.toString().equals(filter.getSortBy()) &&
!SortingOrder.DESC.toString().equals(filter.getSortBy())) {
return null;

@ -133,9 +133,9 @@ public interface ApplicationManagementAPI {
message = "OK. \n Successfully got application list.",
response = ApplicationList.class),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version "
+ "of the requested resource."),
code = 404,
message = "Not Found. There doesn't have an application which is matched with requested " +
"query."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Error occurred while getting the application list.",
@ -146,7 +146,17 @@ public interface ApplicationManagementAPI {
name = "filter",
value = "Filter to get application list",
required = true)
@Valid Filter filter
@Valid Filter filter,
@ApiParam(
name = "offset",
value = "offset",
defaultValue = "0")
@QueryParam("offset") int offset,
@ApiParam(
name = "limit",
value = "limit",
defaultValue = "20")
@QueryParam("limit") int limit
);
@GET

@ -61,10 +61,15 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@GET
@Override
@Consumes("application/json")
public Response getApplications(@Valid Filter filter) {
public Response getApplications(
@Valid Filter filter,
@QueryParam("offset") int offset,
@QueryParam("limit") int limit) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
try {
filter.setOffset(offset);
filter.setLimit(limit);
ApplicationList applications = applicationManager.getApplications(filter);
if (applications.getApplications().isEmpty()) {
return Response.status(Response.Status.NOT_FOUND).entity

Loading…
Cancel
Save