summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
index b62d8be281..df7b57f3a3 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
@@ -45,18 +45,27 @@ public class OofInfraUtils {
public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
- Optional <CloudSite> optCloudsite = Optional.empty();
-
- CatalogDbClient client = new CatalogDbClient(endpoint, auth);
try {
- optCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/"));
+ CloudSite getCloudsite;
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+
+ getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")).orElse(new CloudSite());
+ if (!cloudSite.getId().equals(getCloudsite.getId())) {
+ client.postCloudSite(cloudSite);
+ LOGGER.debug("Did not findd cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Will create cloudSite: " + cloudSite.toString());
+ }
+ else {
+ LOGGER.debug("Found cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Will not create cloudSite: " + cloudSite.toString());
+ }
} catch (Exception e) {
- LOGGER.debug("Could not find cloudsite : " + cloudSite.getId());
- LOGGER.debug("Creating cloudSite: " + cloudSite.toString());
- }
- if (optCloudsite.isPresent() && (cloudSite.getId()) != optCloudsite.get().getId()) {
- client.postCloudSite(cloudSite);
+ LOGGER.debug("Error looking up or creating cloudsite : " + cloudSite.getId());
+ LOGGER.debug("CloudSite Lookup/Creation Error: " + e);
}
+
+
}
/**