diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2018-03-05 17:46:49 +0100 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2018-03-05 17:46:49 +0100 |
commit | 32eaf1e97f17a9d7a7b304fdc2b2be00c5830434 (patch) | |
tree | 0406597957b6cac404a8013741b3f5c62869cb8f /src/main/java/org/onap/clamp | |
parent | 35c6bda8ced4143b4fc1731727ee9bbe76b34c96 (diff) |
Remove globalClds.properties
Remove the globalClds.properties and merge that to
application.properties
Issue-ID: CLAMP-136
Change-Id: I9c5bc8745b576ca8fad0cca3bff4c136329515d8
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java/org/onap/clamp')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java | 22 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/service/CldsService.java | 34 |
2 files changed, 10 insertions, 46 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java index 5664653bf..fd7d096fa 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java @@ -72,6 +72,7 @@ import org.onap.clamp.clds.model.sdc.SdcResource; import org.onap.clamp.clds.model.sdc.SdcResourceBasicInfo;
import org.onap.clamp.clds.model.sdc.SdcServiceDetail;
import org.onap.clamp.clds.model.sdc.SdcServiceInfo;
+import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.util.CryptoUtils;
import org.onap.clamp.clds.util.LoggingUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -840,11 +841,13 @@ public class SdcCatalogServices { * @param globalProps
* @param cldsServiceData
* @return
+ * @throws IOException
+ * In case of issues during the parsing of the Global Properties
*/
- public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) {
+ public String createPropertiesObjectByUUID(CldsServiceData cldsServiceData) throws IOException {
String totalPropsStr;
ObjectMapper mapper = new ObjectMapper();
- ObjectNode globalPropsJson;
+ ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY);
if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {
// Objectnode to save all byservice, byvf , byvfc and byalarm nodes
ObjectNode byIdObjectNode = mapper.createObjectNode();
@@ -886,28 +889,13 @@ public class SdcCatalogServices { "alertDescription");
ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(mapper, allAlertDescriptions);
byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert);
- globalPropsJson = decodeGlobalProp(globalProps, mapper);
globalPropsJson.putPOJO("shared", byIdObjectNode);
logger.info("Global properties JSON created with SDC info:" + globalPropsJson);
- } else {
- /**
- * to create json with total properties when no serviceUUID passed
- */
- globalPropsJson = decodeGlobalProp(globalProps, mapper);
}
totalPropsStr = globalPropsJson.toString();
return totalPropsStr;
}
- private ObjectNode decodeGlobalProp(String globalProps, ObjectMapper mapper) {
- try {
- return (ObjectNode) mapper.readValue(globalProps, JsonNode.class);
- } catch (IOException e) {
- logger.error("Exception occurred during decoding of the global props, returning an empty objectNode", e);
- return mapper.createObjectNode();
- }
- }
-
/**
* Method to get alarm conditions/alert description from Service Data.
*
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java index 3b6bc3778..2968f60a4 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -87,7 +87,6 @@ import org.onap.clamp.clds.transform.XslTransformer; import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; @@ -102,9 +101,8 @@ public class CldsService extends SecureServiceBase { @Produce(uri = "direct:processSubmit") private CamelProxy camelProxy; protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger(); - @Autowired - private ApplicationContext appContext; private static final String RESOURCE_NAME = "clds-version.properties"; + public static final String GLOBAL_PROPERTIES_KEY = "files.globalProperties"; @Value("${clamp.config.security.permission.type.cl:permission-type-cl}") private String cldsPersmissionTypeCl; @Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}") @@ -132,9 +130,6 @@ public class CldsService extends SecureServiceBase { "update"); } - @Value("${org.onap.clamp.config.files.globalClds:'classpath:/clds/globalClds.properties'}") - private String globalClds; - private Properties globalCldsProperties; @Autowired private CldsDao cldsDao; @Autowired @@ -585,7 +580,7 @@ public class CldsService extends SecureServiceBase { @Path("/properties") @Produces(MediaType.APPLICATION_JSON) public String getSdcProperties() throws IOException { - return createPropertiesObjectByUUID(getGlobalCldsString(), "{}"); + return createPropertiesObjectByUUID("{}"); } /** @@ -620,7 +615,7 @@ public class CldsService extends SecureServiceBase { // filter out VFs the user is not authorized for cldsServiceData.filterVfs(this); // format retrieved data into properties json - String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData); + String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(cldsServiceData); // audit log LoggingUtils.setTimeContext(startTime, new Date()); LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName()); @@ -689,10 +684,10 @@ public class CldsService extends SecureServiceBase { return serviceNode.toString(); } - private String createPropertiesObjectByUUID(String globalProps, String cldsResponseStr) throws IOException { + private String createPropertiesObjectByUUID(String cldsResponseStr) throws IOException { ObjectMapper mapper = new ObjectMapper(); SdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, SdcServiceDetail.class); - ObjectNode globalPropsJson = null; + ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY); if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getUuid() != null) { /** * to create json with vf, alarm and locations @@ -711,14 +706,8 @@ public class CldsService extends SecureServiceBase { */ ObjectNode emptyvfcobjectNode = createByVFCObjectNode(mapper, cldsSdcServiceDetail.getResources()); byServiceBasicObjetNode.putPOJO("byVf", emptyvfcobjectNode); - globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); globalPropsJson.putPOJO("shared", byServiceBasicObjetNode); logger.info("valuie of objNode: {}", globalPropsJson); - } else { - /** - * to create json with total properties when no serviceUUID passed - */ - globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); } return globalPropsJson.toString(); } @@ -903,19 +892,6 @@ public class CldsService extends SecureServiceBase { return model; } - private String getGlobalCldsString() { - try { - if (null == globalCldsProperties) { - globalCldsProperties = new Properties(); - globalCldsProperties.load(appContext.getResource(globalClds).getInputStream()); - } - return (String) globalCldsProperties.get("globalCldsProps"); - } catch (IOException e) { - logger.error("Unable to load the globalClds due to an exception", e); - throw new CldsConfigException("Unable to load the globalClds due to an exception", e); - } - } - private void checkForDuplicateServiceVf(String modelName, String modelPropText) throws IOException { JsonNode modelJson = new ObjectMapper().readTree(modelPropText); JsonNode globalNode = modelJson.get("global"); |