aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java64
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java55
-rw-r--r--src/main/java/org/onap/clamp/clds/client/PolicyClient.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java33
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java97
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java12
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java14
-rw-r--r--src/main/java/org/onap/clamp/clds/dao/CldsDao.java13
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java6
9 files changed, 51 insertions, 245 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java
deleted file mode 100644
index 8abc395d1..000000000
--- a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java
+++ /dev/null
@@ -1,64 +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.client;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.clamp.clds.client.req.DcaeReq;
-import org.onap.clamp.clds.model.prop.ModelProperties;
-import org.onap.clamp.clds.model.refprop.RefProp;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-/**
- * Send control loop model to dcae proxy.
- */
-public class DcaeReqDelegate implements JavaDelegate {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReqDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
- @Autowired
- private RefProp refProp;
-
- @Value("${org.onap.clamp.config.dcae.url:http://localhost:9000/closedloop-dcae-services}")
- private String cldsDcaeUrl;
-
- /**
- * Perform activity. Send to dcae proxy.
- *
- * @param execution
- */
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- ModelProperties prop = ModelProperties.create(execution);
- String dcaeReq = DcaeReq.format(refProp, prop);
- if (dcaeReq != null) {
- execution.setVariable("dcaeReq", dcaeReq.getBytes());
- }
- execution.setVariable("dcaeUrl", cldsDcaeUrl + "/" + prop.getControlName());
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java
deleted file mode 100644
index 29a906787..000000000
--- a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java
+++ /dev/null
@@ -1,55 +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.client;
-
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.camunda.bpm.engine.delegate.JavaDelegate;
-import org.onap.clamp.clds.model.prop.ModelProperties;
-import org.onap.clamp.clds.model.refprop.RefProp;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-/**
- * Send control loop model to dcae proxy.
- */
-public class DcaeReqDeleteDelegate implements JavaDelegate {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReqDeleteDelegate.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
- @Autowired
- private RefProp refProp;
-
- /**
- * Perform activity. Send to dcae proxy.
- *
- * @param execution
- */
- @Override
- public void execute(DelegateExecution execution) throws Exception {
- ModelProperties prop = ModelProperties.create(execution);
- execution.setVariable("dcaeUrl", System.getProperty("CLDS_DCAE_URL") + "/" + prop.getControlName());
- }
-}
diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java
index 2bd680af2..391e39556 100644
--- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java
+++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java
@@ -204,7 +204,6 @@ public class PolicyClient {
* @param prop
* The ModelProperties
* @return The response message of Policy
- * @throws Exception
*/
protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) {
// Verify whether it is triggered by Validation Test button from UI
@@ -336,6 +335,7 @@ public class PolicyClient {
logger.info("Policy versions.size()=" + versions.size());
return versions;
+
}
/**
diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java
index 5b9c5d36d..e3d10c756 100644
--- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java
@@ -779,7 +779,9 @@ public class SdcCatalogServices {
* @return
*/
public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) {
+ Date startTime = new Date();
try {
+ LoggingUtils.setTargetContext("SDC", "getCldsServicesOrResourcesBasedOnURL");
String urlReworked = removeUnwantedBracesFromString(url);
URL urlObj = new URL(urlReworked);
@@ -792,7 +794,7 @@ public class SdcCatalogServices {
conn.setRequestMethod("GET");
int responseCode = conn.getResponseCode();
- logger.info("responseCode=" + responseCode);
+ logger.info("Sdc resource url - " + urlReworked + " , responseCode=" + responseCode);
StringBuilder response;
try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
response = new StringBuilder();
@@ -806,10 +808,16 @@ public class SdcCatalogServices {
}
}
}
+ LoggingUtils.setResponseContext("0", "Get sdc resources success", this.getClass().getName());
return response.toString();
} catch (IOException e) {
+ LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());
+ LoggingUtils.setErrorContext("900", "Get sdc resources error");
logger.error("Exception occurred during query to SDC", e);
return "";
+ } finally {
+ LoggingUtils.setTimeContext(startTime, new Date());
+ metricsLogger.info("getCldsServicesOrResourcesBasedOnURL completed");
}
}
@@ -1069,14 +1077,22 @@ public class SdcCatalogServices {
}
}
+ /**
+ * Method to create vfc and kpi nodes inside vf node
+ *
+ * @param mapper
+ * @param cldsVfDataList
+ * @return
+ */
private ObjectNode createVfcObjectNodeByVfUuid(ObjectMapper mapper, List<CldsVfData> cldsVfDataList) {
ObjectNode vfUuidObjectNode = mapper.createObjectNode();
if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) {
for (CldsVfData currCldsVfData : cldsVfDataList) {
if (currCldsVfData != null) {
- ObjectNode vfcObjectNode = mapper.createObjectNode();
+ ObjectNode vfObjectNode = mapper.createObjectNode();
ObjectNode vfcUuidNode = mapper.createObjectNode();
+ ObjectNode kpiObjectNode = mapper.createObjectNode();
if (currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) {
for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) {
vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(),
@@ -1085,8 +1101,17 @@ public class SdcCatalogServices {
} else {
vfcUuidNode.put("", "");
}
- vfcObjectNode.putPOJO("vfc", vfcUuidNode);
- vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfcObjectNode);
+ if (currCldsVfData.getCldsKPIList() != null && !currCldsVfData.getCldsKPIList().isEmpty()) {
+ for (CldsVfKPIData currCldsVfKPIData : currCldsVfData.getCldsKPIList()) {
+ kpiObjectNode.put(currCldsVfKPIData.getThresholdValue(),
+ currCldsVfKPIData.getThresholdValue());
+ }
+ } else {
+ kpiObjectNode.put("", "");
+ }
+ vfObjectNode.putPOJO("vfc", vfcUuidNode);
+ vfObjectNode.putPOJO("kpi", kpiObjectNode);
+ vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfObjectNode);
}
}
} else {
diff --git a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java
deleted file mode 100644
index a97e9d488..000000000
--- a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java
+++ /dev/null
@@ -1,97 +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.client.req;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.onap.clamp.clds.model.prop.Global;
-import org.onap.clamp.clds.model.prop.ModelProperties;
-import org.onap.clamp.clds.model.prop.StringMatch;
-import org.onap.clamp.clds.model.refprop.RefProp;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Construct a DCAE request given CLDS objects.
- */
-public class DcaeReq {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReq.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
- /**
- * Format DCAE request.
- *
- * @param refProp
- * @param prop
- * @return
- * @throws IOException
- * @throws JsonMappingException
- * @throws JsonParseException
- */
- public static String format(RefProp refProp, ModelProperties prop) throws IOException {
- Global globalProp = prop.getGlobal();
-
- StringMatch smProp = prop.getType(StringMatch.class);
- prop.setCurrentModelElementId(smProp.getId());
-
- ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.template");
-
- // "properties":{
- ObjectNode properties = rootNode.with("properties");
- // "service_name":
- properties.put("service_name", globalProp.getService());
- // "service_ids":[
- List<String> serviceIds = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService());
- JsonUtil.addArrayField(properties, "service_ids", serviceIds);
- // "vnf_ids":[
- JsonUtil.addArrayField(properties, "vnf_ids", globalProp.getResourceVf());
- // "location_ids":[
- JsonUtil.addArrayField(properties, "location_ids", globalProp.getLocation());
-
- // "template":{
- ObjectNode template = rootNode.with("template");
- // "string_matching":{
- ObjectNode stringMatching = template.with("string_matching");
- // "dcae":{
- ObjectNode dcae = stringMatching.with("dcae");
-
- dcae.put("inputTopic", smProp.getTopicSubscribes());
- dcae.put("outputTopic", smProp.getTopicPublishes());
- dcae.put("closedLoopControlName", prop.getControlName());
- dcae.put("policyName", prop.getCurrentPolicyScopeAndPolicyName());
-
- // "serviceConfigurations":[
- StringMatchPolicyReq.appendServiceConfigurations(refProp, globalProp.getService(), dcae, smProp, prop);
-
- String dcaeReq = rootNode.toString();
- logger.info("dcaeReq=" + dcaeReq);
- return dcaeReq;
- }
-
-}
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
index c00deea66..a6baa969e 100644
--- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
@@ -35,8 +35,6 @@ import javax.xml.transform.TransformerConfigurationException;
import org.onap.clamp.clds.client.CldsEventDelegate;
import org.onap.clamp.clds.client.DcaeDispatcherServices;
import org.onap.clamp.clds.client.DcaeInventoryServices;
-import org.onap.clamp.clds.client.DcaeReqDelegate;
-import org.onap.clamp.clds.client.DcaeReqDeleteDelegate;
import org.onap.clamp.clds.client.HolmesPolicyDelegate;
import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate;
import org.onap.clamp.clds.client.OperationalPolicyDelegate;
@@ -115,21 +113,11 @@ public class CldsConfiguration {
return new CldsEventDelegate();
}
- @Bean(name = "dcaeReqDelegate")
- public DcaeReqDelegate getDcaeReqDelegate() {
- return new DcaeReqDelegate();
- }
-
@Bean(name = "sdcSendReqDelegate")
public SdcSendReqDelegate getSdcSendReqDelegate() {
return new SdcSendReqDelegate();
}
- @Bean(name = "dcaeReqDeleteDelegate")
- public DcaeReqDeleteDelegate getDcaeReqDeleteDelegate() {
- return new DcaeReqDeleteDelegate();
- }
-
@Bean(name = "operationalPolicyDelegate")
public OperationalPolicyDelegate getOperationalPolicyDelegate() {
return new OperationalPolicyDelegate();
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java
index 09078f07d..db99dbaf4 100644
--- a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java
+++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java
@@ -87,7 +87,6 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter {
* the application.properties).
*
* @param auth
- * @throws Exception
*/
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) {
@@ -115,11 +114,14 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter {
* CldsUser.
*
* @return The array of CldsUser
- * @throws IOException
- * @throws Exception
*/
- private CldsUser[] loadUsers() throws IOException {
- logger.info("Load from clds-users.properties");
- return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream());
+ private CldsUser[] loadUsers() {
+ try {
+ logger.info("Load from clds-users.properties");
+ return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream());
+ } catch (IOException e) {
+ logger.error("Unable to decode the User Json file", e);
+ throw new CldsUsersException("Load from clds-users.properties", e);
+ }
}
}
diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
index b64978346..6aa5f9127 100644
--- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
+++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java
@@ -46,6 +46,7 @@ import org.onap.clamp.clds.model.CldsModelInstance;
import org.onap.clamp.clds.model.CldsServiceData;
import org.onap.clamp.clds.model.CldsTemplate;
import org.onap.clamp.clds.model.ValueItem;
+import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -463,10 +464,14 @@ public class CldsDao {
public CldsServiceData getCldsServiceCache(String invariantUUID) {
CldsServiceData cldsServiceData = null;
List<CldsServiceData> cldsServiceDataList = new ArrayList<>();
- String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? ";
- cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID },
- new CldsServiceDataMapper());
- logger.info("value of cldsServiceDataList: {}", cldsServiceDataList);
+ try {
+ String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? ";
+ cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID },
+ new CldsServiceDataMapper());
+ logger.info("value of cldsServiceDataList: {}", cldsServiceDataList);
+ } catch (EmptyResultDataAccessException e) {
+ logger.info("cache row not found for invariantUUID: {}", invariantUUID);
+ }
return cldsServiceData;
}
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 0d62be55b..19e3caa39 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -702,13 +702,15 @@ public class CldsService extends SecureServiceBase {
// filter out VFs the user is not authorized for
cldsServiceData.filterVfs(this);
+ // format retrieved data into properties json
+ String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData);
+
// audit log
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName());
auditLogger.info("GET sdc properties by uuid completed");
- // format retrieved data into properties json
- return sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData);
+ return sdcProperties;
}
/**