summaryrefslogtreecommitdiffstats
path: root/runtime/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-09-02 09:57:16 -0400
committerJim Hahn <jrh3@att.com>2021-09-02 11:26:11 -0400
commita84ef3cb2133fde745c50d7a23290505e4f4659a (patch)
tree9edcaf76ba26edbcf5c3be67b1e06518d1a5d344 /runtime/src/main
parent5af35328dd1cab498c1d361126fd123dd859eb07 (diff)
Fix eclipse warnings in clamp
Fixed some of these warnings, just in policy-clamp-runtime: - equals() with wrong argument type in junit - remove unneeded "SuppressWarning" - unused fields - deprecated classes/methods Fixed some sonars, too: - use isEqualByComparingTo() - method complexity: used eclipse to auto-extract methods Fixed checkstyle issues: - indentation level Did not address all deprecation issues (e.g., SSLSocketFactory). Issue-ID: POLICY-3200 Change-Id: Ibd92e5326854002dc0ca2d7b3b777699cafb5e98 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'runtime/src/main')
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java1
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java5
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java163
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java19
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java12
8 files changed, 104 insertions, 110 deletions
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java
index 524733115..387ea8c1f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.util.Date;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
-import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.ExchangeBuilder;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
index 0880e9b74..b1141ea49 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
@@ -91,10 +91,6 @@ public class CamelConfiguration extends RouteBuilder {
@Value("${clamp.config.keyFile:#{null}}")
private String keyFile;
-
- @Autowired
- private ClampProperties clampProperties;
-
private void configureDefaultSslProperties() {
if (trustStore != null) {
System.setProperty("javax.net.ssl.trustStore", Thread.currentThread().getContextClassLoader()
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java
index 71986f6fb..f871df70e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java
@@ -88,9 +88,9 @@ public class SdcControllersConfiguration {
Map<String, SdcSingleControllerConfiguration> result = new HashMap<>();
if (jsonRootNode.get(CONTROLLER_SUBTREE_KEY) != null) {
jsonRootNode.get(CONTROLLER_SUBTREE_KEY).getAsJsonObject().entrySet().forEach(
- entry -> result.put(entry.getKey(),
- new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey(),
- keyFile)));
+ entry -> result.put(entry.getKey(),
+ new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey(),
+ keyFile)));
} else {
throw new SdcParametersException(
CONTROLLER_SUBTREE_KEY + " key not found in the file: " + sdcControllerFile);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
index 2d193355e..4a4155446 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
@@ -29,10 +29,8 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import org.onap.policy.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess;
import org.onap.policy.clamp.loop.service.Service;
-import org.onap.policy.clamp.tosca.DictionaryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@@ -44,9 +42,6 @@ public class ToscaMetadataExecutor {
private static final Logger logger =
LoggerFactory.getLogger(ToscaMetadataExecutor.class);
- @Autowired
- private DictionaryService dictionaryService;
-
private Map<String, ToscaMetadataProcess> mapOfProcesses = new HashMap<>();
/**
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
index 1d5ed26e0..9fe199af2 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
@@ -27,7 +27,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashMap;
+import java.util.Map;
import java.util.Map.Entry;
import org.onap.policy.clamp.clds.tosca.update.elements.ToscaElement;
import org.onap.policy.clamp.clds.tosca.update.elements.ToscaElementProperty;
@@ -59,8 +59,8 @@ public class ToscaConverterToJsonSchema {
private static final String TITLE = "title";
private static final String TYPE = "type";
- private LinkedHashMap<String, ToscaElement> components;
- private LinkedHashMap<String, JsonTemplate> templates;
+ private Map<String, ToscaElement> components;
+ private Map<String, JsonTemplate> templates;
private ToscaMetadataParser metadataParser;
@@ -74,8 +74,8 @@ public class ToscaConverterToJsonSchema {
* @param metadataParser The metadata parser to use for metadata section
* @param serviceModel The service model for clamp enrichment
*/
- public ToscaConverterToJsonSchema(LinkedHashMap<String, ToscaElement> toscaElementsMap,
- LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates, ToscaMetadataParser metadataParser,
+ public ToscaConverterToJsonSchema(Map<String, ToscaElement> toscaElementsMap,
+ Map<String, JsonTemplate> jsonSchemaTemplates, ToscaMetadataParser metadataParser,
Service serviceModel) {
this.components = toscaElementsMap;
this.templates = jsonSchemaTemplates;
@@ -204,43 +204,7 @@ public class ToscaConverterToJsonSchema {
for (String propertyField : toscaElementProperty.getItems().keySet()) {
switch (propertyField) {
case TYPE:
- if (currentPropertyJsonTemplate.hasFields(propertyField)) {
- String fieldtype = (String) toscaElementProperty.getItems().get(propertyField);
- switch (fieldtype.toLowerCase()) {
- case LIST:
- propertiesInJson.addProperty(TYPE, ARRAY);
- break;
- case MAP:
- propertiesInJson.addProperty(TYPE, OBJECT);
- break;
- case "scalar-unit.time":
- case "scalar-unit.frequency":
- case "scalar-unit.size":
- propertiesInJson.addProperty(TYPE, "string");
- break;
- case "timestamp":
- propertiesInJson.addProperty(TYPE, "string");
- propertiesInJson.addProperty(FORMAT, "date-time");
- break;
- case "float":
- propertiesInJson.addProperty(TYPE, "number");
- break;
- case "range":
- propertiesInJson.addProperty(TYPE, "integer");
- if (!checkConstraintPresence(toscaElementProperty, "greater_than")
- && currentPropertyJsonTemplate.hasFields("exclusiveMinimum")) {
- propertiesInJson.addProperty("exclusiveMinimum", false);
- }
- if (!checkConstraintPresence(toscaElementProperty, "less_than")
- && currentPropertyJsonTemplate.hasFields("exclusiveMaximum")) {
- propertiesInJson.addProperty("exclusiveMaximum", false);
- }
- break;
- default:
- propertiesInJson.addProperty(TYPE, currentPropertyJsonTemplate.getName());
- break;
- }
- }
+ parseType(toscaElementProperty, propertyField, propertiesInJson, currentPropertyJsonTemplate);
break;
case METADATA:
if (metadataParser != null) {
@@ -254,37 +218,7 @@ public class ToscaConverterToJsonSchema {
currentPropertyJsonTemplate);
break;
case ENTRY_SCHEMA:
- // Here, a way to check if entry is a component (datatype) or a simple string
- if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA)) != null) {
- String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
- var child = new ToscaConverterToJsonSchema(components, templates, metadataParser, serviceModel);
- var propertiesContainer = new JsonObject();
-
- if (((String) toscaElementProperty.getItems().get(TYPE)).equals(MAP)) {
- JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent);
- propertiesContainer.add(nameComponent, componentAsProperty);
- if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
- propertiesInJson.add(PROPERTIES, propertiesContainer);
- }
- } else {
- JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent);
- if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
- propertiesInJson.add("items", componentAsItem);
- propertiesInJson.addProperty(FORMAT, "tabs-top");
- }
- }
- } else if (toscaElementProperty.getItems().get(TYPE).equals(LIST)) {
- // Native cases
- var itemContainer = new JsonObject();
- String valueInEntrySchema =
- this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
- itemContainer.addProperty(TYPE, valueInEntrySchema);
- propertiesInJson.add("items", itemContainer);
- propertiesInJson.addProperty(FORMAT, "tabs-top");
- }
-
- // MAP Case, for now nothing
-
+ parseEntrySchema(toscaElementProperty, propertiesInJson, currentPropertyJsonTemplate);
break;
default:
// Each classical field : type, description, default..
@@ -298,6 +232,81 @@ public class ToscaConverterToJsonSchema {
return propertiesInJson;
}
+ private void parseType(ToscaElementProperty toscaElementProperty, String propertyField, JsonObject propertiesInJson,
+ JsonTemplate currentPropertyJsonTemplate) {
+ if (currentPropertyJsonTemplate.hasFields(propertyField)) {
+ String fieldtype = (String) toscaElementProperty.getItems().get(propertyField);
+ switch (fieldtype.toLowerCase()) {
+ case LIST:
+ propertiesInJson.addProperty(TYPE, ARRAY);
+ break;
+ case MAP:
+ propertiesInJson.addProperty(TYPE, OBJECT);
+ break;
+ case "scalar-unit.time":
+ case "scalar-unit.frequency":
+ case "scalar-unit.size":
+ propertiesInJson.addProperty(TYPE, "string");
+ break;
+ case "timestamp":
+ propertiesInJson.addProperty(TYPE, "string");
+ propertiesInJson.addProperty(FORMAT, "date-time");
+ break;
+ case "float":
+ propertiesInJson.addProperty(TYPE, "number");
+ break;
+ case "range":
+ propertiesInJson.addProperty(TYPE, "integer");
+ if (!checkConstraintPresence(toscaElementProperty, "greater_than")
+ && currentPropertyJsonTemplate.hasFields("exclusiveMinimum")) {
+ propertiesInJson.addProperty("exclusiveMinimum", false);
+ }
+ if (!checkConstraintPresence(toscaElementProperty, "less_than")
+ && currentPropertyJsonTemplate.hasFields("exclusiveMaximum")) {
+ propertiesInJson.addProperty("exclusiveMaximum", false);
+ }
+ break;
+ default:
+ propertiesInJson.addProperty(TYPE, currentPropertyJsonTemplate.getName());
+ break;
+ }
+ }
+ }
+
+ private void parseEntrySchema(ToscaElementProperty toscaElementProperty, JsonObject propertiesInJson,
+ JsonTemplate currentPropertyJsonTemplate) {
+ // Here, a way to check if entry is a component (datatype) or a simple string
+ if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA)) != null) {
+ String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
+ var child = new ToscaConverterToJsonSchema(components, templates, metadataParser, serviceModel);
+ var propertiesContainer = new JsonObject();
+
+ if (((String) toscaElementProperty.getItems().get(TYPE)).equals(MAP)) {
+ JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent);
+ propertiesContainer.add(nameComponent, componentAsProperty);
+ if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
+ propertiesInJson.add(PROPERTIES, propertiesContainer);
+ }
+ } else {
+ JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent);
+ if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
+ propertiesInJson.add("items", componentAsItem);
+ propertiesInJson.addProperty(FORMAT, "tabs-top");
+ }
+ }
+ } else if (toscaElementProperty.getItems().get(TYPE).equals(LIST)) {
+ // Native cases
+ var itemContainer = new JsonObject();
+ String valueInEntrySchema =
+ this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
+ itemContainer.addProperty(TYPE, valueInEntrySchema);
+ propertiesInJson.add("items", itemContainer);
+ propertiesInJson.addProperty(FORMAT, "tabs-top");
+ }
+
+ // MAP Case, for now nothing
+ }
+
/**
* Look for a matching Component for the name parameter, in the components list.
*
@@ -326,8 +335,8 @@ public class ToscaConverterToJsonSchema {
*/
@SuppressWarnings("unchecked")
public String extractSpecificFieldFromMap(ToscaElementProperty toscaElementProperty, String fieldName) {
- LinkedHashMap<String, String> entrySchemaFields =
- (LinkedHashMap<String, String>) toscaElementProperty.getItems().get(fieldName);
+ Map<String, String> entrySchemaFields =
+ (Map<String, String>) toscaElementProperty.getItems().get(fieldName);
return entrySchemaFields.get(TYPE);
}
@@ -344,8 +353,8 @@ public class ToscaConverterToJsonSchema {
@SuppressWarnings("unchecked")
ArrayList<Object> constraints = (ArrayList<Object>) toscaElementProperty.getItems().get(CONSTRAINTS);
for (Object constraint : constraints) {
- if (constraint instanceof LinkedHashMap
- && ((LinkedHashMap<?, ?>) constraint).containsKey(nameConstraint)) {
+ if (constraint instanceof Map
+ && ((Map<?, ?>) constraint).containsKey(nameConstraint)) {
presentConstraint = true;
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
index af7f8cc54..f9b274e26 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -38,8 +38,8 @@ import org.onap.policy.clamp.clds.util.JsonUtils;
import org.onap.policy.clamp.loop.service.Service;
public class JsonTemplateManager {
- private LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates;
- private LinkedHashMap<String, ToscaElement> toscaElements;
+ private Map<String, JsonTemplate> jsonSchemaTemplates;
+ private Map<String, ToscaElement> toscaElements;
/**
* Constructor.
@@ -58,19 +58,19 @@ public class JsonTemplateManager {
}
// GETTERS & SETTERS
- public LinkedHashMap<String, ToscaElement> getToscaElements() {
+ public Map<String, ToscaElement> getToscaElements() {
return toscaElements;
}
- public void setToscaElements(LinkedHashMap<String, ToscaElement> toscaElements) {
+ public void setToscaElements(Map<String, ToscaElement> toscaElements) {
this.toscaElements = toscaElements;
}
- public LinkedHashMap<String, JsonTemplate> getJsonSchemaTemplates() {
+ public Map<String, JsonTemplate> getJsonSchemaTemplates() {
return jsonSchemaTemplates;
}
- public void setJsonSchemaTemplates(LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates) {
+ public void setJsonSchemaTemplates(Map<String, JsonTemplate> jsonSchemaTemplates) {
this.jsonSchemaTemplates = jsonSchemaTemplates;
}
@@ -157,10 +157,9 @@ public class JsonTemplateManager {
* @param jsonTemplates The template properties as String
* @return a map
*/
- @SuppressWarnings("unused")
- private LinkedHashMap<String, JsonTemplate> initializeTemplates(String jsonTemplates) {
+ private Map<String, JsonTemplate> initializeTemplates(String jsonTemplates) {
- LinkedHashMap<String, JsonTemplate> generatedTemplates = new LinkedHashMap<>();
+ Map<String, JsonTemplate> generatedTemplates = new LinkedHashMap<>();
JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class);
for (Map.Entry<String, JsonElement> templateAsJson : templates.entrySet()) {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
index aefe4556d..1542d9736 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
@@ -43,7 +43,6 @@ import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.loop.template.LoopElementModel;
import org.onap.policy.clamp.loop.template.LoopTemplate;
import org.onap.policy.clamp.loop.template.LoopTemplatesRepository;
-import org.onap.policy.clamp.loop.template.PolicyModelsRepository;
import org.onap.policy.clamp.policy.PolicyEngineServices;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,9 +62,6 @@ public class CsarInstaller {
private static final Logger logger = LoggerFactory.getLogger(CsarInstaller.class);
@Autowired
- private PolicyModelsRepository policyModelsRepository;
-
- @Autowired
private LoopTemplatesRepository loopTemplatesRepository;
@Autowired
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java
index bbf33d54c..a161860ad 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java
@@ -119,12 +119,12 @@ public class PdpGroupPayload {
this.deploymentGroups.getGroups().stream().filter(group ->
group.getName().equals(pdpGroup)).findFirst()
.ifPresentOrElse(group -> group.getDeploymentSubgroups().add(newSubGroup),
- () -> {
- var newGroup = new DeploymentGroup();
- newGroup.setName(pdpGroup);
- newGroup.setDeploymentSubgroups(new ArrayList<>(Arrays.asList(newSubGroup)));
- this.deploymentGroups.getGroups().add(newGroup);
- });
+ () -> {
+ var newGroup = new DeploymentGroup();
+ newGroup.setName(pdpGroup);
+ newGroup.setDeploymentSubgroups(new ArrayList<>(Arrays.asList(newSubGroup)));
+ this.deploymentGroups.getGroups().add(newGroup);
+ });
}
/**