use of org.onap.so.client.exception.MapperException in project so by onap.
the class SdnCommonTasks method buildJsonRequest.
/**
* @param request
* @return
* @throws MapperException
*/
public String buildJsonRequest(Object request) throws MapperException {
String jsonRequest;
ObjectMapper objMapper = new ObjectMapper();
objMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
try {
jsonRequest = objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(request);
} catch (JsonProcessingException e) {
logger.error(BRACKETS, MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, "BPMN", ErrorCode.DataError.getValue(), e.getMessage());
throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON);
}
jsonRequest = "{\"input\":" + jsonRequest + "}";
logger.info(jsonRequest);
return jsonRequest;
}
use of org.onap.so.client.exception.MapperException in project so by onap.
the class GeneralTopologyObjectMapper method buildVfModuleInformation.
/*
* Build GenericResourceApiVfModuleinformationVfModuleInformation
*/
public GenericResourceApiVfmoduleinformationVfModuleInformation buildVfModuleInformation(VfModule vfModule, GenericVnf vnf, ServiceInstance serviceInstance, RequestContext requestContext, boolean includeModelInformation) throws MapperException {
GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = new GenericResourceApiVfmoduleinformationVfModuleInformation();
if (includeModelInformation) {
if (vfModule.getModelInfoVfModule() == null) {
throw new MapperException("VF Module model info is null for " + vfModule.getVfModuleId());
} else {
GenericResourceApiOnapmodelinformationOnapModelInformation onapModelInformation = new GenericResourceApiOnapmodelinformationOnapModelInformation();
onapModelInformation.setModelInvariantUuid(vfModule.getModelInfoVfModule().getModelInvariantUUID());
onapModelInformation.setModelName(vfModule.getModelInfoVfModule().getModelName());
onapModelInformation.setModelVersion(vfModule.getModelInfoVfModule().getModelVersion());
onapModelInformation.setModelUuid(vfModule.getModelInfoVfModule().getModelUUID());
onapModelInformation.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
vfModuleInformation.setOnapModelInformation(onapModelInformation);
}
}
if (vfModule.getModelInfoVfModule() != null) {
vfModuleInformation.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
}
vfModuleInformation.setVfModuleId(vfModule.getVfModuleId());
if (requestContext != null && requestContext.getRequestParameters() != null) {
vfModuleInformation.setFromPreload(requestContext.getRequestParameters().getUsePreload());
} else {
vfModuleInformation.setFromPreload(true);
}
return vfModuleInformation;
}
use of org.onap.so.client.exception.MapperException in project so by onap.
the class SDNCRequestTasks method callSDNC.
public void callSDNC(DelegateExecution execution) {
SDNCRequest request = (SDNCRequest) execution.getVariable(SDNC_REQUEST);
try {
String response = sdncClient.post(request.getSDNCPayload(), request.getTopology());
String finalMessageIndicator = JsonPath.read(response, "$.output.ack-final-indicator");
execution.setVariable("isSDNCCompleted", convertIndicatorToBoolean(finalMessageIndicator));
} catch (PathNotFoundException e) {
logger.error("Error Parsing SDNC Response. Could not find read final ack indicator from JSON.", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Recieved invalid response from SDNC, unable to read message content.", ONAPComponents.SO);
} catch (MapperException e) {
logger.error("Failed to map SDNC object to JSON prior to POST.", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Failed to map SDNC object to JSON prior to POST.", ONAPComponents.SO);
} catch (BadResponseException e) {
logger.error("Did not receive a successful response from SDNC.", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage(), ONAPComponents.SDNC);
} catch (HttpClientErrorException e) {
logger.error("HttpClientErrorException: 404 Not Found, Failed to contact SDNC", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted.", ONAPComponents.SO);
}
}
Aggregations