Fix build failure

feature/appm-store/pbac
lasanthaDLPDS 6 years ago
parent f6532e2e5f
commit 23e3732ac1

@ -98,32 +98,41 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI {
@GET @GET
@Consumes("application/json") @Consumes("application/json")
@Path("/{appType}") @Path("/{appType}")
public Response getApplication( public Response getApplication(@PathParam("appType") String appType,
@PathParam("appType") String appType,
@QueryParam("appName") String appName) { @QueryParam("appName") String appName) {
ApplicationManager applicationManager = APIUtil.getApplicationManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager();
List<ApplicationRelease> publishedApplicationRelease = new ArrayList<>(); List<Application> filteredApps = new ArrayList<>();
Filter filter;
try { try {
Application application = applicationManager.getApplication(appType, appName); filter = new Filter();
if (application == null) { filter.setOffset(0);
filter.setLimit(20);
filter.setAppType(appType);
filter.setAppName(appName);
ApplicationList applications = applicationManager.getApplications(filter);
if (applications.getApplications().isEmpty()) {
return Response.status(Response.Status.NOT_FOUND) return Response.status(Response.Status.NOT_FOUND)
.entity("Application with application type: " + appType + " not found").build(); .entity("Application with application type: " + appType + " not found").build();
} }
for (Application application : applications.getApplications()) {
List<ApplicationRelease> publishedApplicationRelease = new ArrayList<>();
for (ApplicationRelease appRelease : application.getApplicationReleases()) { for (ApplicationRelease appRelease : application.getApplicationReleases()) {
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getLifecycleState().getCurrentState())){ if (AppLifecycleState.PUBLISHED.toString()
.equals(appRelease.getLifecycleState().getCurrentState())) {
publishedApplicationRelease.add(appRelease); publishedApplicationRelease.add(appRelease);
} }
} }
if (publishedApplicationRelease.size() > 1) { if (publishedApplicationRelease.size() > 1) {
String msg = String msg = "Application " + application.getName()
"Application " + application.getName() + " has more than one PUBLISHED application releases"; + " has more than one PUBLISHED application releases";
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} }
application.setApplicationReleases(publishedApplicationRelease); application.setApplicationReleases(publishedApplicationRelease);
filteredApps.add(application);
return Response.status(Response.Status.OK).entity(application).build(); }
applications.setApplications(filteredApps);
return Response.status(Response.Status.OK).entity(applications).build();
} catch (NotFoundException e) { } catch (NotFoundException e) {
return Response.status(Response.Status.NOT_FOUND).build(); return Response.status(Response.Status.NOT_FOUND).build();
} catch (ApplicationManagementException e) { } catch (ApplicationManagementException e) {

Loading…
Cancel
Save