use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class BBInputSetupUtilsTest method loadOriginalFlowExecutionPathTest.
@Test
public void loadOriginalFlowExecutionPathTest() throws IOException {
final String requestId = "123";
final String originalRequestId = "originalRequestId";
final String flowsToExecuteString = new String(Files.readAllBytes(Paths.get(RESOURCE_PATH + "FlowsToExecute.json")), StandardCharsets.UTF_8);
InfraActiveRequests request = new InfraActiveRequests();
ExecuteBuildingBlock[] expectedFlowsToExecute = mapper.readValue(flowsToExecuteString, ExecuteBuildingBlock[].class);
request.setRequestId(requestId);
request.setOriginalRequestId(originalRequestId);
doReturn(request).when(MOCK_requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
RequestProcessingData requestProcessingData = new RequestProcessingData();
requestProcessingData.setValue(flowsToExecuteString);
doReturn(requestProcessingData).when(MOCK_requestsDbClient).getRequestProcessingDataBySoRequestIdAndName(anyString(), anyString());
List<ExecuteBuildingBlock> flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
assertEquals(mapper.writeValueAsString(expectedFlowsToExecute), mapper.writeValueAsString(flowsToExecute));
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class RequestsDbClient method updateRequestProcessingData.
public void updateRequestProcessingData(RequestProcessingData requestProcessingData) {
HttpHeaders headers = getHttpHeaders();
URI uri = getUri(requestProcessingDataURI + "/" + requestProcessingData.getId());
HttpEntity<RequestProcessingData> entity = new HttpEntity<>(requestProcessingData, headers);
restTemplate.put(uri, entity);
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class RequestsDbClient method persistProcessingData.
public void persistProcessingData(String flowExecutionPath, String requestId) {
HttpHeaders headers = getHttpHeaders();
URI uri = getUri(requestProcessingDataURI);
RequestProcessingData rpd = new RequestProcessingData();
rpd.setName(FLOW_EXECUTION_PATH);
rpd.setSoRequestId(requestId);
rpd.setValue(flowExecutionPath);
rpd.setTag(BPMN_EXECUTION_DATA_TAG);
rpd.setIsDataInternal(true);
HttpEntity<RequestProcessingData> entity = new HttpEntity<>(rpd, headers);
restTemplate.postForLocation(uri, entity);
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class OrchestrationRequests method getOrchestrationRequest.
@GET
@Path("/{version:[vV][4-8]}/{requestId}")
@Operation(description = "Find Orchestrated Requests for a given requestId", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest, @QueryParam(value = "format") String format) throws ApiException {
GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
InfraActiveRequests infraActiveRequest = null;
List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = null;
if (!UUIDChecker.isValidUUID(requestId)) {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MODIFIED_BY_APIHANDLER).build();
throw new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
}
infraActiveRequest = infraActiveRequestLookup(requestId);
if (isRequestProcessingDataRequired(format)) {
try {
requestProcessingData = requestsDbClient.getExternalRequestProcessingDataBySoRequestId(requestId);
} catch (Exception e) {
logger.error("Exception occurred while communicating with RequestDb during requestProcessingData lookup ", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError).build();
ValidateException validateException = new ValidateException.Builder("Exception occurred while communicating with RequestDb during requestProcessingData lookup", HttpStatus.SC_NOT_FOUND, ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB).cause(e).errorInfo(errorLoggerInfo).build();
throw validateException;
}
}
Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, format, version);
if (null != requestProcessingData && !requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
}
request.setRequestId(requestId);
orchestrationResponse.setRequest(request);
return builder.buildResponse(HttpStatus.SC_OK, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID), orchestrationResponse, version);
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class OrchestrationRequests method mapRequestProcessingData.
public List<org.onap.so.serviceinstancebeans.RequestProcessingData> mapRequestProcessingData(List<org.onap.so.db.request.beans.RequestProcessingData> processingData) {
List<org.onap.so.serviceinstancebeans.RequestProcessingData> addedRequestProcessingData = new ArrayList<>();
org.onap.so.serviceinstancebeans.RequestProcessingData finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData();
String currentGroupingId = null;
HashMap<String, String> tempMap = new HashMap<>();
List<HashMap<String, String>> tempList = new ArrayList<>();
for (RequestProcessingData data : processingData) {
String groupingId = data.getGroupingId();
String tag = data.getTag();
if (currentGroupingId == null || !currentGroupingId.equals(groupingId)) {
if (!tempMap.isEmpty()) {
tempList.add(tempMap);
finalProcessingData.setDataPairs(tempList);
addedRequestProcessingData.add(finalProcessingData);
}
finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData();
if (groupingId != null) {
finalProcessingData.setGroupingId(groupingId);
}
if (tag != null) {
finalProcessingData.setTag(tag);
}
currentGroupingId = groupingId;
tempMap = new HashMap<>();
tempList = new ArrayList<>();
if (data.getName() != null && data.getValue() != null) {
tempMap.put(data.getName(), data.getValue());
}
} else {
if (data.getName() != null && data.getValue() != null) {
tempMap.put(data.getName(), data.getValue());
}
}
}
if (tempMap.size() > 0) {
tempList.add(tempMap);
finalProcessingData.setDataPairs(tempList);
}
addedRequestProcessingData.add(finalProcessingData);
return addedRequestProcessingData;
}
Aggregations