+ void terminateNSIQuery(DelegateExecution execution)
+ {
+ logger.debug("Start terminateNSIQuery")
+
+ String requestId = execution.getVariable("msoRequestId")
+ String nxlId = currentNSSI['nsiServiceInstanceId']
+ String nxlType = "NSI"
+ String messageType = "nsiTerminationResponse"
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
+
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
+ String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+
+ String basicAuthValue = utils.encrypt(basicAuth, msokey)
+ if (basicAuthValue != null) {
+ logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+ try {
+ authHeader = utils.getBasicAuth(basicAuthValue, msokey)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+ } catch (Exception ex) {
+ logger.debug( "Unable to encode username and password string: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
+ "encode username and password string")
+ }
+ } else {
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
+ "value null")
+ }
+
+ URL requestUrl = new URL(oofUrl + "/api/oof/terminate/nxi/v1")
+ String oofRequest = oofUtils.buildTerminateNxiRequest(requestId, nxlId, nxlType, messageType, serviceInstanceId)
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(requestUrl, ONAPComponents.OOF)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+
+ if(responseCode != 200){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ }
+ try {
+ Map<String, String> resMap = httpResponse.readEntity(Map.class)
+ boolean terminateResponse = resMap.get("terminateResponse")
+ execution.setVariable("terminateNSI", terminateResponse)
+ } catch (Exception ex) {
+ logger.debug( "Failed to get terminate Response suggested by OOF.")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get terminate Response suggested by OOF.")
+ }
+ logger.debug("Finish terminateNSIQuery")
+ }