use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class OrchestrationRequests method getOrchestrationRequest.
@GET
@Path("/{version:[vV][4-8]}")
@Operation(description = "Find Orchestrated Requests for a URI Information", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest, @QueryParam(value = "format") String format) throws ApiException {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
List<InfraActiveRequests> activeRequests;
GetOrchestrationListResponse orchestrationList;
Map<String, List<String>> orchestrationMap;
String apiVersion = version.substring(1);
try {
orchestrationMap = msoRequest.getOrchestrationFilters(queryParams);
if (orchestrationMap.isEmpty()) {
throw new ValidationException("At least one filter query param must be specified");
}
} catch (ValidationException ex) {
logger.error("Exception occurred", ex);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.DataError).build();
ValidateException validateException = new ValidateException.Builder(ex.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build();
throw validateException;
}
activeRequests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
orchestrationList = new GetOrchestrationListResponse();
List<RequestList> requestLists = new ArrayList<>();
for (InfraActiveRequests infraActive : activeRequests) {
RequestList requestList = new RequestList();
Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format, version);
if (isRequestProcessingDataRequired(format)) {
List<RequestProcessingData> requestProcessingData = requestsDbClient.getExternalRequestProcessingDataBySoRequestId(infraActive.getRequestId());
if (null != requestProcessingData && !requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
}
}
requestList.setRequest(request);
requestLists.add(requestList);
}
orchestrationList.setRequestList(requestLists);
return builder.buildResponse(HttpStatus.SC_OK, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), orchestrationList, apiVersion);
}
use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class RequestHandlerUtils method updateStatus.
@Override
public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException {
if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
aq.setStatusMessage(errorMessage);
aq.setProgress(new Long(100));
aq.setRequestStatus(status.toString());
Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
aq.setEndTime(endTimeStamp);
try {
infraActiveRequestsClient.save(aq);
} catch (Exception e) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
}
}
}
use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class Onap3gppServiceInstances method deleteServiceInstances.
/**
* process delete service instance request and call corresponding workflow
*
* @param request
* @param action
* @param version
* @return
* @throws ApiException
*/
private Response deleteServiceInstances(DeAllocate3gppService request, Action action, String version, String requestId, HashMap<String, String> instanceIdMap, String requestUri) throws ApiException {
String defaultServiceModelName = "COMMON_SS_DEFAULT";
String requestScope = ModelType.service.name();
String apiVersion = version.substring(1);
String serviceRequestJson = toString.apply(request);
if (serviceRequestJson != null) {
InfraActiveRequests currentActiveReq = createRequestObject(request, action, requestId, Status.IN_PROGRESS, requestScope, serviceRequestJson);
requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, null);
try {
requestsDbClient.save(currentActiveReq);
} catch (Exception e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build();
}
RecipeLookupResult recipeLookupResult;
try {
recipeLookupResult = getServiceInstanceOrchestrationURI(null, action, defaultServiceModelName);
} catch (Exception e) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
if (recipeLookupResult == null) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB");
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
String serviceInstanceType = request.getSubscriptionServiceType();
String serviceInstanceId = request.getServiceInstanceID();
RequestClientParameter parameter;
try {
parameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()).setServiceInstanceId(serviceInstanceId).setServiceType(serviceInstanceType).setRequestDetails(serviceRequestJson).setApiVersion(version).setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).setApiVersion(apiVersion).build();
} catch (Exception e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
}
return postBPELRequest(currentActiveReq, parameter, recipeLookupResult.getOrchestrationURI(), requestScope);
} else {
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, "JsonProcessingException occurred - serviceRequestJson is null", ErrorNumbers.SVC_BAD_PARAMETER, null, version);
return response;
}
}
use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class ResumeOrchestrationRequest method setRequestClientParameter.
protected RequestClientParameter setRequestClientParameter(RecipeLookupResult recipeLookupResult, String version, InfraActiveRequests infraActiveRequest, InfraActiveRequests currentActiveRequest, String pnfCorrelationId, Boolean aLaCarte, ServiceInstancesRequest sir) throws ApiException {
RequestClientParameter requestClientParameter = null;
Action action = Action.valueOf(infraActiveRequest.getRequestAction());
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
Boolean isBaseVfModule = false;
if (requestHandlerUtils.getModelType(action, modelInfo).equals(ModelType.vfModule)) {
isBaseVfModule = requestHandlerUtils.getIsBaseVfModule(modelInfo, action, infraActiveRequest.getVnfType(), msoRequest.getSDCServiceModelVersion(sir), currentActiveRequest);
}
try {
requestClientParameter = new RequestClientParameter.Builder().setRequestId(currentActiveRequest.getRequestId()).setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(infraActiveRequest.getRequestAction()).setServiceInstanceId(infraActiveRequest.getServiceInstanceId()).setPnfCorrelationId(pnfCorrelationId).setVnfId(infraActiveRequest.getVnfId()).setVfModuleId(infraActiveRequest.getVfModuleId()).setVolumeGroupId(infraActiveRequest.getVolumeGroupId()).setNetworkId(infraActiveRequest.getNetworkId()).setServiceType(infraActiveRequest.getServiceType()).setVnfType(infraActiveRequest.getVnfType()).setVfModuleType(msoRequest.getVfModuleType(sir, infraActiveRequest.getRequestScope())).setNetworkType(infraActiveRequest.getNetworkType()).setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(infraActiveRequest.getRequestBody(), sir, aLaCarte, action)).setApiVersion(version).setALaCarte(aLaCarte).setRequestUri(currentActiveRequest.getRequestUrl()).setInstanceGroupId(infraActiveRequest.getInstanceGroupId()).build();
} catch (IOException e) {
logger.error("IOException while generating requestClientParameter to send to BPMN", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
throw new ValidateException.Builder("IOException while generating requestClientParameter to send to BPMN: " + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
}
return requestClientParameter;
}
use of org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo in project so by onap.
the class ResumeOrchestrationRequest method resumeOrchestrationRequest.
@POST
@Path("/{version:[vV][7]}/{requestId}/resume")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Resume request for a given requestId", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Transactional
public Response resumeOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException {
Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
String currentRequestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
logger.info("Beginning resume operation for new request: {}", currentRequestId);
InfraActiveRequests infraActiveRequest = null;
String source = MDC.get(MdcConstants.ORIGINAL_PARTNER_NAME);
String requestorId = MDC.get(HttpHeadersConstants.REQUESTOR_ID);
requestHandlerUtils.getRequestUri(requestContext, uriPrefix);
String requestUri = MDC.get(LogConstants.HTTP_URL);
version = version.substring(1);
try {
infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
} catch (HttpClientErrorException e) {
logger.error("Error occurred while performing requestDb lookup by requestId: " + requestId, e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError).build();
throw new ValidateException.Builder("Exception while performing requestDb lookup by requestId", HttpStatus.SC_NOT_FOUND, ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB).cause(e).errorInfo(errorLoggerInfo).build();
}
InfraActiveRequests currentActiveRequest = requestHandlerUtils.createNewRecordCopyFromInfraActiveRequest(infraActiveRequest, currentRequestId, startTimeStamp, source, requestUri, requestorId, requestId);
if (infraActiveRequest == null) {
logger.error("No infraActiveRequest record found for requestId: {} in requesteDb lookup", requestId);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.BusinessProcessError).build();
ValidateException validateException = new ValidateException.Builder("Null response from requestDB when searching by requestId: " + requestId, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
requestHandlerUtils.updateStatus(currentActiveRequest, Status.FAILED, validateException.getMessage());
throw validateException;
}
return resumeRequest(infraActiveRequest, currentActiveRequest, version, requestUri);
}
Aggregations