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]}")
@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.db.request.beans.RequestProcessingData in project so by onap.
the class RequestsDbClient method saveRequestProcessingData.
public void saveRequestProcessingData(RequestProcessingData requestProcessingData) {
HttpHeaders headers = getHttpHeaders();
URI uri = getUri(requestProcessingDataURI);
HttpEntity<RequestProcessingData> entity = new HttpEntity<>(requestProcessingData, headers);
restTemplate.postForLocation(uri, entity);
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class RequestDbClientTest method updateRequestProcessingDataTest.
@Test
public void updateRequestProcessingDataTest() {
RequestProcessingData requestProcessingData = new RequestProcessingData();
requestProcessingData.setId(1);
URI uri = URI.create("/requestProcessingData/1");
requestsDbClient.updateRequestProcessingData(requestProcessingData);
Mockito.verify(restTemplate, times(1)).put(eq(uri), isA(HttpEntity.class));
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class RequestProcessingDataRequestDbQueryTest method testGetRequestProcessingDataBySoRequestIdAndIsInternalData.
@Test
@Transactional
public void testGetRequestProcessingDataBySoRequestIdAndIsInternalData() {
String soRequestId = "00032ab7-na18-42e5-965d-8ea592502018";
String tag = "pincFabricConfigRequest";
RequestProcessingData firstEntry = new RequestProcessingData();
List<RequestProcessingData> expectedList = new ArrayList<>();
firstEntry.setSoRequestId(soRequestId);
firstEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
firstEntry.setName("configurationId");
firstEntry.setValue("52234bc0-d6a6-41d4-a901-79015e4877e2");
firstEntry.setTag(tag);
expectedList.add(firstEntry);
List<RequestProcessingData> dataFound = client.getExternalRequestProcessingDataBySoRequestId(soRequestId);
assertEquals(1, dataFound.size());
assertEquals(dataFound.get(0).getSoRequestId(), firstEntry.getSoRequestId());
assertEquals(dataFound.get(0).getGroupingId(), firstEntry.getGroupingId());
assertEquals(dataFound.get(0).getName(), firstEntry.getName());
assertEquals(dataFound.get(0).getValue(), firstEntry.getValue());
assertEquals(dataFound.get(0).getTag(), firstEntry.getTag());
}
use of org.onap.so.db.request.beans.RequestProcessingData in project so by onap.
the class StackStatusHandler method updateStackStatus.
@Async
public void updateStackStatus(Stack stack, String requestId) {
try {
String stackStatus = mapper.writeValueAsString(stack);
RequestProcessingData requestProcessingData = requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, stack.getStackName(), stack.getId());
if (requestProcessingData == null) {
requestProcessingData = new RequestProcessingData();
requestProcessingData.setGroupingId(stack.getId());
requestProcessingData.setName(stack.getStackName());
requestProcessingData.setTag("StackInformation");
requestProcessingData.setSoRequestId(requestId);
requestProcessingData.setValue(stackStatus);
requestDBClient.saveRequestProcessingData(requestProcessingData);
} else {
requestProcessingData.setValue(stackStatus);
requestDBClient.updateRequestProcessingData(requestProcessingData);
}
} catch (Exception e) {
logger.warn("Error adding stack status to request database", e);
}
}
Aggregations