aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/main/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-27 14:49:41 -0400
committerJim Hahn <jrh3@att.com>2021-08-27 15:48:46 -0400
commit9d8894092ced589c0bdc5b9e85ee1bf1c85d3e36 (patch)
tree88ff5f3891e8780cf8386bb46283dec82c0b3897 /services/services-engine/src/main/java/org
parent18c8028c79d1bdd7bca80fe1e22e2cd9bc072695 (diff)
Address more sonars in apex-pdp
Fixed services-engine thru utilities. Fixed: - use "var" - use Files.delete() - only one method call in assert() Issue-ID: POLICY-3093 Change-Id: I6f62108c770c15e8b84bc51746066fefa409e0fc Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'services/services-engine/src/main/java/org')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java2
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java15
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java6
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java9
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java31
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java12
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java8
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java19
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java12
11 files changed, 59 insertions, 59 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
index 1194a2ce8..9522e30ca 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java
@@ -156,7 +156,7 @@ public class EventRequestorConsumer implements ApexEventConsumer, Runnable {
while (consumerThread.isAlive() && !stopOrderedFlag) {
try {
// Take the next event from the queue
- final Object eventObject =
+ final var eventObject =
incomingEventRequestQueue.poll(EVENT_REQUESTOR_WAIT_SLEEP_TIME, TimeUnit.MILLISECONDS);
if (eventObject == null) {
// Poll timed out, wait again
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java
index 36f3b9423..8cd6156a7 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java
@@ -108,7 +108,7 @@ public class EventRequestorProducer implements ApexEventProducer {
public void sendEvent(final long executionId, final Properties executorProperties, final String eventName,
final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
+ final var synchronousEventCache =
(SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
index a85997315..086d5f75d 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParameters.java
@@ -127,7 +127,7 @@ public class FileCarrierTechnologyParameters extends CarrierTechnologyParameters
String absoluteFileName = null;
// Resolve the file name if it is a relative file name
- File theFile = new File(fileName);
+ var theFile = new File(fileName);
if (theFile.isAbsolute()) {
absoluteFileName = fileName;
} else {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java
index 85ae52702..2c30c456f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/CharacterDelimitedTextBlockReader.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -104,13 +105,13 @@ public class CharacterDelimitedTextBlockReader implements TextBlockReader {
*/
private StringBuilder readTextBlockText() throws IOException {
// Holder for the text block
- final StringBuilder textBlockBuilder = new StringBuilder();
+ final var textBlockBuilder = new StringBuilder();
+
+ var nestingLevel = 0;
- int nestingLevel = 0;
-
// Read the next text block
while (true) {
- final char nextChar = (char) inputStream.read();
+ final var nextChar = (char) inputStream.read();
// Check for EOF
if (nextChar == (char) -1) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
index c2f14a261..b127abfa5 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/HeaderDelimitedTextBlockReader.java
@@ -106,7 +106,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
this.inputStream = incomingInputStream;
// Configure and start the text reading thread
- Thread textConsumputionThread = new ApplicationThreadFactory(this.getClass().getName()).newThread(this);
+ var textConsumputionThread = new ApplicationThreadFactory(this.getClass().getName()).newThread(this);
textConsumputionThread.setDaemon(true);
textConsumputionThread.start();
}
@@ -117,7 +117,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
@Override
public TextBlock readTextBlock() throws IOException {
// Holder for the current text block
- final StringBuilder textBlockBuilder = new StringBuilder();
+ final var textBlockBuilder = new StringBuilder();
// Wait for the timeout period if there is no input
if (!eofOnInputStream && textLineQueue.isEmpty()) {
@@ -169,7 +169,7 @@ public class HeaderDelimitedTextBlockReader implements TextBlockReader, Runnable
*/
@Override
public void run() {
- try (BufferedReader textReader = new BufferedReader(new InputStreamReader(inputStream))) {
+ try (var textReader = new BufferedReader(new InputStreamReader(inputStream))) {
// Read the input line by line until we see end of file on the stream
String line;
while ((line = textReader.readLine()) != null) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java
index fb57a2d7b..bf2c4c210 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/consumer/TextBlockReaderFactory.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. 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
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
@@ -64,7 +65,7 @@ public class TextBlockReaderFactory {
(EventProtocolTextTokenDelimitedParameters) eventProtocolParameters;
// Create the text block reader
- final HeaderDelimitedTextBlockReader headerDelimitedTextBlockReader =
+ final var headerDelimitedTextBlockReader =
new HeaderDelimitedTextBlockReader(tokenDelimitedParameters);
headerDelimitedTextBlockReader.init(inputStream);
return headerDelimitedTextBlockReader;
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
index b686d3e2a..f69eae664 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * 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.
@@ -21,9 +22,7 @@
package org.onap.policy.apex.service.engine.runtime.impl;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -41,7 +40,6 @@ import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.core.engine.engine.ApexEngine;
import org.onap.policy.apex.core.engine.engine.impl.ApexEngineFactory;
-import org.onap.policy.apex.core.engine.event.EnEvent;
import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -49,7 +47,6 @@ import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
-import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbums;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState;
@@ -450,7 +447,7 @@ final class EngineWorker implements EngineService {
// Convert that information into a string
try {
- final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream();
+ final var baOutputStream = new ByteArrayOutputStream();
final ApexModelWriter<AxEngineModel> modelWriter = new ApexModelWriter<>(AxEngineModel.class);
modelWriter.setJsonOutput(true);
modelWriter.write(apexEngineModel, baOutputStream);
@@ -477,14 +474,14 @@ final class EngineWorker implements EngineService {
@Override
public String getRuntimeInfo(final AxArtifactKey engineKey) {
// We'll build up the JSON string for runtime information bit by bit
- final StringBuilder runtimeJsonStringBuilder = new StringBuilder();
+ final var runtimeJsonStringBuilder = new StringBuilder();
// Get the engine information
final AxEngineModel engineModel = engine.getEngineStatus();
final Map<AxArtifactKey, Map<String, Object>> engineContextAlbums = engine.getEngineContext();
// Use GSON to convert our context information into JSON
- final Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ final var gson = new GsonBuilder().setPrettyPrinting().create();
// Get context into a JSON string
runtimeJsonStringBuilder.append("{\"TimeStamp\":");
@@ -497,7 +494,7 @@ final class EngineWorker implements EngineService {
// Get context into a JSON string
runtimeJsonStringBuilder.append(",\"ContextAlbums\":[");
- boolean firstAlbum = true;
+ var firstAlbum = true;
for (final Entry<AxArtifactKey, Map<String, Object>> contextAlbumEntry : engineContextAlbums.entrySet()) {
if (firstAlbum) {
firstAlbum = false;
@@ -510,7 +507,7 @@ final class EngineWorker implements EngineService {
runtimeJsonStringBuilder.append(",\"AlbumContent\":[");
// Get the schema helper to use to marshal context album objects to JSON
- final AxContextAlbum axContextAlbum =
+ final var axContextAlbum =
ModelService.getModel(AxContextAlbums.class).get(contextAlbumEntry.getKey());
SchemaHelper schemaHelper = null;
@@ -520,7 +517,7 @@ final class EngineWorker implements EngineService {
schemaHelper = new SchemaHelperFactory().createSchemaHelper(axContextAlbum.getKey(),
axContextAlbum.getItemSchema());
} catch (final ContextRuntimeException e) {
- final String resultString =
+ final var resultString =
"could not find schema helper to marshal context album \"" + axContextAlbum + "\" to JSON";
LOGGER.warn(resultString, e);
@@ -531,7 +528,7 @@ final class EngineWorker implements EngineService {
continue;
}
- boolean firstEntry = true;
+ var firstEntry = true;
for (final Entry<String, Object> contextEntry : contextAlbumEntry.getValue().entrySet()) {
if (firstEntry) {
firstEntry = false;
@@ -554,8 +551,8 @@ final class EngineWorker implements EngineService {
runtimeJsonStringBuilder.append("]}");
// Tidy up the JSON string
- final JsonElement jsonElement = JsonParser.parseString(runtimeJsonStringBuilder.toString());
- final String tidiedRuntimeString = gson.toJson(jsonElement);
+ final var jsonElement = JsonParser.parseString(runtimeJsonStringBuilder.toString());
+ final var tidiedRuntimeString = gson.toJson(jsonElement);
LOGGER.debug("runtime information={}", tidiedRuntimeString);
@@ -592,7 +589,7 @@ final class EngineWorker implements EngineService {
// Take events from the event processing queue of the worker and pass them to the engine
// for processing
- boolean stopFlag = false;
+ var stopFlag = false;
while (processorThread != null && !processorThread.isInterrupted() && !stopFlag) {
ApexEvent event = null;
try {
@@ -603,12 +600,12 @@ final class EngineWorker implements EngineService {
LOGGER.debug("Engine {} processing interrupted ", engineWorkerKey);
break;
}
- boolean executedResult = false;
+ var executedResult = false;
try {
if (event != null) {
debugEventIfDebugEnabled(event);
- final EnEvent enevent = apexEnEventConverter.fromApexEvent(event);
+ final var enevent = apexEnEventConverter.fromApexEvent(event);
executedResult = engine.handleEvent(enevent);
}
} catch (final ApexException e) {
@@ -617,7 +614,7 @@ final class EngineWorker implements EngineService {
LOGGER.warn("Engine {} terminated processing event {}", engineWorkerKey, event.toString(), e);
stopFlag = true;
}
- ApexPolicyStatisticsManager apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ var apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (!stopFlag && apexPolicyCounter != null) {
apexPolicyCounter.updatePolicyExecutedCounter(executedResult);
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java
index 46e7f842f..d55c49d0f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * 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.
@@ -24,7 +25,6 @@ package org.onap.policy.apex.service.parameters.carriertechnology;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -71,7 +71,7 @@ public class CarrierTechnologyParametersJsonAdapter
@Override
public JsonElement serialize(final CarrierTechnologyParameters src, final Type typeOfSrc,
final JsonSerializationContext context) {
- final String returnMessage = "serialization of Apex carrier technology parameters to Json is not supported";
+ final var returnMessage = "serialization of Apex carrier technology parameters to Json is not supported";
LOGGER.error(returnMessage);
throw new ParameterRuntimeException(returnMessage);
}
@@ -82,10 +82,10 @@ public class CarrierTechnologyParametersJsonAdapter
@Override
public CarrierTechnologyParameters deserialize(final JsonElement json, final Type typeOfT,
final JsonDeserializationContext context) {
- final JsonObject jsonObject = json.getAsJsonObject();
+ final var jsonObject = json.getAsJsonObject();
// Get the carrier technology label primitive
- final JsonPrimitive labelJsonPrimitive = (JsonPrimitive) jsonObject.get(CARRIER_TECHNOLOGY_TOKEN);
+ final var labelJsonPrimitive = (JsonPrimitive) jsonObject.get(CARRIER_TECHNOLOGY_TOKEN);
// Check if we found our carrier technology
if (labelJsonPrimitive == null) {
@@ -107,7 +107,7 @@ public class CarrierTechnologyParametersJsonAdapter
// Get the technology carrier parameter class for the carrier technology plugin class from
// the configuration parameters
- final JsonPrimitive classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
+ final var classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
// If no technology carrier parameter class was specified, we try to use a built in carrier
// technology
@@ -142,7 +142,7 @@ public class CarrierTechnologyParametersJsonAdapter
}
// Deserialise the class
- CarrierTechnologyParameters carrierTechnologyParameters =
+ var carrierTechnologyParameters = (CarrierTechnologyParameters)
context.deserialize(jsonObject.get(CARRIER_TECHNOLOGY_PARAMETERS), carrierTechnologyParameterClass);
if (carrierTechnologyParameters == null) {
// OK no parameters for the carrier technology have been specified, just instantiate the
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
index 9e47926bc..66f253b56 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/RestPluginCarrierTechnologyParameters.java
@@ -183,7 +183,7 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
return null;
}
- Matcher matcher = patternErrorKey.matcher(url2);
+ var matcher = patternErrorKey.matcher(url2);
if (matcher.find()) {
final String urlInvalidMessage = "invalid URL has been set for event sending on " + getLabel();
return new ObjectValidationResult("url", url2, ValidationStatus.INVALID, urlInvalidMessage);
@@ -202,13 +202,13 @@ public class RestPluginCarrierTechnologyParameters extends CarrierTechnologyPara
return null;
}
- BeanValidationResult result = new BeanValidationResult(HTTP_HEADERS, httpHeaders);
+ var result = new BeanValidationResult(HTTP_HEADERS, httpHeaders);
- int item = 0;
+ var item = 0;
for (String[] httpHeader : httpHeaders) {
final String label = "entry " + (item++);
final List<String> value = (httpHeader == null ? null : Arrays.asList(httpHeader));
- BeanValidationResult result2 = new BeanValidationResult(label, value);
+ var result2 = new BeanValidationResult(label, value);
if (httpHeader == null) {
// note: add to result, not result2
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java
index 5319d763e..dee3a15bb 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * 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.
@@ -78,7 +79,7 @@ public class EngineServiceParametersJsonAdapter
@Override
public JsonElement serialize(final EngineParameters src, final Type typeOfSrc,
final JsonSerializationContext context) {
- final String returnMessage = "serialization of Apex parameters to Json is not supported";
+ final var returnMessage = "serialization of Apex parameters to Json is not supported";
LOGGER.error(returnMessage);
throw new ParameterRuntimeException(returnMessage);
}
@@ -89,9 +90,9 @@ public class EngineServiceParametersJsonAdapter
@Override
public EngineParameters deserialize(final JsonElement json, final Type typeOfT,
final JsonDeserializationContext context) {
- final JsonObject engineParametersJsonObject = json.getAsJsonObject();
+ final var engineParametersJsonObject = json.getAsJsonObject();
- final EngineParameters engineParameters = new EngineParameters();
+ final var engineParameters = new EngineParameters();
// Deserialise context parameters, they may be a subclass of the ContextParameters class
engineParameters.setContextParameters(
@@ -151,12 +152,12 @@ public class EngineServiceParametersJsonAdapter
}
// We do this because the JSON parameters may be for a subclass of ContextParameters
- final ContextParameters contextParameters = (ContextParameters) deserializeParameters(CONTEXT_PARAMETERS,
+ final var contextParameters = (ContextParameters) deserializeParameters(CONTEXT_PARAMETERS,
contextParametersElement, context);
// We know this will work because if the context parameters was not a Json object, the
// previous deserializeParameters() call would not have worked
- final JsonObject contextParametersObject = engineParametersJsonObject.get(CONTEXT_PARAMETERS).getAsJsonObject();
+ final var contextParametersObject = engineParametersJsonObject.get(CONTEXT_PARAMETERS).getAsJsonObject();
// Now get the distributor, lock manager, and persistence parameters
final JsonElement distributorParametersElement = contextParametersObject.get(DISTRIBUTOR_PARAMETERS);
@@ -204,11 +205,11 @@ public class EngineServiceParametersJsonAdapter
}
// Deserialize the executor parameters
- final JsonObject executorParametersJsonObject = engineParametersJsonObject.get(EXECUTOR_PARAMETERS)
+ final var executorParametersJsonObject = engineParametersJsonObject.get(EXECUTOR_PARAMETERS)
.getAsJsonObject();
for (final Entry<String, JsonElement> executorEntries : executorParametersJsonObject.entrySet()) {
- final ExecutorParameters executorParameters = (ExecutorParameters) deserializeParameters(
+ final var executorParameters = (ExecutorParameters) deserializeParameters(
EXECUTOR_PARAMETERS + ':' + executorEntries.getKey(), executorEntries.getValue(), context);
engineParameters.getExecutorParameterMap().put(executorEntries.getKey(), executorParameters);
}
@@ -235,7 +236,7 @@ public class EngineServiceParametersJsonAdapter
}
// Deserialize the executor parameters
- final JsonObject schemaHelperParametersJsonObject = contextParametersJsonObject.get(SCHEMA_PARAMETERS)
+ final var schemaHelperParametersJsonObject = contextParametersJsonObject.get(SCHEMA_PARAMETERS)
.getAsJsonObject();
for (final Entry<String, JsonElement> schemaHelperEntries : schemaHelperParametersJsonObject.entrySet()) {
@@ -286,7 +287,7 @@ public class EngineServiceParametersJsonAdapter
}
// Check the parameter has a value
- final String parameterClassName = parameterClassNameElement.getAsString();
+ final var parameterClassName = parameterClassNameElement.getAsString();
if (parameterClassName == null || parameterClassName.trim().length() == 0) {
final String returnMessage = "value for field \"" + PARAMETER_CLASS_NAME + "\" in \"" + parametersLabel
+ "\" entry is not specified or is blank";
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java
index ce1860ecf..f0074872f 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJsonAdapter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * 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.
@@ -24,7 +25,6 @@ package org.onap.policy.apex.service.parameters.eventprotocol;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@@ -69,7 +69,7 @@ public class EventProtocolParametersJsonAdapter
@Override
public JsonElement serialize(final EventProtocolParameters src, final Type typeOfSrc,
final JsonSerializationContext context) {
- final String returnMessage = "serialization of Apex event protocol parameters to Json is not supported";
+ final var returnMessage = "serialization of Apex event protocol parameters to Json is not supported";
LOGGER.error(returnMessage);
throw new ParameterRuntimeException(returnMessage);
}
@@ -80,10 +80,10 @@ public class EventProtocolParametersJsonAdapter
@Override
public EventProtocolParameters deserialize(final JsonElement json, final Type typeOfT,
final JsonDeserializationContext context) {
- final JsonObject jsonObject = json.getAsJsonObject();
+ final var jsonObject = json.getAsJsonObject();
// Get the event protocol label primitive
- final JsonPrimitive labelJsonPrimitive = (JsonPrimitive) jsonObject.get(EVENT_PROTOCOL_TOKEN);
+ final var labelJsonPrimitive = (JsonPrimitive) jsonObject.get(EVENT_PROTOCOL_TOKEN);
// Check if we found our event protocol
if (labelJsonPrimitive == null) {
@@ -105,7 +105,7 @@ public class EventProtocolParametersJsonAdapter
// Get the event protocol parameter class for the event protocol plugin class from the
// configuration parameters
- final JsonPrimitive classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
+ final var classNameJsonPrimitive = (JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME);
// If no event protocol parameter class was specified, we use the default
if (classNameJsonPrimitive == null) {
@@ -137,7 +137,7 @@ public class EventProtocolParametersJsonAdapter
}
// Deserialise the class
- EventProtocolParameters eventProtocolParameters =
+ var eventProtocolParameters = (EventProtocolParameters)
context.deserialize(jsonObject.get(EVENT_PROTOCOL_PARAMETERS), eventProtocolParameterClass);
if (eventProtocolParameters == null) {
// OK no parameters for the event protocol have been specified, just instantiate the