summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy125
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy174
2 files changed, 100 insertions, 199 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
index e2aa7972df..2d0034a34d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
@@ -4,7 +4,6 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
import org.onap.aai.domain.yang.SliceProfile
-import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.beans.nsmf.AllocateAnNssi
import org.onap.so.beans.nsmf.AllocateCnNssi
import org.onap.so.beans.nsmf.AllocateTnNssi
@@ -19,18 +18,15 @@ import org.onap.so.beans.nsmf.PerfReq
import org.onap.so.beans.nsmf.PerfReqEmbbList
import org.onap.so.beans.nsmf.PerfReqUrllcList
import org.onap.so.beans.nsmf.ResourceSharingLevel
-import org.onap.so.beans.nsmf.ServiceProfile
import org.onap.so.beans.nsmf.SliceTaskParams
import org.onap.so.beans.nsmf.TnSliceProfile
import org.onap.so.beans.nsmf.UeMobilityLevel
import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
import org.onap.so.bpmn.core.RollbackData
-import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.domain.ModelInfo
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.client.HttpClientFactory
import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
@@ -39,7 +35,6 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import com.fasterxml.jackson.databind.ObjectMapper;
-import javax.ws.rs.core.Response
import static org.apache.commons.lang3.StringUtils.isBlank
@@ -53,6 +48,8 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask
JsonUtils jsonUtil = new JsonUtils()
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
+
/**
* Pre Process the BPMN Flow Request
* Inclouds:
@@ -155,134 +152,78 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask
void sendUpdateRequestNSSMF(DelegateExecution execution) {
- logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
- String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- logger.debug( "get NSSMF: " + urlString)
-
- //Prepare auth for NSSMF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ logger.debug("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
String domain = execution.getVariable("nsstDomain")
String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase())
- //send request to update NSSI option - Begin
- URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(nssmfRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF sync response code is: " + responseCode)
-
- if(responseCode < 199 && responseCode > 299){
- String nssmfResponse ="NSSMF response have nobody"
- if(httpResponse.hasEntity())
- nssmfResponse = httpResponse.readEntity(String.class)
- logger.trace("received error message from NSSMF : "+nssmfResponse)
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
- }
+ String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
+
+ String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
- if(httpResponse.hasEntity()){
- String nssmfResponse = httpResponse.readEntity(String.class)
+ if (nssmfResponse != null) {
execution.setVariable("nssmfResponse", nssmfResponse)
String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
execution.setVariable("nssiId",nssiId)
execution.setVariable("jobId",jobId)
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+
+ } else {
+ logger.error("received error message from NSSMF : "+ nssmfResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
}
logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()")
}
void sendCreateRequestNSSMF(DelegateExecution execution) {
- logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
- String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- logger.debug( "get NSSMF: " + urlString)
-
+ logger.debug("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
//Prepare auth for NSSMF - Begin
String domain = execution.getVariable("nsstDomain")
String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase())
- //send request to get NSI option - Begin
- URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(nssmfRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF sync response code is: " + responseCode)
-
- if(responseCode < 199 || responseCode > 299 ){
- String nssmfResponse ="NSSMF response have nobody"
- if(httpResponse.hasEntity())
- nssmfResponse = httpResponse.readEntity(String.class)
- logger.trace("received error message from NSSMF : "+nssmfResponse)
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
- }
+ String urlString = "/api/rest/provMns/v1/NSS/SliceProfiles"
+
+ String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest)
- if(httpResponse.hasEntity()){
- String nssmfResponse = httpResponse.readEntity(String.class)
+ if (nssmfResponse != null) {
execution.setVariable("nssmfResponse", nssmfResponse)
String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
execution.setVariable("nssiId",nssiId)
execution.setVariable("jobId",jobId)
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+
+ } else {
+ logger.error("received error message from NSSMF : "+ nssmfResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
}
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ logger.debug("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
}
void getNSSMFProgresss(DelegateExecution execution) {
- logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()")
-
- String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- logger.debug( "get NSSMF: " + endpoint)
-
- //Prepare auth for NSSMF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ logger.debug("Enter getNSSMFProgresss in DoAllocateNSSI()")
String nssmfRequest = buildNSSMFProgressRequest(execution)
- String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId")
- //send request to update NSSI option - Begin
- URL url = new URL(endpoint+strUrl)
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(nssmfRequest)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF sync response code is: " + responseCode)
-
- if(responseCode < 199 || responseCode > 299){
- String nssmfResponse ="NSSMF response have nobody"
- if(httpResponse.hasEntity())
- nssmfResponse = httpResponse.readEntity(String.class)
- logger.trace("received error message from NSSMF : "+nssmfResponse)
- logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
- }
+ String strUrl="/api/rest/provMns/v1/NSS/jobs/" + execution.getVariable("jobId")
+
+ String nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, strUrl, nssmfRequest)
- if(httpResponse.hasEntity()){
- String nssmfResponse = httpResponse.readEntity(String.class)
+ if(nssmfResponse != null){
Boolean isNSSICreated = false
execution.setVariable("nssmfResponse", nssmfResponse)
- Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
+ Integer progress = Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status")
String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription")
execution.setVariable("nssmfProgress",progress)
execution.setVariable("nssmfStatus",status)
execution.setVariable("nddmfStatusDescription",statusDescription)
- if(progress>99)
+ if(progress > 99)
isNSSICreated = true
execution.setVariable("isNSSICreated",isNSSICreated)
-
- }else{
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ } else {
+ logger.error("received error message from NSSMF : "+ nssmfResponse)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000,"Received a Bad Sync Response from NSSMF.")
}
- logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()")
-
+ logger.debug("Exit getNSSMFProgresss in DoAllocateNSSI()")
}
void updateRelationship(DelegateExecution execution) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy
index 5acc016c7b..a85f5d8ab3 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoSendCommandToNSSMF.groovy
@@ -25,17 +25,13 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.beans.nsmf.*
import org.onap.so.bpmn.common.scripts.*
-import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.domain.ServiceArtifact
import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.client.HttpClient
-import org.onap.so.client.HttpClientFactory
import org.onap.logging.filter.base.ErrorCode
import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
@@ -43,7 +39,6 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.web.util.UriUtils
-import javax.ws.rs.core.Response
import java.lang.reflect.Type
/**
@@ -60,7 +55,8 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
JsonUtils jsonUtil = new JsonUtils()
VidUtils vidUtils = new VidUtils(this)
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
- OofInfraUtils oofInfraUtils = new OofInfraUtils()
+
+ private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil)
/**
* This method gets and validates the incoming
@@ -99,7 +95,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
execution.setVariable("msoRequestId", requestId)
String operationType = execution.getVariable("operationType")
- execution.setVariable("operationType", operationType)
+ execution.setVariable("operationType", operationType.toLowerCase())
logger.debug("Incoming operationType is: " + operationType)
if (operationType == "activation") {
@@ -123,6 +119,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
}
logger.trace("COMPLETED DoSendCommandToNSSMF PreProcessRequest Process")
}
+
private String mapToJsonStr(Map<String, NSSI> stringNSSIHashMap) {
HashMap<String, NSSI> map = new HashMap<String, NSSI>()
for(Map.Entry<String, NSSI> child:stringNSSIHashMap.entrySet())
@@ -131,6 +128,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
}
return new Gson().toJson(map)
}
+
public void getNSSIformlist(DelegateExecution execution) {
String nssiMap = execution.getVariable("DonssiMap")
@@ -179,6 +177,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
execution.setVariable("activationIndex", indexcurrent)}
}
+
/**
* get vendor Info
* @param execution
@@ -204,6 +203,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
}
logger.debug("***** Exit processDecomposition *****")
}
+
public void UpdateIndex(DelegateExecution execution) {
def activationIndex = execution.getVariable("activationIndex")
int activateNumberSlice = execution.getVariable("activateNumberSlice") as Integer
@@ -225,7 +225,7 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
String operationId = UUID.randomUUID().toString()
String operationType = execution.getVariable("operationType")
String userId = ""
- String result = (operationType.equals("activation"))? "ACTIVATING": "DEACTIVATING"
+ String result = (operationType.equalsIgnoreCase("activation"))? "ACTIVATING": "DEACTIVATING"
int progress = rate
String reason = ""
String operationContent = "Service activation in progress"
@@ -269,24 +269,25 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
}
logger.trace("finished Activate Slice")
}
+
public void WaitForReturn(DelegateExecution execution) {
//logger.debug("Query : "+ Jobid)
- def miniute=execution.getVariable("miniute")
+ String miniute = execution.getVariable("miniute")
Thread.sleep(10000)
int miniute01 = Integer.parseInt(miniute) + 1
logger.debug("waiting for : "+ miniute + "miniutes")
execution.setVariable("miniute", String.valueOf(miniute01))
}
+
public void GetTheStatusOfActivation(DelegateExecution execution) {
- String snssai= execution.getVariable("snssai")
String domaintype = execution.getVariable("domainType")
String NSIserviceid=execution.getVariable("NSIserviceid")
String nssiId = execution.getVariable("nssiId")
String Jobid=execution.getVariable("JobId")
- def miniute=execution.getVariable("miniute")
+ String miniute=execution.getVariable("miniute")
String vendor = execution.getVariable("vendor")
- String jobstatus ="error"
+ String jobstatus
logger.debug("Query the jobid activation of SNSSAI: "+ Jobid)
@@ -306,66 +307,46 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
ObjectMapper mapper = new ObjectMapper()
- String Reqjson = mapper.writeValueAsString(jobStatusRequest)
- String isActivateSuccessfull=false
-
- String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
- String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/jobs/" +Jobid
-
- //send request to active NSSI TN option
- URL url = new URL(nssmfRequest)
-
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(Reqjson)
-
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF activation response code is: " + responseCode)
-
- if (responseCode == 404) {
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.")
- isActivateSuccessfull = false
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
- jobstatus="error"
- }else if(responseCode == 200) {
- if (httpResponse.hasEntity()) {
- JobStatusResponse jobStatusResponse = httpResponse.readEntity(JobStatusResponse.class)
- execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription())
- jobstatus = jobStatusResponse.getResponseDescriptor().getStatus()
- switch(jobstatus) {
- case "started":
- case "processing":
- isActivateSuccessfull = "waitting"
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
- break
- case "finished":
- isActivateSuccessfull = "true"
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
- execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1)
- break
- case "error":
- default:
- isActivateSuccessfull = "false"
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
-
- }
- if(Integer.parseInt(miniute) > 6 )
- {
- isActivateSuccessfull = "false"
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a timeout job status Response from NSSMF.")
- }
- }else
- {
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.")
- isActivateSuccessfull = false
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
- }
- } else {
- isActivateSuccessfull = false
- execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad job status Response from NSSMF.")
- }
+ String nssmfRequest = mapper.writeValueAsString(jobStatusRequest)
+ String isActivateSuccessfull
+
+ String urlString = "/api/rest/provMns/v1/NSS/jobs/" +Jobid
+
+ JobStatusResponse jobStatusResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, JobStatusResponse.class)
+
+ if (jobStatusResponse != null) {
+ execution.setVariable("statusDescription", jobStatusResponse.getResponseDescriptor().getStatusDescription())
+ jobstatus = jobStatusResponse.getResponseDescriptor().getStatus()
+ switch(jobstatus) {
+ case "started":
+ case "processing":
+ isActivateSuccessfull = "waitting"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ break
+ case "finished":
+ isActivateSuccessfull = "true"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ execution.setVariable("activateNumberSlice",execution.getVariable("activateNumberSlice")+ 1)
+ break
+ case "error":
+ default:
+ isActivateSuccessfull = "false"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+
+ }
+ if(Integer.parseInt(miniute) > 6 )
+ {
+ isActivateSuccessfull = "false"
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a timeout job status Response from NSSMF.")
+ }
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad job status Response from NSSMF.")
+ isActivateSuccessfull = false
+ execution.setVariable("isActivateSuccessfull", isActivateSuccessfull)
+ }
}
+
public void SendCommandToNssmf(DelegateExecution execution) {
String snssai= execution.getVariable("snssai")
@@ -391,49 +372,28 @@ class DoSendCommandToNSSMF extends AbstractServiceTaskProcessor {
actRequest.setActDeActNssi(actNssi);
actRequest.setEsrInfo(esr)
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(actRequest);
-
-
- String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ ObjectMapper mapper = new ObjectMapper()
+ String nssmfRequest = mapper.writeValueAsString(actRequest)
- //Prepare auth for NSSMF - Begin
- def authHeader = ""
- String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
String operationType = execution.getVariable("operationType")
- String nssmfRequest = urlString + "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType
-
- //send request to active NSSI TN option
- URL url = new URL(nssmfRequest)
+ String urlString = "/api/rest/provMns/v1/NSS/" + snssai + "/" + operationType.toLowerCase()
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
- Response httpResponse = httpClient.post(json)
+ NssiResponse nssmfResponse = nssmfAdapterUtils.sendPostRequestNSSMF(execution, urlString, nssmfRequest, NssiResponse.class)
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF activate response code is: " + responseCode)
- checkNssmfResponse(httpResponse, execution)
-
- NssiResponse nssmfResponse = httpResponse.readEntity(NssiResponse.class)
- String jobId = nssmfResponse.getJobId() ?: ""
- execution.setVariable("JobId", jobId)
+ if (nssmfResponse != null) {
+ String isNSSIActivated = "true"
+ execution.setVariable("isNSSIActivated", isNSSIActivated)
+ String jobId = nssmfResponse.getJobId() ?: ""
+ execution.setVariable("JobId", jobId)
+ } else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.")
+ String isNSSIActivated = "false"
+ execution.setVariable("isNSSIActivated", isNSSIActivated)
+ execution.setVariable("isNSSIActivate","false")
+ }
}
- private void checkNssmfResponse(Response httpResponse, DelegateExecution execution) {
- int responseCode = httpResponse.getStatus()
- logger.debug("NSSMF response code is: " + responseCode)
-
- if ( responseCode < 200 || responseCode > 202 || !httpResponse.hasEntity()) {
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Response from NSSMF.")
- String isNSSIActivated = "false"
- execution.setVariable("isNSSIActivated", isNSSIActivated)
- execution.setVariable("isNSSIActivate","false")
- }else{
- String isNSSIActivated = "true"
- execution.setVariable("isNSSIActivated", isNSSIActivated)
- }
- }
-
void sendSyncError (DelegateExecution execution) {
logger.trace("start sendSyncError")