Search in sources :

Example 1 with ResourceOperationStatus

use of org.onap.so.db.request.beans.ResourceOperationStatus in project so by onap.

the class AbstractSdncOperationTask method updateProgress.

public void updateProgress(DelegateExecution execution, String status, String errorCode, String progress, String statusDescription) {
    logger.info("AbstractSdncOperationTask.updateProgress begin!");
    String serviceId = (String) execution.getVariable("serviceId");
    serviceId = StringUtils.isBlank(serviceId) ? (String) execution.getVariable("serviceInstanceId") : serviceId;
    String operationId = (String) execution.getVariable("operationId");
    String resourceTemplateUUID = (String) execution.getVariable("resourceUUID");
    String resourceTemplateId = (String) execution.getVariable("resourceTemplateId");
    resourceTemplateId = StringUtils.isBlank(resourceTemplateId) ? "" : resourceTemplateUUID;
    resourceTemplateUUID = StringUtils.isBlank(resourceTemplateUUID) ? resourceTemplateId : resourceTemplateUUID;
    try {
        ResourceOperationStatus resourceOperationStatus = getResourceOperationStatus(serviceId, operationId, resourceTemplateUUID);
        if (!StringUtils.isBlank(status)) {
            resourceOperationStatus.setStatus(status);
        }
        if (!StringUtils.isBlank(errorCode)) {
            resourceOperationStatus.setErrorCode(errorCode);
        }
        if (!StringUtils.isBlank(progress)) {
            resourceOperationStatus.setProgress(progress);
        }
        if (!StringUtils.isBlank(statusDescription)) {
            resourceOperationStatus.setStatusDescription(statusDescription);
        }
        updateResOperStatus(resourceOperationStatus);
        logger.info("AbstractSdncOperationTask.updateProgress end!");
    } catch (Exception exception) {
        logger.info("exception: AbstractSdncOperationTask.updateProgress fail!");
        logger.error("exception: AbstractSdncOperationTask.updateProgress fail:", exception);
        logger.error(LoggingAnchor.FIVE, MessageEnum.GENERAL_EXCEPTION.toString(), " updateProgress catch exception: ", ErrorCode.UnknownError.getValue(), exception.getClass().toString());
    }
}
Also used : ResourceOperationStatus(org.onap.so.db.request.beans.ResourceOperationStatus) RouteException(org.onap.msb.sdk.discovery.common.RouteException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 2 with ResourceOperationStatus

use of org.onap.so.db.request.beans.ResourceOperationStatus in project so by onap.

the class AbstractSdncOperationTask method getResourceOperationStatusFromXmlString.

private ResourceOperationStatus getResourceOperationStatusFromXmlString(String result) {
    logger.info("AbstractSdncOperationTask.getResourceOperationStatusFromXmlString begin!");
    ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();
    resourceOperationStatus.setErrorCode(getValueByName("errorCode", result));
    resourceOperationStatus.setJobId(getValueByName("jobId", result));
    resourceOperationStatus.setOperType(getValueByName("operType", result));
    resourceOperationStatus.setOperationId(getValueByName("operationId", result));
    resourceOperationStatus.setProgress(getValueByName("progress", result));
    resourceOperationStatus.setResourceTemplateUUID(getValueByName("resourceTemplateUUID", result));
    resourceOperationStatus.setServiceId(getValueByName("serviceId", result));
    resourceOperationStatus.setStatus(getValueByName("status", result));
    resourceOperationStatus.setStatusDescription(getValueByName("statusDescription", result));
    logger.info("AbstractSdncOperationTask.getResourceOperationStatusFromXmlString end!");
    return resourceOperationStatus;
}
Also used : ResourceOperationStatus(org.onap.so.db.request.beans.ResourceOperationStatus)

Example 3 with ResourceOperationStatus

use of org.onap.so.db.request.beans.ResourceOperationStatus in project so by onap.

the class SdncUnderlayVpnPreprocessTask method getOperType.

private String getOperType(DelegateExecution execution) {
    String serviceId = (String) execution.getVariable("serviceId");
    serviceId = StringUtils.isBlank(serviceId) ? (String) execution.getVariable("serviceInstanceId") : serviceId;
    String operationId = (String) execution.getVariable("operationId");
    String resourceTemplateUUID = (String) execution.getVariable("resourceTemplateUUID");
    resourceTemplateUUID = StringUtils.isBlank(resourceTemplateUUID) ? (String) execution.getVariable("resourceTemplateId") : resourceTemplateUUID;
    // rosRepo.getOne(new
    ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus();
    // resourceTemplateUUID));
    return resourceOperationStatus.getOperType();
}
Also used : ResourceOperationStatus(org.onap.so.db.request.beans.ResourceOperationStatus)

Example 4 with ResourceOperationStatus

use of org.onap.so.db.request.beans.ResourceOperationStatus in project so by onap.

the class MSORequestDBImplTest method initResourceOperationStatus.

@Test
public void initResourceOperationStatus() throws MsoRequestsDbException {
    String resourceTemplateUUIDs = "template1:template2:template3:";
    String serviceId = "serviceId";
    String operationId = "operationId";
    String operationType = "operationType";
    ResourceOperationStatus resource1 = new ResourceOperationStatus();
    resource1.setOperationId(operationId);
    resource1.setServiceId(serviceId);
    resource1.setResourceTemplateUUID("template1");
    resource1.setOperType(operationType);
    resource1.setStatus(RequestsDbConstant.Status.PROCESSING);
    resource1.setStatusDescription("Waiting for start");
    ResourceOperationStatus resource2 = new ResourceOperationStatus();
    resource2.setOperationId(operationId);
    resource2.setServiceId(serviceId);
    resource2.setResourceTemplateUUID("template2");
    resource2.setOperType(operationType);
    resource2.setStatus(RequestsDbConstant.Status.PROCESSING);
    resource2.setStatusDescription("Waiting for start");
    ResourceOperationStatus resource3 = new ResourceOperationStatus();
    resource3.setOperationId(operationId);
    resource3.setServiceId(serviceId);
    resource3.setResourceTemplateUUID("template3");
    resource3.setOperType(operationType);
    resource3.setStatus(RequestsDbConstant.Status.PROCESSING);
    resource3.setStatusDescription("Waiting for start");
    List<ResourceOperationStatus> expectedResult = new ArrayList<ResourceOperationStatus>();
    expectedResult.add(resource1);
    expectedResult.add(resource2);
    expectedResult.add(resource3);
    dbAdapter.initResourceOperationStatus(serviceId, operationId, operationType, resourceTemplateUUIDs);
    List<ResourceOperationStatus> testList = resourceOperationStatusRepo.findByServiceIdAndOperationId(serviceId, operationId);
    assertThat(testList, sameBeanAs(expectedResult));
}
Also used : ResourceOperationStatus(org.onap.so.db.request.beans.ResourceOperationStatus) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with ResourceOperationStatus

use of org.onap.so.db.request.beans.ResourceOperationStatus in project so by onap.

the class AbstractSdncOperationTask method getResourceOperationStatus.

private ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId, String resourceTemplateUUID) throws RouteException {
    logger.info("AbstractSdncOperationTask.getResourceOperationStatus begin!");
    String requestsdbEndPoint = env.getProperty("mso.adapters.openecomp.db.endpoint");
    HttpPost httpPost = new HttpPost(requestsdbEndPoint);
    httpPost.addHeader("Authorization", "Basic YnBlbDpwYXNzd29yZDEk");
    httpPost.addHeader("Content-type", "application/soap+xml");
    String getBody = getGetStringBody(serviceId, operationId, resourceTemplateUUID);
    httpPost.setEntity(new StringEntity(getBody, ContentType.APPLICATION_XML));
    String result = httpPost(requestsdbEndPoint, httpPost);
    ResourceOperationStatus resourceOperationStatus = getResourceOperationStatusFromXmlString(result);
    logger.info("AbstractSdncOperationTask.getResourceOperationStatus end!");
    return resourceOperationStatus;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) ResourceOperationStatus(org.onap.so.db.request.beans.ResourceOperationStatus)

Aggregations

ResourceOperationStatus (org.onap.so.db.request.beans.ResourceOperationStatus)10 Test (org.junit.Test)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Transactional (javax.transaction.Transactional)1 HttpPost (org.apache.http.client.methods.HttpPost)1 StringEntity (org.apache.http.entity.StringEntity)1 RouteException (org.onap.msb.sdk.discovery.common.RouteException)1 OperationStatus (org.onap.so.db.request.beans.OperationStatus)1