diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-09 03:55:30 -0700 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-05-09 05:18:51 -0700 |
commit | b1e5734ef566af5d49ba17d05ca0ab7b56d6666d (patch) | |
tree | 92a232e908ae587cb244fd102e9c2c5648c66a9f /adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java | |
parent | d4f2190943216278826f39e7010d57f872bda90d (diff) |
[MSO-8] Additional fixes for the second rebase
DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file
not reloaded properly when it's wrong (JSON error or model hierarchy
mistake) at MSO startup
Change-Id: I2853030b78499e2a761706b643ea210955e72de3
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
[MSO-8] Restore files removed in patch set 2
Those groovy files must be there
Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java')
-rw-r--r-- | adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java index 6ee6721..688e554 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/CloudConfigFactory.java @@ -41,6 +41,7 @@ import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.map.JsonMappingException; import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.openstack.exceptions.MsoCloudIdentityNotFound; import org.openecomp.mso.openstack.utils.MsoHeatUtils; import org.openecomp.mso.openstack.utils.MsoKeystoneUtils; import org.openecomp.mso.openstack.utils.MsoNeutronUtils; @@ -77,7 +78,7 @@ public class CloudConfigFactory implements Serializable { } } - public void initializeCloudConfig (String filePath, int refreshTimer) { + public void initializeCloudConfig (String filePath, int refreshTimer) throws MsoCloudIdentityNotFound { rwl.writeLock ().lock (); try { @@ -94,7 +95,7 @@ public class CloudConfigFactory implements Serializable { } } - public void changeMsoPropertiesFilePath (String newMsoPropPath) throws MsoPropertiesException { + public void changeMsoPropertiesFilePath (String newMsoPropPath) { rwl.writeLock ().lock (); try { CloudConfigFactory.cloudConfigCache.configFilePath = prefixMsoPropertiesPath + newMsoPropPath; @@ -109,7 +110,11 @@ public class CloudConfigFactory implements Serializable { public CloudConfig getCloudConfig () { rwl.readLock ().lock (); try { - return cloudConfigCache.clone (); + if (cloudConfigCache.isValidCloudConfig()) { + return cloudConfigCache.clone (); + } else { + return new CloudConfig(); + } } finally { rwl.readLock ().unlock (); } @@ -139,7 +144,10 @@ public class CloudConfigFactory implements Serializable { try { if (refreshTimer <= 1) { - CloudConfig oldCloudConfig = cloudConfigCache.clone(); + CloudConfig oldCloudConfig = null; + if (cloudConfigCache.isValidCloudConfig()) { + oldCloudConfig = cloudConfigCache.clone(); + } cloudConfigCache.reloadPropertiesFile (); refreshTimer = cloudConfigCache.refreshTimerInMinutes; if (!cloudConfigCache.equals(oldCloudConfig)) { @@ -173,19 +181,22 @@ public class CloudConfigFactory implements Serializable { @Produces("text/plain") public Response showCloudConfig () { CloudConfig cloudConfig = this.getCloudConfig (); - - StringBuffer response = new StringBuffer (); - response.append ("Cloud Sites:\n"); - for (CloudSite site : cloudConfig.getCloudSites ().values ()) { - response.append (site.toString () + "\n"); - } - - response.append ("\n\nCloud Identity Services:\n"); - for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { - response.append (identity.toString () + "\n"); + if (cloudConfig != null) { + StringBuffer response = new StringBuffer (); + response.append ("Cloud Sites:\n"); + for (CloudSite site : cloudConfig.getCloudSites ().values ()) { + response.append (site.toString () + "\n"); + } + + response.append ("\n\nCloud Identity Services:\n"); + for (CloudIdentity identity : cloudConfig.getIdentityServices ().values ()) { + response.append (identity.toString () + "\n"); + } + + return Response.status (200).entity (response).build (); + } else { + return Response.status (500).entity ("Cloud Config has not been loaded properly, this could be due to a bad JSON structure (Check the logs for additional details)").build (); } - - return Response.status (200).entity (response).build (); } @GET |