Search in sources :

Example 1 with RequestDetails

use of org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails in project so by onap.

the class ActivateVnfOperationalEnvironmentTest method executionTest.

@Test
public void executionTest() throws Exception {
    List<ServiceModelList> serviceModelVersionIdList = new ArrayList<>();
    ServiceModelList serviceModelList1 = new ServiceModelList();
    serviceModelList1.setRecoveryAction(RecoveryAction.retry);
    serviceModelList1.setServiceModelVersionId(serviceModelVersionId);
    serviceModelVersionIdList.add(serviceModelList1);
    RequestDetails requestDetails = new RequestDetails();
    RequestParameters requestParameters = new RequestParameters();
    Manifest manifest = new Manifest();
    manifest.setServiceModelList(serviceModelVersionIdList);
    requestParameters.setManifest(manifest);
    requestParameters.setWorkloadContext(workloadContext);
    requestDetails.setRequestParameters(requestParameters);
    request.setOperationalEnvironmentId(vnfOperationalEnvironmentId);
    request.setRequestDetails(requestDetails);
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("statusCode", "202");
    jsonObject.put("message", "Success");
    jsonObject.put("distributionId", sdcDistributionId);
    wireMockServer.stubFor(get(urlPathMatching("/aai/" + AAIVersion.LATEST + "/cloud-infrastructure/operational-environments/.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("vnfoperenv/activateOperationalEnvironmentWithRelationship.json").withStatus(HttpStatus.SC_ACCEPTED)));
    wireMockServer.stubFor(post(urlPathMatching("/sdc/v1/catalog/services/TEST_serviceModelVersionId/distr.*")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED)));
    activateVnf.execute(requestId, request);
}
Also used : ServiceModelList(org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) Manifest(org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest) RequestDetails(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails) RequestParameters(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters) BaseTest(org.onap.so.apihandlerinfra.BaseTest) Test(org.junit.Test)

Example 2 with RequestDetails

use of org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails in project so by onap.

the class CreateEcompOperationalEnvironmentTest method getCloudOrchestrationRequest.

public CloudOrchestrationRequest getCloudOrchestrationRequest() {
    CloudOrchestrationRequest request = new CloudOrchestrationRequest();
    RequestDetails reqDetails = new RequestDetails();
    RequestInfo reqInfo = new RequestInfo();
    RequestParameters reqParams = new RequestParameters();
    reqParams.setTenantContext("TEST");
    reqParams.setWorkloadContext("ECOMP_TEST");
    reqParams.setOperationalEnvironmentType(OperationalEnvironment.ECOMP);
    reqInfo.setInstanceName("TEST_ECOMP_ENVIRONMENT");
    reqDetails.setRequestInfo(reqInfo);
    reqDetails.setRequestParameters(reqParams);
    request.setRequestDetails(reqDetails);
    request.setOperationalEnvironmentId("operationalEnvId");
    return request;
}
Also used : CloudOrchestrationRequest(org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest) RequestInfo(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo) RequestDetails(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails) RequestParameters(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters)

Example 3 with RequestDetails

use of org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails in project so by onap.

the class CloudResourcesOrchestration method mapInfraActiveRequestToRequest.

private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException {
    Request request = new Request();
    request.setRequestId(iar.getRequestId());
    request.setRequestScope(iar.getRequestScope());
    request.setRequestType(iar.getRequestAction());
    InstanceReferences ir = new InstanceReferences();
    if (iar.getOperationalEnvId() != null)
        ir.setOperationalEnvironmentId(iar.getOperationalEnvId());
    if (iar.getOperationalEnvName() != null)
        ir.setOperationalEnvName(iar.getOperationalEnvName());
    if (iar.getRequestorId() != null)
        ir.setRequestorId(iar.getRequestorId());
    request.setInstanceReferences(ir);
    String requestBody = iar.getRequestBody();
    RequestDetails requestDetails = null;
    if (requestBody != null) {
        try {
            ObjectMapper mapper = new ObjectMapper();
            requestDetails = mapper.readValue(requestBody, RequestDetails.class);
        } catch (IOException e) {
            ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build();
            ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed.  " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
            throw validateException;
        }
    }
    request.setRequestDetails(requestDetails);
    String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT";
    request.setStartTime(startTimeStamp);
    RequestStatus status = new RequestStatus();
    if (iar.getStatusMessage() != null) {
        status.setStatusMessage(iar.getStatusMessage());
    }
    if (iar.getEndTime() != null) {
        String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT";
        status.setTimeStamp(endTimeStamp);
    }
    if (iar.getRequestStatus() != null) {
        status.setRequestState(iar.getRequestStatus());
    }
    if (iar.getProgress() != null) {
        status.setPercentProgress(iar.getProgress().toString());
    }
    request.setRequestStatus(status);
    return request;
}
Also used : ErrorLoggerInfo(org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo) ValidateException(org.onap.so.apihandlerinfra.exceptions.ValidateException) InstanceReferences(org.onap.so.apihandlerinfra.tenantisolationbeans.InstanceReferences) ResponseBuilder(org.onap.so.apihandler.common.ResponseBuilder) Request(org.onap.so.apihandlerinfra.tenantisolationbeans.Request) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) RequestDetails(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RequestStatus(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus)

Example 4 with RequestDetails

use of org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails in project so by onap.

the class TenantIsolationRequest method parse.

void parse(CloudOrchestrationRequest request, HashMap<String, String> instanceIdMap, Action action) throws ValidationException {
    this.cor = request;
    this.requestInfo = request.getRequestDetails().getRequestInfo();
    try {
        ObjectMapper mapper = new ObjectMapper();
        requestJSON = mapper.writeValueAsString(request.getRequestDetails());
    } catch (JsonProcessingException e) {
        logger.error("Exception in JSON processing", e);
        throw new ValidationException("Parse ServiceInstanceRequest to JSON string", true);
    }
    String envId = null;
    if (instanceIdMap != null) {
        envId = instanceIdMap.get("operationalEnvironmentId");
        if (envId != null && !UUIDChecker.isValidUUID(envId)) {
            throw new ValidationException("operationalEnvironmentId", true);
        }
        cor.setOperationalEnvironmentId(envId);
    }
    this.operationalEnvironmentId = envId;
    RequestDetails requestDetails = request.getRequestDetails();
    RequestParameters requestParameters = requestDetails.getRequestParameters();
    requestInfoValidation(action, requestInfo);
    requestParamsValidation(action, requestParameters);
    relatedInstanceValidation(action, requestDetails, requestParameters);
}
Also used : ValidationException(org.onap.so.exceptions.ValidationException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RequestDetails(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails) RequestParameters(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters)

Example 5 with RequestDetails

use of org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails in project so by onap.

the class AAIClientObjectBuilderTest method getCloudOrchestrationRequest.

public CloudOrchestrationRequest getCloudOrchestrationRequest() {
    CloudOrchestrationRequest cor = new CloudOrchestrationRequest();
    RequestDetails reqDetails = new RequestDetails();
    RequestInfo reqInfo = new RequestInfo();
    RequestParameters reqParams = new RequestParameters();
    reqParams.setTenantContext("TEST");
    reqParams.setWorkloadContext("ECOMP_TEST");
    reqParams.setOperationalEnvironmentType(OperationalEnvironment.ECOMP);
    reqInfo.setInstanceName("TEST_ECOMP_ENVIRONMENT");
    reqDetails.setRequestInfo(reqInfo);
    reqDetails.setRequestParameters(reqParams);
    cor.setRequestDetails(reqDetails);
    return cor;
}
Also used : CloudOrchestrationRequest(org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest) RequestInfo(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo) RequestDetails(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails) RequestParameters(org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters)

Aggregations

RequestDetails (org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails)5 RequestParameters (org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 CloudOrchestrationRequest (org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest)2 RequestInfo (org.onap.so.apihandlerinfra.tenantisolationbeans.RequestInfo)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)1 BaseTest (org.onap.so.apihandlerinfra.BaseTest)1 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)1 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)1 InstanceReferences (org.onap.so.apihandlerinfra.tenantisolationbeans.InstanceReferences)1 Manifest (org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest)1 Request (org.onap.so.apihandlerinfra.tenantisolationbeans.Request)1 RequestStatus (org.onap.so.apihandlerinfra.tenantisolationbeans.RequestStatus)1 ServiceModelList (org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList)1