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()) {
for (ApplicationRelease appRelease : application.getApplicationReleases()) { List<ApplicationRelease> publishedApplicationRelease = new ArrayList<>();
if (AppLifecycleState.PUBLISHED.toString().equals(appRelease.getLifecycleState().getCurrentState())){ for (ApplicationRelease appRelease : application.getApplicationReleases()) {
publishedApplicationRelease.add(appRelease); if (AppLifecycleState.PUBLISHED.toString()
.equals(appRelease.getLifecycleState().getCurrentState())) {
publishedApplicationRelease.add(appRelease);
}
} }
if (publishedApplicationRelease.size() > 1) {
String msg = "Application " + application.getName()
+ " has more than one PUBLISHED application releases";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
application.setApplicationReleases(publishedApplicationRelease);
filteredApps.add(application);
} }
if (publishedApplicationRelease.size() > 1) { applications.setApplications(filteredApps);
String msg = return Response.status(Response.Status.OK).entity(applications).build();
"Application " + application.getName() + " has more than one PUBLISHED application releases";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
application.setApplicationReleases(publishedApplicationRelease);
return Response.status(Response.Status.OK).entity(application).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