aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java4
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java9
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java10
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java8
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java2
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java11
-rw-r--r--model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java10
-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
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java12
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java10
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java6
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java2
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java19
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java17
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java17
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java26
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java2
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java2
-rw-r--r--tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java4
-rw-r--r--tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java21
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java5
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java7
32 files changed, 169 insertions, 153 deletions
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
index 8ca6d153e..9636ea7ce 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/CollectionUtils.java
@@ -92,9 +92,9 @@ public final class CollectionUtils {
// Get the next objects
@SuppressWarnings("unchecked")
- final T leftObject = (T) leftIterator.next();
+ final var leftObject = (T) leftIterator.next();
@SuppressWarnings("unchecked")
- final T rightObject = (T) rightIterator.next();
+ final var rightObject = (T) rightIterator.next();
// Compare the objects
@SuppressWarnings("unchecked")
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
index 2d96a5954..21c417c4d 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryDeleteShutdownHook.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 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.
@@ -22,6 +23,8 @@
package org.onap.policy.apex.model.utilities;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -54,8 +57,10 @@ final class DirectoryDeleteShutdownHook extends Thread {
if (tempDir.exists()) {
// Empty and delete the directory
DirectoryUtils.emptyDirectory(tempDir);
- if (!tempDir.delete()) {
- LOGGER.warn("Failed to delete directory {}", tempDir);
+ try {
+ Files.delete(tempDir.toPath());
+ } catch (IOException e) {
+ LOGGER.warn("Failed to delete directory {}", tempDir, e);
}
}
}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
index cc92d2a7f..b0e8332b1 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/DirectoryUtils.java
@@ -23,6 +23,8 @@
package org.onap.policy.apex.model.utilities;
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.slf4j.ext.XLogger;
@@ -51,7 +53,7 @@ public final class DirectoryUtils {
try {
// Get the name of the temporary directory
final String tempDirName = System.getProperty("java.io.tmpdir") + "/" + nameprefix + System.nanoTime();
- final File tempDir = new File(tempDirName);
+ final var tempDir = new File(tempDirName);
// Delete the directory if it already exists
if (tempDir.exists()) {
@@ -95,8 +97,10 @@ public final class DirectoryUtils {
}
// Delete the directory entry
- if (!directoryFile.delete()) {
- LOGGER.warn("Failed to delete directory file {}", directoryFile);
+ try {
+ Files.delete(directoryFile.toPath());
+ } catch (IOException e) {
+ LOGGER.warn("Failed to delete directory file {}", directoryFile, e);
}
}
}
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
index 3f369c0e0..d8bb469cf 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/TreeMapUtils.java
@@ -100,15 +100,15 @@ public final class TreeMapUtils {
Map.Entry<?, ?> leftEntry = (Entry<?, ?>) leftIt.next();
Map.Entry<?, ?> rightEntry = (Entry<?, ?>) rightIt.next();
- K leftKey = (K) leftEntry.getKey();
- K rightKey = (K) rightEntry.getKey();
+ var leftKey = (K) leftEntry.getKey();
+ var rightKey = (K) rightEntry.getKey();
int result = ((Comparable<K>) leftKey).compareTo(rightKey);
if (result != 0) {
return result;
}
- V leftValue = (V) leftEntry.getValue();
- V rightValue = (V) rightEntry.getValue();
+ var leftValue = (V) leftEntry.getValue();
+ var rightValue = (V) rightEntry.getValue();
result = ((Comparable<V>) leftValue).compareTo(rightValue);
if (result != 0) {
return result;
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
index b01c83d59..a0395cf16 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyDifference.java
@@ -63,7 +63,7 @@ public class KeyDifference<K> {
* @return the difference between the keys as a string
*/
public String asString(final boolean diffsOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
if (leftKey.equals(rightKey)) {
if (!diffsOnly) {
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
index 24ff55263..9943690fa 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapComparer.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=========================================================
*/
@@ -74,8 +75,8 @@ public class KeyedMapComparer<K, V> {
// Save the common values to two maps, an identical and different map
for (K key : commonKeys) {
// Check if the values are identical in each map
- V leftValue = leftMap.get(key);
- V rightValue = rightMap.get(key);
+ var leftValue = leftMap.get(key);
+ var rightValue = rightMap.get(key);
// Store as appropriate
if (leftValue.equals(rightValue)) {
diff --git a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
index a070ec9ce..e10854926 100644
--- a/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
+++ b/model/utilities/src/main/java/org/onap/policy/apex/model/utilities/comparison/KeyedMapDifference.java
@@ -58,7 +58,7 @@ public class KeyedMapDifference<K, V> {
* @return the string
*/
public String asString(final boolean diffsOnly, final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
if (leftOnly.isEmpty()) {
if (!diffsOnly) {
@@ -101,7 +101,7 @@ public class KeyedMapDifference<K, V> {
*/
private Object getInOneSideOnlyAsString(final Map<K, V> sideMap, final String sideMapString,
final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.append("*** list of keys on " + sideMapString + " only\n");
for (Entry<K, V> leftEntry : sideMap.entrySet()) {
@@ -124,7 +124,7 @@ public class KeyedMapDifference<K, V> {
* @return the differences as a string
*/
private String getDifferencesAsString(final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.append("*** list of differing entries between left and right\n");
for (Entry<K, List<V>> differentEntry : differentValues.entrySet()) {
@@ -132,7 +132,7 @@ public class KeyedMapDifference<K, V> {
builder.append(differentEntry.getKey());
if (!keysOnly) {
builder.append(",values={");
- boolean first = true;
+ var first = true;
for (V differentEntryValue : differentEntry.getValue()) {
builder.append(differentEntryValue);
if (first) {
@@ -156,7 +156,7 @@ public class KeyedMapDifference<K, V> {
* @return the identical entries as a string
*/
private String getIdenticalsAsString(final boolean keysOnly) {
- StringBuilder builder = new StringBuilder();
+ var builder = new StringBuilder();
builder.append("*** list of identical entries in left and right\n");
for (Entry<K, V> identicalEntry : identicalValues.entrySet()) {
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
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java
index 068880a9d..dd960b298 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/SynchronousEventCacheTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2021. 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.
@@ -138,11 +139,12 @@ public class SynchronousEventCacheTest {
final SynchronousEventCache cache =
new SynchronousEventCache(EventHandlerPeeredMode.SYNCHRONOUS, consumer, producer, timeout);
- assertThatCode(() -> {
- cache.cacheSynchronizedEventFromApex(executionId, new Object());
- cache.cacheSynchronizedEventFromApex(executionId, new Object());
- })
- .isInstanceOf(ApexEventRuntimeException.class);
+ final var obj1 = new Object();
+ cache.cacheSynchronizedEventFromApex(executionId, obj1);
+
+ final var obj2 = new Object();
+ assertThatCode(() -> cache.cacheSynchronizedEventFromApex(executionId, obj2))
+ .isInstanceOf(ApexEventRuntimeException.class);
}
@Test
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
index 2993bbe07..a4cd8a004 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java
@@ -109,9 +109,9 @@ public class ApexStarterActivator {
throw new ApexStarterRunTimeException(e);
}
- final PdpUpdateListener pdpUpdateListener = new PdpUpdateListener();
- final PdpStateChangeListener pdpStateChangeListener = new PdpStateChangeListener();
- final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
+ final var pdpUpdateListener = new PdpUpdateListener();
+ final var pdpStateChangeListener = new PdpStateChangeListener();
+ final var pdpMessageHandler = new PdpMessageHandler();
supportedPolicyTypes =
pdpMessageHandler.getSupportedPolicyTypesFromParameters(apexStarterParameterGroup.getPdpStatusParameters());
@@ -160,7 +160,7 @@ public class ApexStarterActivator {
* Method to stop and unregister the pdp status publisher.
*/
private void stopAndRemovePdpStatusPublisher() {
- final PdpStatusPublisher pdpStatusPublisher =
+ final var pdpStatusPublisher =
Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
pdpStatusPublisher.terminate();
Registry.unregister(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
@@ -196,7 +196,7 @@ public class ApexStarterActivator {
throw new IllegalStateException("activator is not running");
}
try {
- final PdpStatusPublisher pdpStatusPublisher =
+ final var pdpStatusPublisher =
Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
// send a final heartbeat with terminated status
pdpStatusPublisher.send(new PdpMessageHandler().getTerminatedPdpStatus());
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
index 2976f8260..7912d377f 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterMain.java
@@ -54,11 +54,11 @@ public class ApexStarterMain {
* @param args the command line arguments
*/
public ApexStarterMain(final String[] args) {
- final String params = Arrays.toString(args);
+ final var params = Arrays.toString(args);
LOGGER.info("In ApexStarter with parameters {}", params);
// Check the arguments
- final ApexStarterCommandLineArguments arguments = new ApexStarterCommandLineArguments();
+ final var arguments = new ApexStarterCommandLineArguments();
try {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
@@ -90,7 +90,7 @@ public class ApexStarterMain {
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new ApexStarterShutdownHookClass());
- String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_APEX_PDP);
+ var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_APEX_PDP);
LOGGER.info(successMsg);
}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
index dcd368371..499a0280a 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/comm/PdpStatusPublisher.java
@@ -61,7 +61,7 @@ public class PdpStatusPublisher extends TimerTask {
@Override
public void run() {
- final PdpStatus pdpStatus = new PdpMessageHandler().createPdpStatusFromContext();
+ final var pdpStatus = new PdpMessageHandler().createPdpStatusFromContext();
topicSinkClient.send(pdpStatus);
LOGGER.debug("Sent heartbeat to PAP - {}", pdpStatus);
}
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
index 7aa663c58..b676450a3 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. 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.
@@ -31,7 +32,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.TaskParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
@@ -103,7 +103,7 @@ public class ApexEngineHandler {
policiesToUnDeploy.removeIf(p -> !runningPolicies.contains(p));
Map<ToscaConceptIdentifier, ApexMain> undeployedPoliciesMainMap = new LinkedHashMap<>();
policiesToUnDeploy.forEach(policyId -> {
- ApexMain apexMain = apexMainMap.get(policyId);
+ var apexMain = apexMainMap.get(policyId);
try {
apexMain.shutdown();
undeployedPoliciesMainMap.put(policyId, apexMain);
@@ -183,7 +183,7 @@ public class ApexEngineHandler {
.stream().filter(key -> !outputParamKeysToRetain.contains(key)).collect(Collectors.toList());
eventInputParamKeysToRemove.forEach(existingParameters.getEventInputParameters()::remove);
eventOutputParamKeysToRemove.forEach(existingParameters.getEventOutputParameters()::remove);
- EngineParameters engineParameters = main.getApexParameters().getEngineServiceParameters().getEngineParameters();
+ var engineParameters = main.getApexParameters().getEngineServiceParameters().getEngineParameters();
final List<TaskParameters> taskParametersToRemove = engineParameters.getTaskParameters().stream()
.filter(taskParameter -> !taskParametersToRetain.contains(taskParameter)).collect(Collectors.toList());
final List<String> executorParamKeysToRemove = engineParameters.getExecutorParameterMap().keySet().stream()
@@ -191,8 +191,7 @@ public class ApexEngineHandler {
final List<String> schemaParamKeysToRemove =
engineParameters.getContextParameters().getSchemaParameters().getSchemaHelperParameterMap().keySet()
.stream().filter(key -> !schemaParamKeysToRetain.contains(key)).collect(Collectors.toList());
- EngineParameters aggregatedEngineParameters =
- existingParameters.getEngineServiceParameters().getEngineParameters();
+ var aggregatedEngineParameters = existingParameters.getEngineServiceParameters().getEngineParameters();
aggregatedEngineParameters.getTaskParameters().removeAll(taskParametersToRemove);
executorParamKeysToRemove.forEach(aggregatedEngineParameters.getExecutorParameterMap()::remove);
schemaParamKeysToRemove.forEach(aggregatedEngineParameters.getContextParameters().getSchemaParameters()
@@ -248,9 +247,9 @@ public class ApexEngineHandler {
Map<ToscaConceptIdentifier, ApexMain> failedPoliciesMainMap = new LinkedHashMap<>();
for (ToscaPolicy policy : policies) {
String policyName = policy.getIdentifier().getName();
- final StandardCoder standardCoder = new StandardCoder();
- ToscaServiceTemplate toscaServiceTemplate = new ToscaServiceTemplate();
- ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate();
+ final var standardCoder = new StandardCoder();
+ var toscaServiceTemplate = new ToscaServiceTemplate();
+ var toscaTopologyTemplate = new ToscaTopologyTemplate();
toscaTopologyTemplate.setPolicies(List.of(Map.of(policyName, policy)));
toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate);
File file;
@@ -260,9 +259,9 @@ public class ApexEngineHandler {
} catch (CoderException | IOException e) {
throw new ApexStarterException(e);
}
- final String[] apexArgs = {"-p", file.getAbsolutePath()};
+ final var apexArgs = new String[] {"-p", file.getAbsolutePath()};
LOGGER.info("Starting apex engine for policy {}", policy.getIdentifier());
- ApexMain apexMain = new ApexMain(apexArgs);
+ var apexMain = new ApexMain(apexArgs);
if (apexMain.isAlive()) {
apexMainMap.put(policy.getIdentifier(), apexMain);
} else {
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
index 134b45c14..97feba152 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 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.
@@ -63,7 +64,7 @@ public class PdpMessageHandler {
*/
public PdpStatus createPdpStatusFromParameters(final String instanceId,
final PdpStatusParameters pdpStatusParameters) {
- final PdpStatus pdpStatus = new PdpStatus();
+ final var pdpStatus = new PdpStatus();
pdpStatus.setPdpGroup(pdpStatusParameters.getPdpGroup());
pdpStatus.setPdpType(pdpStatusParameters.getPdpType());
pdpStatus.setState(PdpState.PASSIVE);
@@ -97,8 +98,8 @@ public class PdpMessageHandler {
* @return PdpStatus the pdp status message
*/
public PdpStatus createPdpStatusFromContext() {
- final PdpStatus pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
- final PdpStatus pdpStatus = new PdpStatus();
+ final var pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpStatus = new PdpStatus();
pdpStatus.setName(pdpStatusContext.getName());
pdpStatus.setPdpType(pdpStatusContext.getPdpType());
pdpStatus.setState(pdpStatusContext.getState());
@@ -128,7 +129,7 @@ public class PdpMessageHandler {
*/
private PdpStatistics getStatistics(final PdpStatus pdpStatusContext, final ApexEngineHandler apexEngineHandler) {
- PdpStatistics pdpStatistics = new PdpStatistics();
+ var pdpStatistics = new PdpStatistics();
pdpStatistics.setPdpInstanceId(pdpStatusContext.getName());
pdpStatistics.setTimeStamp(Instant.now());
pdpStatistics.setPdpGroupName(pdpStatusContext.getPdpGroup());
@@ -136,7 +137,7 @@ public class PdpMessageHandler {
if (apexEngineHandler != null) {
pdpStatistics.setEngineStats(getEngineWorkerStats(apexEngineHandler));
}
- final ApexPolicyStatisticsManager apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ final var apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (apexPolicyCounter != null) {
pdpStatistics.setPolicyDeploySuccessCount(apexPolicyCounter.getPolicyDeploySuccessCount());
pdpStatistics.setPolicyDeployFailCount(apexPolicyCounter.getPolicyDeployFailCount());
@@ -158,7 +159,7 @@ public class PdpMessageHandler {
List<AxEngineModel> engineModels = apexEngineHandler.getEngineStats();
if (engineModels != null) {
engineModels.forEach(engineModel -> {
- PdpEngineWorkerStatistics workerStatistics = new PdpEngineWorkerStatistics();
+ var workerStatistics = new PdpEngineWorkerStatistics();
workerStatistics.setEngineWorkerState(transferEngineState(engineModel.getState()));
workerStatistics.setEngineId(engineModel.getId());
workerStatistics.setEventCount(engineModel.getStats().getEventCount());
@@ -195,7 +196,7 @@ public class PdpMessageHandler {
* @return PdpStatus the pdp status message
*/
public PdpStatus getTerminatedPdpStatus() {
- final PdpStatus pdpStatusInContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpStatusInContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
pdpStatusInContext.setState(PdpState.TERMINATED);
pdpStatusInContext.setDescription("Apex pdp shutting down.");
return createPdpStatusFromContext();
@@ -212,7 +213,7 @@ public class PdpMessageHandler {
*/
public PdpResponseDetails createPdpResonseDetails(final String requestId, final PdpResponseStatus status,
final String responseMessage) {
- final PdpResponseDetails pdpResponseDetails = new PdpResponseDetails();
+ final var pdpResponseDetails = new PdpResponseDetails();
pdpResponseDetails.setResponseTo(requestId);
pdpResponseDetails.setResponseStatus(status);
pdpResponseDetails.setResponseMessage(responseMessage);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
index bbdbb22db..e6fd9e477 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpStateChangeMessageHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 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.
@@ -52,9 +53,10 @@ public class PdpStateChangeMessageHandler {
* @param pdpStateChangeMsg pdp state change message
*/
public void handlePdpStateChangeEvent(final PdpStateChange pdpStateChangeMsg) {
- final PdpStatus pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
- final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
- final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
+ final var pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpStatusPublisher =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+ final var pdpMessageHandler = new PdpMessageHandler();
PdpResponseDetails pdpResponseDetails = null;
if (pdpStateChangeMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
pdpStatusContext.getPdpSubgroup())) {
@@ -68,7 +70,7 @@ public class PdpStateChangeMessageHandler {
default:
break;
}
- final PdpStatus pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
+ final var pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
pdpStatus.setResponse(pdpResponseDetails);
pdpStatus.setDescription("Pdp status response message for PdpStateChange");
pdpStatusPublisher.send(pdpStatus);
@@ -115,7 +117,7 @@ public class PdpStateChangeMessageHandler {
final PdpMessageHandler pdpMessageHandler, final List<ToscaPolicy> policies) {
PdpResponseDetails pdpResponseDetails;
try {
- final ApexEngineHandler apexEngineHandler = new ApexEngineHandler(policies);
+ final var apexEngineHandler = new ApexEngineHandler(policies);
Registry.registerOrReplace(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, apexEngineHandler);
if (apexEngineHandler.isApexEngineRunning()) {
List<ToscaConceptIdentifier> runningPolicies = apexEngineHandler.getRunningPolicies();
@@ -127,7 +129,7 @@ public class PdpStateChangeMessageHandler {
pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
PdpResponseStatus.SUCCESS, "Apex engine started. State changed to active.");
} else {
- StringBuilder message = new StringBuilder(
+ var message = new StringBuilder(
"Apex engine started. But, only the following polices are running - ");
for (ToscaConceptIdentifier policy : runningPolicies) {
message.append(policy.getName()).append(":").append(policy.getVersion()).append(" ");
@@ -146,8 +148,7 @@ public class PdpStateChangeMessageHandler {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpStateChangeMsg.getRequestId(),
PdpResponseStatus.FAIL, "Apex engine service running failed. " + e.getMessage());
}
- final ApexPolicyStatisticsManager apexPolicyStatisticsManager =
- ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ final var apexPolicyStatisticsManager = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (apexPolicyStatisticsManager != null) {
apexPolicyStatisticsManager
.updatePolicyDeployCounter(pdpResponseDetails.getResponseStatus() == PdpResponseStatus.SUCCESS);
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
index 09fb92dd3..24ebc14de 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -58,8 +59,8 @@ public class PdpUpdateMessageHandler {
* @param pdpUpdateMsg pdp update message
*/
public void handlePdpUpdateEvent(final PdpUpdate pdpUpdateMsg) {
- final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler();
- final PdpStatus pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
+ final var pdpMessageHandler = new PdpMessageHandler();
+ final var pdpStatusContext = Registry.get(ApexStarterConstants.REG_PDP_STATUS_OBJECT, PdpStatus.class);
PdpResponseDetails pdpResponseDetails = null;
if (pdpUpdateMsg.appliesTo(pdpStatusContext.getName(), pdpStatusContext.getPdpGroup(),
pdpStatusContext.getPdpSubgroup())) {
@@ -69,9 +70,9 @@ public class PdpUpdateMessageHandler {
} else {
pdpResponseDetails = handlePdpUpdate(pdpUpdateMsg, pdpMessageHandler, pdpStatusContext);
}
- final PdpStatusPublisher pdpStatusPublisherTemp =
- Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
- final PdpStatus pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
+ final var pdpStatusPublisherTemp =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
+ final var pdpStatus = pdpMessageHandler.createPdpStatusFromContext();
pdpStatus.setResponse(pdpResponseDetails);
pdpStatus.setDescription("Pdp status response message for PdpUpdate");
pdpStatusPublisherTemp.send(pdpStatus);
@@ -89,7 +90,8 @@ public class PdpUpdateMessageHandler {
private PdpResponseDetails handlePdpUpdate(final PdpUpdate pdpUpdateMsg, final PdpMessageHandler pdpMessageHandler,
final PdpStatus pdpStatusContext) {
PdpResponseDetails pdpResponseDetails = null;
- final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
+ final var pdpStatusPublisher =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
if (null != pdpUpdateMsg.getPdpHeartbeatIntervalMs() && pdpUpdateMsg.getPdpHeartbeatIntervalMs() > 0
&& pdpStatusPublisher.getInterval() != pdpUpdateMsg.getPdpHeartbeatIntervalMs()) {
updateInterval(pdpUpdateMsg.getPdpHeartbeatIntervalMs());
@@ -109,7 +111,7 @@ public class PdpUpdateMessageHandler {
if (pdpStatusContext.getState().equals(PdpState.ACTIVE)) {
pdpResponseDetails = startOrStopApexEngineBasedOnPolicies(pdpUpdateMsg, pdpMessageHandler);
- ApexEngineHandler apexEngineHandler =
+ var apexEngineHandler =
Registry.getOrDefault(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, ApexEngineHandler.class, null);
// in hearbeat while in active state, only the policies which are running should be there.
// if some policy fails, that shouldn't go in the heartbeat.
@@ -210,7 +212,7 @@ public class PdpUpdateMessageHandler {
List<ToscaConceptIdentifier> policiesToBeUndeployed = pdpUpdateMsg.getPoliciesToBeUndeployed();
if (runningPolicies.containsAll(policiesToBeDeployed)
&& !containsAny(runningPolicies, policiesToBeUndeployed)) {
- StringBuilder message = new StringBuilder("Apex engine started. ");
+ var message = new StringBuilder("Apex engine started. ");
if (!policiesToBeDeployed.isEmpty()) {
message.append("Deployed policies are: ");
for (ToscaConceptIdentifier policy : policiesToBeDeployed) {
@@ -226,7 +228,7 @@ public class PdpUpdateMessageHandler {
pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(),
PdpResponseStatus.SUCCESS, message.toString());
} else {
- StringBuilder message =
+ var message =
new StringBuilder("Apex engine started. But, only the following polices are running - ");
for (ToscaConceptIdentifier policy : runningPolicies) {
message.append(policy.getName()).append(":").append(policy.getVersion()).append(" ");
@@ -262,7 +264,8 @@ public class PdpUpdateMessageHandler {
* @param interval time interval received in the pdp update message from pap
*/
public void updateInterval(final long interval) {
- final PdpStatusPublisher pdpStatusPublisher = Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER);
+ final var pdpStatusPublisher =
+ Registry.get(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER, PdpStatusPublisher.class);
pdpStatusPublisher.terminate();
final List<TopicSink> topicSinks = Registry.get(ApexStarterConstants.REG_APEX_PDP_TOPIC_SINKS);
Registry.registerOrReplace(ApexStarterConstants.REG_PDP_STATUS_PUBLISHER,
@@ -287,8 +290,7 @@ public class PdpUpdateMessageHandler {
* @param pdpResponseDetails the pdp response
*/
private void updateDeploymentCounts(final PdpUpdate pdpUpdateMsg, PdpResponseDetails pdpResponseDetails) {
- final ApexPolicyStatisticsManager statisticsManager =
- ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ final var statisticsManager = ApexPolicyStatisticsManager.getInstanceFromRegistry();
if (statisticsManager != null) {
if (pdpUpdateMsg.getPoliciesToBeDeployed() != null && !pdpUpdateMsg.getPoliciesToBeDeployed().isEmpty()) {
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
index 691b30d2d..7eba23028 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java
@@ -55,7 +55,7 @@ public class ApexStarterParameterHandler {
// Read the parameters
try {
// Read the parameters from JSON
- final File file = new File(arguments.getFullConfigurationFilePath());
+ final var file = new File(arguments.getFullConfigurationFilePath());
apexStarterParameterGroup = CODER.decode(file, ApexStarterParameterGroup.class);
} catch (final CoderException e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
index 1c6b88700..b6962e925 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/rest/HealthCheckProvider.java
@@ -47,7 +47,7 @@ public class HealthCheckProvider {
Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class);
final boolean alive = activator.isAlive();
- final HealthCheckReport report = new HealthCheckReport();
+ final var report = new HealthCheckReport();
report.setName(activator.getInstanceId());
report.setUrl(URL);
report.setHealthy(alive);
diff --git a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java
index ca123c9bb..8e607ebd4 100644
--- a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java
+++ b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java
@@ -133,8 +133,8 @@ public class SimpleConsole extends WebSocketClient {
thread.setName("ClientThread");
thread.start();
- final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- StringBuilder event = new StringBuilder();
+ final var in = new BufferedReader(new InputStreamReader(System.in));
+ var event = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
if ("exit".equals(line)) {
diff --git a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java
index 9b0674df9..e3af4dcc1 100644
--- a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java
+++ b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java
@@ -1,6 +1,7 @@
/*-
* ============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.
@@ -50,14 +51,14 @@ public final class WsClientMain {
/**
* Run the command.
- *
+ *
* @param args the command line arguments
* @param outStream stream for output
*/
WsClientMain(final String[] args, final PrintStream outStream) {
- boolean console = false;
+ var console = false;
- final CliParser cli = new CliParser();
+ final var cli = new CliParser();
cli.addOption(CliOptions.HELP);
cli.addOption(CliOptions.VERSION);
cli.addOption(CliOptions.CONSOLE);
@@ -89,7 +90,7 @@ public final class WsClientMain {
/**
* Run the console or echo.
- *
+ *
* @param console if true, run the console otherwise run echo
* @param cmd the command line to run
* @param outStream stream for output
@@ -140,7 +141,7 @@ public final class WsClientMain {
outStream.println();
try {
- final SimpleEcho simpleEcho = new SimpleEcho(server, port, APP_NAME, outStream, outStream);
+ final var simpleEcho = new SimpleEcho(server, port, APP_NAME, outStream, outStream);
simpleEcho.connect();
} catch (final URISyntaxException uex) {
String message = APP_NAME + ": URI exception, could not create URI from server and port settings";
@@ -180,7 +181,7 @@ public final class WsClientMain {
outStream.println();
try {
- final SimpleConsole simpleConsole = new SimpleConsole(server, port, APP_NAME, outStream, outStream);
+ final var simpleConsole = new SimpleConsole(server, port, APP_NAME, outStream, outStream);
simpleConsole.runClient();
} catch (final URISyntaxException uex) {
String message = APP_NAME + ": URI exception, could not create URI from server and port settings";
@@ -207,15 +208,15 @@ public final class WsClientMain {
/**
* Get the help string for the application.
- *
+ *
* @param cli the command line options
* @return the help string
*/
private String getHelpString(final CliParser cli) {
- HelpFormatter formatter = new HelpFormatter();
+ var formatter = new HelpFormatter();
- final StringWriter helpStringWriter = new StringWriter();
- final PrintWriter helpPrintWriter = new PrintWriter(helpStringWriter);
+ final var helpStringWriter = new StringWriter();
+ final var helpPrintWriter = new PrintWriter(helpStringWriter);
formatter.printHelp(helpPrintWriter, 120, APP_NAME, APP_DESCRIPTION, cli.getOptions(), 2, 4, "");
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
index 1b80af3f2..59c3c0e73 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.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.
@@ -188,7 +189,7 @@ public final class Console {
return;
}
- final StringBuilder err = new StringBuilder();
+ final var err = new StringBuilder();
if (appName != null) {
err.append(this.getAppName()).append(": ");
}
@@ -217,7 +218,7 @@ public final class Console {
return;
}
- final StringBuilder warn = new StringBuilder();
+ final var warn = new StringBuilder();
if (appName != null) {
warn.append(this.getAppName()).append(": ");
}
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
index 2a20554b5..4b04b4037 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.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.
@@ -29,7 +30,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.file.FileSystems;
-import java.nio.file.Path;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,8 +76,7 @@ public class OutputFile {
* @return a File object for this output file
*/
public File toFile() {
- final Path fp = FileSystems.getDefault().getPath(fileName);
- return fp.toFile();
+ return FileSystems.getDefault().getPath(fileName).toFile();
}
/**
@@ -115,7 +114,7 @@ public class OutputFile {
* @return null on success, an error message on error
*/
public String validate() {
- final File file = toFile();
+ final var file = toFile();
if (file.exists()) {
if (!overwrite) {
return "file already exists";