use of org.onap.so.db.request.beans.OperationStatus in project so by onap.
the class MsoRequestsDbAdapterImpl method initServiceOperationStatus.
/**
* Init operation status <br>
*
* @param serviceId
* @param operationId
* @param operationType
* @param userId
* @param result
* @param operationContent
* @param progress
* @param reason
* @throws MsoRequestsDbException
* @since ONAP Casablanca Release
*/
@Override
@Transactional
public void initServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
OperationStatus operStatus = new OperationStatus();
operStatus.setOperationId(operationId);
operStatus.setServiceId(serviceId);
operStatus.setUserId(userId);
operStatus.setOperation(operationType);
operStatus.setReason(reason);
operStatus.setProgress(progress);
operStatus.setResult(result);
operStatus.setOperationContent(operationContent);
operStatus.setResult(result);
operationStatusRepository.save(operStatus);
}
use of org.onap.so.db.request.beans.OperationStatus in project so by onap.
the class MsoRequestsDbAdapterImpl method updateServiceOperationStatus.
/**
* update operation status <br>
*
* @param serviceId
* @param operationId
* @param operationType
* @param userId
* @param result
* @param operationContent
* @param progress
* @param reason
* @throws MsoRequestsDbException
* @since ONAP Amsterdam Release
*/
@Override
@Transactional
public void updateServiceOperationStatus(String serviceId, String operationId, String operationType, String userId, String result, String operationContent, String progress, String reason) throws MsoRequestsDbException {
OperationStatus operStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId, operationId);
if (operStatus == null) {
String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId;
logger.error(error);
operStatus = new OperationStatus();
operStatus.setOperationId(operationId);
operStatus.setServiceId(serviceId);
}
operStatus.setUserId(userId);
operStatus.setOperation(operationType);
operStatus.setReason(reason);
operStatus.setProgress(progress);
operStatus.setResult(result);
operStatus.setOperationContent(operationContent);
operStatus.setResult(result);
operationStatusRepository.save(operStatus);
}
use of org.onap.so.db.request.beans.OperationStatus in project so by onap.
the class OperationStatusTest method timeStampCreated.
@Test
@Transactional
public void timeStampCreated() throws InterruptedException, NoEntityFoundException {
final String testServiceId = "test-service-id";
final String testOperationId = "test-operation-id";
final OperationStatusId id = new OperationStatusId(testServiceId, testOperationId);
OperationStatus status = new OperationStatus();
status.setServiceId(testServiceId);
status.setOperationId(testOperationId);
status = repository.saveAndFlush(status);
OperationStatus found = repository.findById(id).orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
Date operateAt = found.getOperateAt();
assertNotNull(operateAt);
assertEquals(testServiceId, found.getServiceId());
Date finishedAt = found.getFinishedAt();
status.setProgress("test-progress");
// timestamps only set to save on 1 second changes
Thread.sleep(1000);
repository.saveAndFlush(status);
OperationStatus foundUpdate = repository.findById(id).orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation"));
assertEquals(operateAt.toString(), foundUpdate.getOperateAt().toString());
assertNotNull(foundUpdate.getFinishedAt());
assertNotEquals(finishedAt.toString(), foundUpdate.getFinishedAt().toString());
assertEquals("test-progress", foundUpdate.getProgress());
}
use of org.onap.so.db.request.beans.OperationStatus in project so by onap.
the class E2EServiceInstances method getE2EServiceInstance.
private Response getE2EServiceInstance(String serviceId, String operationId, String version) {
GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse();
String apiVersion = version.substring(1);
OperationStatus operationStatus;
try {
operationStatus = requestsDbClient.getOneByServiceIdAndOperationId(serviceId, operationId);
} catch (Exception e) {
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Request DB - Infra Request Lookup", e);
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version);
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
if (operationStatus == null) {
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NO_CONTENT, MsoException.ServiceException, "E2E serviceId " + serviceId + " is not found in DB", ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null, version);
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from RequestDB when searching by serviceId");
logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
e2eServiceResponse.setOperation(operationStatus);
return builder.buildResponse(HttpStatus.SC_OK, null, e2eServiceResponse, apiVersion);
}
use of org.onap.so.db.request.beans.OperationStatus in project so by onap.
the class RequestsDbClient method getOneByServiceIdAndOperationId.
public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId) {
OperationStatus operationStatus = getSingleResponse(getUri(UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)).queryParam(SERVICE_ID, serviceId).queryParam(OPERATION_ID, operationId).build().toString()), OperationStatus.class);
if (operationStatus != null) {
operationStatus.setServiceId(serviceId);
operationStatus.setOperationId(operationId);
}
return operationStatus;
}
Aggregations