use of org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse in project so by onap.
the class CloudResourcesOrchestration method getOperationEnvironmentStatusFilter.
@GET
@Path("/{version:[vV][1]}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Get status of an Operational Environment based on filter criteria", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Transactional
public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version) throws ApiException {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
List<String> requestIdKey = queryParams.get("requestId");
String apiVersion = version.substring(1);
if (queryParams.size() == 1 && requestIdKey != null) {
String requestId = requestIdKey.get(0);
CloudOrchestrationResponse cloudOrchestrationGetResponse = new CloudOrchestrationResponse();
InfraActiveRequests requestDB;
try {
requestDB = requestDbClient.getInfraActiveRequestbyRequestId(requestId);
} catch (Exception e) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError).build();
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
throw validateException;
}
if (requestDB == null) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcessError).build();
ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
throw validateException;
}
Request request = mapInfraActiveRequestToRequest(requestDB);
cloudOrchestrationGetResponse.setRequest(request);
return builder.buildResponse(HttpStatus.SC_OK, requestId, cloudOrchestrationGetResponse, apiVersion);
} else {
TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest();
List<InfraActiveRequests> activeRequests;
CloudOrchestrationRequestList orchestrationList;
Map<String, String> orchestrationMap;
try {
orchestrationMap = tenantIsolationRequest.getOrchestrationFilters(queryParams);
} catch (ValidationException ex) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcessError).build();
ValidateException validateException = new ValidateException.Builder(ex.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build();
throw validateException;
}
activeRequests = requestDbClient.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
orchestrationList = new CloudOrchestrationRequestList();
List<CloudOrchestrationResponse> requestLists = new ArrayList<>();
for (InfraActiveRequests infraActive : activeRequests) {
Request request = mapInfraActiveRequestToRequest(infraActive);
CloudOrchestrationResponse requestList = new CloudOrchestrationResponse();
requestList.setRequest(request);
requestLists.add(requestList);
}
orchestrationList.setRequestList(requestLists);
return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion);
}
}
Aggregations