From 57867d108c2f4db22379f5148c9dbab85a29662f Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 15 Feb 2018 16:04:12 +0100 Subject: Code refactoring Code refactoring, mainly Classes/Methods name renaming Issue-ID: CLAMP-85 Change-Id: I12bd190576e324ed33f057dc1a4ad32c16fcb6c2 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/Application.java | 4 +- .../clamp/clds/client/DcaeDispatcherServices.java | 4 +- .../clamp/clds/client/DcaeInventoryServices.java | 8 +- .../clamp/clds/client/HolmesPolicyDelegate.java | 8 +- .../clds/client/HolmesPolicyDeleteDelegate.java | 4 +- .../clds/client/OperationalPolicyDelegate.java | 10 +- .../client/OperationalPolicyDeleteDelegate.java | 6 +- .../onap/clamp/clds/client/SdcSendReqDelegate.java | 15 +- .../onap/clamp/clds/client/TcaPolicyDelegate.java | 8 +- .../clamp/clds/client/TcaPolicyDeleteDelegate.java | 4 +- .../client/req/policy/OperationalPolicyReq.java | 22 +- .../clamp/clds/client/req/policy/PolicyClient.java | 6 +- .../clds/client/req/sdc/SdcCatalogServices.java | 85 +++-- .../org/onap/clamp/clds/client/req/sdc/SdcReq.java | 227 ------------- .../clamp/clds/client/req/sdc/SdcRequests.java | 227 +++++++++++++ .../clds/client/req/tca/TcaRequestFormatter.java | 18 +- .../clamp/clds/config/CldsReferenceProperties.java | 110 +++++++ .../org/onap/clamp/clds/model/CldsSdcArtifact.java | 112 ------- .../org/onap/clamp/clds/model/CldsSdcResource.java | 166 ---------- .../clamp/clds/model/CldsSdcResourceBasicInfo.java | 196 ------------ .../clamp/clds/model/CldsSdcServiceDetail.java | 142 --------- .../onap/clamp/clds/model/CldsSdcServiceInfo.java | 184 ----------- .../clds/model/prop/AbstractModelElement.java | 242 -------------- .../org/onap/clamp/clds/model/prop/Global.java | 131 -------- .../org/onap/clamp/clds/model/prop/Holmes.java | 71 ----- .../org/onap/clamp/clds/model/prop/ModelBpmn.java | 171 ---------- .../onap/clamp/clds/model/prop/ModelBpmnEntry.java | 102 ------ .../clamp/clds/model/prop/ModelProperties.java | 350 --------------------- .../org/onap/clamp/clds/model/prop/Policy.java | 90 ------ .../onap/clamp/clds/model/prop/PolicyChain.java | 114 ------- .../org/onap/clamp/clds/model/prop/PolicyItem.java | 189 ----------- .../onap/clamp/clds/model/prop/ResourceGroup.java | 114 ------- .../clds/model/prop/ServiceConfiguration.java | 181 ----------- .../java/org/onap/clamp/clds/model/prop/Tca.java | 67 ---- .../org/onap/clamp/clds/model/prop/TcaItem.java | 115 ------- .../onap/clamp/clds/model/prop/TcaThreshold.java | 96 ------ .../model/properties/AbstractModelElement.java | 242 ++++++++++++++ .../onap/clamp/clds/model/properties/Global.java | 131 ++++++++ .../onap/clamp/clds/model/properties/Holmes.java | 71 +++++ .../clamp/clds/model/properties/ModelBpmn.java | 171 ++++++++++ .../clds/model/properties/ModelBpmnEntry.java | 102 ++++++ .../clds/model/properties/ModelProperties.java | 350 +++++++++++++++++++++ .../onap/clamp/clds/model/properties/Policy.java | 90 ++++++ .../clamp/clds/model/properties/PolicyChain.java | 114 +++++++ .../clamp/clds/model/properties/PolicyItem.java | 189 +++++++++++ .../clamp/clds/model/properties/ResourceGroup.java | 114 +++++++ .../model/properties/ServiceConfiguration.java | 181 +++++++++++ .../org/onap/clamp/clds/model/properties/Tca.java | 67 ++++ .../onap/clamp/clds/model/properties/TcaItem.java | 115 +++++++ .../clamp/clds/model/properties/TcaThreshold.java | 96 ++++++ .../org/onap/clamp/clds/model/refprop/RefProp.java | 110 ------- .../org/onap/clamp/clds/model/sdc/SdcArtifact.java | 112 +++++++ .../org/onap/clamp/clds/model/sdc/SdcResource.java | 166 ++++++++++ .../clamp/clds/model/sdc/SdcResourceBasicInfo.java | 196 ++++++++++++ .../clamp/clds/model/sdc/SdcServiceDetail.java | 142 +++++++++ .../onap/clamp/clds/model/sdc/SdcServiceInfo.java | 184 +++++++++++ .../org/onap/clamp/clds/service/CldsService.java | 34 +- .../java/org/onap/clamp/clds/AbstractItCase.java | 4 +- .../clds/it/CldsReferencePropertiesItCase.java | 63 ++++ .../clamp/clds/it/HolmesPolicyDelegateItCase.java | 4 +- .../clamp/clds/it/OperationPolicyReqItCase.java | 6 +- .../org/onap/clamp/clds/it/PolicyClientItCase.java | 8 +- .../java/org/onap/clamp/clds/it/RefPropItCase.java | 63 ---- .../clamp/clds/it/SdcCatalogServicesItCase.java | 54 ++-- .../java/org/onap/clamp/clds/it/SdcReqItCase.java | 8 +- .../clamp/clds/it/TcaRequestFormatterItCase.java | 2 +- .../clamp/clds/model/prop/CustomModelElement.java | 4 + .../clds/model/prop/CustomModelElementTest.java | 1 + .../clamp/clds/model/prop/ModelPropertiesTest.java | 4 + src/test/resources/http-cache/start_http_cache.sh | 2 +- 70 files changed, 3403 insertions(+), 3396 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/client/req/sdc/SdcReq.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/sdc/SdcRequests.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Global.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Holmes.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Policy.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Tca.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/TcaThreshold.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/Global.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/Holmes.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/Policy.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/ResourceGroup.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/ServiceConfiguration.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/Tca.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java create mode 100644 src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java create mode 100644 src/main/java/org/onap/clamp/clds/model/sdc/SdcArtifact.java create mode 100644 src/main/java/org/onap/clamp/clds/model/sdc/SdcResource.java create mode 100644 src/main/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfo.java create mode 100644 src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceDetail.java create mode 100644 src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceInfo.java create mode 100644 src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java delete mode 100644 src/test/java/org/onap/clamp/clds/it/RefPropItCase.java (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index 281a87ca5..9d057b583 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -28,8 +28,8 @@ import com.att.eelf.configuration.EELFManager; import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.catalina.connector.Connector; -import org.onap.clamp.clds.model.prop.Holmes; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration; diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index 6053a0de9..3c8649cd3 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -31,8 +31,8 @@ import java.util.Date; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.exception.DcaeDeploymentException; -import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -47,7 +47,7 @@ public class DcaeDispatcherServices { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; private static final String STATUS_URL_LOG = "Status URL extracted: "; private static final String DCAE_URL_PREFIX = "/dcae-deployments/"; private static final String DCAE_URL_PROPERTY_NAME = "DCAE_DISPATCHER_URL"; diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java index 4dfe089f9..1abd88985 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java @@ -41,13 +41,13 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsModel; import org.onap.clamp.clds.model.DcaeEvent; -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.model.properties.Global; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -63,7 +63,7 @@ public class DcaeInventoryServices { protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); private static final String DCAE_INVENTORY_URL = "DCAE_INVENTORY_URL"; @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; @Autowired private CldsDao cldsDao; diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java index 34655986d..4e165e141 100644 --- a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java @@ -31,9 +31,9 @@ import java.util.UUID; import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.prop.Holmes; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.config.CldsReferenceProperties; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -48,7 +48,7 @@ public class HolmesPolicyDelegate { @Autowired private PolicyClient policyClient; @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; /** * Perform activity. Send Holmes info to policy api. diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java index 28da14851..9075ea62a 100644 --- a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java @@ -29,8 +29,8 @@ import com.att.eelf.configuration.EELFManager; import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.prop.Holmes; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java index 77d7680bb..ec83db9de 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java @@ -33,10 +33,10 @@ import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; -import org.onap.clamp.clds.model.prop.PolicyChain; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.config.CldsReferenceProperties; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.PolicyChain; import org.onap.clamp.clds.util.LoggingUtils; import org.onap.policy.api.AttributeType; import org.onap.policy.controlloop.policy.builder.BuilderException; @@ -61,7 +61,7 @@ public class OperationalPolicyDelegate { * Automatically injected by Spring, define in CldsConfiguration as a bean. */ @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; /** * Perform activity. Send Operational Policy info to policy api. diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java index 4dd204080..862d68a7b 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java @@ -29,9 +29,9 @@ import com.att.eelf.configuration.EELFManager; import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; -import org.onap.clamp.clds.model.prop.PolicyChain; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.PolicyChain; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java index e21bfce41..438ea4727 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java @@ -34,11 +34,11 @@ import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.apache.commons.codec.DecoderException; import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices; -import org.onap.clamp.clds.client.req.sdc.SdcReq; +import org.onap.clamp.clds.client.req.sdc.SdcRequests; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.model.DcaeEvent; -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.model.properties.Global; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -53,9 +53,9 @@ public class SdcSendReqDelegate { @Autowired private SdcCatalogServices sdcCatalogServices; @Autowired - private SdcReq sdcReq; + private SdcRequests sdcReq; @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; /** * Perform activity. Send to sdc proxy. @@ -72,7 +72,6 @@ public class SdcSendReqDelegate { @Handler public void execute(Exchange camelExchange) throws GeneralSecurityException, DecoderException, IOException { String controlName = (String) camelExchange.getProperty("controlName"); - String baseUrl = refProp.getStringValue("sdc.serviceUrl"); String artifactLabel = sdcReq .normalizeResourceInstanceName(refProp.getStringValue("sdc.artifactLabel") + "-" + controlName); String locationArtifactLabel = sdcReq @@ -98,7 +97,7 @@ public class SdcSendReqDelegate { String serviceInvariantUUID = globalProps.getService(); camelExchange.setProperty("serviceInvariantUUID", serviceInvariantUUID); } - List sdcReqUrlsList = sdcReq.getSdcReqUrlsList(prop, baseUrl); + List sdcReqUrlsList = sdcReq.getSdcReqUrlsList(prop); String sdcLocationsPayload = sdcReq.formatSdcLocationsReq(prop, artifactName); String locationArtifactName = (String) camelExchange.getProperty("controlName") + "-location.json"; String formattedSdcLocationReq = sdcReq.formatSdcReq(sdcLocationsPayload, locationArtifactName, diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java index 2657a03f9..55fe2c571 100644 --- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java @@ -32,9 +32,9 @@ import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.onap.clamp.clds.client.req.policy.PolicyClient; import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.config.CldsReferenceProperties; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Tca; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -47,7 +47,7 @@ public class TcaPolicyDelegate { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDelegate.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; @Autowired private PolicyClient policyClient; diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java index c2aa303a5..c38d30075 100644 --- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java @@ -29,8 +29,8 @@ import com.att.eelf.configuration.EELFManager; import org.apache.camel.Exchange; import org.apache.camel.Handler; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Tca; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java index 8753a9fd3..434da4b65 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java @@ -39,12 +39,12 @@ import java.util.Map; import javax.ws.rs.BadRequestException; -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.PolicyChain; -import org.onap.clamp.clds.model.prop.PolicyItem; -import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.config.CldsReferenceProperties; +import org.onap.clamp.clds.model.properties.Global; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.PolicyChain; +import org.onap.clamp.clds.model.properties.PolicyItem; +import org.onap.clamp.clds.model.properties.Tca; import org.onap.policy.api.AttributeType; import org.onap.policy.controlloop.policy.OperationsAccumulateParams; import org.onap.policy.controlloop.policy.Policy; @@ -80,7 +80,7 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - public static Map> formatAttributes(RefProp refProp, ModelProperties prop, + public static Map> formatAttributes(CldsReferenceProperties refProp, ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { Global global = prop.getGlobal(); prop.setCurrentModelElementId(modelElementId); @@ -163,7 +163,7 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - protected static String formatOpenLoopYaml(RefProp refProp, ModelProperties prop, String modelElementId, + protected static String formatOpenLoopYaml(CldsReferenceProperties refProp, ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects Global global = prop.getGlobal(); @@ -193,7 +193,7 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - protected static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId, + protected static String formatYaml(CldsReferenceProperties refProp, ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects Global global = prop.getGlobal(); @@ -251,7 +251,7 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - protected static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId, + protected static String formateNodeBYaml(CldsReferenceProperties refProp, ModelProperties prop, String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { // get property objects Global global = prop.getGlobal(); @@ -329,7 +329,7 @@ public class OperationalPolicyReq { * @param inOrigList * @return */ - private static List addAOTSActorRecipe(RefProp refProp, String service, List inOrigList) { + private static List addAOTSActorRecipe(CldsReferenceProperties refProp, String service, List inOrigList) { List outList = new ArrayList<>(); try { PolicyItem policyItem = inOrigList.get(0); diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java index 046003309..ee78b45f8 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java @@ -37,9 +37,9 @@ import java.util.UUID; import javax.ws.rs.BadRequestException; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.exception.policy.PolicyClientException; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.LoggingUtils; import org.onap.policy.api.AttributeType; import org.onap.policy.api.ConfigRequestParameters; @@ -76,7 +76,7 @@ public class PolicyClient { @Autowired protected ApplicationContext appContext; @Autowired - protected RefProp refProp; + protected CldsReferenceProperties refProp; /** * Perform BRMS policy type. 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 45dbf81fe..299ec1e9e 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 @@ -58,20 +58,20 @@ import org.apache.commons.csv.CSVRecord; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHeaders; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.exception.SdcCommunicationException; import org.onap.clamp.clds.model.CldsAlarmCondition; -import org.onap.clamp.clds.model.CldsSdcArtifact; -import org.onap.clamp.clds.model.CldsSdcResource; -import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; -import org.onap.clamp.clds.model.CldsSdcServiceDetail; -import org.onap.clamp.clds.model.CldsSdcServiceInfo; import org.onap.clamp.clds.model.CldsServiceData; import org.onap.clamp.clds.model.CldsVfData; import org.onap.clamp.clds.model.CldsVfKPIData; import org.onap.clamp.clds.model.CldsVfcData; -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.model.properties.Global; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.sdc.SdcArtifact; +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.util.CryptoUtils; import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -93,7 +93,7 @@ public class SdcCatalogServices { private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool"; private static final String RESOURCE_URL_PREFIX = "resources"; @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; /** * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic @@ -165,8 +165,8 @@ public class SdcCatalogServices { * A list of CldsSdcServiceInfo * @return A list of CldsSdcServiceInfo without duplicate service UUID */ - public List removeDuplicateServices(List rawCldsSdcServiceList) { - List cldsSdcServiceInfoList = null; + public List removeDuplicateServices(List rawCldsSdcServiceList) { + List cldsSdcServiceInfoList = null; if (rawCldsSdcServiceList != null && !rawCldsSdcServiceList.isEmpty()) { // sort list Collections.sort(rawCldsSdcServiceList); @@ -176,7 +176,7 @@ public class SdcCatalogServices { for (int i = 1; i < rawCldsSdcServiceList.size(); i++) { // compare name with previous - if not equal, then keep the // previous (it's the last with that name) - CldsSdcServiceInfo prev = rawCldsSdcServiceList.get(i - 1); + SdcServiceInfo prev = rawCldsSdcServiceList.get(i - 1); if (!rawCldsSdcServiceList.get(i).getName().equals(prev.getName())) { cldsSdcServiceInfoList.add(prev); } @@ -193,8 +193,8 @@ public class SdcCatalogServices { * @param rawCldsSdcResourceList * @return List of CldsSdcResource */ - public List removeDuplicateSdcResourceInstances(List rawCldsSdcResourceList) { - List cldsSdcResourceList = null; + public List removeDuplicateSdcResourceInstances(List rawCldsSdcResourceList) { + List cldsSdcResourceList = null; if (rawCldsSdcResourceList != null && !rawCldsSdcResourceList.isEmpty()) { // sort list Collections.sort(rawCldsSdcResourceList); @@ -204,7 +204,7 @@ public class SdcCatalogServices { for (int i = 1; i < rawCldsSdcResourceList.size(); i++) { // compare name with previous - if not equal, then keep the // previous (it's the last with that name) - CldsSdcResource prev = rawCldsSdcResourceList.get(i - 1); + SdcResource prev = rawCldsSdcResourceList.get(i - 1); if (!rawCldsSdcResourceList.get(i).getResourceInstanceName().equals(prev.getResourceInstanceName())) { cldsSdcResourceList.add(prev); } @@ -221,9 +221,9 @@ public class SdcCatalogServices { * @param rawCldsSdcResourceListBasicList * @return List of CldsSdcResourceBasicInfo */ - public List removeDuplicateSdcResourceBasicInfo( - List rawCldsSdcResourceListBasicList) { - List cldsSdcResourceBasicInfoList = null; + public List removeDuplicateSdcResourceBasicInfo( + List rawCldsSdcResourceListBasicList) { + List cldsSdcResourceBasicInfoList = null; if (rawCldsSdcResourceListBasicList != null && !rawCldsSdcResourceListBasicList.isEmpty()) { // sort list Collections.sort(rawCldsSdcResourceListBasicList); @@ -233,7 +233,7 @@ public class SdcCatalogServices { for (int i = 1; i < rawCldsSdcResourceListBasicList.size(); i++) { // compare name with previous - if not equal, then keep the // previous (it's the last with that name) - CldsSdcResourceBasicInfo prev = rawCldsSdcResourceListBasicList.get(i - 1); + SdcResourceBasicInfo prev = rawCldsSdcResourceListBasicList.get(i - 1); if (!rawCldsSdcResourceListBasicList.get(i).getName().equals(prev.getName())) { cldsSdcResourceBasicInfoList.add(prev); } @@ -260,10 +260,10 @@ public class SdcCatalogServices { throws GeneralSecurityException, DecoderException { String serviceUuid = ""; String responseStr = getSdcServicesInformation(null); - List rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr); - List cldsSdcServicesList = removeDuplicateServices(rawCldsSdcServicesList); + List rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr); + List cldsSdcServicesList = removeDuplicateServices(rawCldsSdcServicesList); if (cldsSdcServicesList != null && !cldsSdcServicesList.isEmpty()) { - for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) { + for (SdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) { if (currCldsSdcServiceInfo != null && currCldsSdcServiceInfo.getInvariantUUID() != null && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) { serviceUuid = currCldsSdcServiceInfo.getUuid(); @@ -282,14 +282,14 @@ public class SdcCatalogServices { * @return The list of CldsSdcServiceInfo, if there is a failure it return * an empty list */ - private List getCldsSdcServicesListFromJson(String jsonStr) { + private List getCldsSdcServicesListFromJson(String jsonStr) { ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isBlank(jsonStr)) { return new ArrayList<>(); } try { return objectMapper.readValue(jsonStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); + objectMapper.getTypeFactory().constructCollectionType(List.class, SdcServiceInfo.class)); } catch (IOException e) { logger.error("Error when attempting to decode the JSON containing CldsSdcServiceInfo", e); return new ArrayList<>(); @@ -304,14 +304,14 @@ public class SdcCatalogServices { * @return The list of CldsSdcResourceBasicInfo, an empty list in case of * issues */ - private List getAllSdcResourcesListFromJson(String jsonStr) { + private List getAllSdcResourcesListFromJson(String jsonStr) { ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isBlank(jsonStr)) { return new ArrayList<>(); } try { return objectMapper.readValue(jsonStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class)); + objectMapper.getTypeFactory().constructCollectionType(List.class, SdcResourceBasicInfo.class)); } catch (IOException e) { logger.error("Exception occurred when attempting to decode the list of CldsSdcResourceBasicInfo JSON", e); return new ArrayList<>(); @@ -324,10 +324,10 @@ public class SdcCatalogServices { * @param jsonStr * @return */ - public CldsSdcServiceDetail getCldsSdcServiceDetailFromJson(String jsonStr) { + public SdcServiceDetail decodeCldsSdcServiceDetailFromJson(String jsonStr) { ObjectMapper objectMapper = new ObjectMapper(); try { - return objectMapper.readValue(jsonStr, CldsSdcServiceDetail.class); + return objectMapper.readValue(jsonStr, SdcServiceDetail.class); } catch (IOException e) { logger.error("Exception when attempting to decode the CldsSdcServiceDetail JSON", e); return null; @@ -472,9 +472,9 @@ public class SdcCatalogServices { ObjectMapper objectMapper = new ObjectMapper(); CldsServiceData cldsServiceData = new CldsServiceData(); if (responseStr != null) { - CldsSdcServiceDetail cldsSdcServiceDetail; + SdcServiceDetail cldsSdcServiceDetail; try { - cldsSdcServiceDetail = objectMapper.readValue(responseStr, CldsSdcServiceDetail.class); + cldsSdcServiceDetail = objectMapper.readValue(responseStr, SdcServiceDetail.class); } catch (IOException e) { logger.error("Exception when decoding the CldsServiceData JSON from SDC", e); throw new SdcCommunicationException("Exception when decoding the CldsServiceData JSON from SDC", e); @@ -484,11 +484,11 @@ public class SdcCatalogServices { if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) { cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid()); cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID()); - List cldsSdcResourceList = removeDuplicateSdcResourceInstances( + List cldsSdcResourceList = removeDuplicateSdcResourceInstances( cldsSdcServiceDetail.getResources()); if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { List cldsVfDataList = new ArrayList<>(); - for (CldsSdcResource currCldsSdcResource : cldsSdcResourceList) { + for (SdcResource currCldsSdcResource : cldsSdcResourceList) { if (currCldsSdcResource != null && currCldsSdcResource.getResoucreType() != null && "VF".equalsIgnoreCase(currCldsSdcResource.getResoucreType())) { CldsVfData currCldsVfData = new CldsVfData(); @@ -511,9 +511,8 @@ public class SdcCatalogServices { throws GeneralSecurityException { // todo : refact this.. if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) { - List allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType( - RESOURCE_VF_TYPE); - List allVfcResources = getAllSdcVForVfcResourcesBasedOnResourceType( + List allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType(RESOURCE_VF_TYPE); + List allVfcResources = getAllSdcVForVfcResourcesBasedOnResourceType( RESOURCE_VFC_TYPE); allVfcResources.addAll(getAllSdcVForVfcResourcesBasedOnResourceType(RESOURCE_CVFC_TYPE)); for (CldsVfData currCldsVfData : cldsVfDataList) { @@ -1128,18 +1127,18 @@ public class SdcCatalogServices { * The artifact name that will be searched * @return The artifact UUID found */ - public String getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail cldsSdcServiceDetail, String artifactName) { + public String getArtifactIdIfArtifactAlreadyExists(SdcServiceDetail cldsSdcServiceDetail, String artifactName) { String artifactUuid = null; boolean artifactExists = false; if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null && !cldsSdcServiceDetail.getResources().isEmpty()) { - for (CldsSdcResource currCldsSdcResource : cldsSdcServiceDetail.getResources()) { + for (SdcResource currCldsSdcResource : cldsSdcServiceDetail.getResources()) { if (artifactExists) { break; } if (currCldsSdcResource != null && currCldsSdcResource.getArtifacts() != null && !currCldsSdcResource.getArtifacts().isEmpty()) { - for (CldsSdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) { + for (SdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) { if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null && currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { artifactUuid = currCldsSdcArtifact.getArtifactUUID(); @@ -1154,7 +1153,7 @@ public class SdcCatalogServices { } // To get all sdc VF/VFC Resources basic info. - private List getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) { + private List getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) { String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME); String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType; String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl); @@ -1162,10 +1161,10 @@ public class SdcCatalogServices { } private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUuid, - List resourceInfoList) { + List resourceInfoList) { String resourceUuid = null; if (resourceInfoList != null && !resourceInfoList.isEmpty()) { - for (CldsSdcResourceBasicInfo currResource : resourceInfoList) { + for (SdcResourceBasicInfo currResource : resourceInfoList) { if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUuid)) { resourceUuid = currResource.getUuid(); @@ -1220,7 +1219,7 @@ public class SdcCatalogServices { String originalServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid); logger.info("ServiceUUID used before upload in url:" + originalServiceUuid); String sdcServicesInformation = getSdcServicesInformation(originalServiceUuid); - CldsSdcServiceDetail cldsSdcServiceDetail = getCldsSdcServiceDetailFromJson(sdcServicesInformation); + SdcServiceDetail cldsSdcServiceDetail = decodeCldsSdcServiceDetailFromJson(sdcServicesInformation); String uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail, artifactName); // Upload artifacts to sdc @@ -1233,7 +1232,7 @@ public class SdcCatalogServices { } logger.info("ServiceUUID used after upload in ulr:" + updatedServiceUuid); sdcServicesInformation = getSdcServicesInformation(updatedServiceUuid); - cldsSdcServiceDetail = getCldsSdcServiceDetailFromJson(sdcServicesInformation); + cldsSdcServiceDetail = decodeCldsSdcServiceDetailFromJson(sdcServicesInformation); uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail, locationArtifactName); // To send location information also to sdc diff --git a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcReq.java deleted file mode 100644 index 3fb53a3b6..000000000 --- a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcReq.java +++ /dev/null @@ -1,227 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.client.req.sdc; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.security.GeneralSecurityException; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; - -import org.apache.commons.codec.DecoderException; -import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; -import org.onap.clamp.clds.model.CldsSdcResource; -import org.onap.clamp.clds.model.CldsSdcServiceDetail; -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * Construct a Sdc request given CLDS objects. - */ -@Component -public class SdcReq { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcReq.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - @Autowired - private SdcCatalogServices sdcCatalogServices; - @Autowired - protected RefProp refProp; - - /** - * Format the Blueprint from a Yaml - * - * @param prop - * The ModelProperties describing the clds model - * @param docText - * The Yaml file that must be converted - * @return A String containing the BluePrint - * @throws IOException - * In case of issues - */ - public String formatBlueprint(ModelProperties prop, String docText) throws IOException { - String yamlvalue = getYamlvalue(docText); - String updatedBlueprint = ""; - Tca tca = prop.getType(Tca.class); - if (tca.isFound()) { - updatedBlueprint = TcaRequestFormatter.updatedBlueprintWithConfiguration(refProp, prop, yamlvalue); - } - logger.info("value of blueprint:" + updatedBlueprint); - return updatedBlueprint; - } - - /** - * Format the SDC Locations Request in the JSON Format - * - * @param prop - * The ModelProperties describing the clds model - * @param artifactName - * The name of the artifact - * @return SDC Locations request in the JSON Format - */ - public String formatSdcLocationsReq(ModelProperties prop, String artifactName) { - ObjectMapper objectMapper = new ObjectMapper(); - Global global = prop.getGlobal(); - List locationsList = global.getLocation(); - ArrayNode locationsArrayNode = objectMapper.createArrayNode(); - ObjectNode locationObject = objectMapper.createObjectNode(); - for (String currLocation : locationsList) { - locationsArrayNode.add(currLocation); - } - locationObject.put("artifactName", artifactName); - locationObject.putPOJO("locations", locationsArrayNode); - String locationJsonFormat = locationObject.toString(); - logger.info("Value of location Json Artifact:" + locationsArrayNode); - return locationJsonFormat; - } - - /** - * Format the SDC Request - * - * @param payloadData - * The ModelProperties describing the clds model - * @param artifactName - * The name of the artifact - * @param artifactLabel - * The Label of the artifact - * @param artifactType - * The type of the artifact - * @return formatted SDC Request - */ - public String formatSdcReq(String payloadData, String artifactName, String artifactLabel, String artifactType) { - logger.info("artifact=" + payloadData); - String base64Artifact = Base64.getEncoder().encodeToString(payloadData.getBytes(StandardCharsets.UTF_8)); - return "{ \n" + "\"payloadData\" : \"" + base64Artifact + "\",\n" + "\"artifactLabel\" : \"" + artifactLabel - + "\",\n" + "\"artifactName\" :\"" + artifactName + "\",\n" + "\"artifactType\" : \"" + artifactType - + "\",\n" + "\"artifactGroupType\" : \"DEPLOYMENT\",\n" + "\"description\" : \"from CLAMP Cockpit\"\n" - + "} \n"; - } - - /** - * To get List of urls for all vfresources - * - * @param prop - * The model properties JSON describing the closed loop flow - * @param baseUrl - * The URL to trigger - * @return A list of Service URL - * @throws GeneralSecurityException - * In case of issues when decrypting the password - * @throws DecoderException - * In case of issues when decoding the Hex String - */ - public List getSdcReqUrlsList(ModelProperties prop, String baseUrl) - throws GeneralSecurityException, DecoderException { - List urlList = new ArrayList<>(); - Global globalProps = prop.getGlobal(); - if (globalProps != null && globalProps.getService() != null) { - String serviceInvariantUUID = globalProps.getService(); - List resourceVfList = globalProps.getResourceVf(); - String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); - CldsSdcServiceDetail cldsSdcServiceDetail = sdcCatalogServices - .getCldsSdcServiceDetailFromJson(sdcCatalogServices.getSdcServicesInformation(serviceUUID)); - if (cldsSdcServiceDetail != null && resourceVfList != null) { - List cldsSdcResourcesList = cldsSdcServiceDetail.getResources(); - if (cldsSdcResourcesList != null && !cldsSdcResourcesList.isEmpty()) { - for (CldsSdcResource cldsSdcResource : cldsSdcResourcesList) { - if (cldsSdcResource != null && cldsSdcResource.getResoucreType() != null - && cldsSdcResource.getResoucreType().equalsIgnoreCase("VF") - && resourceVfList.contains(cldsSdcResource.getResourceInvariantUUID())) { - String normalizedResourceInstanceName = normalizeResourceInstanceName( - cldsSdcResource.getResourceInstanceName()); - String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" - + normalizedResourceInstanceName + "/artifacts"; - urlList.add(svcUrl); - } else { - logger.warn("The VF Resource invariant UUID (" + cldsSdcResource.getResourceInvariantUUID() - + ") has not been found in the Service (Invariant ID:" + serviceInvariantUUID - + ")VF resource list"); - } - } - } - } - } else { - logger.warn("GlobalProperties json is empty, skipping getSdcReqUrlsList and returning empty list"); - } - return urlList; - } - - /** - * "Normalize" the resource instance name: - Remove spaces, underscores, - * dashes, and periods. - make lower case This is required by SDC when using - * the resource instance name to upload an artifact. - * - * @param inText - * @return - */ - public String normalizeResourceInstanceName(String inText) { - return inText.replace(" ", "").replace("-", "").replace(".", "").toLowerCase(); - } - - /** - * Method to get yaml/template properties value from json. - * - * @param jsonGlobal - * The Json containing a Yaml file - * @return The yaml extracted from the JSON - * @throws IOException - * In case of issues with the Json parser - */ - protected String getYamlvalue(String jsonGlobal) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - String yamlFileValue = ""; - ObjectNode root = objectMapper.readValue(jsonGlobal, ObjectNode.class); - Iterator> entryItr = root.fields(); - while (entryItr.hasNext()) { - Entry entry = entryItr.next(); - String key = entry.getKey(); - if (key != null && key.equalsIgnoreCase("global")) { - ArrayNode arrayNode = (ArrayNode) entry.getValue(); - for (JsonNode anArrayNode : arrayNode) { - ObjectNode node = (ObjectNode) anArrayNode; - ArrayNode arrayValueNode = (ArrayNode) node.get("value"); - JsonNode jsonNode = arrayValueNode.get(0); - yamlFileValue = jsonNode.asText(); - logger.info("value:" + yamlFileValue); - } - break; - } - } - return yamlFileValue; - } -} diff --git a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcRequests.java b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcRequests.java new file mode 100644 index 000000000..214933d49 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcRequests.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.client.req.sdc; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; + +import org.apache.commons.codec.DecoderException; +import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; +import org.onap.clamp.clds.config.CldsReferenceProperties; +import org.onap.clamp.clds.model.properties.Global; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Tca; +import org.onap.clamp.clds.model.sdc.SdcResource; +import org.onap.clamp.clds.model.sdc.SdcServiceDetail; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * Construct a Sdc request given CLDS objects. + */ +@Component +public class SdcRequests { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcRequests.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + @Autowired + private SdcCatalogServices sdcCatalogServices; + @Autowired + protected CldsReferenceProperties refProp; + + /** + * Format the Blueprint from a Yaml + * + * @param prop + * The ModelProperties describing the clds model + * @param docText + * The Yaml file that must be converted + * @return A String containing the BluePrint + * @throws IOException + * In case of issues + */ + public String formatBlueprint(ModelProperties prop, String docText) throws IOException { + String yamlvalue = getYamlvalue(docText); + String updatedBlueprint = ""; + Tca tca = prop.getType(Tca.class); + if (tca.isFound()) { + updatedBlueprint = TcaRequestFormatter.updatedBlueprintWithConfiguration(refProp, prop, yamlvalue); + } + logger.info("value of blueprint:" + updatedBlueprint); + return updatedBlueprint; + } + + /** + * Format the SDC Locations Request in the JSON Format + * + * @param prop + * The ModelProperties describing the clds model + * @param artifactName + * The name of the artifact + * @return SDC Locations request in the JSON Format + */ + public String formatSdcLocationsReq(ModelProperties prop, String artifactName) { + ObjectMapper objectMapper = new ObjectMapper(); + Global global = prop.getGlobal(); + List locationsList = global.getLocation(); + ArrayNode locationsArrayNode = objectMapper.createArrayNode(); + ObjectNode locationObject = objectMapper.createObjectNode(); + for (String currLocation : locationsList) { + locationsArrayNode.add(currLocation); + } + locationObject.put("artifactName", artifactName); + locationObject.putPOJO("locations", locationsArrayNode); + String locationJsonFormat = locationObject.toString(); + logger.info("Value of location Json Artifact:" + locationsArrayNode); + return locationJsonFormat; + } + + /** + * Format the SDC Request + * + * @param payloadData + * The ModelProperties describing the clds model + * @param artifactName + * The name of the artifact + * @param artifactLabel + * The Label of the artifact + * @param artifactType + * The type of the artifact + * @return formatted SDC Request + */ + public String formatSdcReq(String payloadData, String artifactName, String artifactLabel, String artifactType) { + logger.info("artifact=" + payloadData); + String base64Artifact = Base64.getEncoder().encodeToString(payloadData.getBytes(StandardCharsets.UTF_8)); + return "{ \n" + "\"payloadData\" : \"" + base64Artifact + "\",\n" + "\"artifactLabel\" : \"" + artifactLabel + + "\",\n" + "\"artifactName\" :\"" + artifactName + "\",\n" + "\"artifactType\" : \"" + artifactType + + "\",\n" + "\"artifactGroupType\" : \"DEPLOYMENT\",\n" + "\"description\" : \"from CLAMP Cockpit\"\n" + + "} \n"; + } + + private List filterVfResourceList(String serviceUuid, List sdcResourcesList, + List cldsResourceVfList) { + List urlList = new ArrayList<>(); + for (SdcResource cldsSdcResource : sdcResourcesList) { + if (cldsSdcResource != null && cldsSdcResource.getResoucreType() != null + && cldsSdcResource.getResoucreType().equalsIgnoreCase("VF") + && cldsResourceVfList.contains(cldsSdcResource.getResourceInvariantUUID())) { + String normalizedResourceInstanceName = normalizeResourceInstanceName( + cldsSdcResource.getResourceInstanceName()); + String svcUrl = createUrlForResource(normalizedResourceInstanceName, serviceUuid); + urlList.add(svcUrl); + } + } + return urlList; + } + + private String createUrlForResource(String normalizedResourceInstanceName, String serviceUuid) { + return refProp.getStringValue("sdc.serviceUrl") + "/" + serviceUuid + "/resourceInstances/" + + normalizedResourceInstanceName + "/artifacts"; + } + + /** + * To get List of urls for all vfresources + * + * @param prop + * The model properties JSON describing the closed loop flow + * @return A list of Service URL + * @throws GeneralSecurityException + * In case of issues when decrypting the password + * @throws DecoderException + * In case of issues when decoding the Hex String + */ + public List getSdcReqUrlsList(ModelProperties prop) throws GeneralSecurityException, DecoderException { + List urlList = new ArrayList<>(); + Global globalProps = prop.getGlobal(); + if (globalProps != null && globalProps.getService() != null && globalProps.getResourceVf() != null) { + String serviceUuid = sdcCatalogServices.getServiceUuidFromServiceInvariantId(globalProps.getService()); + SdcServiceDetail sdcServiceDetail = sdcCatalogServices + .decodeCldsSdcServiceDetailFromJson(sdcCatalogServices.getSdcServicesInformation(serviceUuid)); + if (sdcServiceDetail != null) { + urlList = filterVfResourceList(serviceUuid, sdcServiceDetail.getResources(), + globalProps.getResourceVf()); + } + } else { + logger.warn("GlobalProperties json is empty, skipping getSdcReqUrlsList and returning empty list"); + } + return urlList; + } + + /** + * "Normalize" the resource instance name: - Remove spaces, underscores, + * dashes, and periods. - make lower case This is required by SDC when using + * the resource instance name to upload an artifact. + * + * @param inText + * @return + */ + public String normalizeResourceInstanceName(String inText) { + return inText.replace(" ", "").replace("-", "").replace(".", "").toLowerCase(); + } + + /** + * Method to get yaml/template properties value from json. + * + * @param jsonGlobal + * The Json containing a Yaml file + * @return The yaml extracted from the JSON + * @throws IOException + * In case of issues with the Json parser + */ + protected String getYamlvalue(String jsonGlobal) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + String yamlFileValue = ""; + ObjectNode root = objectMapper.readValue(jsonGlobal, ObjectNode.class); + Iterator> entryItr = root.fields(); + while (entryItr.hasNext()) { + Entry entry = entryItr.next(); + String key = entry.getKey(); + if (key != null && key.equalsIgnoreCase("global")) { + ArrayNode arrayNode = (ArrayNode) entry.getValue(); + for (JsonNode anArrayNode : arrayNode) { + ObjectNode node = (ObjectNode) anArrayNode; + ArrayNode arrayValueNode = (ArrayNode) node.get("value"); + JsonNode jsonNode = arrayValueNode.get(0); + yamlFileValue = jsonNode.asText(); + logger.info("value:" + yamlFileValue); + } + break; + } + } + return yamlFileValue; + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java index f13f42220..73355a7a4 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java +++ b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java @@ -32,12 +32,12 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import java.io.IOException; import java.util.Map; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.exception.TcaRequestFormatterException; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.model.prop.TcaItem; -import org.onap.clamp.clds.model.prop.TcaThreshold; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Tca; +import org.onap.clamp.clds.model.properties.TcaItem; +import org.onap.clamp.clds.model.properties.TcaThreshold; import org.yaml.snakeyaml.Yaml; /** @@ -64,7 +64,7 @@ public class TcaRequestFormatter { * The Model Prop created from BPMN JSON and BPMN properties JSON * @return The Json string containing that should be sent to policy */ - public static String createPolicyJson(RefProp refProp, ModelProperties modelProperties) { + public static String createPolicyJson(CldsReferenceProperties refProp, ModelProperties modelProperties) { try { String service = modelProperties.getGlobal().getService(); Tca tca = modelProperties.getType(Tca.class); @@ -103,7 +103,7 @@ public class TcaRequestFormatter { * modelProperties.setCurrentModelElementId will be used * @return The Json node containing what should be sent to policy */ - public static JsonNode createPolicyContent(RefProp refProp, ModelProperties modelProperties, String service, + public static JsonNode createPolicyContent(CldsReferenceProperties refProp, ModelProperties modelProperties, String service, String policyName, Tca tca) { try { String serviceToUse = service; @@ -153,7 +153,7 @@ public class TcaRequestFormatter { * The Model Properties created from BPMN JSON and BPMN * properties JSON */ - private static void addThresholds(RefProp refProp, String service, ObjectNode appendToNode, TcaItem tcaItem, + private static void addThresholds(CldsReferenceProperties refProp, String service, ObjectNode appendToNode, TcaItem tcaItem, ModelProperties modelProperties) { ArrayNode tcaNodes = appendToNode.withArray("thresholds"); ObjectNode tcaNode; @@ -185,7 +185,7 @@ public class TcaRequestFormatter { * The yaml string received from the UI * @return The updated YAML as a string */ - public static String updatedBlueprintWithConfiguration(RefProp refProp, ModelProperties modelProperties, + public static String updatedBlueprintWithConfiguration(CldsReferenceProperties refProp, ModelProperties modelProperties, String yamlValue) { String jsonPolicy = ((ObjectNode) createPolicyContent(refProp, modelProperties, null, null, null)).toString(); logger.info("Yaml that will be updated:" + yamlValue); diff --git a/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java b/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java new file mode 100644 index 000000000..a8acdee14 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.config; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.util.Properties; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Component; + +/** + * Holds reference properties. + */ +@Component +public class CldsReferenceProperties { + + @Autowired + private ApplicationContext appContext; + private Properties prop; + @Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}") + private String cldsReferenceValuesFile; + + @PostConstruct + public void loadConfig() throws IOException { + prop = new Properties(); + Resource resource = appContext.getResource(cldsReferenceValuesFile); + prop.load(resource.getInputStream()); + } + + /** + * get property value + * + * @param key + * @return + */ + public String getStringValue(String key) { + return prop.getProperty(key); + } + + /** + * get property value for a combo key (key1 + "." + key2). If not found just + * use key1. + * + * @param key1 + * @param key2 + * @return + */ + public String getStringValue(String key1, String key2) { + String value = getStringValue(key1 + "." + key2); + if (value == null || value.length() == 0) { + value = getStringValue(key1); + } + return value; + } + + /** + * Return json as objects that can be updated + * + * @param key + * @return + * @throws IOException + */ + public JsonNode getJsonTemplate(String key) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(getStringValue(key), JsonNode.class); + } + + /** + * Return json as objects that can be updated. First try with combo key + * (key1 + "." + key2), otherwise default to just key1. + * + * @param key1 + * @param key2 + * @return + * @throws IOException + */ + public JsonNode getJsonTemplate(String key1, String key2) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(getStringValue(key1, key2), JsonNode.class); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java deleted file mode 100644 index 48f90170c..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsSdcArtifact { - - private String artifactName; - private String artifactType; - private String artifactUrl; - private String artifactDescription; - private String artifactTimeout; - private String artifactChecksum; - private String artifactUuid; - private String artifactVersion; - private String generatedFromUuid; - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(String artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactURL() { - return artifactUrl; - } - - public void setArtifactURL(String artifactURL) { - this.artifactUrl = artifactURL; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public String getArtifactTimeout() { - return artifactTimeout; - } - - public void setArtifactTimeout(String artifactTimeout) { - this.artifactTimeout = artifactTimeout; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getArtifactUUID() { - return artifactUuid; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUuid = artifactUUID; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getGeneratedFromUUID() { - return generatedFromUuid; - } - - public void setGeneratedFromUUID(String generatedFromUUID) { - this.generatedFromUuid = generatedFromUUID; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java deleted file mode 100644 index 9c47f450c..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java +++ /dev/null @@ -1,166 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.math.BigDecimal; -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsSdcResource implements Comparable { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcResource.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - private String resourceInstanceName; - private String resourceName; - private String resourceInvariantUuid; - private String resourceVersion; - private String resoucreType; - private String resourceUuid; - private List artifacts; - - public String getResourceInstanceName() { - return resourceInstanceName; - } - - public void setResourceInstanceName(String resourceInstanceName) { - this.resourceInstanceName = resourceInstanceName; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceInvariantUUID() { - return resourceInvariantUuid; - } - - public void setResourceInvariantUUID(String resourceInvariantUUID) { - this.resourceInvariantUuid = resourceInvariantUUID; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public String getResoucreType() { - return resoucreType; - } - - public void setResoucreType(String resoucreType) { - this.resoucreType = resoucreType; - } - - public String getResourceUUID() { - return resourceUuid; - } - - public void setResourceUUID(String resourceUUID) { - this.resourceUuid = resourceUUID; - } - - public List getArtifacts() { - return artifacts; - } - - public void setArtifacts(List artifacts) { - this.artifacts = artifacts; - } - - @Override - public int compareTo(CldsSdcResource in) { - // Compares this object with the specified object for order. - // Returns a negative integer, zero, or a positive integer as this - // object is less than, equal to, or greater than the specified object. - - // first compare based on name - int rtn = resourceInstanceName.compareToIgnoreCase(in.resourceInstanceName); - - if (rtn == 0) { - BigDecimal myVersion = convertVersion(resourceVersion); - BigDecimal inVersion = convertVersion(in.resourceVersion); - rtn = myVersion.compareTo(inVersion); - } - return rtn; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode()); - result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CldsSdcResource other = (CldsSdcResource) obj; - if (resourceInstanceName == null) { - if (other.resourceInstanceName != null) - return false; - } else if (!resourceInstanceName.equals(other.resourceInstanceName)) - return false; - if (resourceVersion == null) { - if (other.resourceVersion != null) - return false; - } else if (!resourceVersion.equals(other.resourceVersion)) - return false; - return true; - } - - /** - * Convert version String into a BigDecimal - * - * @param versionText - * @return - */ - private BigDecimal convertVersion(String versionText) { - BigDecimal rtn = BigDecimal.valueOf(0.0); - try { - rtn = new BigDecimal(versionText); - } catch (NumberFormatException nfe) { - logger.warn("SDC version=" + versionText + " is not decimal for name=" + resourceInstanceName); - } - return rtn; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java deleted file mode 100644 index f91e36a81..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.math.BigDecimal; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsSdcResourceBasicInfo implements Comparable { - - protected static final EELFLogger logger = EELFManager.getInstance() - .getLogger(CldsSdcResourceBasicInfo.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String subCategory; - private String resourceType; - private String lifecycleState; - private String lastUpdaterUserId; - - @Override - public int compareTo(CldsSdcResourceBasicInfo in) { - // Compares this object with the specified object for order. - // Returns a negative integer, zero, or a positive integer as this - // object is less than, equal to, or greater than the specified object. - // first compare based on name - int rtn = name.compareToIgnoreCase(in.name); - - if (rtn == 0) { - BigDecimal myVersion = convertVersion(version); - BigDecimal inVersion = convertVersion(in.version); - rtn = myVersion.compareTo(inVersion); - } - return rtn; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CldsSdcResourceBasicInfo other = (CldsSdcResourceBasicInfo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (version == null) { - if (other.version != null) - return false; - } else if (!version.equals(other.version)) - return false; - return true; - } - - /** - * Convert version String into a BigDecimal - * - * @param version - * @return - */ - private BigDecimal convertVersion(String version) { - BigDecimal rtn = BigDecimal.valueOf(0.0); - try { - rtn = new BigDecimal(version); - } catch (NumberFormatException nfe) { - logger.warn("SDC version=" + version + " is not decimal for name=" + name); - } - return rtn; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getSubCategory() { - return subCategory; - } - - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public EELFLogger getLOGGER() { - return logger; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java deleted file mode 100644 index 551418b79..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java +++ /dev/null @@ -1,142 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsSdcServiceDetail { - - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String lifecycleState; - private String lastUpdaterUserId; - private String distributionStatus; - private String lastUpdaterFullName; - private List resources; - private List artifacts; - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public String getDistributionStatus() { - return distributionStatus; - } - - public void setDistributionStatus(String distributionStatus) { - this.distributionStatus = distributionStatus; - } - - public String getLastUpdaterFullName() { - return lastUpdaterFullName; - } - - public void setLastUpdaterFullName(String lastUpdaterFullName) { - this.lastUpdaterFullName = lastUpdaterFullName; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getArtifacts() { - return artifacts; - } - - public void setArtifacts(List artifacts) { - this.artifacts = artifacts; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java deleted file mode 100644 index cf447c5c7..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.math.BigDecimal; - -public class CldsSdcServiceInfo implements Comparable { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcServiceInfo.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String lifecycleState; - private String lastUpdaterUserId; - private String distributionStatus; - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public String getDistributionStatus() { - return distributionStatus; - } - - public void setDistributionStatus(String distributionStatus) { - this.distributionStatus = distributionStatus; - } - - /** - * Compare using name and then version. Version is converted to a decimal. - */ - @Override - public int compareTo(CldsSdcServiceInfo in) { - // Compares this object with the specified object for order. - // Returns a negative integer, zero, or a positive integer as this - // object is less than, equal to, or greater than the specified object. - // first compare based on name - int rtn = name.compareToIgnoreCase(in.name); - - if (rtn == 0) { - BigDecimal myVersion = convertVersion(version); - BigDecimal inVersion = convertVersion(in.version); - rtn = myVersion.compareTo(inVersion); - } - - return rtn; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CldsSdcServiceInfo other = (CldsSdcServiceInfo) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (version == null) { - if (other.version != null) - return false; - } else if (!version.equals(other.version)) - return false; - return true; - } - - /** - * Convert version String into a BigDecimal - * - * @param versionText - * @return - */ - private BigDecimal convertVersion(String versionText) { - try { - return new BigDecimal(versionText); - } catch (NumberFormatException nfe) { - logger.warn("SDC version=" + versionText + " is not decimal for name=" + name); - } - return BigDecimal.valueOf(0.0); - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java deleted file mode 100644 index a0685228b..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java +++ /dev/null @@ -1,242 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Provide base ModelElement functionality. Perform base parsing of properties - * for a ModelElement (such as, VesCollector, Policy, Tca, Holmes, - * ...) - */ -public abstract class AbstractModelElement { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private final String type; - private final ModelBpmn modelBpmn; - private final String id; - protected String topicPublishes; - protected final JsonNode modelElementJsonNode; - private boolean isFound; - - private final ModelProperties modelProp; - - private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON"; - private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}"; - - /** - * Perform base parsing of properties for a ModelElement (such as, - * VesCollector, Policy and Tca) - */ - protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - this.type = type; - this.modelProp = modelProp; - this.modelBpmn = modelBpmn; - this.id = modelBpmn.getId(type); - this.modelElementJsonNode = modelJson.get(id); - this.isFound = modelBpmn.isModelElementTypeInList(type); - } - - /** - * topicSubscribes is the topicPublishes of the from Model Element (the - * previous one in the chain). - * - * @return the topicSubscribes - */ - public String getTopicSubscribes() { - // get fromId for this type - String fromId = modelBpmn.getFromId(type); - // find the type of the from model element - String fromType = modelBpmn.getType(fromId); - // get the model element for the type - AbstractModelElement me = modelProp.getModelElementByType(fromType); - // get the topic publishes for the model element - return me.topicPublishes; - } - - /** - * @return the topicPublishes - */ - public String getTopicPublishes() { - return topicPublishes; - } - - /** - * Return the value field of the json node element that has a name field - * equals to the given name. - */ - public static String getValueByName(JsonNode nodeIn, String name) { - String value = null; - if (nodeIn != null) { - for (JsonNode node : nodeIn) { - if (node.path("name").asText().equals(name)) { - JsonNode vnode = node.path("value"); - if (vnode.isArray()) { - // if array, assume value is in first element - value = vnode.path(0).asText(); - } else { - // otherwise, just return text - value = vnode.asText(); - } - } - } - } - if (value == null || value.length() == 0) { - logger.warn(LOG_ELEMENT_NOT_FOUND, name); - } else { - logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString()); - } - return value; - } - - /** - * Return the value field of the json node element that has a name field - * that equals the given name. - */ - public static String getNodeValueByName(JsonNode nodeIn, String name) { - String value = null; - if (nodeIn != null) { - value = nodeIn.path(name).asText(); - } - if (value == null || value.length() == 0) { - logger.warn(LOG_ELEMENT_NOT_FOUND, name); - } else { - logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString()); - } - return value; - } - - /** - * Return the value field of the json node element that has a name field - * that equals the given name. - */ - public static List getNodeValuesByName(JsonNode nodeIn, String name) { - List values = new ArrayList<>(); - if (nodeIn != null) { - for (JsonNode node : nodeIn) { - if (node.path("name").asText().equals(name)) { - JsonNode vnode = node.path("value"); - if (vnode.isArray()) { - // if array, assume value is in first element - values.add(vnode.path(0).asText()); - } else { - // otherwise, just return text - values.add(vnode.asText()); - } - } - } - } - return values; - } - - /** - * Return the int value field of the json node element that has a name field - * equals to the given name. - */ - public static Integer getIntValueByName(JsonNode nodeIn, String name) { - String value = getValueByName(nodeIn, name); - return Integer.valueOf(value); - } - - /** - * Return an array of values for the field of the json node element that has - * a name field equals to the given name. - */ - public static List getValuesByName(JsonNode nodeIn, String name) { - List values = null; - if (nodeIn != null) { - for (JsonNode node : nodeIn) { - if (node.path("name").asText().equals(name)) { - values = getValuesList(node); - } - } - } - if (values == null || values.isEmpty()) { - logger.warn(LOG_ELEMENT_NOT_FOUND, name); - } else { - logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString()); - } - return values; - } - - /** - * Return an array of String values. - */ - public static List getValuesList(JsonNode nodeIn) { - ArrayList al = new ArrayList<>(); - if (nodeIn != null) { - Iterator itr = nodeIn.path("value").elements(); - while (itr.hasNext()) { - JsonNode node = itr.next(); - al.add(node.asText()); - } - } - return al; - } - - /** - * Return the value field of the json node element that has a name field - * equals to the given name. - */ - public String getValueByName(String name) { - return getValueByName(modelElementJsonNode, name); - } - - /** - * Return the int value field of the json node element that has a name field - * equals to the given name. - */ - public Integer getIntValueByName(String name) { - return getIntValueByName(modelElementJsonNode, name); - } - - /** - * Return an array of values for the field of the json node element that has - * a name field equals to the given name. - */ - public List getValuesByName(String name) { - return getValuesByName(modelElementJsonNode, name); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the isFound - */ - public boolean isFound() { - return isFound; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Global.java b/src/main/java/org/onap/clamp/clds/model/prop/Global.java deleted file mode 100644 index 48c2fd9fb..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/Global.java +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import java.util.List; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -/** - * Parse global json properties. - *

- * Example json: - * "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS", - * "v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city" - * ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}] - */ -public class Global { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String service; - private String actionSet; - private List resourceVf; - private List resourceVfc; - private List location; - - /** - * Parse global given json node. - * - * @param modelJson - */ - public Global(JsonNode modelJson) { - JsonNode globalNode = modelJson.get("global"); - service = AbstractModelElement.getValueByName(globalNode, "service"); - actionSet = AbstractModelElement.getValueByName(globalNode, "actionSet"); - resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf"); - resourceVfc = AbstractModelElement.getValuesByName(globalNode, "vfc"); - location = AbstractModelElement.getValuesByName(globalNode, "location"); - } - - /** - * @return the service - */ - public String getService() { - return service; - } - - /** - * @param service - * the service to set - */ - public void setService(String service) { - this.service = service; - } - - /** - * @return the actionSet - */ - public String getActionSet() { - return actionSet; - } - - /** - * @return the resourceVf - */ - public List getResourceVf() { - return resourceVf; - } - - /** - * @param resourceVf - * the resourceVf to set - */ - public void setResourceVf(List resourceVf) { - this.resourceVf = resourceVf; - } - - /** - * @return the resourceVfc - */ - public List getResourceVfc() { - return resourceVfc; - } - - /** - * @param resourceVfc - * the resourceVfc to set - */ - public void setResourceVfc(List resourceVfc) { - this.resourceVfc = resourceVfc; - } - - /** - * @return the location - */ - public List getLocation() { - return location; - } - - /** - * @param location - * the location to set - */ - public void setLocation(List location) { - this.location = location; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java deleted file mode 100644 index bd47e8d78..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.fasterxml.jackson.databind.JsonNode; - -/** - * Parse Holmes bpmn parameters json properties. - *

- * Example json: - * [{"name":"correlationalLogic","value":"vcwx"},{"name":"configPolicyName","value":"cccc"}] - * - */ -public class Holmes extends AbstractModelElement { - - private static final String TYPE_HOLMES = "holmes"; - - private String correlationLogic; - - private String configPolicyName; - - /** - * Default constructor for Holmes Element - * - * @param modelProp - * The ModelProperties containing the all the info, like bpmn, - * bpmn params, etc ... - * @param modelBpmn - * @param modelJson - */ - public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(TYPE_HOLMES, modelProp, modelBpmn, modelJson); - - correlationLogic = this.getValueByName("correlationalLogic"); - configPolicyName = this.getValueByName("configPolicyName"); - } - - public static final String getType() { - return TYPE_HOLMES; - } - - public String getCorrelationLogic() { - return correlationLogic; - } - - public String getConfigPolicyName() { - return configPolicyName; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java deleted file mode 100644 index 9738396a9..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java +++ /dev/null @@ -1,171 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.onap.clamp.clds.exception.ModelBpmnException; -import org.onap.clamp.clds.service.CldsService; - -/** - * Parse Model BPMN properties. - *

- * Example json: {"policy" :[{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]} - */ -public class ModelBpmn { - protected static final EELFLogger logger = EELFManager.getInstance() - .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - // for each type, an array of entries - private final Map> entriesByType = new HashMap<>(); - // for each id, an array of entries - private final Map> entriesById = new HashMap<>(); - // List of all elementIds - private List bpmnElementIds; - - /** - * Create ModelBpmn and populate maps from json - * - * @param modelBpmnPropText - * @return - */ - public static ModelBpmn create(String modelBpmnPropText) { - try { - ModelBpmn modelBpmn = new ModelBpmn(); - ObjectMapper objectMapper = new ObjectMapper(); - ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class); - // iterate over each entry like: - // "Policy":[{"id":"Policy","from":"StartEvent_1"}] - Iterator> entryItr = root.fields(); - List bpmnElementIdList = new ArrayList<>(); - while (entryItr.hasNext()) { - // process the entry - Entry entry = entryItr.next(); - String type = entry.getKey(); - ArrayNode arrayNode = (ArrayNode) entry.getValue(); - // process each id/from object, like: - // {"id":"Policy","from":"StartEvent_1"} - for (JsonNode anArrayNode : arrayNode) { - ObjectNode node = (ObjectNode) anArrayNode; - String id = node.get("id").asText(); - String fromId = node.get("from").asText(); - ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId); - modelBpmn.addEntry(modelBpmnEntry); - bpmnElementIdList.add(id); - } - modelBpmn.setBpmnElementIds(bpmnElementIdList); - } - return modelBpmn; - } catch (IOException e) { - throw new ModelBpmnException("Exception occurred during the decoding of the bpmn JSON", e); - } - } - - /** - * Add entry to both maps. - * - * @param entry - */ - private void addEntry(ModelBpmnEntry entry) { - addEntry(entriesByType, entry, entry.getType()); - addEntry(entriesById, entry, entry.getId()); - } - - /** - * Add an entry to provided map with provided key. - * - * @param map - * @param entry - * @param key - */ - private static void addEntry(Map> map, ModelBpmnEntry entry, String key) { - List list = map.computeIfAbsent(key, k -> new ArrayList<>()); - list.add(entry); - } - - /** - * This method verifies if the ModelElement Type (holmes, tca, ...) is in - * the list. - * - * @param type - * A model Element type (tca, ...) - * @return true if the element is found or false otherwise - */ - public boolean isModelElementTypeInList(String type) { - return entriesByType.get(type) != null; - } - - /** - * @return the id field given the ModelElement type - */ - public String getId(String type) { - String modelElementId = ""; - if (entriesByType.get(type) != null) { - modelElementId = entriesByType.get(type).get(0).getId(); - } - return modelElementId; - } - - /** - * @return the fromId field given the ModelElement type - */ - public String getFromId(String type) { - String modelElementFromIdId = ""; - if (entriesByType.get(type) != null) { - modelElementFromIdId = entriesByType.get(type).get(0).getFromId(); - } - return modelElementFromIdId; - } - - /** - * @return the ModelElement type given the ModelElement id - */ - public String getType(String id) { - return entriesById.get(id).get(0).getType(); - } - - /** - * @return list of elementIds from bpmn - */ - public List getBpmnElementIds() { - return bpmnElementIds; - } - - public void setBpmnElementIds(List bpmnElementIds) { - this.bpmnElementIds = bpmnElementIds; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java deleted file mode 100644 index dc6682297..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * Model BPMN property entry - *

- * Example json: {"policy": - * [{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]} - */ -public class ModelBpmnEntry { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelBpmnEntry.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String type; - private String id; - private String fromId; - - /** - * Parse the json so that the "id" and "from" fields can be retrieved on - * demand. - * - * @param type - * @param id - * @param fromId - */ - public ModelBpmnEntry(String type, String id, String fromId) { - this.type = type; - this.id = id; - this.fromId = fromId; - } - - /** - * @return the type - */ - public String getType() { - return type; - } - - /** - * @param type - * the type to set - */ - public void setType(String type) { - this.type = type; - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @param id - * the id to set - */ - public void setId(String id) { - this.id = id; - } - - /** - * @return the fromId - */ - public String getFromId() { - return fromId; - } - - /** - * @param fromId - * the fromId to set - */ - public void setFromId(String fromId) { - this.fromId = fromId; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java deleted file mode 100644 index dca93e46d..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ /dev/null @@ -1,350 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.camel.Exchange; -import org.onap.clamp.clds.exception.ModelBpmnException; -import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.CldsModel; -import org.onap.clamp.clds.service.CldsService; - -/** - * Parse model properties. - */ -public class ModelProperties { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private ModelBpmn modelBpmn; - private JsonNode modelJson; - private final String modelName; - private final String controlName; - private final String actionCd; - // Flag indicate whether it is triggered by Validation Test button from UI - private final boolean testOnly; - private Global global; - private final Map modelElements = new ConcurrentHashMap<>(); - private String currentModelElementId; - private String policyUniqueId; - private static final Object lock = new Object(); - private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); - static { - synchronized (lock) { - modelElementClasses.put(Policy.class, Policy.getType()); - modelElementClasses.put(Tca.class, Tca.getType()); - modelElementClasses.put(Holmes.class, Holmes.getType()); - } - } - - /** - * Retain data required to parse the ModelElement objects. (Rather than - * parse them all - parse them on demand if requested.) - * - * @param modelName - * The model name coming form the UI - * @param controlName - * The closed loop name coming from the UI - * @param actionCd - * Type of operation PUT,UPDATE,DELETE - * @param isATest - * The test flag coming from the UI (for validation only, no - * query are physically executed) - * @param modelBpmnText - * The BPMN flow in JSON from the UI - * @param modelPropText - * The BPMN parameters for all boxes defined in modelBpmnTest - */ - public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText, - String modelPropText) { - try { - this.modelName = modelName; - this.controlName = controlName; - this.actionCd = actionCd; - this.testOnly = isATest; - modelBpmn = ModelBpmn.create(modelBpmnText); - modelJson = new ObjectMapper().readTree(modelPropText); - instantiateMissingModelElements(); - } catch (IOException e) { - throw new ModelBpmnException("Exception occurred when trying to decode the BPMN Properties JSON", e); - } - } - - /** - * This method is meant to ensure that one ModelElement instance exists for - * each ModelElement class. As new ModelElement classes could have been - * registered after instantiation of this ModelProperties, we need to build - * the missing ModelElement instances. - */ - private final void instantiateMissingModelElements() { - if (modelElementClasses.size() != modelElements.size()) { - Set missingTypes = new HashSet<>(modelElementClasses.values()); - missingTypes.removeAll(modelElements.keySet()); - // Parse the list of base Model Elements and build up the - // ModelElements - modelElementClasses.entrySet().stream().parallel() - .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey()) - && missingTypes.contains(entry.getValue()))) - .forEach(entry -> { - try { - modelElements.put(entry.getValue(), - (entry.getKey() - .getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class) - .newInstance(this, modelBpmn, modelJson))); - } catch (InstantiationException | NoSuchMethodException | IllegalAccessException - | InvocationTargetException e) { - logger.warn("Unable to instantiate a ModelElement, exception follows: ", e); - } - }); - } - } - - /** - * Get the VF for a model. If return null if there is no VF. - * - * @param model - * @return - */ - public static String getVf(CldsModel model) { - List vfs = null; - try { - ObjectMapper mapper = new ObjectMapper(); - JsonNode modelJson = mapper.readTree(model.getPropText()); - Global global = new Global(modelJson); - vfs = global.getResourceVf(); - } catch (IOException e) { - logger.warn("no VF found", e); - } - String vf = null; - if (vfs != null && !vfs.isEmpty()) { - vf = vfs.get(0); - } - return vf; - } - - /** - * Create ModelProperties extracted from a CamelExchange. - * - * @param camelExchange - * The camel Exchange object that contains all info provided to - * the flow - * @return A model Properties created from the parameters found in - * camelExchange object - */ - public static ModelProperties create(Exchange camelExchange) { - String modelProp = (String) camelExchange.getProperty("modelProp"); - String modelBpmnProp = (String) camelExchange.getProperty("modelBpmnProp"); - String modelName = (String) camelExchange.getProperty("modelName"); - String controlName = (String) camelExchange.getProperty("controlName"); - String actionCd = (String) camelExchange.getProperty("actionCd"); - boolean isTest = (boolean) camelExchange.getProperty("isTest"); - return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp); - } - - /** - * return appropriate model element given the type - * - * @param type - * @return - */ - public AbstractModelElement getModelElementByType(String type) { - AbstractModelElement modelElement = modelElements.get(type); - if (modelElement == null) { - throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type); - } - return modelElement; - } - - /** - * @return the modelName - */ - public String getModelName() { - return modelName; - } - - /** - * @return the controlName - */ - public String getControlName() { - return controlName; - } - - /** - * @return the controlNameAndPolicyUniqueId - */ - public String getControlNameAndPolicyUniqueId() { - return controlName + "_" + policyUniqueId; - } - - /** - * @return the currentPolicyName - */ - private String getCurrentPolicyName() { - return normalizePolicyScopeName(controlName + "_" + currentModelElementId); - } - - /** - * @return the currentPolicyScopeAndPolicyName - */ - public String getCurrentPolicyScopeAndPolicyName() { - return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName()); - } - - /** - * @return the policyScopeAndNameWithUniqueId - */ - public String getPolicyScopeAndNameWithUniqueId() { - return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName() + "_" + policyUniqueId); - } - - /** - * @return the currentPolicyScopeAndFullPolicyName - */ - public String getCurrentPolicyScopeAndFullPolicyName(String policyNamePrefix) { - return normalizePolicyScopeName(modelName + "." + policyNamePrefix + getCurrentPolicyName()); - } - - /** - * @return the currentPolicyScopeAndFullPolicyNameWithVersion - */ - public String getCurrentPolicyScopeAndFullPolicyNameWithVersion(String policyNamePrefix, int version) { - return normalizePolicyScopeName( - modelName + "." + policyNamePrefix + getCurrentPolicyName() + "." + version + ".xml"); - } - - /** - * Replace all '-' with '_' within policy scope and name. - * - * @param inName - * @return - */ - private String normalizePolicyScopeName(String inName) { - return inName.replaceAll("-", "_"); - } - - /** - * @return the currentModelElementId - */ - public String getCurrentModelElementId() { - return currentModelElementId; - } - - /** - * When generating a policy request for a model element, must set the id of - * that model element using this method. Used to generate the policy name. - * - * @param currentModelElementId - * the currentModelElementId to set - */ - public void setCurrentModelElementId(String currentModelElementId) { - this.currentModelElementId = currentModelElementId; - } - - /** - * @return the policyUniqueId - */ - public String getPolicyUniqueId() { - return policyUniqueId; - } - - /** - * When generating a policy request for a model element, must set the unique - * id of that policy using this method. Used to generate the policy name. - * - * @param policyUniqueId - * the policyUniqueId to set - */ - public void setPolicyUniqueId(String policyUniqueId) { - this.policyUniqueId = policyUniqueId; - } - - /** - * @return the actionCd - */ - public String getActionCd() { - return actionCd; - } - - /** - * @return the testOnly - */ - public boolean isTestOnly() { - return testOnly; - } - - /** - * @return the isCreateRequest - */ - public boolean isCreateRequest() { - switch (actionCd) { - case CldsEvent.ACTION_SUBMIT: - case CldsEvent.ACTION_RESTART: - return true; - } - return false; - } - - public boolean isStopRequest() { - switch (actionCd) { - case CldsEvent.ACTION_STOP: - return true; - } - return false; - } - - /** - * @return the global - */ - public Global getGlobal() { - if (global == null) { - global = new Global(modelJson); - } - return global; - } - - public static final synchronized void registerModelElement(Class modelElementClass, - String type) { - if (!modelElementClasses.containsKey(modelElementClass.getClass())) { - modelElementClasses.put(modelElementClass, type); - } - } - - public T getType(Class clazz) { - instantiateMissingModelElements(); - String type = modelElementClasses.get(clazz); - return (type != null ? (T) modelElements.get(type) : null); - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java deleted file mode 100644 index 80d12aaba..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Parse Policy json properties. - *

- * Example json: - * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ - * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ - * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ - * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} - * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] - * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] - * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} - * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} - * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" - * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ - * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ - * "vf3RtPi"]}]]}] - */ -public class Policy extends AbstractModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private List policyChains; - - private static final String TYPE_POLICY = "policy"; - - /** - * Parse Policy given json node. - * - * @param modelProp - * @param modelBpmn - * @param modelJson - */ - public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(TYPE_POLICY, modelProp, modelBpmn, modelJson); - - // process policies - if (modelElementJsonNode != null) { - Iterator itr = modelElementJsonNode.elements(); - policyChains = new ArrayList<>(); - while (itr.hasNext()) { - policyChains.add(new PolicyChain(itr.next())); - } - } - } - - /** - * @return the policyChains - */ - public List getPolicyChains() { - return policyChains; - } - - public static final String getType() { - return TYPE_POLICY; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java deleted file mode 100644 index 217f7fd2d..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Parse Policy json properties. - * - * Example json: - * {"Policy_1e33tn8":{"PolicyTest1":[{"name":"pname","value":"PolicyTest1"},{ - * "name":"pid","value":"1"},{"name":"timeout","value":"345"},{ - * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": - * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" - * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": - * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": - * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": - * "parentPolicy","value":[""]},{"name": - * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}], - * "PolicyTest2":[{"name":"pname","value": - * "PolicyTest2"},{"name":"pid","value":"2"},{"name":"timeout","value":"345"},{ - * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": - * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" - * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": - * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": - * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": - * "parentPolicy","value":[""]},{"name": - * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]}} f - * - */ -public class PolicyChain { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyChain.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String policyId; - private Integer timeout; - private List policyItems; - private String policyType; - - public PolicyChain(JsonNode node) { - - policyId = AbstractModelElement.getValueByName(node, "pid"); - timeout = AbstractModelElement.getIntValueByName(node, "timeout"); - policyType = AbstractModelElement.getValueByName(node, "policyType"); - - if(node != null && node.size() > 0) { - JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations"); - if(policyNode != null) { - Iterator itr = policyNode.elements(); - policyItems = new ArrayList<>(); - while (itr.hasNext()) { - policyItems.add(new PolicyItem(itr.next())); - } - - } - } - } - /** - * @return the policyId - */ - public String getPolicyId() { - return policyId; - } - - /** - * @return the timeout - */ - public Integer getTimeout() { - return timeout; - } - - /** - * @return the policyItems - */ - public List getPolicyItems() { - return policyItems; - } - - /** - * @return the policyType - */ - public String getPolicyType() { - return policyType; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java deleted file mode 100644 index 5fc829835..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.List; - -/** - * Parse policyConfigurations from Policy json properties. - *

- * Example json: - * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ - * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ - * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ - * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} - * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] - * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] - * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} - * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} - * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" - * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ - * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ - * "vf3RtPi"]},{"name": - * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}] - */ -public class PolicyItem implements Cloneable { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String id; - private String recipe; - private int maxRetries; - private int retryTimeLimit; - private String parentPolicy; - private List parentPolicyConditions; - private String actor; - private String targetResourceId; - - /** - * Parse Policy given json node. - * - * @param node - */ - public PolicyItem(JsonNode node) { - id = AbstractModelElement.getValueByName(node, "_id"); - recipe = AbstractModelElement.getValueByName(node, "recipe"); - maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries"); - retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit"); - parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy"); - parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions"); - targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId"); - - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the recipe - */ - public String getRecipe() { - return recipe; - } - - /** - * @set the id - */ - public void setId(String id) { - this.id = id; - } - - /** - * @set the recipe - */ - public void setRecipe(String recipe) { - this.recipe = recipe; - } - - /** - * @set the parentPolicy - */ - public void setParentPolicy(String parentPolicy) { - this.parentPolicy = parentPolicy; - } - - /** - * @set the maxRetries - */ - public void setMaxRetries(int maxRetries) { - this.maxRetries = maxRetries; - } - - /** - * @set the retryTimeLimit - */ - public void setRetryTimeLimit(int retryTimeLimit) { - this.retryTimeLimit = retryTimeLimit; - } - - /** - * @set the parentPolicyConditions - */ - public void setParentPolicyConditions(List parentPolicyConditions) { - this.parentPolicyConditions = parentPolicyConditions; - } - - /** - * @return the maxRetries - */ - public int getMaxRetries() { - return maxRetries; - } - - /** - * @return the retryTimeLimit - */ - public int getRetryTimeLimit() { - return retryTimeLimit; - } - - /** - * @return the parentPolicy - */ - public String getParentPolicy() { - return parentPolicy; - } - - /** - * @return the parentPolicyConditions - */ - public List getParentPolicyConditions() { - return parentPolicyConditions; - } - - /** - * @return the actor - */ - public String getActor() { - return actor; - } - - /** - * @set the actor - */ - public void setActor(String actor) { - this.actor = actor; - } - - public String getTargetResourceId() { - return targetResourceId; - } - - public void setTargetResourceId(String targetResourceId) { - this.targetResourceId = targetResourceId; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java deleted file mode 100644 index 8b2dbeb83..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Parse Resource Group json properties. - * - * Example json: - * {"TCA_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ - * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": - * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" - * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" - * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": - * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ - * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ - * "name":"createClosedLoopEventId","value":["Initial"]},{"name": - * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": - * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": - * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ - * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ - * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", - * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": - * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ - * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ - * "name":"createClosedLoopEventId","value":["Initial"]},{"name": - * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ - * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", - * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": - * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} - * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, - * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": - * "outputEventName","value":["ABATED"]}]]}]}} - * - */ -public class ResourceGroup { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String groupNumber; - private String policyId; - private List serviceConfigurations; - - /** - * Parse String Match Resource Group given json node. - * - * @param modelBpmn - * @param modelJson - */ - public ResourceGroup(JsonNode node) { - - groupNumber = AbstractModelElement.getValueByName(node, "rgname"); - policyId = AbstractModelElement.getValueByName(node, "policyId"); - - // process Server_Configurations - JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); - Iterator itr = serviceConfigurationsNode.elements(); - serviceConfigurations = new ArrayList<>(); - while (itr.hasNext()) { - serviceConfigurations.add(new ServiceConfiguration(itr.next())); - } - } - - /** - * @return the groupNumber - */ - public String getGroupNumber() { - return groupNumber; - } - - /** - * @return the policyId - */ - public String getPolicyId() { - return policyId; - } - - /** - * @return the serviceConfigurations - */ - public List getServiceConfigurations() { - return serviceConfigurations; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java deleted file mode 100644 index 418afbb9f..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -/** - * Parse serviceConfigurations from Tca json properties. - *

- * Example json: - * {"Tca_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ - * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": - * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" - * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" - * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": - * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ - * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ - * "name":"createClosedLoopEventId","value":["Initial"]},{"name": - * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": - * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": - * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ - * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ - * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", - * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": - * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ - * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ - * "name":"createClosedLoopEventId","value":["Initial"]},{"name": - * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ - * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", - * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": - * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} - * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, - * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": - * "outputEventName","value":["ABATED"]}]]}]}} - * - */ -public class ServiceConfiguration { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ServiceConfiguration.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private final List aaiMatchingFields; - private final List aaiSendFields; - // private final String groupNumber; - private final List resourceVf; - private final List resourceVfc; - private final String timeWindow; - private final String ageLimit; - private final String createClosedLoopEventId; - private final String outputEventName; - private final Map stringSet; - - /** - * Parse serviceConfigurations given json node. - * - * @param node - */ - public ServiceConfiguration(JsonNode node) { - aaiMatchingFields = AbstractModelElement.getValuesByName(node, "aaiMatchingFields"); - aaiSendFields = AbstractModelElement.getValuesByName(node, "aaiSendFields"); - // groupNumber = ModelElement.getValueByName(node, "groupNumber"); - resourceVf = AbstractModelElement.getValuesByName(node, "vf"); - resourceVfc = AbstractModelElement.getValuesByName(node, "vfc"); - timeWindow = AbstractModelElement.getValueByName(node, "timeWindow"); - ageLimit = AbstractModelElement.getValueByName(node, "ageLimit"); - createClosedLoopEventId = AbstractModelElement.getValueByName(node, "createClosedLoopEventId"); - outputEventName = AbstractModelElement.getValueByName(node, "outputEventName"); - - // process the stringSet fields - JsonNode ssNodes = node.findPath("stringSet"); - Iterator itr = ssNodes.elements(); - stringSet = new HashMap<>(); - while (itr.hasNext()) { - JsonNode ssNode = itr.next(); - String key = ssNode.path("name").asText(); - String value = ssNode.path("value").path(0).asText(); - if (key.length() != 0 && value.length() != 0) { - // only add string set field if not null - logger.debug("stringSet: " + key + "=" + value); - stringSet.put(key, value); - } - } - } - - /** - * @return the aaiMatchingFields - */ - public List getaaiMatchingFields() { - return aaiMatchingFields; - } - - /** - * @return the aaiSendFields - */ - public List getaaiSendFields() { - return aaiSendFields; - } - - /** - * @return the groupNumber - */ /* - * public String getGroupNumber() { return groupNumber; } - */ - /** - * @return the resourceVf - */ - public List getResourceVf() { - return resourceVf; - } - - /** - * @return the resourceVfc - */ - public List getResourceVfc() { - return resourceVfc; - } - - /** - * @return the timeWindow - */ - public String getTimeWindow() { - return timeWindow; - } - - /** - * @return the ageLimit - */ - public String getAgeLimit() { - return ageLimit; - } - - /** - * @return the createClosedLoopEventId - */ - public String getCreateClosedLoopEventId() { - return createClosedLoopEventId; - } - - /** - * @return the outputEventName - */ - public String getOutputEventName() { - return outputEventName; - } - - /** - * @return the stringSet - */ - public Map getStringSet() { - return stringSet; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java deleted file mode 100644 index 4fd6b595d..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -/** - * Parse ONAP Tca json properties. - * - */ -public class Tca extends AbstractModelElement { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private TcaItem tcaItem; - - private static final String TYPE_TCA = "tca"; - - /** - * Parse Tca given json node - * - * @param modelProp - * @param modelBpmn - * @param modelJson - */ - public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(TYPE_TCA, modelProp, modelBpmn, modelJson); - - // process Server_Configurations - if (modelElementJsonNode != null) { - tcaItem = new TcaItem(modelElementJsonNode.elements().next()); - } - } - - public TcaItem getTcaItem() { - return tcaItem; - } - - public static final String getType() { - return TYPE_TCA; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java deleted file mode 100644 index 13bff0024..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Parse ONAP Tca Item json properties. - * - */ -public class TcaItem { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaItem.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String tcaName; - private String tcaUuId; - private String policyId; - private String eventName; - private String controlLoopSchemaType; - private List tcaThresholds; - - /** - * Parse Tca Item given json node - * - * @param node - */ - public TcaItem(JsonNode node) { - - tcaName = AbstractModelElement.getValueByName(node, "tname"); - tcaUuId = AbstractModelElement.getValueByName(node, "tuuid"); - policyId = AbstractModelElement.getValueByName(node, "tcaPolId"); - eventName = AbstractModelElement.getValueByName(node, "eventName"); - controlLoopSchemaType = AbstractModelElement.getValueByName(node, "controlLoopSchemaType"); - // process service Configurations - JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); - Iterator itr = serviceConfigurationsNode.elements(); - tcaThresholds = new ArrayList<>(); - while (itr.hasNext()) { - tcaThresholds.add(new TcaThreshold(itr.next())); - } - } - - public String getControlLoopSchemaType() { - return controlLoopSchemaType; - } - - public void setControlLoopSchemaType(String controlLoopSchemaType) { - this.controlLoopSchemaType = controlLoopSchemaType; - } - - public String getTcaName() { - return tcaName; - } - - public void setTcaName(String tcaName) { - this.tcaName = tcaName; - } - - public String getTcaUuId() { - return tcaUuId; - } - - public void setTcaUuId(String tcaUuId) { - this.tcaUuId = tcaUuId; - } - - public String getPolicyId() { - return policyId; - } - - public void setPolicyId(String policyId) { - this.policyId = policyId; - } - - public List getTcaThresholds() { - return tcaThresholds; - } - - public String getEventName() { - return eventName; - } - - public void setEventName(String eventName) { - this.eventName = eventName; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshold.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshold.java deleted file mode 100644 index d278c254f..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshold.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -/** - * Parse ONAP Tca Threshold json properties. - * - */ -public class TcaThreshold { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaThreshold.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private String fieldPath; - private String operator; - private Integer threshold; - private String closedLoopEventStatus; - - /** - * Parse Tca Threshhold given json node - * - * @param node - */ - public TcaThreshold(JsonNode node) { - - if (node.get(0) != null) { - fieldPath = node.get(0).asText(); - } - if (node.get(1) != null) { - operator = node.get(1).asText(); - } - if (node.get(2) != null) { - threshold = Integer.valueOf(node.get(2).asText()); - } - if (node.get(3) != null) { - closedLoopEventStatus = node.get(3).asText(); - } - } - - public String getFieldPath() { - return fieldPath; - } - - public void setFieldPath(String fieldPath) { - this.fieldPath = fieldPath; - } - - public String getOperator() { - return operator; - } - - public void setOperator(String operator) { - this.operator = operator; - } - - public Integer getThreshold() { - return threshold; - } - - public void setThreshold(Integer threshold) { - this.threshold = threshold; - } - - public String getClosedLoopEventStatus() { - return closedLoopEventStatus; - } - - public void setClosedLoopEventStatus(String closedLoopEventStatus) { - this.closedLoopEventStatus = closedLoopEventStatus; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java new file mode 100644 index 000000000..9b8d9d9ce --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Provide base ModelElement functionality. Perform base parsing of properties + * for a ModelElement (such as, VesCollector, Policy, Tca, Holmes, + * ...) + */ +public abstract class AbstractModelElement { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private final String type; + private final ModelBpmn modelBpmn; + private final String id; + protected String topicPublishes; + protected final JsonNode modelElementJsonNode; + private boolean isFound; + + private final ModelProperties modelProp; + + private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON"; + private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}"; + + /** + * Perform base parsing of properties for a ModelElement (such as, + * VesCollector, Policy and Tca) + */ + protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + this.type = type; + this.modelProp = modelProp; + this.modelBpmn = modelBpmn; + this.id = modelBpmn.getId(type); + this.modelElementJsonNode = modelJson.get(id); + this.isFound = modelBpmn.isModelElementTypeInList(type); + } + + /** + * topicSubscribes is the topicPublishes of the from Model Element (the + * previous one in the chain). + * + * @return the topicSubscribes + */ + public String getTopicSubscribes() { + // get fromId for this type + String fromId = modelBpmn.getFromId(type); + // find the type of the from model element + String fromType = modelBpmn.getType(fromId); + // get the model element for the type + AbstractModelElement me = modelProp.getModelElementByType(fromType); + // get the topic publishes for the model element + return me.topicPublishes; + } + + /** + * @return the topicPublishes + */ + public String getTopicPublishes() { + return topicPublishes; + } + + /** + * Return the value field of the json node element that has a name field + * equals to the given name. + */ + public static String getValueByName(JsonNode nodeIn, String name) { + String value = null; + if (nodeIn != null) { + for (JsonNode node : nodeIn) { + if (node.path("name").asText().equals(name)) { + JsonNode vnode = node.path("value"); + if (vnode.isArray()) { + // if array, assume value is in first element + value = vnode.path(0).asText(); + } else { + // otherwise, just return text + value = vnode.asText(); + } + } + } + } + if (value == null || value.length() == 0) { + logger.warn(LOG_ELEMENT_NOT_FOUND, name); + } else { + logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString()); + } + return value; + } + + /** + * Return the value field of the json node element that has a name field + * that equals the given name. + */ + public static String getNodeValueByName(JsonNode nodeIn, String name) { + String value = null; + if (nodeIn != null) { + value = nodeIn.path(name).asText(); + } + if (value == null || value.length() == 0) { + logger.warn(LOG_ELEMENT_NOT_FOUND, name); + } else { + logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString()); + } + return value; + } + + /** + * Return the value field of the json node element that has a name field + * that equals the given name. + */ + public static List getNodeValuesByName(JsonNode nodeIn, String name) { + List values = new ArrayList<>(); + if (nodeIn != null) { + for (JsonNode node : nodeIn) { + if (node.path("name").asText().equals(name)) { + JsonNode vnode = node.path("value"); + if (vnode.isArray()) { + // if array, assume value is in first element + values.add(vnode.path(0).asText()); + } else { + // otherwise, just return text + values.add(vnode.asText()); + } + } + } + } + return values; + } + + /** + * Return the int value field of the json node element that has a name field + * equals to the given name. + */ + public static Integer getIntValueByName(JsonNode nodeIn, String name) { + String value = getValueByName(nodeIn, name); + return Integer.valueOf(value); + } + + /** + * Return an array of values for the field of the json node element that has + * a name field equals to the given name. + */ + public static List getValuesByName(JsonNode nodeIn, String name) { + List values = null; + if (nodeIn != null) { + for (JsonNode node : nodeIn) { + if (node.path("name").asText().equals(name)) { + values = getValuesList(node); + } + } + } + if (values == null || values.isEmpty()) { + logger.warn(LOG_ELEMENT_NOT_FOUND, name); + } else { + logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString()); + } + return values; + } + + /** + * Return an array of String values. + */ + public static List getValuesList(JsonNode nodeIn) { + ArrayList al = new ArrayList<>(); + if (nodeIn != null) { + Iterator itr = nodeIn.path("value").elements(); + while (itr.hasNext()) { + JsonNode node = itr.next(); + al.add(node.asText()); + } + } + return al; + } + + /** + * Return the value field of the json node element that has a name field + * equals to the given name. + */ + public String getValueByName(String name) { + return getValueByName(modelElementJsonNode, name); + } + + /** + * Return the int value field of the json node element that has a name field + * equals to the given name. + */ + public Integer getIntValueByName(String name) { + return getIntValueByName(modelElementJsonNode, name); + } + + /** + * Return an array of values for the field of the json node element that has + * a name field equals to the given name. + */ + public List getValuesByName(String name) { + return getValuesByName(modelElementJsonNode, name); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the isFound + */ + public boolean isFound() { + return isFound; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Global.java b/src/main/java/org/onap/clamp/clds/model/properties/Global.java new file mode 100644 index 000000000..ef36fef91 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/Global.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import java.util.List; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse global json properties. + *

+ * Example json: + * "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS", + * "v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city" + * ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}] + */ +public class Global { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String service; + private String actionSet; + private List resourceVf; + private List resourceVfc; + private List location; + + /** + * Parse global given json node. + * + * @param modelJson + */ + public Global(JsonNode modelJson) { + JsonNode globalNode = modelJson.get("global"); + service = AbstractModelElement.getValueByName(globalNode, "service"); + actionSet = AbstractModelElement.getValueByName(globalNode, "actionSet"); + resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf"); + resourceVfc = AbstractModelElement.getValuesByName(globalNode, "vfc"); + location = AbstractModelElement.getValuesByName(globalNode, "location"); + } + + /** + * @return the service + */ + public String getService() { + return service; + } + + /** + * @param service + * the service to set + */ + public void setService(String service) { + this.service = service; + } + + /** + * @return the actionSet + */ + public String getActionSet() { + return actionSet; + } + + /** + * @return the resourceVf + */ + public List getResourceVf() { + return resourceVf; + } + + /** + * @param resourceVf + * the resourceVf to set + */ + public void setResourceVf(List resourceVf) { + this.resourceVf = resourceVf; + } + + /** + * @return the resourceVfc + */ + public List getResourceVfc() { + return resourceVfc; + } + + /** + * @param resourceVfc + * the resourceVfc to set + */ + public void setResourceVfc(List resourceVfc) { + this.resourceVfc = resourceVfc; + } + + /** + * @return the location + */ + public List getLocation() { + return location; + } + + /** + * @param location + * the location to set + */ + public void setLocation(List location) { + this.location = location; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java new file mode 100644 index 000000000..db07cac4f --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/Holmes.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Holmes bpmn parameters json properties. + *

+ * Example json: + * [{"name":"correlationalLogic","value":"vcwx"},{"name":"configPolicyName","value":"cccc"}] + * + */ +public class Holmes extends AbstractModelElement { + + private static final String TYPE_HOLMES = "holmes"; + + private String correlationLogic; + + private String configPolicyName; + + /** + * Default constructor for Holmes Element + * + * @param modelProp + * The ModelProperties containing the all the info, like bpmn, + * bpmn params, etc ... + * @param modelBpmn + * @param modelJson + */ + public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_HOLMES, modelProp, modelBpmn, modelJson); + + correlationLogic = this.getValueByName("correlationalLogic"); + configPolicyName = this.getValueByName("configPolicyName"); + } + + public static final String getType() { + return TYPE_HOLMES; + } + + public String getCorrelationLogic() { + return correlationLogic; + } + + public String getConfigPolicyName() { + return configPolicyName; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java new file mode 100644 index 000000000..2b86b3fdc --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.onap.clamp.clds.exception.ModelBpmnException; +import org.onap.clamp.clds.service.CldsService; + +/** + * Parse Model BPMN properties. + *

+ * Example json: {"policy" :[{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]} + */ +public class ModelBpmn { + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + // for each type, an array of entries + private final Map> entriesByType = new HashMap<>(); + // for each id, an array of entries + private final Map> entriesById = new HashMap<>(); + // List of all elementIds + private List bpmnElementIds; + + /** + * Create ModelBpmn and populate maps from json + * + * @param modelBpmnPropText + * @return + */ + public static ModelBpmn create(String modelBpmnPropText) { + try { + ModelBpmn modelBpmn = new ModelBpmn(); + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class); + // iterate over each entry like: + // "Policy":[{"id":"Policy","from":"StartEvent_1"}] + Iterator> entryItr = root.fields(); + List bpmnElementIdList = new ArrayList<>(); + while (entryItr.hasNext()) { + // process the entry + Entry entry = entryItr.next(); + String type = entry.getKey(); + ArrayNode arrayNode = (ArrayNode) entry.getValue(); + // process each id/from object, like: + // {"id":"Policy","from":"StartEvent_1"} + for (JsonNode anArrayNode : arrayNode) { + ObjectNode node = (ObjectNode) anArrayNode; + String id = node.get("id").asText(); + String fromId = node.get("from").asText(); + ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId); + modelBpmn.addEntry(modelBpmnEntry); + bpmnElementIdList.add(id); + } + modelBpmn.setBpmnElementIds(bpmnElementIdList); + } + return modelBpmn; + } catch (IOException e) { + throw new ModelBpmnException("Exception occurred during the decoding of the bpmn JSON", e); + } + } + + /** + * Add entry to both maps. + * + * @param entry + */ + private void addEntry(ModelBpmnEntry entry) { + addEntry(entriesByType, entry, entry.getType()); + addEntry(entriesById, entry, entry.getId()); + } + + /** + * Add an entry to provided map with provided key. + * + * @param map + * @param entry + * @param key + */ + private static void addEntry(Map> map, ModelBpmnEntry entry, String key) { + List list = map.computeIfAbsent(key, k -> new ArrayList<>()); + list.add(entry); + } + + /** + * This method verifies if the ModelElement Type (holmes, tca, ...) is in + * the list. + * + * @param type + * A model Element type (tca, ...) + * @return true if the element is found or false otherwise + */ + public boolean isModelElementTypeInList(String type) { + return entriesByType.get(type) != null; + } + + /** + * @return the id field given the ModelElement type + */ + public String getId(String type) { + String modelElementId = ""; + if (entriesByType.get(type) != null) { + modelElementId = entriesByType.get(type).get(0).getId(); + } + return modelElementId; + } + + /** + * @return the fromId field given the ModelElement type + */ + public String getFromId(String type) { + String modelElementFromIdId = ""; + if (entriesByType.get(type) != null) { + modelElementFromIdId = entriesByType.get(type).get(0).getFromId(); + } + return modelElementFromIdId; + } + + /** + * @return the ModelElement type given the ModelElement id + */ + public String getType(String id) { + return entriesById.get(id).get(0).getType(); + } + + /** + * @return list of elementIds from bpmn + */ + public List getBpmnElementIds() { + return bpmnElementIds; + } + + public void setBpmnElementIds(List bpmnElementIds) { + this.bpmnElementIds = bpmnElementIds; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java new file mode 100644 index 000000000..81cc48d63 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/ModelBpmnEntry.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +/** + * Model BPMN property entry + *

+ * Example json: {"policy": + * [{"id":"Policy_0oxeocn", "from":"StartEvent_1"}]} + */ +public class ModelBpmnEntry { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelBpmnEntry.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String type; + private String id; + private String fromId; + + /** + * Parse the json so that the "id" and "from" fields can be retrieved on + * demand. + * + * @param type + * @param id + * @param fromId + */ + public ModelBpmnEntry(String type, String id, String fromId) { + this.type = type; + this.id = id; + this.fromId = fromId; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type + * the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the fromId + */ + public String getFromId() { + return fromId; + } + + /** + * @param fromId + * the fromId to set + */ + public void setFromId(String fromId) { + this.fromId = fromId; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java new file mode 100644 index 000000000..f9b1c25a4 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java @@ -0,0 +1,350 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.camel.Exchange; +import org.onap.clamp.clds.exception.ModelBpmnException; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.service.CldsService; + +/** + * Parse model properties. + */ +public class ModelProperties { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + private ModelBpmn modelBpmn; + private JsonNode modelJson; + private final String modelName; + private final String controlName; + private final String actionCd; + // Flag indicate whether it is triggered by Validation Test button from UI + private final boolean testOnly; + private Global global; + private final Map modelElements = new ConcurrentHashMap<>(); + private String currentModelElementId; + private String policyUniqueId; + private static final Object lock = new Object(); + private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); + static { + synchronized (lock) { + modelElementClasses.put(Policy.class, Policy.getType()); + modelElementClasses.put(Tca.class, Tca.getType()); + modelElementClasses.put(Holmes.class, Holmes.getType()); + } + } + + /** + * Retain data required to parse the ModelElement objects. (Rather than + * parse them all - parse them on demand if requested.) + * + * @param modelName + * The model name coming form the UI + * @param controlName + * The closed loop name coming from the UI + * @param actionCd + * Type of operation PUT,UPDATE,DELETE + * @param isATest + * The test flag coming from the UI (for validation only, no + * query are physically executed) + * @param modelBpmnText + * The BPMN flow in JSON from the UI + * @param modelPropText + * The BPMN parameters for all boxes defined in modelBpmnTest + */ + public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText, + String modelPropText) { + try { + this.modelName = modelName; + this.controlName = controlName; + this.actionCd = actionCd; + this.testOnly = isATest; + modelBpmn = ModelBpmn.create(modelBpmnText); + modelJson = new ObjectMapper().readTree(modelPropText); + instantiateMissingModelElements(); + } catch (IOException e) { + throw new ModelBpmnException("Exception occurred when trying to decode the BPMN Properties JSON", e); + } + } + + /** + * This method is meant to ensure that one ModelElement instance exists for + * each ModelElement class. As new ModelElement classes could have been + * registered after instantiation of this ModelProperties, we need to build + * the missing ModelElement instances. + */ + private final void instantiateMissingModelElements() { + if (modelElementClasses.size() != modelElements.size()) { + Set missingTypes = new HashSet<>(modelElementClasses.values()); + missingTypes.removeAll(modelElements.keySet()); + // Parse the list of base Model Elements and build up the + // ModelElements + modelElementClasses.entrySet().stream().parallel() + .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey()) + && missingTypes.contains(entry.getValue()))) + .forEach(entry -> { + try { + modelElements.put(entry.getValue(), + (entry.getKey() + .getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class) + .newInstance(this, modelBpmn, modelJson))); + } catch (InstantiationException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + logger.warn("Unable to instantiate a ModelElement, exception follows: ", e); + } + }); + } + } + + /** + * Get the VF for a model. If return null if there is no VF. + * + * @param model + * @return + */ + public static String getVf(CldsModel model) { + List vfs = null; + try { + ObjectMapper mapper = new ObjectMapper(); + JsonNode modelJson = mapper.readTree(model.getPropText()); + Global global = new Global(modelJson); + vfs = global.getResourceVf(); + } catch (IOException e) { + logger.warn("no VF found", e); + } + String vf = null; + if (vfs != null && !vfs.isEmpty()) { + vf = vfs.get(0); + } + return vf; + } + + /** + * Create ModelProperties extracted from a CamelExchange. + * + * @param camelExchange + * The camel Exchange object that contains all info provided to + * the flow + * @return A model Properties created from the parameters found in + * camelExchange object + */ + public static ModelProperties create(Exchange camelExchange) { + String modelProp = (String) camelExchange.getProperty("modelProp"); + String modelBpmnProp = (String) camelExchange.getProperty("modelBpmnProp"); + String modelName = (String) camelExchange.getProperty("modelName"); + String controlName = (String) camelExchange.getProperty("controlName"); + String actionCd = (String) camelExchange.getProperty("actionCd"); + boolean isTest = (boolean) camelExchange.getProperty("isTest"); + return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp); + } + + /** + * return appropriate model element given the type + * + * @param type + * @return + */ + public AbstractModelElement getModelElementByType(String type) { + AbstractModelElement modelElement = modelElements.get(type); + if (modelElement == null) { + throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type); + } + return modelElement; + } + + /** + * @return the modelName + */ + public String getModelName() { + return modelName; + } + + /** + * @return the controlName + */ + public String getControlName() { + return controlName; + } + + /** + * @return the controlNameAndPolicyUniqueId + */ + public String getControlNameAndPolicyUniqueId() { + return controlName + "_" + policyUniqueId; + } + + /** + * @return the currentPolicyName + */ + private String getCurrentPolicyName() { + return normalizePolicyScopeName(controlName + "_" + currentModelElementId); + } + + /** + * @return the currentPolicyScopeAndPolicyName + */ + public String getCurrentPolicyScopeAndPolicyName() { + return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName()); + } + + /** + * @return the policyScopeAndNameWithUniqueId + */ + public String getPolicyScopeAndNameWithUniqueId() { + return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName() + "_" + policyUniqueId); + } + + /** + * @return the currentPolicyScopeAndFullPolicyName + */ + public String getCurrentPolicyScopeAndFullPolicyName(String policyNamePrefix) { + return normalizePolicyScopeName(modelName + "." + policyNamePrefix + getCurrentPolicyName()); + } + + /** + * @return the currentPolicyScopeAndFullPolicyNameWithVersion + */ + public String getCurrentPolicyScopeAndFullPolicyNameWithVersion(String policyNamePrefix, int version) { + return normalizePolicyScopeName( + modelName + "." + policyNamePrefix + getCurrentPolicyName() + "." + version + ".xml"); + } + + /** + * Replace all '-' with '_' within policy scope and name. + * + * @param inName + * @return + */ + private String normalizePolicyScopeName(String inName) { + return inName.replaceAll("-", "_"); + } + + /** + * @return the currentModelElementId + */ + public String getCurrentModelElementId() { + return currentModelElementId; + } + + /** + * When generating a policy request for a model element, must set the id of + * that model element using this method. Used to generate the policy name. + * + * @param currentModelElementId + * the currentModelElementId to set + */ + public void setCurrentModelElementId(String currentModelElementId) { + this.currentModelElementId = currentModelElementId; + } + + /** + * @return the policyUniqueId + */ + public String getPolicyUniqueId() { + return policyUniqueId; + } + + /** + * When generating a policy request for a model element, must set the unique + * id of that policy using this method. Used to generate the policy name. + * + * @param policyUniqueId + * the policyUniqueId to set + */ + public void setPolicyUniqueId(String policyUniqueId) { + this.policyUniqueId = policyUniqueId; + } + + /** + * @return the actionCd + */ + public String getActionCd() { + return actionCd; + } + + /** + * @return the testOnly + */ + public boolean isTestOnly() { + return testOnly; + } + + /** + * @return the isCreateRequest + */ + public boolean isCreateRequest() { + switch (actionCd) { + case CldsEvent.ACTION_SUBMIT: + case CldsEvent.ACTION_RESTART: + return true; + } + return false; + } + + public boolean isStopRequest() { + switch (actionCd) { + case CldsEvent.ACTION_STOP: + return true; + } + return false; + } + + /** + * @return the global + */ + public Global getGlobal() { + if (global == null) { + global = new Global(modelJson); + } + return global; + } + + public static final synchronized void registerModelElement(Class modelElementClass, + String type) { + if (!modelElementClasses.containsKey(modelElementClass.getClass())) { + modelElementClasses.put(modelElementClass, type); + } + } + + public T getType(Class clazz) { + instantiateMissingModelElements(); + String type = modelElementClasses.get(clazz); + return (type != null ? (T) modelElements.get(type) : null); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Policy.java b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java new file mode 100644 index 000000000..438936f75 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/Policy.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Parse Policy json properties. + *

+ * Example json: + * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ + * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ + * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ + * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} + * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] + * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] + * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} + * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} + * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" + * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ + * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ + * "vf3RtPi"]}]]}] + */ +public class Policy extends AbstractModelElement { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private List policyChains; + + private static final String TYPE_POLICY = "policy"; + + /** + * Parse Policy given json node. + * + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_POLICY, modelProp, modelBpmn, modelJson); + + // process policies + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + policyChains = new ArrayList<>(); + while (itr.hasNext()) { + policyChains.add(new PolicyChain(itr.next())); + } + } + } + + /** + * @return the policyChains + */ + public List getPolicyChains() { + return policyChains; + } + + public static final String getType() { + return TYPE_POLICY; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java new file mode 100644 index 000000000..dddd73506 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Parse Policy json properties. + * + * Example json: + * {"Policy_1e33tn8":{"PolicyTest1":[{"name":"pname","value":"PolicyTest1"},{ + * "name":"pid","value":"1"},{"name":"timeout","value":"345"},{ + * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": + * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" + * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": + * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": + * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": + * "parentPolicy","value":[""]},{"name": + * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}], + * "PolicyTest2":[{"name":"pname","value": + * "PolicyTest2"},{"name":"pid","value":"2"},{"name":"timeout","value":"345"},{ + * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": + * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" + * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": + * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": + * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": + * "parentPolicy","value":[""]},{"name": + * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]}} f + * + */ +public class PolicyChain { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyChain.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String policyId; + private Integer timeout; + private List policyItems; + private String policyType; + + public PolicyChain(JsonNode node) { + + policyId = AbstractModelElement.getValueByName(node, "pid"); + timeout = AbstractModelElement.getIntValueByName(node, "timeout"); + policyType = AbstractModelElement.getValueByName(node, "policyType"); + + if(node != null && node.size() > 0) { + JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations"); + if(policyNode != null) { + Iterator itr = policyNode.elements(); + policyItems = new ArrayList<>(); + while (itr.hasNext()) { + policyItems.add(new PolicyItem(itr.next())); + } + + } + } + } + /** + * @return the policyId + */ + public String getPolicyId() { + return policyId; + } + + /** + * @return the timeout + */ + public Integer getTimeout() { + return timeout; + } + + /** + * @return the policyItems + */ + public List getPolicyItems() { + return policyItems; + } + + /** + * @return the policyType + */ + public String getPolicyType() { + return policyType; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java new file mode 100644 index 000000000..d1c1906a2 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java @@ -0,0 +1,189 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; + +/** + * Parse policyConfigurations from Policy json properties. + *

+ * Example json: + * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ + * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ + * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ + * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} + * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] + * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] + * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} + * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} + * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" + * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ + * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ + * "vf3RtPi"]},{"name": + * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}] + */ +public class PolicyItem implements Cloneable { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String id; + private String recipe; + private int maxRetries; + private int retryTimeLimit; + private String parentPolicy; + private List parentPolicyConditions; + private String actor; + private String targetResourceId; + + /** + * Parse Policy given json node. + * + * @param node + */ + public PolicyItem(JsonNode node) { + id = AbstractModelElement.getValueByName(node, "_id"); + recipe = AbstractModelElement.getValueByName(node, "recipe"); + maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries"); + retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit"); + parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy"); + parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions"); + targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId"); + + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the recipe + */ + public String getRecipe() { + return recipe; + } + + /** + * @set the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * @set the recipe + */ + public void setRecipe(String recipe) { + this.recipe = recipe; + } + + /** + * @set the parentPolicy + */ + public void setParentPolicy(String parentPolicy) { + this.parentPolicy = parentPolicy; + } + + /** + * @set the maxRetries + */ + public void setMaxRetries(int maxRetries) { + this.maxRetries = maxRetries; + } + + /** + * @set the retryTimeLimit + */ + public void setRetryTimeLimit(int retryTimeLimit) { + this.retryTimeLimit = retryTimeLimit; + } + + /** + * @set the parentPolicyConditions + */ + public void setParentPolicyConditions(List parentPolicyConditions) { + this.parentPolicyConditions = parentPolicyConditions; + } + + /** + * @return the maxRetries + */ + public int getMaxRetries() { + return maxRetries; + } + + /** + * @return the retryTimeLimit + */ + public int getRetryTimeLimit() { + return retryTimeLimit; + } + + /** + * @return the parentPolicy + */ + public String getParentPolicy() { + return parentPolicy; + } + + /** + * @return the parentPolicyConditions + */ + public List getParentPolicyConditions() { + return parentPolicyConditions; + } + + /** + * @return the actor + */ + public String getActor() { + return actor; + } + + /** + * @set the actor + */ + public void setActor(String actor) { + this.actor = actor; + } + + public String getTargetResourceId() { + return targetResourceId; + } + + public void setTargetResourceId(String targetResourceId) { + this.targetResourceId = targetResourceId; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ResourceGroup.java b/src/main/java/org/onap/clamp/clds/model/properties/ResourceGroup.java new file mode 100644 index 000000000..d3280876a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/ResourceGroup.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Parse Resource Group json properties. + * + * Example json: + * {"TCA_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * + */ +public class ResourceGroup { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String groupNumber; + private String policyId; + private List serviceConfigurations; + + /** + * Parse String Match Resource Group given json node. + * + * @param modelBpmn + * @param modelJson + */ + public ResourceGroup(JsonNode node) { + + groupNumber = AbstractModelElement.getValueByName(node, "rgname"); + policyId = AbstractModelElement.getValueByName(node, "policyId"); + + // process Server_Configurations + JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); + Iterator itr = serviceConfigurationsNode.elements(); + serviceConfigurations = new ArrayList<>(); + while (itr.hasNext()) { + serviceConfigurations.add(new ServiceConfiguration(itr.next())); + } + } + + /** + * @return the groupNumber + */ + public String getGroupNumber() { + return groupNumber; + } + + /** + * @return the policyId + */ + public String getPolicyId() { + return policyId; + } + + /** + * @return the serviceConfigurations + */ + public List getServiceConfigurations() { + return serviceConfigurations; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ServiceConfiguration.java b/src/main/java/org/onap/clamp/clds/model/properties/ServiceConfiguration.java new file mode 100644 index 000000000..4b80ac68a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/ServiceConfiguration.java @@ -0,0 +1,181 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse serviceConfigurations from Tca json properties. + *

+ * Example json: + * {"Tca_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * + */ +public class ServiceConfiguration { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ServiceConfiguration.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private final List aaiMatchingFields; + private final List aaiSendFields; + // private final String groupNumber; + private final List resourceVf; + private final List resourceVfc; + private final String timeWindow; + private final String ageLimit; + private final String createClosedLoopEventId; + private final String outputEventName; + private final Map stringSet; + + /** + * Parse serviceConfigurations given json node. + * + * @param node + */ + public ServiceConfiguration(JsonNode node) { + aaiMatchingFields = AbstractModelElement.getValuesByName(node, "aaiMatchingFields"); + aaiSendFields = AbstractModelElement.getValuesByName(node, "aaiSendFields"); + // groupNumber = ModelElement.getValueByName(node, "groupNumber"); + resourceVf = AbstractModelElement.getValuesByName(node, "vf"); + resourceVfc = AbstractModelElement.getValuesByName(node, "vfc"); + timeWindow = AbstractModelElement.getValueByName(node, "timeWindow"); + ageLimit = AbstractModelElement.getValueByName(node, "ageLimit"); + createClosedLoopEventId = AbstractModelElement.getValueByName(node, "createClosedLoopEventId"); + outputEventName = AbstractModelElement.getValueByName(node, "outputEventName"); + + // process the stringSet fields + JsonNode ssNodes = node.findPath("stringSet"); + Iterator itr = ssNodes.elements(); + stringSet = new HashMap<>(); + while (itr.hasNext()) { + JsonNode ssNode = itr.next(); + String key = ssNode.path("name").asText(); + String value = ssNode.path("value").path(0).asText(); + if (key.length() != 0 && value.length() != 0) { + // only add string set field if not null + logger.debug("stringSet: " + key + "=" + value); + stringSet.put(key, value); + } + } + } + + /** + * @return the aaiMatchingFields + */ + public List getaaiMatchingFields() { + return aaiMatchingFields; + } + + /** + * @return the aaiSendFields + */ + public List getaaiSendFields() { + return aaiSendFields; + } + + /** + * @return the groupNumber + */ /* + * public String getGroupNumber() { return groupNumber; } + */ + /** + * @return the resourceVf + */ + public List getResourceVf() { + return resourceVf; + } + + /** + * @return the resourceVfc + */ + public List getResourceVfc() { + return resourceVfc; + } + + /** + * @return the timeWindow + */ + public String getTimeWindow() { + return timeWindow; + } + + /** + * @return the ageLimit + */ + public String getAgeLimit() { + return ageLimit; + } + + /** + * @return the createClosedLoopEventId + */ + public String getCreateClosedLoopEventId() { + return createClosedLoopEventId; + } + + /** + * @return the outputEventName + */ + public String getOutputEventName() { + return outputEventName; + } + + /** + * @return the stringSet + */ + public Map getStringSet() { + return stringSet; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/Tca.java b/src/main/java/org/onap/clamp/clds/model/properties/Tca.java new file mode 100644 index 000000000..90a8a1ab4 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/Tca.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse ONAP Tca json properties. + * + */ +public class Tca extends AbstractModelElement { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private TcaItem tcaItem; + + private static final String TYPE_TCA = "tca"; + + /** + * Parse Tca given json node + * + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_TCA, modelProp, modelBpmn, modelJson); + + // process Server_Configurations + if (modelElementJsonNode != null) { + tcaItem = new TcaItem(modelElementJsonNode.elements().next()); + } + } + + public TcaItem getTcaItem() { + return tcaItem; + } + + public static final String getType() { + return TYPE_TCA; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java new file mode 100644 index 000000000..299143c72 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Parse ONAP Tca Item json properties. + * + */ +public class TcaItem { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaItem.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String tcaName; + private String tcaUuId; + private String policyId; + private String eventName; + private String controlLoopSchemaType; + private List tcaThresholds; + + /** + * Parse Tca Item given json node + * + * @param node + */ + public TcaItem(JsonNode node) { + + tcaName = AbstractModelElement.getValueByName(node, "tname"); + tcaUuId = AbstractModelElement.getValueByName(node, "tuuid"); + policyId = AbstractModelElement.getValueByName(node, "tcaPolId"); + eventName = AbstractModelElement.getValueByName(node, "eventName"); + controlLoopSchemaType = AbstractModelElement.getValueByName(node, "controlLoopSchemaType"); + // process service Configurations + JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); + Iterator itr = serviceConfigurationsNode.elements(); + tcaThresholds = new ArrayList<>(); + while (itr.hasNext()) { + tcaThresholds.add(new TcaThreshold(itr.next())); + } + } + + public String getControlLoopSchemaType() { + return controlLoopSchemaType; + } + + public void setControlLoopSchemaType(String controlLoopSchemaType) { + this.controlLoopSchemaType = controlLoopSchemaType; + } + + public String getTcaName() { + return tcaName; + } + + public void setTcaName(String tcaName) { + this.tcaName = tcaName; + } + + public String getTcaUuId() { + return tcaUuId; + } + + public void setTcaUuId(String tcaUuId) { + this.tcaUuId = tcaUuId; + } + + public String getPolicyId() { + return policyId; + } + + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + + public List getTcaThresholds() { + return tcaThresholds; + } + + public String getEventName() { + return eventName; + } + + public void setEventName(String eventName) { + this.eventName = eventName; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java b/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java new file mode 100644 index 000000000..6cd13f2ee --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.properties; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse ONAP Tca Threshold json properties. + * + */ +public class TcaThreshold { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaThreshold.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String fieldPath; + private String operator; + private Integer threshold; + private String closedLoopEventStatus; + + /** + * Parse Tca Threshhold given json node + * + * @param node + */ + public TcaThreshold(JsonNode node) { + + if (node.get(0) != null) { + fieldPath = node.get(0).asText(); + } + if (node.get(1) != null) { + operator = node.get(1).asText(); + } + if (node.get(2) != null) { + threshold = Integer.valueOf(node.get(2).asText()); + } + if (node.get(3) != null) { + closedLoopEventStatus = node.get(3).asText(); + } + } + + public String getFieldPath() { + return fieldPath; + } + + public void setFieldPath(String fieldPath) { + this.fieldPath = fieldPath; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public Integer getThreshold() { + return threshold; + } + + public void setThreshold(Integer threshold) { + this.threshold = threshold; + } + + public String getClosedLoopEventStatus() { + return closedLoopEventStatus; + } + + public void setClosedLoopEventStatus(String closedLoopEventStatus) { + this.closedLoopEventStatus = closedLoopEventStatus; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java deleted file mode 100644 index f0cf71c1e..000000000 --- a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.model.refprop; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.IOException; -import java.util.Properties; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; -import org.springframework.core.io.Resource; -import org.springframework.stereotype.Component; - -/** - * Holds reference properties. - */ -@Component -public class RefProp { - - @Autowired - private ApplicationContext appContext; - private Properties prop; - @Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}") - private String cldsReferenceValuesFile; - - @PostConstruct - public void loadConfig() throws IOException { - prop = new Properties(); - Resource resource = appContext.getResource(cldsReferenceValuesFile); - prop.load(resource.getInputStream()); - } - - /** - * get property value - * - * @param key - * @return - */ - public String getStringValue(String key) { - return prop.getProperty(key); - } - - /** - * get property value for a combo key (key1 + "." + key2). If not found just - * use key1. - * - * @param key1 - * @param key2 - * @return - */ - public String getStringValue(String key1, String key2) { - String value = getStringValue(key1 + "." + key2); - if (value == null || value.length() == 0) { - value = getStringValue(key1); - } - return value; - } - - /** - * Return json as objects that can be updated - * - * @param key - * @return - * @throws IOException - */ - public JsonNode getJsonTemplate(String key) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(getStringValue(key), JsonNode.class); - } - - /** - * Return json as objects that can be updated. First try with combo key - * (key1 + "." + key2), otherwise default to just key1. - * - * @param key1 - * @param key2 - * @return - * @throws IOException - */ - public JsonNode getJsonTemplate(String key1, String key2) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(getStringValue(key1, key2), JsonNode.class); - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/sdc/SdcArtifact.java b/src/main/java/org/onap/clamp/clds/model/sdc/SdcArtifact.java new file mode 100644 index 000000000..0f7b391f6 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/sdc/SdcArtifact.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.sdc; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SdcArtifact { + + private String artifactName; + private String artifactType; + private String artifactUrl; + private String artifactDescription; + private String artifactTimeout; + private String artifactChecksum; + private String artifactUuid; + private String artifactVersion; + private String generatedFromUuid; + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactURL() { + return artifactUrl; + } + + public void setArtifactURL(String artifactURL) { + this.artifactUrl = artifactURL; + } + + public String getArtifactDescription() { + return artifactDescription; + } + + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public String getArtifactTimeout() { + return artifactTimeout; + } + + public void setArtifactTimeout(String artifactTimeout) { + this.artifactTimeout = artifactTimeout; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getArtifactUUID() { + return artifactUuid; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUuid = artifactUUID; + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getGeneratedFromUUID() { + return generatedFromUuid; + } + + public void setGeneratedFromUUID(String generatedFromUUID) { + this.generatedFromUuid = generatedFromUUID; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/sdc/SdcResource.java b/src/main/java/org/onap/clamp/clds/model/sdc/SdcResource.java new file mode 100644 index 000000000..9717d7c8e --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/sdc/SdcResource.java @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.sdc; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.math.BigDecimal; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SdcResource implements Comparable { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcResource.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private String resourceInstanceName; + private String resourceName; + private String resourceInvariantUUID; + private String resourceVersion; + private String resoucreType; + private String resourceUuid; + private List artifacts; + + public String getResourceInstanceName() { + return resourceInstanceName; + } + + public void setResourceInstanceName(String resourceInstanceName) { + this.resourceInstanceName = resourceInstanceName; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getResourceInvariantUUID() { + return resourceInvariantUUID; + } + + public void setResourceInvariantUUID(String resourceInvUuid) { + this.resourceInvariantUUID = resourceInvUuid; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public String getResoucreType() { + return resoucreType; + } + + public void setResoucreType(String resoucreType) { + this.resoucreType = resoucreType; + } + + public String getResourceUUID() { + return resourceUuid; + } + + public void setResourceUUID(String resourceUUID) { + this.resourceUuid = resourceUUID; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + + @Override + public int compareTo(SdcResource in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this + // object is less than, equal to, or greater than the specified object. + + // first compare based on name + int rtn = resourceInstanceName.compareToIgnoreCase(in.resourceInstanceName); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(resourceVersion); + BigDecimal inVersion = convertVersion(in.resourceVersion); + rtn = myVersion.compareTo(inVersion); + } + return rtn; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode()); + result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SdcResource other = (SdcResource) obj; + if (resourceInstanceName == null) { + if (other.resourceInstanceName != null) + return false; + } else if (!resourceInstanceName.equals(other.resourceInstanceName)) + return false; + if (resourceVersion == null) { + if (other.resourceVersion != null) + return false; + } else if (!resourceVersion.equals(other.resourceVersion)) + return false; + return true; + } + + /** + * Convert version String into a BigDecimal + * + * @param versionText + * @return + */ + private BigDecimal convertVersion(String versionText) { + BigDecimal rtn = BigDecimal.valueOf(0.0); + try { + rtn = new BigDecimal(versionText); + } catch (NumberFormatException nfe) { + logger.warn("SDC version=" + versionText + " is not decimal for name=" + resourceInstanceName); + } + return rtn; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfo.java b/src/main/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfo.java new file mode 100644 index 000000000..3a60f6dcc --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfo.java @@ -0,0 +1,196 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.sdc; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.math.BigDecimal; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SdcResourceBasicInfo implements Comparable { + + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(SdcResourceBasicInfo.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String subCategory; + private String resourceType; + private String lifecycleState; + private String lastUpdaterUserId; + + @Override + public int compareTo(SdcResourceBasicInfo in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this + // object is less than, equal to, or greater than the specified object. + // first compare based on name + int rtn = name.compareToIgnoreCase(in.name); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(version); + BigDecimal inVersion = convertVersion(in.version); + rtn = myVersion.compareTo(inVersion); + } + return rtn; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SdcResourceBasicInfo other = (SdcResourceBasicInfo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (version == null) { + if (other.version != null) + return false; + } else if (!version.equals(other.version)) + return false; + return true; + } + + /** + * Convert version String into a BigDecimal + * + * @param version + * @return + */ + private BigDecimal convertVersion(String version) { + BigDecimal rtn = BigDecimal.valueOf(0.0); + try { + rtn = new BigDecimal(version); + } catch (NumberFormatException nfe) { + logger.warn("SDC version=" + version + " is not decimal for name=" + name); + } + return rtn; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public EELFLogger getLOGGER() { + return logger; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceDetail.java b/src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceDetail.java new file mode 100644 index 000000000..8113ea546 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceDetail.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.sdc; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class SdcServiceDetail { + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; + private String lastUpdaterFullName; + private List resources; + private List artifacts; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public List getResources() { + return resources; + } + + public void setResources(List resources) { + this.resources = resources; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceInfo.java b/src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceInfo.java new file mode 100644 index 000000000..c829726a3 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/sdc/SdcServiceInfo.java @@ -0,0 +1,184 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model.sdc; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.math.BigDecimal; + +public class SdcServiceInfo implements Comparable { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcServiceInfo.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + /** + * Compare using name and then version. Version is converted to a decimal. + */ + @Override + public int compareTo(SdcServiceInfo in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this + // object is less than, equal to, or greater than the specified object. + // first compare based on name + int rtn = name.compareToIgnoreCase(in.name); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(version); + BigDecimal inVersion = convertVersion(in.version); + rtn = myVersion.compareTo(inVersion); + } + + return rtn; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SdcServiceInfo other = (SdcServiceInfo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (version == null) { + if (other.version != null) + return false; + } else if (!version.equals(other.version)) + return false; + return true; + } + + /** + * Convert version String into a BigDecimal + * + * @param versionText + * @return + */ + private BigDecimal convertVersion(String versionText) { + try { + return new BigDecimal(versionText); + } catch (NumberFormatException nfe) { + logger.warn("SDC version=" + versionText + " is not decimal for name=" + name); + } + return BigDecimal.valueOf(0.0); + } + +} 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 a139de115..14e65627f 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -64,6 +64,7 @@ import org.onap.clamp.clds.camel.CamelProxy; import org.onap.clamp.clds.client.DcaeDispatcherServices; import org.onap.clamp.clds.client.DcaeInventoryServices; import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.exception.CldsConfigException; import org.onap.clamp.clds.exception.SdcCommunicationException; @@ -75,16 +76,15 @@ import org.onap.clamp.clds.model.CldsHealthCheck; import org.onap.clamp.clds.model.CldsInfo; import org.onap.clamp.clds.model.CldsModel; import org.onap.clamp.clds.model.CldsModelProp; -import org.onap.clamp.clds.model.CldsSdcResource; -import org.onap.clamp.clds.model.CldsSdcServiceDetail; -import org.onap.clamp.clds.model.CldsSdcServiceInfo; import org.onap.clamp.clds.model.CldsServiceData; import org.onap.clamp.clds.model.CldsTemplate; import org.onap.clamp.clds.model.DcaeEvent; import org.onap.clamp.clds.model.ValueItem; -import org.onap.clamp.clds.model.prop.AbstractModelElement; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.model.properties.AbstractModelElement; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.sdc.SdcResource; +import org.onap.clamp.clds.model.sdc.SdcServiceDetail; +import org.onap.clamp.clds.model.sdc.SdcServiceInfo; import org.onap.clamp.clds.transform.XslTransformer; import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -142,7 +142,7 @@ public class CldsService extends SecureServiceBase { @Autowired private XslTransformer cldsBpmnTransformer; @Autowired - private RefProp refProp; + private CldsReferenceProperties refProp; @Autowired private SdcCatalogServices sdcCatalogServices; @Autowired @@ -680,14 +680,14 @@ public class CldsService extends SecureServiceBase { return ""; } ObjectMapper objectMapper = new ObjectMapper(); - List rawList = objectMapper.readValue(responseStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); + List rawList = objectMapper.readValue(responseStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, SdcServiceInfo.class)); ObjectNode invariantIdServiceNode = objectMapper.createObjectNode(); ObjectNode serviceNode = objectMapper.createObjectNode(); logger.info("value of cldsserviceiNfolist: {}", rawList); if (rawList != null && !rawList.isEmpty()) { - List cldsSdcServiceInfoList = sdcCatalogServices.removeDuplicateServices(rawList); - for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServiceInfoList) { + List cldsSdcServiceInfoList = sdcCatalogServices.removeDuplicateServices(rawList); + for (SdcServiceInfo currCldsSdcServiceInfo : cldsSdcServiceInfoList) { if (currCldsSdcServiceInfo != null) { invariantIdServiceNode.put(currCldsSdcServiceInfo.getInvariantUUID(), currCldsSdcServiceInfo.getName()); @@ -700,7 +700,7 @@ public class CldsService extends SecureServiceBase { private String createPropertiesObjectByUUID(String globalProps, String cldsResponseStr) throws IOException { ObjectMapper mapper = new ObjectMapper(); - CldsSdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, CldsSdcServiceDetail.class); + SdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, SdcServiceDetail.class); ObjectNode globalPropsJson = null; if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getUuid() != null) { /** @@ -745,18 +745,18 @@ public class CldsService extends SecureServiceBase { } private void createVfObjectNode(ObjectNode vfObjectNode2, ObjectMapper mapper, - List rawCldsSdcResourceList) { + List rawCldsSdcResourceList) { ObjectNode vfNode = mapper.createObjectNode(); vfNode.put("", ""); // To remove repeated resource instance name from // resourceInstanceList - List cldsSdcResourceList = sdcCatalogServices + List cldsSdcResourceList = sdcCatalogServices .removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); /** * Creating vf resource node using cldsSdcResource Object */ if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { - for (CldsSdcResource cldsSdcResource : cldsSdcResourceList) { + for (SdcResource cldsSdcResource : cldsSdcResourceList) { if (cldsSdcResource != null && "VF".equalsIgnoreCase(cldsSdcResource.getResoucreType())) { vfNode.put(cldsSdcResource.getResourceUUID(), cldsSdcResource.getResourceName()); } @@ -792,7 +792,7 @@ public class CldsService extends SecureServiceBase { vfObjectNode2.putPOJO("alarmCondition", alarmStringJsonNode); } - private ObjectNode createByVFCObjectNode(ObjectMapper mapper, List cldsSdcResourceList) { + private ObjectNode createByVFCObjectNode(ObjectMapper mapper, List cldsSdcResourceList) { ObjectNode emptyObjectNode = mapper.createObjectNode(); ObjectNode emptyvfcobjectNode = mapper.createObjectNode(); ObjectNode vfCObjectNode = mapper.createObjectNode(); @@ -800,7 +800,7 @@ public class CldsService extends SecureServiceBase { ObjectNode subVfCObjectNode = mapper.createObjectNode(); subVfCObjectNode.putPOJO("vfc", emptyObjectNode); if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { - for (CldsSdcResource cldsSdcResource : cldsSdcResourceList) { + for (SdcResource cldsSdcResource : cldsSdcResourceList) { if (cldsSdcResource != null && "VF".equalsIgnoreCase(cldsSdcResource.getResoucreType())) { vfCObjectNode.putPOJO(cldsSdcResource.getResourceUUID(), subVfCObjectNode); } diff --git a/src/test/java/org/onap/clamp/clds/AbstractItCase.java b/src/test/java/org/onap/clamp/clds/AbstractItCase.java index 2903248b6..7e2908841 100644 --- a/src/test/java/org/onap/clamp/clds/AbstractItCase.java +++ b/src/test/java/org/onap/clamp/clds/AbstractItCase.java @@ -25,7 +25,7 @@ package org.onap.clamp.clds; import org.junit.BeforeClass; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ActiveProfiles; @@ -33,7 +33,7 @@ import org.springframework.test.context.ActiveProfiles; public abstract class AbstractItCase { @Autowired - protected RefProp refProp; + protected CldsReferenceProperties refProp; @Autowired protected PolicyClient policyClient; diff --git a/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java new file mode 100644 index 000000000..6c94fc16f --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.it; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.IOException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.clamp.clds.AbstractItCase; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Test corg.onap.clamp.ClampDesigner.model.refprop package using RefProp. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +public class CldsReferencePropertiesItCase extends AbstractItCase { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsReferencePropertiesItCase.class); + + /** + * Test getting prop value as a JSON Node / template. + * + * @throws IOException + * when JSON parsing fails + */ + @Test + public void testJsonTemplate() throws IOException { + ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template"); + root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"); + ObjectMapper mapper = new ObjectMapper(); + String jsonText = mapper.writeValueAsString(root); + logger.error("Exception caught IllegalArgumentException as expected"); + // assertEquals(topicsJson, ref.getTopicsToJson()); + } +} diff --git a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java index 6f5c24d5e..c530a059f 100644 --- a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java @@ -31,8 +31,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.HolmesPolicyDelegate; -import org.onap.clamp.clds.model.prop.Holmes; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; diff --git a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java index 9013e0c41..873b01922 100644 --- a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java @@ -38,9 +38,9 @@ import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; -import org.onap.clamp.clds.model.prop.PolicyChain; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.PolicyChain; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.policy.api.AttributeType; import org.onap.policy.controlloop.policy.builder.BuilderException; diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java index 71bd2d521..0e8a21772 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java @@ -37,10 +37,10 @@ import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq; import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; -import org.onap.clamp.clds.model.prop.PolicyChain; -import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.PolicyChain; +import org.onap.clamp.clds.model.properties.Tca; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.policy.api.AttributeType; import org.springframework.boot.test.context.SpringBootTest; diff --git a/src/test/java/org/onap/clamp/clds/it/RefPropItCase.java b/src/test/java/org/onap/clamp/clds/it/RefPropItCase.java deleted file mode 100644 index 8f76b1822..000000000 --- a/src/test/java/org/onap/clamp/clds/it/RefPropItCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.it; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.io.IOException; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.clamp.clds.AbstractItCase; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Test corg.onap.clamp.ClampDesigner.model.refprop package using RefProp. - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class RefPropItCase extends AbstractItCase { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefPropItCase.class); - - /** - * Test getting prop value as a JSON Node / template. - * - * @throws IOException - * when JSON parsing fails - */ - @Test - public void testJsonTemplate() throws IOException { - ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template"); - root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"); - ObjectMapper mapper = new ObjectMapper(); - String jsonText = mapper.writeValueAsString(root); - logger.error("Exception caught IllegalArgumentException as expected"); - // assertEquals(topicsJson, ref.getTopicsToJson()); - } -} diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java index 548212ef8..7f962215b 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java @@ -35,10 +35,10 @@ import org.mockito.Mockito; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices; import org.onap.clamp.clds.model.CldsAlarmCondition; -import org.onap.clamp.clds.model.CldsSdcResource; -import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; -import org.onap.clamp.clds.model.CldsSdcServiceInfo; import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.sdc.SdcResource; +import org.onap.clamp.clds.model.sdc.SdcResourceBasicInfo; +import org.onap.clamp.clds.model.sdc.SdcServiceInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -55,33 +55,33 @@ public class SdcCatalogServicesItCase extends AbstractItCase { @Test public void removeDuplicateServicesTest() { - CldsSdcServiceInfo service1a = new CldsSdcServiceInfo(); + SdcServiceInfo service1a = new SdcServiceInfo(); service1a.setName("service1"); service1a.setVersion("1.0"); service1a.setInvariantUUID("invariantUUID1.0"); - List rawCldsSdcServiceList = new LinkedList<>(); + List rawCldsSdcServiceList = new LinkedList<>(); rawCldsSdcServiceList.add(service1a); rawCldsSdcServiceList.add(service1a); - CldsSdcServiceInfo service1b = new CldsSdcServiceInfo(); + SdcServiceInfo service1b = new SdcServiceInfo(); service1b.setName("service1"); service1b.setVersion("1.1"); service1b.setInvariantUUID("invariantUUID1.1"); rawCldsSdcServiceList.add(service1b); - CldsSdcServiceInfo service1c = new CldsSdcServiceInfo(); + SdcServiceInfo service1c = new SdcServiceInfo(); service1c.setName("service1"); service1c.setVersion("1.2"); service1c.setInvariantUUID("invariantUUID1.2"); rawCldsSdcServiceList.add(service1c); - CldsSdcServiceInfo service2 = new CldsSdcServiceInfo(); + SdcServiceInfo service2 = new SdcServiceInfo(); service2.setName("service2"); service2.setVersion("1.0"); service2.setInvariantUUID("invariantUUID2.0"); rawCldsSdcServiceList.add(service2); SdcCatalogServices catalogServices = new SdcCatalogServices(); - List resultList = catalogServices.removeDuplicateServices(rawCldsSdcServiceList); + List resultList = catalogServices.removeDuplicateServices(rawCldsSdcServiceList); assertTrue(resultList.size() == 2); - CldsSdcServiceInfo res1; - CldsSdcServiceInfo res2; + SdcServiceInfo res1; + SdcServiceInfo res2; if ("service1".equals(resultList.get(0).getName())) { res1 = resultList.get(0); res2 = resultList.get(1); @@ -97,27 +97,27 @@ public class SdcCatalogServicesItCase extends AbstractItCase { @Test public void removeDuplicateSdcResourceInstancesTest() { - List rawCldsSdcResourceList = new LinkedList<>(); - CldsSdcResource sdcResource1a = new CldsSdcResource(); + List rawCldsSdcResourceList = new LinkedList<>(); + SdcResource sdcResource1a = new SdcResource(); sdcResource1a.setResourceInstanceName("resource1"); sdcResource1a.setResourceVersion("1.0"); rawCldsSdcResourceList.add(sdcResource1a); - CldsSdcResource sdcResource1b = new CldsSdcResource(); + SdcResource sdcResource1b = new SdcResource(); sdcResource1b.setResourceInstanceName("resource1"); sdcResource1b.setResourceVersion("1.1"); rawCldsSdcResourceList.add(sdcResource1b); - CldsSdcResource sdcResource1c = new CldsSdcResource(); + SdcResource sdcResource1c = new SdcResource(); sdcResource1c.setResourceInstanceName("resource1"); sdcResource1c.setResourceVersion("1.2"); rawCldsSdcResourceList.add(sdcResource1c); - CldsSdcResource sdcResource2 = new CldsSdcResource(); + SdcResource sdcResource2 = new SdcResource(); sdcResource2.setResourceInstanceName("resource2"); sdcResource2.setResourceVersion("1.0"); rawCldsSdcResourceList.add(sdcResource2); SdcCatalogServices catalogServices = new SdcCatalogServices(); - List resultList = catalogServices.removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); - CldsSdcResource res1; - CldsSdcResource res2; + List resultList = catalogServices.removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); + SdcResource res1; + SdcResource res2; if ("resource1".equals(resultList.get(0).getResourceInstanceName())) { res1 = resultList.get(0); res2 = resultList.get(1); @@ -133,28 +133,28 @@ public class SdcCatalogServicesItCase extends AbstractItCase { @Test public void removeDuplicateSdcResourceBasicInfoTest() { - List rawCldsSdcResourceList = new LinkedList<>(); - CldsSdcResourceBasicInfo sdcResource1a = new CldsSdcResourceBasicInfo(); + List rawCldsSdcResourceList = new LinkedList<>(); + SdcResourceBasicInfo sdcResource1a = new SdcResourceBasicInfo(); sdcResource1a.setName("resource1"); sdcResource1a.setVersion("1.0"); rawCldsSdcResourceList.add(sdcResource1a); - CldsSdcResourceBasicInfo sdcResource1b = new CldsSdcResourceBasicInfo(); + SdcResourceBasicInfo sdcResource1b = new SdcResourceBasicInfo(); sdcResource1b.setName("resource1"); sdcResource1b.setVersion("1.1"); rawCldsSdcResourceList.add(sdcResource1b); - CldsSdcResourceBasicInfo sdcResource1c = new CldsSdcResourceBasicInfo(); + SdcResourceBasicInfo sdcResource1c = new SdcResourceBasicInfo(); sdcResource1c.setName("resource1"); sdcResource1c.setVersion("1.2"); rawCldsSdcResourceList.add(sdcResource1c); - CldsSdcResourceBasicInfo sdcResource2 = new CldsSdcResourceBasicInfo(); + SdcResourceBasicInfo sdcResource2 = new SdcResourceBasicInfo(); sdcResource2.setName("resource2"); sdcResource2.setVersion("1.0"); rawCldsSdcResourceList.add(sdcResource2); SdcCatalogServices catalogServices = new SdcCatalogServices(); - List resultList = catalogServices + List resultList = catalogServices .removeDuplicateSdcResourceBasicInfo(rawCldsSdcResourceList); - CldsSdcResourceBasicInfo res1; - CldsSdcResourceBasicInfo res2; + SdcResourceBasicInfo res1; + SdcResourceBasicInfo res2; if ("resource1".equals(resultList.get(0).getName())) { res1 = resultList.get(0); res2 = resultList.get(1); diff --git a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java index afff9dd7d..2efc52866 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java @@ -36,9 +36,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; -import org.onap.clamp.clds.client.req.sdc.SdcReq; +import org.onap.clamp.clds.client.req.sdc.SdcRequests; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; @@ -50,7 +50,7 @@ import org.springframework.test.context.junit4.SpringRunner; public class SdcReqItCase extends AbstractItCase { @Autowired - private SdcReq sdcReq; + private SdcRequests sdcReq; private String modelBpmnProp; private String modelBpmn; private String modelName; @@ -98,7 +98,7 @@ public class SdcReqItCase extends AbstractItCase { @Test public void getSdcReqUrlsListTest() throws GeneralSecurityException, DecoderException { - List listUrls = sdcReq.getSdcReqUrlsList(modelProperties, refProp.getStringValue("sdc.serviceUrl")); + List listUrls = sdcReq.getSdcReqUrlsList(modelProperties); assertNotNull(listUrls); assertTrue(listUrls.size() == 1); assertTrue(listUrls.get(0).contains( diff --git a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java index 419bfde22..c290a386b 100644 --- a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java @@ -35,7 +35,7 @@ import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java index 138d727c0..d3694aea4 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java @@ -25,6 +25,10 @@ package org.onap.clamp.clds.model.prop; import com.fasterxml.jackson.databind.JsonNode; +import org.onap.clamp.clds.model.properties.AbstractModelElement; +import org.onap.clamp.clds.model.properties.ModelBpmn; +import org.onap.clamp.clds.model.properties.ModelProperties; + /** * A CustomModelElement to test the capability to add new elements on the fly. */ diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java index 46c70e55e..851556a6c 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java @@ -27,6 +27,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; public class CustomModelElementTest { diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java index 7bb11a9ef..a7ab94c57 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java @@ -32,6 +32,10 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.Tca; import org.onap.clamp.clds.util.ResourceFileUtil; /** diff --git a/src/test/resources/http-cache/start_http_cache.sh b/src/test/resources/http-cache/start_http_cache.sh index 591fd5047..f318256aa 100755 --- a/src/test/resources/http-cache/start_http_cache.sh +++ b/src/test/resources/http-cache/start_http_cache.sh @@ -34,4 +34,4 @@ fi echo 'Installing requests packages for Python' pip install requests echo 'Executing the Http proxy in Cache mode only' -python sdc_proxy.py --port 8080 --root /usr/src/http-cache-app/data-cache \ No newline at end of file +python sdc_proxy.py --port 2080 --root /usr/src/http-cache-app/data-cache -- cgit 1.2.3-korg