summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/main/java
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2021-06-16 12:23:23 +0100
committerlapentafd <francesco.lapenta@est.tech>2021-06-18 10:27:44 +0100
commit782b1a82328a1ba95d370a014c587e1ba13ca464 (patch)
tree9a5482251e6c995285ba8e2f7320ad78baf2d883 /services/services-engine/src/main/java
parent12f634160f11d03265fac84c8d10cb8765e16187 (diff)
Fix Sonar Issues in apex-pdp-services-engine
Test refactoring and local-variable type inference replaced Issue-ID: POLICY-3093 Change-Id: I0c5506f27ea53da7740acce87a25060ba2bce7f4 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'services/services-engine/src/main/java')
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java9
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java4
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverter.java9
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java7
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java4
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java31
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java20
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java4
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java3
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java10
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java7
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java22
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java11
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java7
14 files changed, 75 insertions, 73 deletions
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
index dabe1fdc7..1300f2176 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPeriodicEventGenerator.java
@@ -1,19 +1,20 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* 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=========================================================
*/
@@ -135,7 +136,7 @@ public class ApexPeriodicEventGenerator extends TimerTask {
// Send the periodic event
try {
- final ApexEvent periodicEvent = new ApexEvent(PERIODIC_EVENT_NAME, PERIODIC_EVENT_VERSION,
+ final var periodicEvent = new ApexEvent(PERIODIC_EVENT_NAME, PERIODIC_EVENT_VERSION,
PERIODIC_EVENT_NAMESPACE, PERIODIC_EVENT_SOURCE, PERIODIC_EVENT_TARGET);
periodicEvent.putAll(periodicEventMap);
engineServiceEventInterface.sendEvent(periodicEvent);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java
index ebfd71f28..d1e9ffd6c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexPluginsEventProducer.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ public abstract class ApexPluginsEventProducer implements ApexEventProducer {
public void sendEvent(final long executionId, final Properties executionProperties, final String eventName,
final Object event) {
// 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/apexprotocolplugin/Apex2ApexEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverter.java
index 5f44be82f..0d85196c3 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/apexprotocolplugin/Apex2ApexEventConverter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,7 +49,7 @@ public class Apex2ApexEventConverter implements ApexEventProtocolConverter {
public void init(final EventProtocolParameters parameters) {
// Check and get the APEX parameters
if (!(parameters instanceof ApexEventProtocolParameters)) {
- final String errorMessage = "specified consumer properties are not applicable to the APEX event protocol";
+ final var errorMessage = "specified consumer properties are not applicable to the APEX event protocol";
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -77,8 +78,8 @@ public class Apex2ApexEventConverter implements ApexEventProtocolConverter {
// Check whether we have any ApexEventList fields, if so this is an event of events and
// all fields should be of type ApexEventList
- boolean foundEventListFields = false;
- boolean foundOtherFields = false;
+ var foundEventListFields = false;
+ var foundOtherFields = false;
for (final Object fieldObject : event.values()) {
if (fieldObject instanceof ApexEventList) {
foundEventListFields = true;
@@ -102,7 +103,7 @@ public class Apex2ApexEventConverter implements ApexEventProtocolConverter {
eventList.add(event);
}
} catch (final Exception e) {
- final String errorString = "Failed to unmarshal APEX event, event=" + eventObject;
+ final var errorString = "Failed to unmarshal APEX event, event=" + eventObject;
throw new ApexEventException(errorString, e);
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
index db9a7663c..ab54d426c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/enevent/ApexEvent2EnEventConverter.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,8 +76,8 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter {
}
// Create the Apex event
- final AxEvent axEvent = enEvent.getAxEvent();
- final ApexEvent apexEvent = new ApexEvent(axEvent.getKey().getName(), axEvent.getKey().getVersion(),
+ final var axEvent = enEvent.getAxEvent();
+ final var apexEvent = new ApexEvent(axEvent.getKey().getName(), axEvent.getKey().getVersion(),
axEvent.getNameSpace(), axEvent.getSource(), axEvent.getTarget());
apexEvent.setExecutionId(enEvent.getExecutionId());
@@ -114,7 +115,7 @@ public final class ApexEvent2EnEventConverter implements ApexEventConverter {
}
// Create the internal engine event
- final EnEvent enEvent = apexEngine.createEvent(eventDefinition.getKey());
+ final var enEvent = apexEngine.createEvent(eventDefinition.getKey());
// Set the data on the engine event
enEvent.putAll(apexEvent);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java
index da5ee025a..5cec21e82 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/producer/ApexFileEventProducer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@ public class ApexFileEventProducer extends ApexPluginsEventProducer {
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- final FileCarrierTechnologyParameters fileCarrierTechnologyParameters =
+ final var fileCarrierTechnologyParameters =
(FileCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Now we create a writer for events
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
index 06d9b477f..d64d46a7c 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JsonEventConverter.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,7 +30,6 @@ import com.google.gson.internal.LinkedTreeMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.eventmodel.concepts.AxEvent;
@@ -67,7 +66,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
public void init(final EventProtocolParameters parameters) {
// Check and get the JSON parameters
if (!(parameters instanceof JsonEventProtocolParameters)) {
- final String errorMessage = "specified consumer properties are not applicable to the JSON event protocol";
+ final var errorMessage = "specified consumer properties are not applicable to the JSON event protocol";
throw new ApexEventRuntimeException(errorMessage);
}
@@ -99,7 +98,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
try {
// We may have a single JSON object with a single event or an array of JSON objects
- final Object decodedJsonObject = new GsonBuilder().serializeNulls().create().fromJson(jsonEventString,
+ final var decodedJsonObject = new GsonBuilder().serializeNulls().create().fromJson(jsonEventString,
Object.class);
// Check if we have a list of objects
@@ -181,8 +180,8 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
apexEvent.getVersion());
// Use a GSON Json object to marshal the Apex event to JSON
- final Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().create();
- final JsonObject jsonObject = new JsonObject();
+ final var gson = new GsonBuilder().serializeNulls().setPrettyPrinting().create();
+ final var jsonObject = new JsonObject();
jsonObject.addProperty(ApexEvent.NAME_HEADER_FIELD, apexEvent.getName());
jsonObject.addProperty(ApexEvent.VERSION_HEADER_FIELD, apexEvent.getVersion());
@@ -209,7 +208,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
final Object fieldValue = apexEvent.get(fieldName);
// Get the schema helper
- final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(),
+ final var fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(),
eventField.getSchema());
jsonObject.add(fieldName, (JsonElement) fieldSchemaHelper.marshal2Object(fieldValue));
}
@@ -254,7 +253,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
final Object fieldValue = apexEvent.get(jsonPars.getPojoField());
// Get the schema helper
- final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory()
+ final var fieldSchemaHelper = new SchemaHelperFactory()
.createSchemaHelper(pojoFieldDefinition.getKey(), pojoFieldDefinition.getSchema());
return fieldSchemaHelper.marshal2String(fieldValue);
@@ -271,7 +270,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
private ApexEvent jsonStringApexEvent(final String eventName, final String jsonEventString)
throws ApexEventException {
// Use GSON to read the event string
- final JsonObject jsonObject = new GsonBuilder().serializeNulls().create().fromJson(jsonEventString,
+ final var jsonObject = new GsonBuilder().serializeNulls().create().fromJson(jsonEventString,
JsonObject.class);
if (jsonObject == null || !jsonObject.isJsonObject()) {
@@ -293,7 +292,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
private ApexEvent jsonObject2ApexEvent(final String eventName, final JsonObject jsonObject)
throws ApexEventException {
// Process the mandatory Apex header
- final ApexEvent apexEvent = processApexEventHeader(eventName, jsonObject);
+ final var apexEvent = processApexEventHeader(eventName, jsonObject);
// Get the event definition for the event from the model service
final AxEvent eventDefinition = ModelService.getModel(AxEvents.class).get(apexEvent.getName(),
@@ -334,7 +333,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
if (fieldValue != null && !fieldValue.isJsonNull()) {
// Get the schema helper
- final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(),
+ final var fieldSchemaHelper = new SchemaHelperFactory().createSchemaHelper(eventField.getKey(),
eventField.getSchema());
apexEvent.put(fieldName, fieldSchemaHelper.createNewInstance(fieldValue));
} else {
@@ -376,7 +375,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
}
// Get the schema helper
- final SchemaHelper fieldSchemaHelper = new SchemaHelperFactory()
+ final var fieldSchemaHelper = new SchemaHelperFactory()
.createSchemaHelper(pojoFieldDefinition.getKey(), pojoFieldDefinition.getSchema());
apexEvent.put(jsonPars.getPojoField(), fieldSchemaHelper.createNewInstance(jsonObject));
}
@@ -429,7 +428,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
* @return the event name to use on the event header
*/
private String getHeaderName(final JsonObject jsonObject, final String parameterEventName) {
- final String jsonEventName = getJsonStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD,
+ final var jsonEventName = getJsonStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD,
jsonPars.getNameAlias(), ApexEvent.NAME_REGEXP, false);
// Check that an event name has been specified
@@ -473,7 +472,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
*/
private String getHeaderNamespace(final JsonObject jsonObject, final String name, final AxEvent eventDefinition) {
// Check the name space is OK if it is defined, if not, use the name space from the model
- String namespace = getJsonStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD,
+ var namespace = getJsonStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD,
jsonPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false);
if (namespace != null) {
if (!namespace.equals(eventDefinition.getNameSpace())) {
@@ -496,7 +495,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
*/
private String getHeaderSource(final JsonObject jsonObject, final AxEvent eventDefinition) {
// For source, use the defined source only if the source is not found on the incoming event
- String source = getJsonStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, jsonPars.getSourceAlias(),
+ var source = getJsonStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, jsonPars.getSourceAlias(),
ApexEvent.SOURCE_REGEXP, false);
if (source == null) {
source = eventDefinition.getSource();
@@ -513,7 +512,7 @@ public class Apex2JsonEventConverter implements ApexEventProtocolConverter {
*/
private String getHeaderTarget(final JsonObject jsonObject, final AxEvent eventDefinition) {
// For target, use the defined source only if the source is not found on the incoming event
- String target = getJsonStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, jsonPars.getTargetAlias(),
+ var target = getJsonStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, jsonPars.getTargetAlias(),
ApexEvent.TARGET_REGEXP, false);
if (target == null) {
target = eventDefinition.getTarget();
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
index 3451c120c..0c4b7b34b 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java
@@ -144,7 +144,7 @@ public class ApexActivator {
private void setUpModelMarshallerAndUnmarshaller(ApexParameters apexParameters) throws ApexException {
AxPolicyModel model;
try {
- final String policyModelString = apexParameters.getEngineServiceParameters().getPolicyModel();
+ final var policyModelString = apexParameters.getEngineServiceParameters().getPolicyModel();
model = EngineServiceImpl.createModel(apexParameters.getEngineServiceParameters().getEngineKey(),
policyModelString);
} catch (ApexException e) {
@@ -206,11 +206,11 @@ public class ApexActivator {
AxContextAlbums existingAlbums, AxTasks existingTasks,
AxPolicies existingPolicies) throws ApexModelException {
- AxContextSchemas axContextSchemas = ModelService.getModel(AxContextSchemas.class);
- AxEvents axEvents = ModelService.getModel(AxEvents.class);
- AxContextAlbums axContextAlbums = ModelService.getModel(AxContextAlbums.class);
- AxTasks axTasks = ModelService.getModel(AxTasks.class);
- AxPolicies axPolicies = ModelService.getModel(AxPolicies.class);
+ var axContextSchemas = ModelService.getModel(AxContextSchemas.class);
+ var axEvents = ModelService.getModel(AxEvents.class);
+ var axContextAlbums = ModelService.getModel(AxContextAlbums.class);
+ var axTasks = ModelService.getModel(AxTasks.class);
+ var axPolicies = ModelService.getModel(AxPolicies.class);
Map<AxArtifactKey, AxContextSchema> newSchemasMap = axContextSchemas.getSchemasMap();
Map<AxArtifactKey, AxEvent> newEventsMap = axEvents.getEventMap();
@@ -218,7 +218,7 @@ public class ApexActivator {
Map<AxArtifactKey, AxTask> newTasksMap = axTasks.getTaskMap();
Map<AxArtifactKey, AxPolicy> newPoliciesMap = axPolicies.getPolicyMap();
- StringBuilder errorMessage = new StringBuilder();
+ var errorMessage = new StringBuilder();
PolicyModelMerger.checkForDuplicateItem(existingSchemas.getSchemasMap(), newSchemasMap, errorMessage, "schema");
PolicyModelMerger.checkForDuplicateItem(existingEvents.getEventMap(), newEventsMap, errorMessage, "event");
PolicyModelMerger.checkForDuplicateItem(existingAlbums.getAlbumsMap(), newAlbumsMap, errorMessage, "album");
@@ -229,7 +229,7 @@ public class ApexActivator {
throw new ApexModelException(errorMessage.toString());
}
- AxKeyInformation axKeyInformation = ModelService.getModel(AxKeyInformation.class);
+ var axKeyInformation = ModelService.getModel(AxKeyInformation.class);
Map<AxArtifactKey, AxKeyInfo> newKeyInfoMap = axKeyInformation.getKeyInfoMap();
// Now add all the concepts that must be copied over
newKeyInfoMap.putAll(existingKeyInformation.getKeyInfoMap());
@@ -248,7 +248,7 @@ public class ApexActivator {
// Apex are
// set up and how they are set up
for (Entry<String, EventHandlerParameters> outputParameters : outputParametersMap.entrySet()) {
- final ApexEventMarshaller marshaller = new ApexEventMarshaller(outputParameters.getKey(),
+ final var marshaller = new ApexEventMarshaller(outputParameters.getKey(),
engineServiceParameters, outputParameters.getValue());
marshaller.init();
apexEngineService.registerActionListener(outputParameters.getKey(), marshaller);
@@ -259,7 +259,7 @@ public class ApexActivator {
// into Apex
// are set up and how they are set up
for (final Entry<String, EventHandlerParameters> inputParameters : inputParametersMap.entrySet()) {
- final ApexEventUnmarshaller unmarshaller = new ApexEventUnmarshaller(inputParameters.getKey(),
+ final var unmarshaller = new ApexEventUnmarshaller(inputParameters.getKey(),
engineServiceParameters, inputParameters.getValue());
unmarshallerMap.put(inputParameters.getKey(), unmarshaller);
unmarshaller.init(engineServiceHandler);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java
index 0d7560f89..9ee091199 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java
@@ -70,7 +70,7 @@ public class ApexCommandLineArguments extends CommandLineArgumentsHandler {
*/
private static Options apexCustomOptions() {
//@formatter:off
- Options options = new Options();
+ var options = new Options();
options.addOption(Option.builder("h")
.longOpt("help")
.desc("outputs the usage of this command")
@@ -203,7 +203,7 @@ public class ApexCommandLineArguments extends CommandLineArgumentsHandler {
* Validate the relative file root.
*/
private void validateRelativeFileRoot() throws ApexException {
- File relativeFileRootPath = new File(relativeFileRoot);
+ var relativeFileRootPath = new File(relativeFileRoot);
if (!relativeFileRootPath.isDirectory()) {
throw new ApexException(RELATIVE_FILE_ROOT + relativeFileRoot + "\" does not exist or is not a directory");
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java
index b071d53dc..08014f92e 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventMarshaller.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -177,7 +178,7 @@ public class ApexEventMarshaller implements ApexEventListener, Runnable {
while (marshallerThread.isAlive() && !stopOrderedFlag) {
try {
// Take the next event from the queue
- final ApexEvent apexEvent = queue.poll(EVENT_QUEUE_POLL_INTERVAL, TimeUnit.MILLISECONDS);
+ final var apexEvent = queue.poll(EVENT_QUEUE_POLL_INTERVAL, TimeUnit.MILLISECONDS);
if (apexEvent == null) {
continue;
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
index d31940aa0..f49115b38 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -213,7 +213,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
final boolean generateExecutionId) throws ApexEventException {
// Push the event onto the queue
if (LOGGER.isTraceEnabled()) {
- String eventString = "onMessage(): event received: " + event.toString();
+ var eventString = "onMessage(): event received: " + event.toString();
LOGGER.trace(eventString);
}
@@ -235,7 +235,7 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
}
// Cache synchronized events that are sent
if (consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) {
- final SynchronousEventCache synchronousEventCache =
+ final var synchronousEventCache =
(SynchronousEventCache) consumer.getPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS);
synchronousEventCache.cacheSynchronizedEventToApex(apexEvent.getExecutionId(), apexEvent);
}
@@ -303,13 +303,13 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
while (unmarshallerThread.isAlive() && !stopOrderedFlag) {
try {
// Take the next event from the queue
- final ApexEvent apexEvent = queue.poll(EVENT_QUEUE_POLL_INTERVAL, TimeUnit.MILLISECONDS);
+ final var apexEvent = queue.poll(EVENT_QUEUE_POLL_INTERVAL, TimeUnit.MILLISECONDS);
if (apexEvent == null) {
continue;
}
if (LOGGER.isTraceEnabled()) {
- String message = apexEvent.toString();
+ var message = apexEvent.toString();
LOGGER.trace("event received {}", message);
}
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
index 80974af31..7adf52311 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexMain.java
@@ -30,7 +30,6 @@ import java.util.Map.Entry;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.Setter;
-import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel;
import org.onap.policy.apex.service.parameters.ApexParameterConstants;
@@ -102,7 +101,7 @@ public class ApexMain {
private ApexParameters populateApexParameters(String[] args) throws ApexException {
// Check the arguments
- final ApexCommandLineArguments arguments = new ApexCommandLineArguments();
+ final var arguments = new ApexCommandLineArguments();
try {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
@@ -163,9 +162,9 @@ public class ApexMain {
}
aggregatedParameters.getEventInputParameters().putAll(apexParameters.getEventInputParameters());
aggregatedParameters.getEventOutputParameters().putAll(apexParameters.getEventOutputParameters());
- EngineParameters aggregatedEngineParameters =
+ var aggregatedEngineParameters =
aggregatedParameters.getEngineServiceParameters().getEngineParameters();
- EngineParameters engineParameters = apexParameters.getEngineServiceParameters().getEngineParameters();
+ var engineParameters = apexParameters.getEngineServiceParameters().getEngineParameters();
aggregatedEngineParameters.getTaskParameters().addAll(engineParameters.getTaskParameters());
aggregatedEngineParameters.getExecutorParameterMap().putAll(engineParameters.getExecutorParameterMap());
aggregatedEngineParameters.getContextParameters().getSchemaParameters().getSchemaHelperParameterMap()
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
index 3deb234c6..22a6a27d5 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications 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");
@@ -112,8 +112,8 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
this.periodicEventPeriod = periodicEventPeriod;
// Start engine workers
- for (int engineCounter = 0; engineCounter < threadCount; engineCounter++) {
- final AxArtifactKey engineWorkerKey = new AxArtifactKey(engineServiceKey.getName() + '-' + engineCounter,
+ for (var engineCounter = 0; engineCounter < threadCount; engineCounter++) {
+ final var engineWorkerKey = new AxArtifactKey(engineServiceKey.getName() + '-' + engineCounter,
engineServiceKey.getVersion());
engineWorkerMap.put(engineWorkerKey, new EngineWorker(engineWorkerKey, queue, atFactory));
LOGGER.info("Created apex engine {} .", engineWorkerKey.getId());
@@ -159,13 +159,13 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
LOGGER.entry(apexEventListener);
if (listenerName == null) {
- String message = "listener name must be specified and may not be null";
+ var message = "listener name must be specified and may not be null";
LOGGER.warn(message);
return;
}
if (apexEventListener == null) {
- String message = "apex event listener must be specified and may not be null";
+ var message = "apex event listener must be specified and may not be null";
LOGGER.warn(message);
return;
}
@@ -346,10 +346,10 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
}
// Update the engines
- boolean isSubsequentInstance = false;
+ var isSubsequentInstance = false;
for (final Entry<AxArtifactKey, EngineWorker> engineWorkerEntry : engineWorkerMap.entrySet()) {
LOGGER.info("Registering apex model on engine {}", engineWorkerEntry.getKey().getId());
- EngineWorker engineWorker = engineWorkerEntry.getValue();
+ var engineWorker = engineWorkerEntry.getValue();
if (isSubsequentInstance) {
// set subsequentInstance flag as true if the current engine worker instance is not the first one
// first engine instance will have this flag as false
@@ -366,7 +366,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
ThreadUtilities.sleep(ENGINE_SERVICE_STOP_START_WAIT_INTERVAL);
}
// Check if all engines are running
- final StringBuilder notRunningEngineIdBuilder = new StringBuilder();
+ final var notRunningEngineIdBuilder = new StringBuilder();
for (final Entry<AxArtifactKey, EngineWorker> engineWorkerEntry : engineWorkerMap.entrySet()) {
if (engineWorkerEntry.getValue().getState() != AxEngineState.READY
&& engineWorkerEntry.getValue().getState() != AxEngineState.EXECUTING) {
@@ -377,7 +377,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
}
}
if (notRunningEngineIdBuilder.length() > 0) {
- final String errorString = "engine start error on model update on engine service with key "
+ final var errorString = "engine start error on model update on engine service with key "
+ incomingEngineServiceKey.getId() + ", engines not running are: "
+ notRunningEngineIdBuilder.toString().trim();
LOGGER.warn(errorString);
@@ -398,7 +398,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
ThreadUtilities.sleep(ENGINE_SERVICE_STOP_START_WAIT_INTERVAL);
}
// Check if all engines are stopped
- final StringBuilder notStoppedEngineIdBuilder = new StringBuilder();
+ final var notStoppedEngineIdBuilder = new StringBuilder();
for (final Entry<AxArtifactKey, EngineWorker> engineWorkerEntry : engineWorkerMap.entrySet()) {
if (engineWorkerEntry.getValue().getState() != AxEngineState.STOPPED) {
notStoppedEngineIdBuilder.append(engineWorkerEntry.getKey().getId());
@@ -408,7 +408,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven
}
}
if (notStoppedEngineIdBuilder.length() > 0) {
- final String errorString = "cannot update model on engine service with key "
+ final var errorString = "cannot update model on engine service with key "
+ incomingEngineServiceKey.getId() + ", engines not stopped after " + MAX_STOP_WAIT_TIME
+ "ms are: " + notStoppedEngineIdBuilder.toString().trim();
LOGGER.warn(errorString);
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
index 0a317d600..cc19080f9 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications 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.
* ================================================================================
@@ -23,7 +23,6 @@
package org.onap.policy.apex.service.parameters;
-import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -81,7 +80,7 @@ public class ApexParameterHandler {
parseConfigAndModel(toscaPolicyFilePath);
// Register the adapters for our carrier technologies and event protocols with GSON
// @formatter:off
- final Gson gson = new GsonBuilder()
+ final var gson = new GsonBuilder()
.registerTypeAdapter(EngineParameters.class,
new EngineServiceParametersJsonAdapter())
.registerTypeAdapter(CarrierTechnologyParameters.class,
@@ -148,10 +147,10 @@ public class ApexParameterHandler {
private void parseConfigAndModel(final String toscaPolicyFilePath) throws ApexException {
policyModel = null;
apexConfig = null;
- final StandardCoder standardCoder = new StandardCoder();
- JsonObject apexConfigJsonObject = new JsonObject();
+ final var standardCoder = new StandardCoder();
+ var apexConfigJsonObject = new JsonObject();
try {
- ToscaServiceTemplate toscaServiceTemplate = standardCoder
+ var toscaServiceTemplate = standardCoder
.decode(Files.readString(Paths.get(toscaPolicyFilePath)), ToscaServiceTemplate.class);
for (Entry<String, Object> property : toscaServiceTemplate.getToscaTopologyTemplate().getPolicies().get(0)
.entrySet().iterator().next().getValue().getProperties().entrySet()) {
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
index 1302661b9..90c5f43ae 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -140,12 +141,12 @@ public class ApexParameters implements ParameterGroup {
return null;
}
- BeanValidationResult result = new BeanValidationResult(JAVA_PROPERTIES, javaProperties);
- int item = 0;
+ var result = new BeanValidationResult(JAVA_PROPERTIES, javaProperties);
+ var item = 0;
for (String[] javaProperty : javaProperties) {
final String label = "entry " + (item++);
final List<String> value = (javaProperty == null ? null : Arrays.asList(javaProperty));
- BeanValidationResult result2 = new BeanValidationResult(label, value);
+ var result2 = new BeanValidationResult(label, value);
if (javaProperty == null) {
// note: add to result, not result2