summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2021-08-24 13:54:50 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-24 13:54:50 +0000
commita17911491046be6af13d8330f0282065dbcc570e (patch)
tree3077bf87199fd1754089a7a9e13b0a8fdeb232cf
parent0dfe7276a5a9448d1ab4ecd81b45ad7269eab1f0 (diff)
parent770410bd0e5a21576c2a31ee733d9b7d2dec4c7e (diff)
Merge "clamp sonar fix on runtime dir"
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java14
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/Application.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java38
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java16
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java10
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java34
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java5
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java11
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java12
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java26
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java31
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java46
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java20
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java13
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java1
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java11
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java19
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java28
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java60
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java7
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java8
55 files changed, 328 insertions, 302 deletions
diff --git a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java
index 5fefc6d79..62614e729 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java
@@ -89,8 +89,8 @@ public class AuthorizationController {
*/
public void authorize(Exchange camelExchange, String typeVar, String instanceVar,
String action) {
- String type = refProp.getStringValue(PERM_PREFIX + typeVar);
- String instance = refProp.getStringValue(PERM_INSTANCE);
+ var type = refProp.getStringValue(PERM_PREFIX + typeVar);
+ var instance = refProp.getStringValue(PERM_INSTANCE);
if (null == type || type.isEmpty()) {
// authorization is turned off, since the permission is not defined
@@ -100,8 +100,8 @@ public class AuthorizationController {
instance = instanceVar;
}
String principalName = AuthorizationController.getPrincipalName(SecurityContextHolder.getContext());
- SecureServicePermission perm = SecureServicePermission.create(type, instance, action);
- Date startTime = new Date();
+ var perm = SecureServicePermission.create(type, instance, action);
+ var startTime = new Date();
LoggingUtils.setTargetContext("Clamp", "authorize");
LoggingUtils.setTimeContext(startTime, new Date());
logger.debug(LoggerUtils.SECURITY_LOG_MARKER, "checking if {} has permission: {}", principalName, perm);
@@ -148,7 +148,7 @@ public class AuthorizationController {
}
protected boolean hasRole(String role) {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ var authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return false;
}
@@ -168,8 +168,8 @@ public class AuthorizationController {
* @return the clds info
*/
public ClampInformation getClampInformation() {
- ClampInformation clampInfo = new ClampInformation();
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ var clampInfo = new ClampInformation();
+ var authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return new ClampInformation();
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java b/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
index 8b0056c0a..229d664be 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
@@ -71,7 +71,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableJpaAuditing
public class Application extends SpringBootServletInitializer {
- protected static final Logger logger = LoggerFactory.getLogger(Application.class);
+ protected static final Logger appLogger = LoggerFactory.getLogger(Application.class);
// This settings is an additional one to Spring config,
// only if we want to have an additional port automatically redirected to
// HTTPS
@@ -120,7 +120,7 @@ public class Application extends SpringBootServletInitializer {
*/
@Bean
public ServletRegistrationBean<ClampServlet> camelServletRegistrationBean() throws IOException {
- logger.info("{} (v {} ), {}, {}", ResourceFileUtils.getResourceAsString("boot-message.txt"),
+ appLogger.info("{} (v {} ), {}, {}", ResourceFileUtils.getResourceAsString("boot-message.txt"),
ClampVersioning.getCldsVersionFromProps(), System.getProperty("line.separator"),
getSslExpirationDate());
var registration = new ServletRegistrationBean<ClampServlet>(new ClampServlet(), "/restservices/clds/*");
@@ -149,7 +149,7 @@ public class Application extends SpringBootServletInitializer {
private Connector createRedirectConnector(int redirectSecuredPort) {
if (redirectSecuredPort <= 0) {
- logger.warn(
+ appLogger.warn(
"HTTP port redirection to HTTPS is disabled because the HTTPS"
+ " port is 0 (random port) or -1 (Connector disabled)");
return null;
@@ -183,7 +183,7 @@ public class Application extends SpringBootServletInitializer {
result.append("* NONE HAS been configured");
}
} catch (CertificateException | NoSuchAlgorithmException | KeyStoreException e) {
- logger.warn("SSL certificate access error", e);
+ appLogger.warn("SSL certificate access error", e);
}
return result.toString();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java
index 428f02a93..0e520dec1 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java
@@ -73,7 +73,7 @@ public class ClampServlet extends CamelHttpTransportServlet {
private static List<SecureServicePermission> permissionList;
private synchronized List<String> loadDynamicAuthenticationClasses() {
- WebApplicationContext webAppContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
+ var webAppContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
if (webAppContext != null) {
String authClassProperty = webAppContext.getEnvironment().getProperty(AUTHENTICATION_CLASS);
if (!StringUtils.isBlank(authClassProperty)) {
@@ -130,14 +130,14 @@ public class ClampServlet extends CamelHttpTransportServlet {
*/
@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) {
- Principal principal = request.getUserPrincipal();
+ var principal = request.getUserPrincipal();
if (principal != null && loadDynamicAuthenticationClasses().stream()
.anyMatch(className -> className.equals(principal.getClass().getName()))) {
// When AAF is enabled, there is a need to provision the permissions to Spring
// system
List<GrantedAuthority> grantedAuths = new ArrayList<>();
for (SecureServicePermission perm : getPermissionList()) {
- String permString = perm.toString();
+ var permString = perm.toString();
if (request.isUserInRole(permString)) {
grantedAuths.add(new SimpleGrantedAuthority(permString));
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java b/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
index f66a09c41..1f71fc843 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,9 +43,9 @@ public class TomcatEmbeddedServletContainerFactoryRedirection extends TomcatServ
*/
@Override
protected void postProcessContext(Context context) {
- SecurityConstraint securityConstraint = new SecurityConstraint();
+ var securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
- SecurityCollection collection = new SecurityCollection();
+ var collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java
index cc15f0f9e..27f706d77 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
- * Modifications Copyright (C) 2021 AT&T.
+ * Modifications Copyright (C) 2021 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.
@@ -71,8 +71,8 @@ public class CdsServices {
public CdsBpWorkFlowListResponse getBlueprintWorkflowList(String blueprintName, String blueprintVersion) {
LoggingUtils.setTargetContext("CDS", "getBlueprintWorkflowList");
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse =
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse =
producerTemplate.send("direct:get-blueprint-workflow-list", ExchangeBuilder.anExchange(camelContext)
.withProperty("blueprintName", blueprintName)
.withProperty("blueprintVersion", blueprintVersion)
@@ -83,7 +83,7 @@ public class CdsServices {
String cdsResponse = (String) exchangeResponse.getIn().getBody();
logger.info("getBlueprintWorkflowList, response from CDS: {}", cdsResponse);
LoggingUtils.setResponseContext("0", "Get Blueprint workflow list", this.getClass().getName());
- Date startTime = new Date();
+ var startTime = new Date();
LoggingUtils.setTimeContext(startTime, new Date());
return JsonUtils.GSON_JPA_MODEL.fromJson(cdsResponse, CdsBpWorkFlowListResponse.class);
} else {
@@ -107,8 +107,8 @@ public class CdsServices {
String workflow) {
LoggingUtils.setTargetContext("CDS", "getWorkflowInputProperties");
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse = producerTemplate
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse = producerTemplate
.send("direct:get-blueprint-workflow-input-properties", ExchangeBuilder.anExchange(camelContext)
.withBody(getCdsPayloadForWorkFlow(blueprintName, blueprintVersion, workflow))
.withProperty("raiseHttpExceptionFlag", false).build());
@@ -118,7 +118,7 @@ public class CdsServices {
logger.info("getWorkflowInputProperties, response from CDS: {}", cdsResponse);
LoggingUtils
.setResponseContext("0", "Get Blueprint workflow input properties", this.getClass().getName());
- Date startTime = new Date();
+ var startTime = new Date();
LoggingUtils.setTimeContext(startTime, new Date());
return parseCdsResponse(cdsResponse);
} else {
@@ -131,11 +131,11 @@ public class CdsServices {
}
protected JsonObject parseCdsResponse(String response) {
- JsonObject root = JsonParser.parseString(response).getAsJsonObject();
- JsonObject inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");
- JsonObject dataTypes = root.getAsJsonObject("dataTypes");
+ var root = JsonParser.parseString(response).getAsJsonObject();
+ var inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");
+ var dataTypes = root.getAsJsonObject("dataTypes");
- JsonObject workFlowProperties = new JsonObject();
+ var workFlowProperties = new JsonObject();
workFlowProperties.add("inputs", getInputProperties(inputs, dataTypes, new JsonObject()));
return workFlowProperties;
}
@@ -147,8 +147,8 @@ public class CdsServices {
for (Map.Entry<String, JsonElement> entry : inputs.entrySet()) {
String key = entry.getKey();
- JsonObject inputProperty = inputs.getAsJsonObject(key);
- String type = inputProperty.get(TYPE).getAsString();
+ var inputProperty = inputs.getAsJsonObject(key);
+ var type = inputProperty.get(TYPE).getAsString();
if (isComplexType(type, dataTypes)) {
inputObject.add(key, handleComplexType(type, dataTypes));
} else if (LIST.equalsIgnoreCase(type)) {
@@ -168,10 +168,10 @@ public class CdsServices {
throw new CdsParametersException("Entry schema is null for " + propertyName);
}
- String type = inputProperty.get("entry_schema").getAsJsonObject().get(
+ var type = inputProperty.get("entry_schema").getAsJsonObject().get(
TYPE).getAsString();
if (dataTypes != null && dataTypes.get(type) != null) {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty(TYPE, LIST);
jsonObject.add(PROPERTIES, getPropertiesObject(type, dataTypes));
inputObject.add(propertyName, jsonObject);
@@ -181,15 +181,15 @@ public class CdsServices {
}
private JsonObject handleComplexType(String key, JsonObject dataTypes) {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty(TYPE, "object");
jsonObject.add(PROPERTIES, getPropertiesObject(key, dataTypes));
return jsonObject;
}
private JsonObject getPropertiesObject(String key, JsonObject dataTypes) {
- JsonObject properties = dataTypes.get(key).getAsJsonObject().get(PROPERTIES).getAsJsonObject();
- JsonObject object = new JsonObject();
+ var properties = dataTypes.get(key).getAsJsonObject().get(PROPERTIES).getAsJsonObject();
+ var object = new JsonObject();
getInputProperties(properties, dataTypes, object);
return object;
}
@@ -218,7 +218,7 @@ public class CdsServices {
* @return returns payload in json format
*/
public String getCdsPayloadForWorkFlow(String blueprintName, String version, String workflow) {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty("blueprintName", blueprintName);
jsonObject.addProperty("version", version);
jsonObject.addProperty("returnContent", "json");
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 af9c1b57b..524733115 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
@@ -70,7 +70,7 @@ public class DcaeInventoryServices {
}
private int getTotalCountFromDcaeInventoryResponse(String responseStr) throws ParseException {
- JSONParser parser = new JSONParser();
+ var parser = new JSONParser();
Object obj0 = parser.parse(responseStr);
JSONObject jsonObj = (JSONObject) obj0;
Long totalCount = (Long) jsonObj.get("totalCount");
@@ -78,7 +78,7 @@ public class DcaeInventoryServices {
}
private DcaeInventoryResponse getItemsFromDcaeInventoryResponse(String responseStr) throws ParseException {
- JSONParser parser = new JSONParser();
+ var parser = new JSONParser();
Object obj0 = parser.parse(responseStr);
JSONObject jsonObj = (JSONObject) obj0;
JSONArray itemsArray = (JSONArray) jsonObj.get("items");
@@ -100,18 +100,18 @@ public class DcaeInventoryServices {
throws IOException, ParseException, InterruptedException {
LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");
- int retryInterval = 0;
- int retryLimit = 1;
+ var retryInterval = 0;
+ var retryLimit = 1;
if (refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT) != null) {
retryLimit = Integer.valueOf(refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT));
}
if (refProp.getStringValue(DCAE_INVENTORY_RETRY_INTERVAL) != null) {
retryInterval = Integer.valueOf(refProp.getStringValue(DCAE_INVENTORY_RETRY_INTERVAL));
}
- for (int i = 0; i < retryLimit; i++) {
+ for (var i = 0; i < retryLimit; i++) {
logger.info(LoggerUtils.METRIC_LOG_MARKER, "Attempt n° {} to contact DCAE inventory", i);
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse = producerTemplate
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse = producerTemplate
.send("direct:get-dcae-blueprint-inventory", ExchangeBuilder.anExchange(camelContext)
.withProperty("blueprintResourceId", resourceUuid)
.withProperty("blueprintServiceId", serviceUuid)
@@ -127,7 +127,7 @@ public class DcaeInventoryServices {
if (totalCount > 0) {
logger.info("getDcaeInformation, answer from DCAE inventory: {}", dcaeResponse);
LoggingUtils.setResponseContext("0", "Get Dcae Information success", this.getClass().getName());
- Date startTime = new Date();
+ var startTime = new Date();
LoggingUtils.setTimeContext(startTime, new Date());
return getItemsFromDcaeInventoryResponse(dcaeResponse);
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java
index f11e16733..34f0662c7 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,7 +63,7 @@ public class ClampProperties {
* @return The string with the value
*/
public String getStringValue(String key1, String key2) {
- String value = getStringValue(key1 + "." + key2);
+ var value = getStringValue(key1 + "." + key2);
if (value == null || value.length() == 0) {
value = getStringValue(key1);
}
@@ -79,7 +79,7 @@ public class ClampProperties {
* @throws IOException In case of issues with the JSON parser
*/
public String getFileContent(String key) throws IOException {
- String fileReference = getStringValue(key);
+ var fileReference = getStringValue(key);
return (fileReference != null) ? getFileContentFromPath(fileReference) : null;
}
@@ -94,12 +94,12 @@ public class ClampProperties {
* @throws IOException In case of issues with the JSON parser
*/
public String getFileContent(String key1, String key2) throws IOException {
- String fileReference = getStringValue(key1, key2);
+ var fileReference = getStringValue(key1, key2);
return (fileReference != null) ? getFileContentFromPath(fileReference) : null;
}
private String getFileContentFromPath(String filepath) throws IOException {
- URL url = appContext.getResource(filepath).getURL();
+ var url = appContext.getResource(filepath).getURL();
return IOUtils.toString(url, StandardCharsets.UTF_8);
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java
index 27cf0b941..3b0bc68fd 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.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");
@@ -49,40 +49,40 @@ public class DefaultDictionaryElements {
private void preProvisionDefaultActors() {
// Set up dictionary elements
- Dictionary actorDictionary = new Dictionary();
+ var actorDictionary = new Dictionary();
actorDictionary.setName("DefaultActors");
actorDictionary.setSecondLevelDictionary(0);
actorDictionary.setSubDictionaryType("");
- DictionaryElement elementSo = new DictionaryElement();
+ var elementSo = new DictionaryElement();
elementSo.setName("SO");
elementSo.setShortName("SO");
elementSo.setType("string");
elementSo.setDescription("SO component");
actorDictionary.addDictionaryElements(elementSo);
- DictionaryElement elementSdnc = new DictionaryElement();
+ var elementSdnc = new DictionaryElement();
elementSdnc.setName("SDNC");
elementSdnc.setShortName("SDNC");
elementSdnc.setType("string");
elementSdnc.setDescription("SDNC component");
actorDictionary.addDictionaryElements(elementSdnc);
- DictionaryElement elementAppc = new DictionaryElement();
+ var elementAppc = new DictionaryElement();
elementAppc.setName("APPC");
elementAppc.setShortName("APPC");
elementAppc.setType("string");
elementAppc.setDescription("APPC component");
actorDictionary.addDictionaryElements(elementAppc);
- DictionaryElement elementVfc = new DictionaryElement();
+ var elementVfc = new DictionaryElement();
elementVfc.setName("VFC");
elementVfc.setShortName("VFC");
elementVfc.setType("string");
elementVfc.setDescription("VFC component");
actorDictionary.addDictionaryElements(elementVfc);
- DictionaryElement elementSdnr = new DictionaryElement();
+ var elementSdnr = new DictionaryElement();
elementSdnr.setName("SDNR");
elementSdnr.setShortName("SDNR");
elementSdnr.setType("string");
@@ -94,68 +94,68 @@ public class DefaultDictionaryElements {
private void preProvisionDefaultOperations() {
// Set up dictionary elements
- Dictionary operationDictionary = new Dictionary();
+ var operationDictionary = new Dictionary();
operationDictionary.setName("DefaultOperations");
operationDictionary.setSecondLevelDictionary(0);
operationDictionary.setSubDictionaryType("");
- DictionaryElement elementRestart = new DictionaryElement();
+ var elementRestart = new DictionaryElement();
elementRestart.setName("Restart");
elementRestart.setShortName("Restart (APPC operation)");
elementRestart.setType("string");
elementRestart.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementRestart);
- DictionaryElement elementRebuild = new DictionaryElement();
+ var elementRebuild = new DictionaryElement();
elementRebuild.setName("Rebuild");
elementRebuild.setShortName("Rebuild (APPC operation)");
elementRebuild.setType("string");
elementRebuild.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementRebuild);
- DictionaryElement elementMigrate = new DictionaryElement();
+ var elementMigrate = new DictionaryElement();
elementMigrate.setName("Migrate");
elementMigrate.setShortName("Migrate (APPC operation)");
elementMigrate.setType("string");
elementMigrate.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementMigrate);
- DictionaryElement elementHealthCheck = new DictionaryElement();
+ var elementHealthCheck = new DictionaryElement();
elementHealthCheck.setName("Health-Check");
elementHealthCheck.setShortName("Health-Check (APPC operation)");
elementHealthCheck.setType("string");
elementHealthCheck.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementHealthCheck);
- DictionaryElement elementModifyConfig = new DictionaryElement();
+ var elementModifyConfig = new DictionaryElement();
elementModifyConfig.setName("ModifyConfig");
elementModifyConfig.setShortName("ModifyConfig (APPC/VFC operation)");
elementModifyConfig.setType("string");
elementModifyConfig.setDescription("APPC/VFC operation");
operationDictionary.addDictionaryElements(elementModifyConfig);
- DictionaryElement elementVfModuleCreate = new DictionaryElement();
+ var elementVfModuleCreate = new DictionaryElement();
elementVfModuleCreate.setName("VF Module Create");
elementVfModuleCreate.setShortName("VF Module Create (SO operation)");
elementVfModuleCreate.setType("string");
elementVfModuleCreate.setDescription("SO operation");
operationDictionary.addDictionaryElements(elementVfModuleCreate);
- DictionaryElement elementVfModuleDelete = new DictionaryElement();
+ var elementVfModuleDelete = new DictionaryElement();
elementVfModuleDelete.setName("VF Module Delete");
elementVfModuleDelete.setShortName("VF Module Delete (SO operation)");
elementVfModuleDelete.setType("string");
elementVfModuleDelete.setDescription("SO operation");
operationDictionary.addDictionaryElements(elementVfModuleDelete);
- DictionaryElement elementReroute = new DictionaryElement();
+ var elementReroute = new DictionaryElement();
elementReroute.setName("Reroute");
elementReroute.setShortName("Reroute (SDNC operation)");
elementReroute.setType("string");
elementReroute.setDescription("SDNC operation");
operationDictionary.addDictionaryElements(elementReroute);
- DictionaryElement elementBandwidthOnDemand = new DictionaryElement();
+ var elementBandwidthOnDemand = new DictionaryElement();
elementBandwidthOnDemand.setName("BandwidthOnDemand");
elementBandwidthOnDemand.setShortName("BandwidthOnDemand (SDNC operation)");
elementBandwidthOnDemand.setType("string");
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java
index 136ed3c0a..32040bd50 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java
@@ -95,7 +95,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) {
// configure algorithm used for password hashing
- final PasswordEncoder passwordEncoder = getPasswordEncoder();
+ final var passwordEncoder = getPasswordEncoder();
try {
CldsUser[] usersList = loadUsers();
@@ -137,4 +137,5 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
"Invalid clamp.config.security.encoder value. 'bcrypt' is the only option at this time.");
}
}
-} \ No newline at end of file
+}
+
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java
index a72cffd09..7ab1e8348 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java
@@ -51,11 +51,11 @@ public class SslConfig {
@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatCustomizer(ServerProperties serverProperties,
ResourceLoader resourceLoader) {
- return (tomcat) -> tomcat.setSslStoreProvider(new SslStoreProvider() {
+ return tomcat -> tomcat.setSslStoreProvider(new SslStoreProvider() {
@Override
public KeyStore getKeyStore() throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
- KeyStore keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
+ var keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"),
env.getProperty("clamp.config.keyFile"));
keystore.load(ResourceFileUtils.getResourceAsStream(env.getProperty("server.ssl.key-store")),
@@ -66,7 +66,7 @@ public class SslConfig {
@Override
public KeyStore getTrustStore() throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
- KeyStore truststore = KeyStore.getInstance("JKS");
+ var truststore = KeyStore.getInstance("JKS");
String password = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"),
env.getProperty("clamp.config.keyFile"));
truststore.load(
@@ -81,7 +81,7 @@ public class SslConfig {
@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatSslCustomizer(ServerProperties serverProperties,
ResourceLoader resourceLoader) {
- return (tomcat) -> tomcat.setSsl(new Ssl() {
+ return tomcat -> tomcat.setSsl(new Ssl() {
@Override
public String getKeyPassword() {
return PassDecoder.decode(env.getProperty("server.ssl.key-password"),
@@ -94,4 +94,5 @@ public class SslConfig {
}
});
}
-} \ No newline at end of file
+}
+
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 5d8cbb05e..71986f6fb 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
@@ -69,7 +69,7 @@ public class SdcControllersConfiguration {
*/
@PostConstruct
public void loadConfiguration() throws IOException {
- try (InputStreamReader controllerFile = new InputStreamReader(
+ try (var controllerFile = new InputStreamReader(
appContext.getResource(sdcControllerFile).getInputStream(), StandardCharsets.UTF_8)) {
jsonRootNode = JsonUtils.GSON.fromJson(controllerFile, JsonObject.class);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
index 67060d776..5119dc86e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
@@ -108,7 +108,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
private String getStringConfig(String key) {
if (jsonRootNode != null && jsonRootNode.get(key) != null) {
- String config = jsonRootNode.get(key).getAsString();
+ var config = jsonRootNode.get(key).getAsString();
return config.isEmpty() ? null : config;
}
return null;
@@ -138,7 +138,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
@Override
public String getConsumerGroup() {
if (jsonRootNode != null && jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME) != null) {
- String config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString();
+ var config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString();
return "NULL".equals(config) || config.isEmpty() ? null : config;
}
return null;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java
index 72f09ce13..083147211 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,13 +43,13 @@ public class CldsConfiguration {
/**
* This loads the file system.properties.
- *
+ *
* @return The PropertiesFactoryBean
*/
@Bean(name = "mapper")
public PropertiesFactoryBean mapper() {
- PropertiesFactoryBean bean = new PropertiesFactoryBean();
+ var bean = new PropertiesFactoryBean();
bean.setLocation(appContext.getResource(refProp.getStringValue("files.systemProperties")));
return bean;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java
index f2a0d70d8..bee1acf2b 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,10 +63,10 @@ public class SdcControllerConfiguration {
*/
@PostConstruct
public void loadSdcControllers() {
- SdcControllersConfiguration sdcControllersConfig = getSdcControllersConfiguration();
+ var sdcControllersConfig = getSdcControllersConfiguration();
sdcControllersConfig.getAllDefinedControllers().forEach((key, value) -> {
logger.info("Creating controller instance: {}", key);
- SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, value, null);
+ var sdcController = new SdcSingleController(clampProp, csarInstaller, value, null);
sdcControllersList.add(sdcController);
});
}
@@ -107,4 +107,4 @@ public class SdcControllerConfiguration {
public SdcControllersConfiguration getSdcControllersConfiguration() {
return new SdcControllersConfiguration();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java
index 2c3c95885..eb9de056c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -147,7 +147,7 @@ public class ClampCadiFilter extends CadiFilter {
try {
String certHeader = ((HttpServletRequest) request).getHeader("X-SSL-Cert");
if (certHeader != null) {
- CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
+ var certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) certificateFactory
.generateCertificate(new ByteArrayInputStream(
URLDecoder.decode(certHeader, StandardCharsets.UTF_8.toString()).getBytes()));
@@ -173,9 +173,9 @@ public class ClampCadiFilter extends CadiFilter {
}
private String convertSpringToPath(String fileName) {
- try (InputStream ioFile = appContext.getResource(fileName).getInputStream()) {
+ try (var ioFile = appContext.getResource(fileName).getInputStream()) {
if (!fileName.contains("file:")) {
- File targetFile = new File(appContext.getResource(fileName).getFilename());
+ var targetFile = new File(appContext.getResource(fileName).getFilename());
java.nio.file.Files.copy(ioFile, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
return targetFile.getPath();
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java
index a3b42524e..f7945d092 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
+ * Modifications Copyright (c) 2021 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
@@ -38,7 +40,7 @@ public class CdsBpWorkFlowListResponse {
private String version;
@Expose
- private List<String> workflows = new LinkedList<String>();
+ private List<String> workflows = new LinkedList<>();
public String getBlueprintName() {
return blueprintName;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java
index 72ae61359..9f5300a9f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java
@@ -6,6 +6,8 @@
* Copyright (C) 2019 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 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
@@ -95,8 +97,8 @@ public class DcaeInventoryResponse implements Comparable<DcaeInventoryResponse>
@Override
public int compareTo(DcaeInventoryResponse otherResponse) {
- int thisResourceId = Integer.parseInt(this.asdcResourceId);
- int otherResourceId = Integer.parseInt(otherResponse.getAsdcResourceId());
- return (thisResourceId < otherResourceId ? -1 : (thisResourceId > otherResourceId ? 1 : 0));
+ var thisResourceId = Integer.parseInt(this.asdcResourceId);
+ var otherResourceId = Integer.parseInt(otherResponse.getAsdcResourceId());
+ return Integer.compare(thisResourceId, otherResourceId);
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java
index 317929268..a2542d51e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java
@@ -93,7 +93,7 @@ public class SdcSingleController {
*/
@Override
public void activateCallback(INotificationData notificationData) {
- Date startTime = new Date();
+ var startTime = new Date();
logger.info("Receive a callback notification in SDC, nb of resources: {}",
notificationData.getResources().size());
sdcController.treatNotification(notificationData);
@@ -194,7 +194,7 @@ public class SdcSingleController {
logger.info("Attempt to start the SDC Controller: {}", sdcConfig.getSdcControllerName());
result = this.distributionClient.start();
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- logger.error("SDC distribution client start failed with reason:" + result.getDistributionMessageResult());
+ logger.error("SDC distribution client start failed with reason: {}", result.getDistributionMessageResult());
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
throw new SdcControllerException(
"Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
@@ -329,7 +329,7 @@ public class SdcSingleController {
try {
downloadResult = distributionClient.download(artifact);
if (null == downloadResult) {
- logger.info("downloadResult is Null for: " + artifact.getArtifactUUID());
+ logger.info("downloadResult is Null for: {}", artifact.getArtifactUUID());
return null;
}
} catch (RuntimeException e) {
@@ -356,7 +356,7 @@ public class SdcSingleController {
event = event + "(" + errorReason + ")";
}
logger.info(event);
- String action = "";
+ var action = "";
try {
IDistributionStatusMessage message = new DistributionStatusMessage(artifactUrl, consumerId, distributionId,
status, timestamp);
@@ -417,7 +417,9 @@ public class SdcSingleController {
} catch (RuntimeException e) {
logger.warn("Unable to send the SDC Notification ({}) due to an exception", status.name(), e);
}
- logger.info("SDC Notification sent successfully ({})", status.name());
+ if (status.name() != null) {
+ logger.info("SDC Notification sent successfully ({})", status.name());
+ }
}
private void sendDownloadStatus(IDistributionStatusMessage message, String errorReason) {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java
index 970c862d1..d301494d9 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 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
@@ -67,7 +69,7 @@ public class BlueprintParser {
/**
* Get all micro services from blueprint.
- *
+ *
* @param blueprintString the blueprint in a String
* @return A set of MircoService
* @throws BlueprintParserException In case of issues with the parsing
@@ -75,11 +77,11 @@ public class BlueprintParser {
public static Set<BlueprintMicroService> getMicroServices(String blueprintString) throws BlueprintParserException {
Set<BlueprintMicroService> microServices = new HashSet<>();
JsonObject blueprintJson = BlueprintParser.convertToJson(blueprintString);
- JsonObject nodeTemplateList = blueprintJson.get(NODE_TEMPLATES).getAsJsonObject();
- JsonObject inputList = blueprintJson.get(INPUT).getAsJsonObject();
+ var nodeTemplateList = blueprintJson.get(NODE_TEMPLATES).getAsJsonObject();
+ var inputList = blueprintJson.get(INPUT).getAsJsonObject();
for (Entry<String, JsonElement> entry : nodeTemplateList.entrySet()) {
- JsonObject nodeTemplate = entry.getValue().getAsJsonObject();
+ var nodeTemplate = entry.getValue().getAsJsonObject();
if (!nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES_POLICY)
&& nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) {
BlueprintMicroService microService = getNodeRepresentation(entry, nodeTemplateList, inputList);
@@ -99,7 +101,7 @@ public class BlueprintParser {
/**
* Does a fallback to TCA.
- *
+ *
* @return The list of microservices
*/
public static List<BlueprintMicroService> fallbackToOneMicroService() {
@@ -109,9 +111,9 @@ public class BlueprintParser {
static String getName(Entry<String, JsonElement> entry) {
String microServiceYamlName = entry.getKey();
- JsonObject ob = entry.getValue().getAsJsonObject();
+ var ob = entry.getValue().getAsJsonObject();
if (ob.has(PROPERTIES)) {
- JsonObject properties = ob.get(PROPERTIES).getAsJsonObject();
+ var properties = ob.get(PROPERTIES).getAsJsonObject();
if (properties.has(NAME)) {
return properties.get(NAME).getAsString();
}
@@ -120,9 +122,9 @@ public class BlueprintParser {
}
static String getInput(Entry<String, JsonElement> entry) {
- JsonObject ob = entry.getValue().getAsJsonObject();
+ var ob = entry.getValue().getAsJsonObject();
if (ob.has(RELATIONSHIPS)) {
- JsonArray relationships = ob.getAsJsonArray(RELATIONSHIPS);
+ var relationships = ob.getAsJsonArray(RELATIONSHIPS);
for (JsonElement element : relationships) {
String target = getTarget(element.getAsJsonObject());
if (!target.isEmpty()) {
@@ -142,7 +144,7 @@ public class BlueprintParser {
+ elem.getAsJsonObject().get(TARGET).getAsString());
} else {
String property = getPropertyValue(propertyName,
- new AbstractMap.SimpleEntry<String, JsonElement>(
+ new AbstractMap.SimpleEntry<>(
elem.getAsJsonObject().get(TARGET).getAsString(), blueprintNodeTemplateList
.get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()),
blueprintNodeTemplateList, blueprintInputList);
@@ -156,7 +158,7 @@ public class BlueprintParser {
static String getDirectOrInputPropertyValue(String propertyName, JsonObject blueprintInputList,
JsonObject nodeTemplateContent) {
- JsonObject properties = nodeTemplateContent.get(PROPERTIES).getAsJsonObject();
+ var properties = nodeTemplateContent.get(PROPERTIES).getAsJsonObject();
if (properties.has(propertyName)) {
if (properties.get(propertyName).isJsonObject()) {
// it's a blueprint parameter
@@ -173,7 +175,7 @@ public class BlueprintParser {
static String getPropertyValue(String propertyName, Entry<String, JsonElement> nodeTemplateEntry,
JsonObject blueprintNodeTemplateList, JsonObject blueprintIputList) throws BlueprintParserException {
- JsonObject nodeTemplateContent = nodeTemplateEntry.getValue().getAsJsonObject();
+ var nodeTemplateContent = nodeTemplateEntry.getValue().getAsJsonObject();
// Search first in this node template
if (nodeTemplateContent.has(PROPERTIES)) {
String propValue = getDirectOrInputPropertyValue(propertyName, blueprintIputList, nodeTemplateContent);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java
index 10e7a56a4..745d4768d 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 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
@@ -62,7 +64,7 @@ public class ChainGenerator {
}
private boolean postValidate(LinkedList<BlueprintMicroService> microServices) {
- for (int i = 1; i < microServices.size() - 1; i++) {
+ for (var i = 1; i < microServices.size() - 1; i++) {
BlueprintMicroService prev = microServices.get(i - 1);
BlueprintMicroService current = microServices.get(i);
if (!current.getInputFrom().equals(prev.getName())) {
@@ -74,8 +76,8 @@ public class ChainGenerator {
private void insertNodeTemplateIntoChain(BlueprintMicroService microServicetoInsert,
LinkedList<BlueprintMicroService> chainOfMicroServices) {
- int insertIndex = 0;
- for (int i = 0; i < chainOfMicroServices.size(); i++) {
+ var insertIndex = 0;
+ for (var i = 0; i < chainOfMicroServices.size(); i++) {
BlueprintMicroService current = chainOfMicroServices.get(i);
if (microServicetoInsert.getName().equals(current.getInputFrom())) {
insertIndex = i;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java
index 6591be422..89046afd1 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -99,7 +99,7 @@ public class CsarHandler {
/**
* This saves the notification to disk and database.
- *
+ *
* @param resultArtifact The artifact to install
* @throws SdcArtifactInstallerException In case of issues with the installation
* @throws SdcToscaParserException In case of issues with the parsing of
@@ -109,10 +109,10 @@ public class CsarHandler {
throws SdcArtifactInstallerException, SdcToscaParserException {
try {
logger.info("Writing CSAR file to: {} UUID {}", csarFilePath, artifactElement.getArtifactUUID());
- Path path = Paths.get(csarFilePath);
+ var path = Paths.get(csarFilePath);
Files.createDirectories(path.getParent());
// Create or replace the file
- try (OutputStream out = Files.newOutputStream(path)) {
+ try (var out = Files.newOutputStream(path)) {
out.write(resultArtifact.getArtifactPayload(), 0, resultArtifact.getArtifactPayload().length);
}
sdcCsarHelper = factory.getSdcCsarHelper(csarFilePath);
@@ -126,8 +126,8 @@ public class CsarHandler {
private IResourceInstance searchForResourceByInstanceName(String blueprintResourceInstanceName)
throws SdcArtifactInstallerException {
for (IResourceInstance resource : this.sdcNotification.getResources()) {
- String filteredString = resource.getResourceInstanceName().replaceAll("-", "");
- filteredString = filteredString.replaceAll(" ", "");
+ var filteredString = resource.getResourceInstanceName().replace("-", "");
+ filteredString = filteredString.replace(" ", "");
if (filteredString.equalsIgnoreCase(blueprintResourceInstanceName)) {
return resource;
}
@@ -137,17 +137,17 @@ public class CsarHandler {
}
private void loadDcaeBlueprint() throws IOException, SdcArtifactInstallerException {
- try (ZipFile zipFile = new ZipFile(csarFilePath)) {
+ try (var zipFile = new ZipFile(csarFilePath)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory() && entry.getName().contains(BLUEPRINT_TYPE)) {
- BlueprintArtifact blueprintArtifact = new BlueprintArtifact();
+ var blueprintArtifact = new BlueprintArtifact();
blueprintArtifact.setBlueprintArtifactName(
entry.getName().substring(entry.getName().lastIndexOf('/') + 1, entry.getName().length()));
blueprintArtifact
.setBlueprintInvariantServiceUuid(this.getSdcNotification().getServiceInvariantUUID());
- try (InputStream stream = zipFile.getInputStream(entry)) {
+ try (var stream = zipFile.getInputStream(entry)) {
blueprintArtifact.setDcaeBlueprint(IOUtils.toString(stream, StandardCharsets.UTF_8));
}
blueprintArtifact.setResourceAttached(searchForResourceByInstanceName(entry.getName().substring(
@@ -173,7 +173,8 @@ public class CsarHandler {
}
public String setFilePath(String newPath) {
- return csarFilePath = newPath;
+ csarFilePath = newPath;
+ return csarFilePath;
}
public synchronized ISdcCsarHelper getSdcCsarHelper() {
@@ -191,20 +192,20 @@ public class CsarHandler {
/**
* Get the whole policy model Yaml. It combines the content of policies.yaml and
* data.yaml.
- *
+ *
* @return The whole policy model yaml
* @throws IOException The IO Exception
*/
public Optional<String> getPolicyModelYaml() throws IOException {
String result = null;
- try (ZipFile zipFile = new ZipFile(csarFilePath)) {
+ try (var zipFile = new ZipFile(csarFilePath)) {
ZipEntry entry = zipFile.getEntry(POLICY_DEFINITION_NAME_SUFFIX);
if (entry != null) {
ZipEntry data = zipFile.getEntry(DATA_DEFINITION_NAME_SUFFIX);
if (data != null) {
- String dataStr = IOUtils.toString(zipFile.getInputStream(data), StandardCharsets.UTF_8);
- String dataStrWithoutHeader = dataStr.substring(dataStr.indexOf(DATA_DEFINITION_KEY));
- String policyStr = IOUtils.toString(zipFile.getInputStream(entry), StandardCharsets.UTF_8);
+ var dataStr = IOUtils.toString(zipFile.getInputStream(data), StandardCharsets.UTF_8);
+ var dataStrWithoutHeader = dataStr.substring(dataStr.indexOf(DATA_DEFINITION_KEY));
+ var policyStr = IOUtils.toString(zipFile.getInputStream(entry), StandardCharsets.UTF_8);
StringUtils.chomp(policyStr);
result = policyStr.concat(dataStrWithoutHeader);
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java b/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java
index 02481494a..43852f9dc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,9 +52,9 @@ public class CldsHealthcheckService {
* @return CldsHealthCheck class containing healthcheck info
*/
public CldsHealthCheck gethealthcheck() {
- CldsHealthCheck cldsHealthCheck = new CldsHealthCheck();
- Date startTime = new Date();
- LoggingUtils util = new LoggingUtils(logger);
+ var cldsHealthCheck = new CldsHealthCheck();
+ var startTime = new Date();
+ var util = new LoggingUtils(logger);
LoggingUtils.setRequestContext("CldsService: GET healthcheck", "Clamp-Health-Check");
LoggingUtils.setTimeContext(startTime, new Date());
try {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java
index 32f328079..add6ed4bd 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018-2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,11 @@
package org.onap.policy.clamp.clds.tosca;
-public class JsonEditorSchemaConstants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class JsonEditorSchemaConstants {
//Data types in JSON Schema
public static final String TYPE_OBJECT = "object";
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java
index c2b5d5963..d8f7bf837 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,11 @@
package org.onap.policy.clamp.clds.tosca;
-public class ToscaSchemaConstants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ToscaSchemaConstants {
// Data types in TOSCA Schema
public static final String TYPE_LIST = "list";
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java
index fb9d66752..7ff0117d3 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.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");
@@ -46,7 +46,7 @@ public class ArrayField {
*/
public JsonArray deploy() {
- JsonArray subPropertyValuesArray = new JsonArray();
+ var subPropertyValuesArray = new JsonArray();
for (Object arrayElement : complexFields) {
//Cast for each Primitive Type
String typeValue = arrayElement.getClass().getSimpleName();
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 2532295d0..2d193355e 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
@@ -58,10 +58,15 @@ public class ToscaMetadataExecutor {
*/
public void executeTheProcess(String processInfo, JsonObject childObject, Service serviceModel) {
String[] processParameters = (processInfo + "/ ").split("/");
+ /*
+ * NOTE: Disabling sonar, because already added / above, hence there is no need
+ * to invoke method only conditionally, as sonar suggested.
+ */
+ String trimStr = processParameters[1].trim(); // NOSONAR
logger.info("Executing the Tosca clamp process {} with parameters {}",
- processParameters[0], processParameters[1].trim());
+ processParameters[0], trimStr);
mapOfProcesses.get(processParameters[0].trim())
- .executeProcess(processParameters[1].trim(), childObject, serviceModel);
+ .executeProcess(trimStr, childObject, serviceModel);
}
/**
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
index 8ecdc1900..613d98490 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
@@ -51,7 +51,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
switch (parameters) {
case "actor":
- JsonArray jsonArray = new JsonArray();
+ var jsonArray = new JsonArray();
jsonArray.add("CDS");
addToJsonArray(childObject, "enum", jsonArray);
break;
@@ -66,7 +66,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static void generatePayload(JsonObject childObject, Service serviceModel) {
- JsonArray schemaAnyOf = new JsonArray();
+ var schemaAnyOf = new JsonArray();
schemaAnyOf.addAll(createBlankEntry());
schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel));
schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel));
@@ -80,14 +80,14 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static void generateOperationPerResource(JsonObject childObject, String resourceName,
Service serviceModel) {
- JsonArray schemaEnum = new JsonArray();
- JsonArray schemaTitle = new JsonArray();
+ var schemaEnum = new JsonArray();
+ var schemaTitle = new JsonArray();
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
.entrySet()) {
- JsonObject controllerProperties = entry.getValue().getAsJsonObject()
+ var controllerProperties = entry.getValue().getAsJsonObject()
.getAsJsonObject("controllerProperties");
if (controllerProperties != null && controllerProperties.getAsJsonObject("workflows") != null) {
- for (String workflowsEntry : controllerProperties.getAsJsonObject("workflows").keySet()) {
+ for (var workflowsEntry : controllerProperties.getAsJsonObject("workflows").keySet()) {
schemaEnum.add(workflowsEntry);
schemaTitle.add(workflowsEntry + " (CDS operation)");
}
@@ -95,7 +95,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
addToJsonArray(childObject, "enum", schemaEnum);
if (childObject.get("options") == null) {
- JsonObject optionsSection = new JsonObject();
+ var optionsSection = new JsonObject();
childObject.add("options", optionsSection);
}
addToJsonArray(childObject.getAsJsonObject("options"), "enum_titles", schemaTitle);
@@ -104,16 +104,16 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static JsonArray generatePayloadPerResource(String resourceName,
Service serviceModel) {
- JsonArray schemaAnyOf = new JsonArray();
+ var schemaAnyOf = new JsonArray();
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
.entrySet()) {
- JsonObject controllerProperties = entry.getValue().getAsJsonObject()
+ var controllerProperties = entry.getValue().getAsJsonObject()
.getAsJsonObject("controllerProperties");
if (controllerProperties != null && controllerProperties.getAsJsonObject("workflows") != null) {
for (Map.Entry<String, JsonElement> workflowsEntry : controllerProperties.getAsJsonObject("workflows")
.entrySet()) {
- JsonObject obj = new JsonObject();
+ var obj = new JsonObject();
obj.addProperty("title", workflowsEntry.getKey());
obj.add("properties",
createInputPropertiesForPayload(workflowsEntry.getValue().getAsJsonObject(),
@@ -127,8 +127,8 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static JsonArray createBlankEntry() {
- JsonArray result = new JsonArray();
- JsonObject blankObject = new JsonObject();
+ var result = new JsonArray();
+ var blankObject = new JsonObject();
blankObject.addProperty("title", "User defined");
blankObject.add("properties", new JsonObject());
result.add(blankObject);
@@ -138,7 +138,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static JsonObject createAnyOfJsonProperty(String name,
String defaultValue,
boolean readOnlyFlag) {
- JsonObject result = new JsonObject();
+ var result = new JsonObject();
result.addProperty("title", name);
result.addProperty("type", "string");
result.addProperty("default", defaultValue);
@@ -166,10 +166,10 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
public static JsonObject createInputPropertiesForPayload(JsonObject workFlow,
JsonObject controllerProperties,
String workFlowName) {
- String artifactName = controllerProperties.get("sdnc_model_name").getAsString();
- String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
- JsonObject inputs = workFlow.getAsJsonObject("inputs");
- JsonObject jsonObject = new JsonObject();
+ var artifactName = controllerProperties.get("sdnc_model_name").getAsString();
+ var artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
+ var inputs = workFlow.getAsJsonObject("inputs");
+ var jsonObject = new JsonObject();
jsonObject.add("artifact_name", createAnyOfJsonProperty(
"artifact name", artifactName, true));
jsonObject.add("artifact_version", createAnyOfJsonProperty(
@@ -181,11 +181,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static JsonObject createDataProperty(JsonObject inputs, String workFlowName) {
- JsonObject data = new JsonObject();
+ var data = new JsonObject();
data.addProperty("title", "data");
data.addProperty("type", "string");
data.addProperty("format", "textarea");
- JsonObject defaultValue = new JsonObject();
+ var defaultValue = new JsonObject();
addDefaultValueForData(inputs, defaultValue, workFlowName);
data.addProperty("default", defaultValue.toString());
return data;
@@ -197,12 +197,12 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
Set<Map.Entry<String, JsonElement>> entrySet = inputs.entrySet();
for (Map.Entry<String, JsonElement> entry : entrySet) {
String key = entry.getKey();
- JsonObject inputProperty = inputs.getAsJsonObject(key);
+ var inputProperty = inputs.getAsJsonObject(key);
if (key.equalsIgnoreCase(workFlowName + "-properties")) {
addDefaultValueForData(entry.getValue().getAsJsonObject().get("properties")
.getAsJsonObject(), defaultValue, workFlowName);
} else if ("object".equalsIgnoreCase(inputProperty.get(ToscaSchemaConstants.TYPE).getAsString())) {
- JsonObject object = new JsonObject();
+ var object = new JsonObject();
addDefaultValueForData(entry.getValue().getAsJsonObject().get("properties")
.getAsJsonObject(), object, workFlowName);
defaultValue.add(entry.getKey(), object);
@@ -218,11 +218,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static JsonArray handleListType(JsonObject inputs,
String workFlowName) {
- JsonObject object = new JsonObject();
+ var object = new JsonObject();
if (inputs.get("properties") != null) {
addDefaultValueForData(inputs.get("properties").getAsJsonObject(), object, workFlowName);
}
- JsonArray arr = new JsonArray();
+ var arr = new JsonArray();
arr.add(object);
return arr;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java
index d9fd11de2..575965549 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.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");
@@ -98,7 +98,7 @@ public class JsonTemplateField {
return false;
}
- JsonTemplateField jsonTemplateField = (JsonTemplateField) otherField;
+ var jsonTemplateField = (JsonTemplateField) otherField;
if (title != null ? !title.equals(jsonTemplateField.title) : jsonTemplateField.title != null) {
return false;
@@ -122,7 +122,7 @@ public class JsonTemplateField {
return false;
}
- JsonTemplateField jsonTemplateField = (JsonTemplateField) object;
+ var jsonTemplateField = (JsonTemplateField) object;
return title != null ? title.equals(jsonTemplateField.title) : jsonTemplateField.title == null;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java
index 3cfbc394a..03fb2bdde 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -48,8 +48,8 @@ public class ClampVersioning {
* @return Clds version from properties
*/
public static String getCldsVersionFromProps() {
- String cldsVersion = "";
- Properties props = new Properties();
+ var cldsVersion = "";
+ var props = new Properties();
try (InputStream resourceStream = ResourceFileUtils.getResourceAsStream(RESOURCE_NAME)) {
props.load(resourceStream);
cldsVersion = props.getProperty(CLDS_VERSION_PROPERTY);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java
index 78b16f1a0..a436c89f2 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -81,7 +81,7 @@ public final class OnapLogConstants {
* @return detached Marker.
*/
private static Marker build(final String m1, final String m2) {
- final Marker marker = MarkerFactory.getDetachedMarker(m1);
+ final var marker = MarkerFactory.getDetachedMarker(m1);
marker.add(MarkerFactory.getDetachedMarker(m2));
return marker;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java
index 975011669..946edd767 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (C) 2021 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
@@ -115,9 +117,9 @@ public class LoopService {
* @param policyVersion The policy model version
* @return The loop modified
*/
- Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) throws IOException {
- Loop loop = getLoop(loopName);
- PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
+ Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) {
+ var loop = getLoop(loopName);
+ var policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
Set<OperationalPolicy> opPolicySet = loop.getOperationalPolicies();
for (OperationalPolicy opPolicy : opPolicySet) {
if (opPolicy.getPolicyModel().equals(policyModel)) {
@@ -142,8 +144,8 @@ public class LoopService {
* @return The loop modified
*/
Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) {
- Loop loop = getLoop(loopName);
- PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
+ var loop = getLoop(loopName);
+ var policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
if (policyModel == null) {
return null;
}
@@ -158,27 +160,27 @@ public class LoopService {
}
Loop updateAndSaveOperationalPolicies(String loopName, List<OperationalPolicy> newOperationalPolicies) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
Set<OperationalPolicy> newPolicies = operationalPolicyService.updatePolicies(loop, newOperationalPolicies);
loop.setOperationalPolicies(newPolicies);
return loopsRepository.save(loop);
}
Loop updateAndSaveMicroservicePolicies(String loopName, List<MicroServicePolicy> newMicroservicePolicies) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
Set<MicroServicePolicy> newPolicies = microservicePolicyService.updatePolicies(loop, newMicroservicePolicies);
loop.setMicroServicePolicies(newPolicies);
return loopsRepository.save(loop);
}
Loop updateAndSaveGlobalPropertiesJson(String loopName, JsonObject newGlobalPropertiesJson) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
loop.setGlobalPropertiesJson(newGlobalPropertiesJson);
return loopsRepository.save(loop);
}
MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
return microservicePolicyService.getAndUpdateMicroServicePolicy(loop, newMicroservicePolicy);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java
index 432659ab6..d41f5359c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java
@@ -2,9 +2,10 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
- * * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * ================================================================================
+ * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -136,7 +137,7 @@ public class CdsDataInstaller {
private JsonObject createCdsArtifactProperties(String sdncModelName, String sdncModelVersion) {
if (sdncModelName != null && !"null".equals(sdncModelName)
&& sdncModelVersion != null && !"null".equals(sdncModelVersion)) {
- JsonObject controllerProperties = new JsonObject();
+ var controllerProperties = new JsonObject();
controllerProperties.addProperty(SDNC_MODEL_NAME, sdncModelName);
controllerProperties.addProperty(SDNC_MODEL_VERSION, sdncModelVersion);
@@ -146,7 +147,7 @@ public class CdsDataInstaller {
return controllerProperties;
}
- JsonObject workFlowProps = new JsonObject();
+ var workFlowProps = new JsonObject();
for (String workFlow : response.getWorkflows()) {
logger.info("Found CDS workflow {} for model name {} and version {}",
workFlow, sdncModelName, sdncModelVersion);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java b/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java
index 92c795e90..fd7adaacc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.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");
@@ -136,11 +136,4 @@ public class AuditEntity {
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
-
- /**
- * Empty constructor.
- */
- public AuditEntity() {
- }
-
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java
index a57800025..4f83ffa76 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,8 +85,8 @@ public class ExternalComponentState implements Comparable<ExternalComponentState
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((stateName == null) ? 0 : stateName.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java
index 2cd8b241a..dd6526344 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java
@@ -77,7 +77,7 @@ public class PolicyComponent extends ExternalComponent {
* @return The json, payload to send
*/
public static String createPoliciesPayloadPdpGroup(Loop loop, String action) {
- PdpGroupPayload pdpGroupPayload = new PdpGroupPayload();
+ var pdpGroupPayload = new PdpGroupPayload();
loop.getOperationalPolicies().stream().forEach(opPolicy -> pdpGroupPayload
.updatePdpGroupMap(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(), opPolicy.getName(), "1.0.0",
action));
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java b/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java
index 00f7e1f41..4540d2280 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -150,8 +150,8 @@ public class LoopLog implements Serializable, Comparable<LoopLog> {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java
index acbf716b0..53365806b 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java
@@ -2,8 +2,9 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
+ * ================================================================================
* Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -68,7 +69,7 @@ public class CsarServiceInstaller {
JsonObject resourcesProp = createServicePropertiesByType(csar);
resourcesProp.add("VFModule", createVfModuleProperties(csar));
- Service modelService = new Service(serviceDetails, resourcesProp,
+ var modelService = new Service(serviceDetails, resourcesProp,
csar.getSdcNotification().getServiceVersion());
serviceRepository.save(modelService);
@@ -77,10 +78,10 @@ public class CsarServiceInstaller {
}
private JsonObject createServicePropertiesByType(CsarHandler csar) {
- JsonObject resourcesProp = new JsonObject();
+ var resourcesProp = new JsonObject();
// Iterate on all types defined in the tosca lib
for (SdcTypes type : SdcTypes.values()) {
- JsonObject resourcesPropByType = new JsonObject();
+ var resourcesPropByType = new JsonObject();
// For each type, get the metadata of each nodetemplate
for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) {
resourcesPropByType.add(nodeTemplate.getName(),
@@ -92,7 +93,7 @@ public class CsarServiceInstaller {
}
private static JsonObject createVfModuleProperties(CsarHandler csar) {
- JsonObject vfModuleProps = new JsonObject();
+ var vfModuleProps = new JsonObject();
// Loop on all Groups defined in the service (VFModule entries type:
// org.openecomp.groups.VfModule)
for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity(
@@ -120,7 +121,7 @@ public class CsarServiceInstaller {
*/
public boolean isServiceAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException {
boolean alreadyInstalled = true;
- JsonObject serviceDetails = JsonUtils.GSON.fromJson(
+ var serviceDetails = JsonUtils.GSON.fromJson(
JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class);
alreadyInstalled = serviceRepository.existsById(serviceDetails.get("UUID").getAsString());
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java
index ecc174b7f..cc4e4c2fc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@Entity
@Table(name = "services")
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class Service implements Serializable {
/**
@@ -136,8 +136,8 @@ public class Service implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((serviceUuid == null) ? 0 : serviceUuid.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java
index f1ab35722..7477ae31f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights
* reserved.
+ * ================================================================================
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java
index ab7367aaf..abedf1896 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -234,8 +234,7 @@ public class LoopTemplate extends AuditEntity implements Serializable {
* @param listPosition The position in the flow
*/
public void addLoopElementModel(LoopElementModel loopElementModel, Integer listPosition) {
- LoopTemplateLoopElementModel jointEntry =
- new LoopTemplateLoopElementModel(this, loopElementModel, listPosition);
+ var jointEntry = new LoopTemplateLoopElementModel(this, loopElementModel, listPosition);
this.loopElementModelsUsed.add(jointEntry);
loopElementModel.getUsedByLoopTemplates().add(jointEntry);
}
@@ -294,8 +293,8 @@ public class LoopTemplate extends AuditEntity implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@@ -336,6 +335,6 @@ public class LoopTemplate extends AuditEntity implements Serializable {
StringBuilder buffer = new StringBuilder("LOOP_TEMPLATE_").append(serviceName).append("_v")
.append(serviceVersion).append("_").append(resourceName).append("_")
.append(blueprintFileName.replaceAll(".yaml", ""));
- return buffer.toString().replace('.', '_').replaceAll(" ", "");
+ return buffer.toString().replace('.', '_').replace(" ", "");
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java
index c0b0c7d24..80c8e447e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -153,8 +153,8 @@ public class LoopTemplateLoopElementModel implements Serializable, Comparable<Lo
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((loopTemplate == null) ? 0 : loopTemplate.hashCode());
result = prime * result + ((loopElementModel == null) ? 0 : loopElementModel.hashCode());
return result;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java
index 2414377d7..0d57caada 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,7 +49,7 @@ import org.onap.policy.clamp.util.SemanticVersioning;
@Entity
@Table(name = "policy_models")
@IdClass(PolicyModelId.class)
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class PolicyModel extends AuditEntity implements Serializable, Comparable<PolicyModel> {
/**
@@ -232,8 +232,8 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((policyModelType == null) ? 0 : policyModelType.hashCode());
result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java
index 2d31b3b10..ba0429fb1 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java
@@ -80,7 +80,7 @@ public class PolicyModelsService {
* @return A JsonObject with the json schema describing the tosca
*/
public JsonObject getPolicyModelJson(String policyType, String policyTypeVersion) {
- PolicyModel thePolicyModel = getPolicyModel(policyType, policyTypeVersion);
+ var thePolicyModel = getPolicyModel(policyType, policyTypeVersion);
// In the following use case we are not in the context of a closed loop, so the enrichment
// of the json cannot be done, that's why the serviceModel provided is NULL.
return toscaConverterWithDictionarySupport
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
index 6c0da687c..1f2e304bc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
@@ -5,7 +5,7 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
- * Modifications Copyright (C) 2021 AT&T
+ * Modifications Copyright (C) 2021 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.
@@ -242,6 +242,6 @@ public abstract class Policy extends AuditEntity {
StringBuilder buffer = new StringBuilder(policyType).append("_").append(serviceName).append("_v")
.append(serviceVersion).append("_").append(resourceName).append("_")
.append(blueprintFilename.replaceAll(".yaml", ""));
- return buffer.toString().replace('.', '_').replaceAll(" ", "");
+ return buffer.toString().replace('.', '_').replace(" ", "");
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
index 8c1d9b5fd..066d88724 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
@@ -101,8 +101,8 @@ public class PolicyEngineServices {
return policyModelsService.savePolicyModelInNewTransaction(
new PolicyModel(policyType, policyTosca, policyVersion));
} else {
- logger.error("Policy not found in the Policy Engine, returning null: " + policyType
- + "/" + policyVersion);
+ logger.error("Policy not found in the Policy Engine, returning null: {} / {}",
+ policyType, policyVersion);
return null;
}
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java
index 2eb78d240..3e53e1295 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java
@@ -27,6 +27,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.io.UnsupportedEncodingException;
import java.util.Map;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.onap.policy.clamp.clds.util.JsonUtils;
@@ -37,7 +39,8 @@ import org.yaml.snakeyaml.Yaml;
/**
* This class is a utility class to create the policy payload.
*/
-public class PolicyPayload {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PolicyPayload {
private static final Logger logger = LoggerFactory.getLogger(PolicyPayload.class);
@@ -56,28 +59,28 @@ public class PolicyPayload {
public static String createPolicyPayload(String policyModelType, String policyModelVersion, String policyName,
String policyVersion, JsonObject policyProperties, String toscaContent)
throws UnsupportedEncodingException {
- JsonObject policyPayloadResult = new JsonObject();
+ var policyPayloadResult = new JsonObject();
policyPayloadResult.add("tosca_definitions_version",
createJsonFromPolicyTosca(toscaContent).get("tosca_definitions_version"));
- JsonObject topologyTemplateNode = new JsonObject();
+ var topologyTemplateNode = new JsonObject();
policyPayloadResult.add("topology_template", topologyTemplateNode);
- JsonArray policiesArray = new JsonArray();
+ var policiesArray = new JsonArray();
topologyTemplateNode.add("policies", policiesArray);
- JsonObject thisPolicy = new JsonObject();
+ var thisPolicy = new JsonObject();
policiesArray.add(thisPolicy);
- JsonObject policyDetails = new JsonObject();
+ var policyDetails = new JsonObject();
thisPolicy.add(policyName, policyDetails);
policyDetails.addProperty("type", policyModelType);
policyDetails.addProperty("type_version", policyModelVersion);
policyDetails.addProperty("version", policyVersion);
policyDetails.addProperty("name", policyName);
- JsonObject policyMetadata = new JsonObject();
+ var policyMetadata = new JsonObject();
policyDetails.add("metadata", policyMetadata);
policyMetadata.addProperty("policy-id", policyName);
policyMetadata.addProperty("policy-version", policyVersion);
@@ -88,4 +91,4 @@ public class PolicyPayload {
logger.info("Policy payload: {}", policyPayload);
return policyPayload;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java
index be5e7917c..96edfa190 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -48,7 +48,7 @@ import org.onap.policy.clamp.policy.Policy;
@Entity
@Table(name = "micro_service_policies")
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class MicroServicePolicy extends Policy implements Serializable {
/**
* The serial version ID.
@@ -246,8 +246,8 @@ public class MicroServicePolicy extends Policy implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java
index deb425106..c7d67bd4e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java
@@ -2,8 +2,9 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
+ * ================================================================================
* Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,7 +53,7 @@ import org.slf4j.LoggerFactory;
@Entity
@Table(name = "operational_policies")
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class OperationalPolicy extends Policy implements Serializable {
/**
* The serial version ID.
@@ -165,24 +166,21 @@ public class OperationalPolicy extends Policy implements Serializable {
@Override
public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter, Service serviceModel) {
- {
- this.setJsonRepresentation(new JsonObject());
- if (this.getPolicyModel() == null) {
- return;
- }
-
- // Generic Case
- this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
- this.getPolicyModel().getPolicyModelTosca(),
- this.getPolicyModel().getPolicyModelType(), serviceModel));
-
+ this.setJsonRepresentation(new JsonObject());
+ if (this.getPolicyModel() == null) {
+ return;
}
+
+ // Generic Case
+ this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
+ this.getPolicyModel().getPolicyModelTosca(),
+ this.getPolicyModel().getPolicyModelType(), serviceModel));
}
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
index ee8db290d..00713f78e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
@@ -100,14 +100,14 @@ public class OperationalPolicyRepresentationBuilder {
private static JsonObject createSchemaProperty(String title, String type, String defaultValue, String readOnlyFlag,
String[] enumArray) {
- JsonObject property = new JsonObject();
+ var property = new JsonObject();
property.addProperty(TITLE, title);
property.addProperty(TYPE, type);
property.addProperty(DEFAULT, defaultValue);
property.addProperty("readOnly", readOnlyFlag);
if (enumArray != null) {
- JsonArray jsonArray = new JsonArray();
+ var jsonArray = new JsonArray();
property.add("enum", jsonArray);
for (String val : enumArray) {
jsonArray.add(val);
@@ -117,13 +117,13 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createVnfSchema(Service modelService, boolean generateType) {
- JsonArray vnfSchemaArray = new JsonArray();
+ var vnfSchemaArray = new JsonArray();
JsonObject modelVnfs = modelService.getResourceByType("VF");
for (Entry<String, JsonElement> entry : modelVnfs.entrySet()) {
- JsonObject vnfOneOfSchema = new JsonObject();
+ var vnfOneOfSchema = new JsonObject();
vnfOneOfSchema.addProperty(TITLE, "VNF" + "-" + entry.getKey());
- JsonObject properties = new JsonObject();
+ var properties = new JsonObject();
if (generateType) {
properties.add(TYPE, createSchemaProperty("Type", STRING, "VNF", "True", null));
}
@@ -137,8 +137,8 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createBlankEntry() {
- JsonArray result = new JsonArray();
- JsonObject blankObject = new JsonObject();
+ var result = new JsonArray();
+ var blankObject = new JsonObject();
blankObject.addProperty(TITLE, "User defined");
blankObject.add(PROPERTIES, new JsonObject());
result.add(blankObject);
@@ -146,13 +146,13 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createVfModuleSchema(Service modelService, boolean generateType) {
- JsonArray vfModuleOneOfSchemaArray = new JsonArray();
+ var vfModuleOneOfSchemaArray = new JsonArray();
JsonObject modelVfModules = modelService.getResourceByType("VFModule");
for (Entry<String, JsonElement> entry : modelVfModules.entrySet()) {
- JsonObject vfModuleOneOfSchema = new JsonObject();
+ var vfModuleOneOfSchema = new JsonObject();
vfModuleOneOfSchema.addProperty(TITLE, "VFMODULE" + "-" + entry.getKey());
- JsonObject properties = new JsonObject();
+ var properties = new JsonObject();
if (generateType) {
properties.add(TYPE, createSchemaProperty("Type", STRING, "VFMODULE", "True", null));
}
@@ -196,7 +196,7 @@ public class OperationalPolicyRepresentationBuilder {
* @return A JsonArray with everything inside
*/
public static JsonArray createAnyOfArray(Service modelJson, boolean generateType) {
- JsonArray targetOneOfStructure = new JsonArray();
+ var targetOneOfStructure = new JsonArray();
// First entry must be user defined
targetOneOfStructure.addAll(createBlankEntry());
targetOneOfStructure.addAll(createVnfSchema(modelJson, generateType));
@@ -205,22 +205,22 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createAnyOfArrayForCdsRecipe(Service modelJson) {
- JsonArray anyOfStructure = new JsonArray();
+ var anyOfStructure = new JsonArray();
anyOfStructure.addAll(createAnyOfCdsRecipe(modelJson.getResourceDetails().getAsJsonObject("VF")));
anyOfStructure.addAll(createAnyOfCdsRecipe(modelJson.getResourceDetails().getAsJsonObject("PNF")));
return anyOfStructure;
}
private static JsonArray createAnyOfCdsRecipe(JsonObject jsonObject) {
- JsonArray schemaArray = new JsonArray();
+ var schemaArray = new JsonArray();
for (Entry<String, JsonElement> entry : jsonObject.entrySet()) {
- JsonObject controllerProperties = entry.getValue().getAsJsonObject()
+ var controllerProperties = entry.getValue().getAsJsonObject()
.getAsJsonObject("controllerProperties");
if (controllerProperties != null && controllerProperties.getAsJsonObject("workflows") != null) {
- JsonObject workflows = controllerProperties.getAsJsonObject("workflows");
+ var workflows = controllerProperties.getAsJsonObject("workflows");
for (Entry<String, JsonElement> workflowsEntry : workflows.entrySet()) {
- JsonObject obj = new JsonObject();
+ var obj = new JsonObject();
obj.addProperty(TITLE, workflowsEntry.getKey());
obj.addProperty(TYPE, TYPE_OBJECT);
obj.add(PROPERTIES, createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(),
@@ -235,23 +235,23 @@ public class OperationalPolicyRepresentationBuilder {
private static JsonObject createPayloadProperty(JsonObject workFlow,
JsonObject controllerProperties, String workFlowName) {
- JsonObject payload = new JsonObject();
+ var payload = new JsonObject();
payload.addProperty(TITLE, "Payload");
payload.addProperty(TYPE, TYPE_OBJECT);
payload.add(PROPERTIES, createInputPropertiesForPayload(workFlow, controllerProperties,
workFlowName));
- JsonObject properties = new JsonObject();
+ var properties = new JsonObject();
properties.add(RECIPE, createRecipeForCdsWorkflow(workFlowName));
properties.add("payload", payload);
return properties;
}
private static JsonObject createRecipeForCdsWorkflow(String workflow) {
- JsonObject recipe = new JsonObject();
+ var recipe = new JsonObject();
recipe.addProperty(TITLE, RECIPE);
recipe.addProperty(TYPE, STRING);
recipe.addProperty(DEFAULT, workflow);
- JsonObject options = new JsonObject();
+ var options = new JsonObject();
options.addProperty("hidden", true);
recipe.add("options", options);
return recipe;
@@ -269,10 +269,10 @@ public class OperationalPolicyRepresentationBuilder {
public static JsonObject createInputPropertiesForPayload(JsonObject workFlow,
JsonObject controllerProperties,
String workFlowName) {
- String artifactName = controllerProperties.get("sdnc_model_name").getAsString();
- String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
- JsonObject inputs = workFlow.getAsJsonObject("inputs");
- JsonObject jsonObject = new JsonObject();
+ var artifactName = controllerProperties.get("sdnc_model_name").getAsString();
+ var artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
+ var inputs = workFlow.getAsJsonObject("inputs");
+ var jsonObject = new JsonObject();
jsonObject.add("artifact_name", createSchemaProperty(
"artifact name", STRING, artifactName, "True", null));
jsonObject.add("artifact_version", createSchemaProperty(
@@ -284,9 +284,9 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonObject createDataProperty(JsonObject inputs, String workflowName) {
- JsonObject data = new JsonObject();
+ var data = new JsonObject();
data.addProperty(TITLE, "data");
- JsonObject dataObj = new JsonObject();
+ var dataObj = new JsonObject();
addDataFields(inputs, dataObj, workflowName);
data.add(PROPERTIES, dataObj);
return data;
@@ -298,7 +298,7 @@ public class OperationalPolicyRepresentationBuilder {
Set<Map.Entry<String, JsonElement>> entrySet = inputs.entrySet();
for (Map.Entry<String, JsonElement> entry : entrySet) {
String key = entry.getKey();
- JsonObject inputProperty = inputs.getAsJsonObject(key);
+ var inputProperty = inputs.getAsJsonObject(key);
if (key.equalsIgnoreCase(workFlowName + "-properties")) {
addDataFields(entry.getValue().getAsJsonObject().get(PROPERTIES).getAsJsonObject(),
dataObj, workFlowName);
@@ -314,13 +314,13 @@ public class OperationalPolicyRepresentationBuilder {
String type,
String defaultValue,
JsonObject cdsProperty) {
- JsonObject property = new JsonObject();
+ var property = new JsonObject();
property.addProperty(TITLE, title);
if (TYPE_LIST.equalsIgnoreCase(type)) {
property.addProperty(TYPE, TYPE_ARRAY);
if (cdsProperty != null && cdsProperty.get(PROPERTIES) != null) {
- JsonObject listProperties = new JsonObject();
+ var listProperties = new JsonObject();
listProperties.add(PROPERTIES, getProperties(cdsProperty.get(PROPERTIES).getAsJsonObject()));
property.add(ITEMS, listProperties);
}
@@ -341,7 +341,7 @@ public class OperationalPolicyRepresentationBuilder {
if (inputProperties == null) {
return null;
}
- JsonObject dataObject = new JsonObject();
+ var dataObject = new JsonObject();
addDataFields(inputProperties, dataObject, null);
return dataObject;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java
index baedc47b8..63df3a7b0 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (C) 2021 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
@@ -40,15 +42,10 @@ public class OperationalPolicyService implements PolicyService<OperationalPolicy
private final OperationalPolicyRepository operationalPolicyRepository;
- private final PolicyModelsRepository policyModelsRepository;
-
- private static final Logger logger = LoggerFactory.getLogger(OperationalPolicyService.class);
-
@Autowired
public OperationalPolicyService(OperationalPolicyRepository repository,
PolicyModelsRepository policyModelsRepository) {
this.operationalPolicyRepository = repository;
- this.policyModelsRepository = policyModelsRepository;
}
@Override
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 63adf4a32..bbf33d54c 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
@@ -111,7 +111,7 @@ public class PdpGroupPayload {
String policyName,
String policyVersion, String action) {
// create subgroup
- DeploymentSubGroup newSubGroup = new DeploymentSubGroup();
+ var newSubGroup = new DeploymentSubGroup();
newSubGroup.setPdpType(pdpSubGroup);
newSubGroup.setAction(DeploymentSubGroup.Action.valueOf(action));
newSubGroup.setPolicies(Arrays.asList(new ToscaConceptIdentifier(policyName, policyVersion)));
@@ -120,7 +120,7 @@ public class PdpGroupPayload {
group.getName().equals(pdpGroup)).findFirst()
.ifPresentOrElse(group -> group.getDeploymentSubgroups().add(newSubGroup),
() -> {
- DeploymentGroup newGroup = new DeploymentGroup();
+ var newGroup = new DeploymentGroup();
newGroup.setName(pdpGroup);
newGroup.setDeploymentSubgroups(new ArrayList<>(Arrays.asList(newSubGroup)));
this.deploymentGroups.getGroups().add(newGroup);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
index 6775eb0c6..8eca11c66 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
@@ -74,8 +74,8 @@ public class PoliciesPdpMerger {
* @return It returns a JsonObject containing the policies list enriched with PdpGroup info
*/
public static JsonObject mergePoliciesAndPdpGroupStates(String jsonPoliciesList, String pdpGroupsJson) {
- PdpGroups pdpGroups = JsonUtils.GSON.fromJson(pdpGroupsJson, PdpGroups.class);
- JsonObject policiesListJson =
+ var pdpGroups = JsonUtils.GSON.fromJson(pdpGroupsJson, PdpGroups.class);
+ var policiesListJson =
JsonUtils.GSON.fromJson(jsonPoliciesList, JsonObject.class).get("topology_template")
.getAsJsonObject();
StreamSupport.stream(policiesListJson.get("policies").getAsJsonArray().spliterator(), true)
@@ -90,7 +90,7 @@ public class PoliciesPdpMerger {
* @param policyJsonNode The policy json node that must be enriched
*/
private static void enrichOnePolicy(PdpGroups pdpGroups, JsonObject policyJsonNode) {
- PdpGroupsAnalyzer pdpGroupAnalyzer = new PdpGroupsAnalyzer(pdpGroups);
+ var pdpGroupAnalyzer = new PdpGroupsAnalyzer(pdpGroups);
JsonObject deploymentPdpJson = pdpGroupAnalyzer
.getPdpGroupsForPolicy(policyJsonNode.get("name").getAsString(),
policyJsonNode.get("version").getAsString());
@@ -101,4 +101,5 @@ public class PoliciesPdpMerger {
policyJsonNode.get("type_version").getAsString());
mergeJsonElement(policyJsonNode, supportedPdpGroupsJson);
}
-} \ No newline at end of file
+}
+
diff --git a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java
index ecf4b876c..d4d314305 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.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");
@@ -224,8 +224,8 @@ public class DictionaryElement extends AuditEntity implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((shortName == null) ? 0 : shortName.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java
index 849d4baae..ac2651d9c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.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");
@@ -60,7 +60,7 @@ public class DictionaryService {
* @return updated Dictionary object with all dictionary elements
*/
public Dictionary saveOrUpdateDictionaryElement(String dictionaryName, Dictionary dictionary) {
- Dictionary dict = getDictionary(dictionaryName);
+ var dict = getDictionary(dictionaryName);
Set<DictionaryElement> newDictionaryElements = dictionary.getDictionaryElements();
@@ -122,7 +122,7 @@ public class DictionaryService {
DictionaryElement element =
dictionaryElementsRepository.findById(dictionaryElementShortName).orElse(null);
if (element != null) {
- Dictionary dict = getDictionary(dictionaryName);
+ var dict = getDictionary(dictionaryName);
dict.removeDictionaryElement(element);
dictionaryRepository.saveAndFlush(dict);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java b/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java
index 58367193f..c1f4111d5 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.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");
@@ -23,10 +23,14 @@
package org.onap.policy.clamp.util;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* This class is the base class for object that requires semantic versioning.
* ... This class supports also a.b.c.d... etc ... as a version.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SemanticVersioning {
public static final int BEFORE = -1;
public static final int EQUAL = 0;
@@ -57,7 +61,7 @@ public class SemanticVersioning {
int smalestStringLength = Math.min(arg0Array.length, arg1Array.length);
- for (int currentVersionIndex =
+ for (var currentVersionIndex =
0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) {
if (Integer.parseInt(arg0Array[currentVersionIndex]) < Integer
.parseInt(arg1Array[currentVersionIndex])) {