aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/groovy
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2019-05-28 20:46:03 -0700
committerMarcus G K Williams <marcus.williams@intel.com>2019-05-29 03:16:30 -0700
commit4db782068934ebd20caa8405cd8644a2bf922934 (patch)
treeee07aecc0461fd0ccb3bf77cac78cc187962e1d0 /bpmn/MSOCommonBPMN/src/main/groovy
parent1b29357c1c41437d3ad93f374e7d735fa6aab907 (diff)
Fix UriBuilder import in OofUtils
Import all changes from Casablanca that were incorrectly removed during merge from Casablanca back into master. Issue-ID: SO-1926 Change-Id: I8355e804586aa80e291f3c72a00bf69ce424316b Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy36
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy35
2 files changed, 30 insertions, 41 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index 623d5a67e3..6583ded413 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -32,17 +32,18 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition
import org.onap.so.bpmn.core.domain.Subscriber
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.DefaultProperties
import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.db.catalog.beans.AuthenticationType
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
import org.onap.so.db.catalog.beans.HomingInstance
import org.onap.so.db.catalog.beans.ServerType
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.utils.TargetEntity
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.json.JSONArray
import org.json.JSONObject
@@ -108,12 +109,12 @@ class OofHoming extends AbstractServiceTaskProcessor {
if (isBlank(subscriberInfo)) {
subscriber = new Subscriber("", "", "")
} else {
- String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")
- String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")
- String subCommonSiteId = ""
- if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) {
- subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")
- }
+ String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId")
+ String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName")
+ String subCommonSiteId = ""
+ if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) {
+ subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId")
+ }
subscriber = new Subscriber(subId, subName, subCommonSiteId)
}
@@ -163,21 +164,24 @@ class OofHoming extends AbstractServiceTaskProcessor {
logger.debug( "Posting to OOF Url: " + urlString)
- URL url = new URL(urlString);
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SNIRO)
+ URL url = new URL(urlString)
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.OOF)
httpClient.addAdditionalHeader("Authorization", authHeader)
- Response httpResponse = httpClient.post(oofRequest)
+ Response httpResponse = httpClient.post(oofRequest)
- int responseCode = httpResponse.getStatus()
- logger.debug("OOF sync response code is: " + responseCode)
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+ if(responseCode != 202){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ }
logger.debug( "*** Completed Homing Call OOF ***")
}
} catch (BpmnError b) {
throw b
} catch (Exception e) {
- logger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2500,
"Internal Error - Occured in Homing callOof: " + e.getMessage())
}
@@ -360,7 +364,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
throw b
} catch (Exception e) {
logger.debug( "ProcessHomingSolution Exception: " + e)
- logger.error(e);
+ logger.error(e);
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in Homing ProcessHomingSolution")
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index 2f46630715..4bfb29bc45 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -25,6 +25,7 @@ package org.onap.so.bpmn.common.scripts
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.domain.HomingSolution
import org.onap.so.bpmn.core.domain.ModelInfo
@@ -53,6 +54,7 @@ import org.slf4j.LoggerFactory
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
+import javax.ws.rs.core.UriBuilder
import javax.xml.ws.http.HTTPException
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
@@ -62,6 +64,7 @@ class OofUtils {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
private AbstractServiceTaskProcessor utils
@@ -504,27 +507,8 @@ class OofUtils {
*
* @return void
*/
- Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) {
-
- String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution)
- String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
- String uri = "/cloudSite"
-
- URL url = new URL(endpoint + uri)
- HttpClient client = new HttpClientFactory().newJsonClient(url, TargetEntity.EXTERNAL)
- client.addAdditionalHeader(HttpHeaders.AUTHORIZATION, auth)
- client.addAdditionalHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
-
- Response response = client.post(request.getBody().toString())
-
- int responseCode = response.getStatus()
- logger.debug("CatalogDB response code is: " + responseCode)
- String syncResponse = response.readEntity(String.class)
- logger.debug("CatalogDB response is: " + syncResponse)
-
- if(responseCode != 202){
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from CatalogDB.")
- }
+ Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+ oofInfraUtils.createCloudSite(cloudSite, execution)
}
/**
@@ -537,11 +521,12 @@ class OofUtils {
Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
oofInfraUtils.createHomingInstance(homingInstance, execution)
}
- String getMsbHost(DelegateExecution execution) {
- String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
- Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger()
+ String getMsbHost(DelegateExecution execution) {
+ String msbHost = UrnPropertiesReader.getVariable("mso.msb.host", execution, "msb-iag.onap")
+
+ Integer msbPort = UrnPropertiesReader.getVariable("mso.msb.port", execution, "80").toInteger()
- return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString()
+ return UriBuilder.fromPath("").host(msbHost).port(msbPort).scheme("http").build().toString()
}
}