Search in sources :

Example 1 with CloudOrchestrationResponse

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);
    }
}
Also used : ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) ValidationException(org.onap.so.exceptions.ValidationException) ResponseBuilder(org.onap.so.apihandler.common.ResponseBuilder) Request(org.onap.so.apihandlerinfra.tenantisolationbeans.Request) ArrayList(java.util.ArrayList) CloudOrchestrationResponse(org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) IOException(java.io.IOException) ValidationException(org.onap.so.exceptions.ValidationException) ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) CloudOrchestrationRequestList(org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) Transactional(javax.transaction.Transactional)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Transactional (javax.transaction.Transactional)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)1 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)1 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 CloudOrchestrationRequestList (org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList)1 CloudOrchestrationResponse (org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse)1 Request (org.onap.so.apihandlerinfra.tenantisolationbeans.Request)1 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)1 ValidationException (org.onap.so.exceptions.ValidationException)1