diff options
author | 2018-03-14 02:07:32 -0400 | |
---|---|---|
committer | 2018-03-14 04:08:41 -0400 | |
commit | 38f720752af4d4aad8c4e467a288d9048659f688 (patch) | |
tree | e81066a8b5c77272e30fb57a64999573c4db4d86 /mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java | |
parent | aee3d223f92a6f250f43e17558a2dfd576ff7294 (diff) |
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases.
Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04
Issue-ID: SO-425
Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java | 425 |
1 files changed, 205 insertions, 220 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java index d60915bf43..7be86fed9d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java @@ -3,7 +3,6 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,40 +37,35 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.http.HttpStatus; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; import org.openecomp.mso.apihandler.common.ErrorNumbers; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2ERequest; -import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationListResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationResponse; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.InstanceReferences; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestList; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestStatus; -import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.requestsdb.InfraActiveRequests; -import org.openecomp.mso.requestsdb.OperationStatus; import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.serviceinstancebeans.GetOrchestrationListResponse; +import org.openecomp.mso.serviceinstancebeans.GetOrchestrationResponse; +import org.openecomp.mso.serviceinstancebeans.InstanceReferences; +import org.openecomp.mso.serviceinstancebeans.Request; +import org.openecomp.mso.serviceinstancebeans.RequestDetails; +import org.openecomp.mso.serviceinstancebeans.RequestList; +import org.openecomp.mso.serviceinstancebeans.RequestStatus; +import org.openecomp.mso.serviceinstancebeans.ServiceInstancesRequest; import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiOperation; -@Path("/") -@Api(value = "/", description = "API Requests for Orchestration requests") +@Path("/orchestrationRequests") +@Api(value="/orchestrationRequests",description="API Requests for Orchestration requests") public class OrchestrationRequests { - public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - - private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); - - private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); + private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); + /** * */ @@ -80,69 +74,66 @@ public class OrchestrationRequests { } @GET - @Path("orchestrationRequests/{version:[vV][2-5]}/{requestId}") - @ApiOperation(value = "Find Orchestrated Requests for a given requestId", response = Response.class) + @Path("/{version:[vV][4-6]}/{requestId}") + @ApiOperation(value="Find Orchestrated Requests for a given requestId",response=Response.class) @Produces(MediaType.APPLICATION_JSON) - public Response getOrchestrationRequest(@PathParam("requestId") String requestId, - @PathParam("version") String version) { + public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version) { GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); - MsoRequest msoRequest = new MsoRequest(requestId); + MsoRequest msoRequest = new MsoRequest (requestId); - long startTime = System.currentTimeMillis(); + long startTime = System.currentTimeMillis (); InfraActiveRequests requestDB = null; - try { - requestDB = requestsDB.getRequestFromInfraActive(requestId); - - } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.AvailabilityError, - "Exception while communciate with Request DB - Infra Request Lookup", e); - msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null); - alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL, - Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, - "Exception while communciate with Request DB"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); - return response; - - } - - if (requestDB == null) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NO_CONTENT, - MsoException.ServiceException, "Orchestration RequestId " + requestId + " is not found in DB", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); - msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Null response from RequestDB when searching by RequestId"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, - "Null response from RequestDB when searching by RequestId"); - msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity()); - return resp; - - } - - Request request = mapInfraActiveRequestToRequest(requestDB); - - orchestrationResponse.setRequest(request); - - return Response.status(200).entity(orchestrationResponse).build(); + try { + requestDB = requestsDB.getRequestFromInfraActive(requestId); + + } catch (Exception e) { + msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e); + msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); + Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, + e.getMessage (), + ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, + null); + alarmLogger.sendAlarm ("MsoDatabaseAccessError", + MsoAlarmLogger.CRITICAL, + Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; + + } + + if(requestDB == null) { + Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NO_CONTENT, + MsoException.ServiceException, + "Orchestration RequestId " + requestId + " is not found in DB", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, + null); + msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); + return resp; + + } + + Request request = mapInfraActiveRequestToRequest(requestDB); + + orchestrationResponse.setRequest(request); + + return Response.status(200).entity(orchestrationResponse).build(); } - - @GET - @Path("orchestrationRequests/{version:[vV][2-5]}") - @ApiOperation(value = "Find Orchestrated Requests for a URI Information", response = Response.class) + @Path("/{version:[vV][4-6]}") + @ApiOperation(value="Find Orchestrated Requests for a URI Information",response=Response.class) @Produces(MediaType.APPLICATION_JSON) public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version) { - long startTime = System.currentTimeMillis(); + long startTime = System.currentTimeMillis (); MsoRequest msoRequest = new MsoRequest(); @@ -152,7 +143,8 @@ public class OrchestrationRequests { GetOrchestrationListResponse orchestrationList = null; - try { + + try{ Map<String, List<String>> orchestrationMap = msoRequest.getOrchestrationFilters(queryParams); @@ -162,7 +154,7 @@ public class OrchestrationRequests { List<RequestList> requestLists = new ArrayList<>(); - for (InfraActiveRequests infraActive : activeRequests) { + for(InfraActiveRequests infraActive : activeRequests){ Request request = mapInfraActiveRequestToRequest(infraActive); RequestList requestList = new RequestList(); @@ -174,216 +166,209 @@ public class OrchestrationRequests { orchestrationList.setRequestList(requestLists); - } catch (Exception e) { - msoLogger.debug("Get Orchestration Request with Filters Failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, - MsoException.ServiceException, "Get Orchestration Request with Filters Failed. " + e.getMessage(), - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null); - msoLogger.error(MessageEnum.APIH_GENERAL_EXCEPTION, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, - "Get Orchestration Request with Filters Failed"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); - return response; + }catch(Exception e){ + msoLogger.debug ("Get Orchestration Request with Filters Failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, + "Get Orchestration Request with Filters Failed. " + e.getMessage(), + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null); + msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Get Orchestration Request with Filters Failed : " + e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Get Orchestration Request with Filters Failed"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); + return response; } - return Response.status(200).entity(orchestrationList).build(); + + return Response.status(200).entity(orchestrationList).build(); } + @POST - @Path("orchestrationRequests/{version: [vV][3-5]}/{requestId}/unlock") + @Path("/{version: [vV][4-6]}/{requestId}/unlock") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Unlock Orchestrated Requests for a given requestId", response = Response.class) - public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, - @PathParam("version") String version) { + @ApiOperation(value="Unlock Orchestrated Requests for a given requestId",response=Response.class) + public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) { - MsoRequest msoRequest = new MsoRequest(requestId); + MsoRequest msoRequest = new MsoRequest (requestId); - long startTime = System.currentTimeMillis(); - msoLogger.debug("requestId is: " + requestId); + long startTime = System.currentTimeMillis (); + msoLogger.debug ("requestId is: " + requestId); InfraActiveRequests requestDB = null; Request request = null; - msoLogger.debug("requestId is: " + requestId); + msoLogger.debug ("requestId is: " + requestId); ServiceInstancesRequest sir = null; - try { + try{ ObjectMapper mapper = new ObjectMapper(); sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); - } catch (Exception e) { - msoLogger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + } catch(Exception e){ + msoLogger.debug ("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null); - if (msoRequest.getRequestId() != null) { - msoLogger.debug("Mapping of request to JSON object failed"); + if (msoRequest.getRequestId () != null) { + msoLogger.debug ("Mapping of request to JSON object failed"); } - msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, - "Mapping of request to JSON object failed"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } - try { + + try{ msoRequest.parseOrchestration(sir); } catch (Exception e) { - msoLogger.debug("Validation failed: ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Error parsing request. " + e.getMessage(), + msoLogger.debug ("Validation failed: ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Error parsing request. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null); - if (msoRequest.getRequestId() != null) { - msoLogger.debug("Logging failed message to the database"); + if (msoRequest.getRequestId () != null) { + msoLogger.debug ("Logging failed message to the database"); } - msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.SchemaError, requestJSON, e); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, - "Validation of the input request failed"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); + msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } try { requestDB = requestsDB.getRequestFromInfraActive(requestId); - if (requestDB == null) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "Orchestration RequestId " + requestId + " is not found in DB", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); - msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.BusinessProcesssError, - "Null response from RequestDB when searching by RequestId"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, - "Null response from RequestDB when searching by RequestId"); - msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity()); + if(requestDB == null) { + Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, + "Orchestration RequestId " + requestId + " is not found in DB", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, + null); + msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from RequestDB when searching by RequestId"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "Null response from RequestDB when searching by RequestId"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); return resp; - } else { + }else{ request = mapInfraActiveRequestToRequest(requestDB); RequestStatus reqStatus = request.getRequestStatus(); Status status = Status.valueOf(reqStatus.getRequestState()); - if (status == Status.IN_PROGRESS || status == Status.PENDING) { - msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED); - reqStatus.setRequestState(Status.UNLOCKED.toString()); - requestsDB.updateInfraStatus(requestId, Status.UNLOCKED.toString(), + if(status == Status.IN_PROGRESS || status == Status.PENDING || status == Status.PENDING_MANUAL_TASK){ + msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED); + reqStatus.setRequestState(Status.UNLOCKED.toString ()); + requestsDB.updateInfraStatus (requestId, + Status.UNLOCKED.toString (), Constants.MODIFIED_BY_APIHANDLER); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "RequestId " + requestId + " has been unlocked"); - - } else { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Orchestration RequestId " + requestId + " has a status of " - + status + " and can not be unlocked", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null); - msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.DataError, "Orchestration RequestId " + requestId + " has a status of " - + status + " and can not be unlocked"); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, - "Orchestration RequestId " + requestId + " has a status of " + status - + " and can not be unlocked"); - msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity()); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "RequestId " + requestId + " has been unlocked"); + + }else{ + Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, + "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, + null); + msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked"); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, "Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ()); return resp; } } } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", - MsoLogger.ErrorCode.AvailabilityError, - "Exception while communciate with Request DB - Infra Request Lookup", e); - msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null); - alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL, - Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, - "Exception while communciate with Request DB"); - msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity()); + msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, Constants.MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e); + msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED); + Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, + e.getMessage (), + ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, + null); + alarmLogger.sendAlarm ("MsoDatabaseAccessError", + MsoAlarmLogger.CRITICAL, + Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB)); + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with Request DB"); + msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ()); return response; } - return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build(); + return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); } - private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) { - - Request request = new Request(); - - ObjectMapper mapper = new ObjectMapper(); - // mapper.configure(Feature.WRAP_ROOT_VALUE, true); - - request.setRequestId(requestDB.getRequestId()); - request.setRequestScope(requestDB.getRequestScope()); - request.setRequestType(requestDB.getRequestAction()); - - InstanceReferences ir = new InstanceReferences(); - if (requestDB.getNetworkId() != null) - ir.setNetworkInstanceId(requestDB.getNetworkId()); - if (requestDB.getNetworkName() != null) - ir.setNetworkInstanceName(requestDB.getNetworkName()); - if (requestDB.getServiceInstanceId() != null) - ir.setServiceInstanceId(requestDB.getServiceInstanceId()); - if (requestDB.getServiceInstanceName() != null) - ir.setServiceInstanceName(requestDB.getServiceInstanceName()); - if (requestDB.getVfModuleId() != null) - ir.setVfModuleInstanceId(requestDB.getVfModuleId()); - if (requestDB.getVfModuleName() != null) - ir.setVfModuleInstanceName(requestDB.getVfModuleName()); - if (requestDB.getVnfId() != null) - ir.setVnfInstanceId(requestDB.getVnfId()); - if (requestDB.getVnfName() != null) - ir.setVnfInstanceName(requestDB.getVnfName()); - if (requestDB.getVolumeGroupId() != null) - ir.setVolumeGroupInstanceId(requestDB.getVolumeGroupId()); - if (requestDB.getVolumeGroupName() != null) - ir.setVolumeGroupInstanceName(requestDB.getVolumeGroupName()); - if (requestDB.getRequestorId() != null) + private Request mapInfraActiveRequestToRequest(InfraActiveRequests requestDB) { + + + Request request = new Request(); + + ObjectMapper mapper = new ObjectMapper(); + // mapper.configure(Feature.WRAP_ROOT_VALUE, true); + + request.setRequestId(requestDB.getRequestId()); + request.setRequestScope(requestDB.getRequestScope()); + request.setRequestType(requestDB.getRequestAction()); + + InstanceReferences ir = new InstanceReferences(); + if(requestDB.getNetworkId() != null) + ir.setNetworkInstanceId(requestDB.getNetworkId()); + if(requestDB.getNetworkName() != null) + ir.setNetworkInstanceName(requestDB.getNetworkName()); + if(requestDB.getServiceInstanceId() != null) + ir.setServiceInstanceId(requestDB.getServiceInstanceId()); + if(requestDB.getServiceInstanceName() != null) + ir.setServiceInstanceName(requestDB.getServiceInstanceName()); + if(requestDB.getVfModuleId() != null) + ir.setVfModuleInstanceId(requestDB.getVfModuleId()); + if(requestDB.getVfModuleName() != null) + ir.setVfModuleInstanceName(requestDB.getVfModuleName()); + if(requestDB.getVnfId() != null) + ir.setVnfInstanceId(requestDB.getVnfId()); + if(requestDB.getVnfName() != null) + ir.setVnfInstanceName(requestDB.getVnfName()); + if(requestDB.getVolumeGroupId() != null) + ir.setVolumeGroupInstanceId(requestDB.getVolumeGroupId()); + if(requestDB.getVolumeGroupName() != null) + ir.setVolumeGroupInstanceName(requestDB.getVolumeGroupName()); + if(requestDB.getRequestorId() != null) ir.setRequestorId(requestDB.getRequestorId()); + request.setInstanceReferences(ir); - String requestBody = requestDB.getRequestBody(); + String requestBody = requestDB.getRequestBody(); - RequestDetails requestDetails = null; + RequestDetails requestDetails = null; - try { - requestDetails = mapper.readValue(requestBody, RequestDetails.class); + try{ + requestDetails = mapper.readValue(requestBody, RequestDetails.class); - } catch (Exception e) { - msoLogger.debug("Exception caught mapping requestBody to RequestDetails", e); - } + }catch(Exception e){ + msoLogger.debug("Exception caught mapping requestBody to RequestDetails"); + } - request.setRequestDetails(requestDetails); - String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) - + " GMT"; - request.setStartTime(startTimeStamp); + request.setRequestDetails(requestDetails); + String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getStartTime()) + " GMT"; + request.setStartTime(startTimeStamp); - RequestStatus status = new RequestStatus(); - if (requestDB.getStatusMessage() != null) { - status.setStatusMessage(requestDB.getStatusMessage()); - } + RequestStatus status = new RequestStatus(); + if(requestDB.getStatusMessage() != null){ + status.setStatusMessage(requestDB.getStatusMessage()); + } - if (requestDB.getEndTime() != null) { - String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) - + " GMT"; - status.setFinishTime(endTimeStamp); - } + if(requestDB.getEndTime() != null){ + String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(requestDB.getEndTime()) + " GMT"; + status.setFinishTime(endTimeStamp); + } - if (requestDB.getRequestStatus() != null) { - status.setRequestState(requestDB.getRequestStatus()); - } - if (requestDB.getProgress() != null) { - status.setPercentProgress(requestDB.getProgress().intValue()); - } + if(requestDB.getRequestStatus() != null){ + status.setRequestState(requestDB.getRequestStatus()); + } - request.setRequestStatus(status); + if(requestDB.getProgress() != null){ + status.setPercentProgress(requestDB.getProgress().intValue()); + } - return request; - } + request.setRequestStatus(status); -}
\ No newline at end of file + return request; + } + } |