diff options
author | Jim Hahn <jrh3@att.com> | 2021-05-06 16:39:17 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-05-06 16:48:30 -0400 |
commit | 8cd519ee397bd6661eddfeea1b989a99d1caac2e (patch) | |
tree | 0770d461c5afd76ecf7e603885cb7f2e936c654c | |
parent | a05cc62b6426d31c23f60dbe4a6f367331431ea4 (diff) |
Fix sonars in policy-distribution
Fixed:
- use "var" instead of actual type
Issue-ID: POLICY-3285
Change-Id: I0dba2f96870722b4071ac0085287bc91a27dde88
Signed-off-by: Jim Hahn <jrh3@att.com>
15 files changed, 52 insertions, 53 deletions
diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java index 7807dcc1..f8eb2758 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java +++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/DistributionParameterHandler.java @@ -22,7 +22,6 @@ package org.onap.policy.distribution.main.parameters; -import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.FileReader; import org.onap.policy.common.parameters.ValidationResult; @@ -55,7 +54,7 @@ public class DistributionParameterHandler { // Read the parameters try { // Read the parameters from JSON using Gson - final Gson gson = new GsonBuilder() + final var gson = new GsonBuilder() .registerTypeAdapter(PolicyForwarderConfigurationParameterGroup.class, new PolicyForwarderConfigurationParametersJsonAdapter()) .registerTypeAdapter(ReceptionHandlerConfigurationParameterGroup.class, diff --git a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java index 3370a95f..b171ce3a 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java +++ b/main/src/main/java/org/onap/policy/distribution/main/parameters/PolicyForwarderConfigurationParametersJsonAdapter.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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. @@ -45,7 +45,7 @@ public class PolicyForwarderConfigurationParametersJsonAdapter @Override public PolicyForwarderConfigurationParameterGroup deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) { - final JsonObject jsonObject = json.getAsJsonObject(); + final var jsonObject = json.getAsJsonObject(); final String policyForwarderParameterClassName = getParameterGroupClassName(jsonObject); final Class<?> policyForwarderParameterClass = getParameterGroupClass(policyForwarderParameterClassName); @@ -54,7 +54,7 @@ public class PolicyForwarderConfigurationParametersJsonAdapter } private String getParameterGroupClassName(final JsonObject jsonObject) { - final JsonPrimitive classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME)); + final var classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME)); if (classNameJsonPrimitive == null || classNameJsonPrimitive.getAsString().length() == 0) { final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \"" diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java index 2fe46b22..e4ebffef 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java +++ b/main/src/main/java/org/onap/policy/distribution/main/rest/HealthCheckProvider.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 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. @@ -43,7 +44,7 @@ public class HealthCheckProvider { * @return Report containing health check status */ public HealthCheckReport performHealthCheck() { - final HealthCheckReport report = new HealthCheckReport(); + final var report = new HealthCheckReport(); report.setName(NAME); report.setUrl(URL); report.setHealthy(DistributionActivator.isAlive()); diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java index 7532ac61..426436fb 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java +++ b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsProvider.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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. @@ -36,7 +37,7 @@ public class StatisticsProvider { * @return Report containing statistics of distribution service */ public StatisticsReport fetchCurrentStatistics() { - final StatisticsReport report = new StatisticsReport(); + final var report = new StatisticsReport(); report.setCode(DistributionActivator.isAlive() ? 200 : 500); report.setTotalDistributionCount(DistributionStatisticsManager.getTotalDistributionCount()); report.setDistributionSuccessCount(DistributionStatisticsManager.getDistributionSuccessCount()); diff --git a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java index 4cbbcd70..8b275501 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java +++ b/main/src/main/java/org/onap/policy/distribution/main/rest/StatisticsReport.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 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. @@ -167,7 +168,7 @@ public class StatisticsReport { */ @Override public String toString() { - final StringBuilder builder = new StringBuilder(); + final var builder = new StringBuilder(); builder.append("StatisticsReport [code="); builder.append(getCode()); builder.append(", totalDistributionCount="); diff --git a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java index 83eee73c..64215e82 100644 --- a/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java +++ b/main/src/main/java/org/onap/policy/distribution/main/startstop/Main.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ @@ -54,11 +54,11 @@ public class Main { * @param args the command line arguments */ public Main(final String[] args) { - final String argumentString = Arrays.toString(args); + final var argumentString = Arrays.toString(args); LOGGER.info("Starting policy distribution service with arguments - {}", argumentString); // Check the arguments - final DistributionCommandLineArguments arguments = new DistributionCommandLineArguments(); + final var arguments = new DistributionCommandLineArguments(); try { // The arguments return a string if there is a message to print and we should exit final String argumentMessage = arguments.parse(args); @@ -85,7 +85,7 @@ public class Main { // Add a shutdown hook to shut everything down in an orderly manner Runtime.getRuntime().addShutdownHook(new PolicyDistributionShutdownHookClass()); - String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_DISTRIBUTION); + var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_DISTRIBUTION); LOGGER.info(successMsg); } diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java index 59d3efc8..b50d6ff3 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Intel Crop. All rights reserved. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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,12 +21,10 @@ package org.onap.policy.distribution.forwarding.file; -import java.io.BufferedWriter; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.InvalidPathException; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; import org.onap.policy.common.parameters.ParameterService; @@ -53,7 +51,7 @@ public class FilePolicyForwarder implements PolicyForwarder { public void configure(final String parameterGroupName) { fileForwarderParameters = ParameterService.get(parameterGroupName); try { - final Path path = Paths.get(fileForwarderParameters.getPath()); + final var path = Paths.get(fileForwarderParameters.getPath()); if (!path.toFile().exists()) { Files.createDirectories(path); } @@ -87,8 +85,8 @@ public class FilePolicyForwarder implements PolicyForwarder { */ private void forwardPolicy(final ToscaPolicy pol) throws PolicyForwardingException { final String name = pol.getName(); - final Path path = Paths.get(fileForwarderParameters.getPath(), name); - try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) { + final var path = Paths.get(fileForwarderParameters.getPath(), name); + try (var writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) { writer.write("policyName: " + name); if (fileForwarderParameters.isVerbose()) { writer.newLine(); diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java index d45b07f6..b6f41fbf 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020-2021 AT&T Inc. + * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2021 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.policy.distribution.forwarding.lifecycle.api; -import com.google.common.collect.ImmutableMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -87,7 +86,7 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder { Response policyCreated = null; try { if (entity instanceof ToscaServiceTemplate) { - final ToscaServiceTemplate toscaServiceTemplate = (ToscaServiceTemplate) entity; + final var toscaServiceTemplate = (ToscaServiceTemplate) entity; if (null != toscaServiceTemplate.getPolicyTypes() && !toscaServiceTemplate.getPolicyTypes().isEmpty()) { createPolicyType(toscaServiceTemplate); } @@ -123,13 +122,13 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder { } private Response deployPolicy(final ToscaServiceTemplate toscaServiceTemplate) throws PolicyForwardingException { - final PdpDeployPolicies pdpPolicies = new PdpDeployPolicies(); + final var pdpPolicies = new PdpDeployPolicies(); final List<ToscaConceptIdentifierOptVersion> policyIdentifierList = new ArrayList<>(); for (final Map<String, ToscaPolicy> policyMap : toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()) { final String policyId = policyMap.entrySet().iterator().next().getValue().getMetadata().get("policy-id"); final String policyVersion = policyMap.entrySet().iterator().next().getValue().getMetadata().get("policy-version"); - final ToscaConceptIdentifierOptVersion toscaPolicyIdentifier = + final var toscaPolicyIdentifier = new ToscaConceptIdentifierOptVersion(policyId, policyVersion); policyIdentifierList.add(toscaPolicyIdentifier); } @@ -141,7 +140,7 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder { throws PolicyForwardingException { Response response = null; try { - response = getHttpClient(wantApi).post(path, entity, ImmutableMap.of(HttpHeaders.ACCEPT, + response = getHttpClient(wantApi).post(path, entity, Map.of(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)); if (response.getStatus() / 100 != 2) { LOGGER.error( diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java index 4703725d..af30c1f1 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020-2021 AT&T Inc. + * Modifications Copyright (C) 2020-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. @@ -74,7 +74,7 @@ public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder<Csar, Tosc public Collection<ToscaEntity> decode(final Csar csar) throws PolicyDecodingException { final Collection<ToscaEntity> policyList = new ArrayList<>(); - try (ZipFile zipFile = new ZipFile(csar.getCsarPath())) { + try (var zipFile = new ZipFile(csar.getCsarPath())) { final Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { // @@ -121,7 +121,7 @@ public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder<Csar, Tosc // // Now ensure that there is no path injection // - Path path = Path.of(csarPath, entryName).normalize(); + var path = Path.of(csarPath, entryName).normalize(); // // Throw an exception if path is outside the csar // diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java index d405f0ad..be27657c 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Intel Corp. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2019 AT&T Intellectual Property. + * Modifications Copyright (C) 2019, 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. @@ -61,9 +61,9 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { try { final FileSystemReceptionHandlerConfigurationParameterGroup handlerParameters = ParameterService.get(parameterGroupName); - final FileClientHandler fileClientHandler = + final var fileClientHandler = new FileClientHandler(this, handlerParameters.getWatchPath(), handlerParameters.getMaxThread()); - final Thread fileWatcherThread = new Thread(fileClientHandler); + final var fileWatcherThread = new Thread(fileClientHandler); fileWatcherThread.start(); } catch (final Exception ex) { LOGGER.error("FileSystemReceptionHandler initialization failed", ex); @@ -93,8 +93,8 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { * @param watchPath Path to watch */ public void initFileWatcher(final String watchPath, final int maxThread) throws IOException { - try (final WatchService watcher = FileSystems.getDefault().newWatchService()) { - final Path dir = Paths.get(watchPath); + try (final var watcher = FileSystems.getDefault().newWatchService()) { + final var dir = Paths.get(watchPath); dir.register(watcher, ENTRY_CREATE); LOGGER.debug("Watch Service registered for dir: {}", dir.getFileName()); startWatchService(watcher, dir, maxThread); @@ -161,7 +161,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { */ protected void createPolicyInputAndCallHandler(final String fileName) { try { - final Csar csarObject = new Csar(fileName); + final var csarObject = new Csar(fileName); DistributionStatisticsManager.updateTotalDownloadCount(); inputReceived(csarObject); DistributionStatisticsManager.updateDownloadSuccessCount(); @@ -174,10 +174,10 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler { } private void waitForFileToBeReady(final String fullFilePath) throws InterruptedException { - boolean flag = true; + var flag = true; while (flag) { TimeUnit.MILLISECONDS.sleep(100); - try (ZipFile zipFile = new ZipFile(fullFilePath)) { + try (var zipFile = new ZipFile(fullFilePath)) { flag = false; } catch (final IOException exp) { LOGGER.error("file is not ready for reading, wait for sometime and try again", exp); diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java index df968f99..23fbca59 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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. @@ -192,14 +192,14 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo * @param notificationData the notification from SDC */ public void processCsarServiceArtifacts(final INotificationData notificationData) { - boolean artifactsProcessedSuccessfully = true; + var artifactsProcessedSuccessfully = true; DistributionStatisticsManager.updateTotalDistributionCount(); for (final IArtifactInfo artifact : notificationData.getServiceArtifacts()) { try { final IDistributionClientDownloadResult resultArtifact = downloadTheArtifact(artifact, notificationData); - final Path filePath = writeArtifactToFile(artifact, resultArtifact); - final Csar csarObject = new Csar(filePath.toString()); + final var filePath = writeArtifactToFile(artifact, resultArtifact); + final var csarObject = new Csar(filePath.toString()); inputReceived(csarObject); sendDistributionStatus(DistributionStatusType.DEPLOY, artifact.getArtifactURL(), notificationData.getDistributionID(), DistributionStatusEnum.DEPLOY_OK, null); @@ -262,8 +262,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo final IDistributionClientDownloadResult resultArtifact) throws ArtifactDownloadException { try { final byte[] payloadBytes = resultArtifact.getArtifactPayload(); - final File tempArtifactFile = File.createTempFile(artifact.getArtifactName(), ".csar"); - try (FileOutputStream fileOutputStream = new FileOutputStream(tempArtifactFile)) { + final var tempArtifactFile = File.createTempFile(artifact.getArtifactName(), ".csar"); + try (var fileOutputStream = new FileOutputStream(tempArtifactFile)) { fileOutputStream.write(payloadBytes, 0, payloadBytes.length); return tempArtifactFile.toPath(); } @@ -315,7 +315,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo clientResult = distributionClient.sendDeploymentStatus(message); } } - final StringBuilder loggerMessage = new StringBuilder(); + final var loggerMessage = new StringBuilder(); loggerMessage.append("distribution status to SDC with values - ").append("DistributionId") .append(distributionId).append(" Artifact: ").append(artifactUrl).append(" StatusType: ") .append(statusType.name()).append(" Status: ").append(status.name()); @@ -351,7 +351,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo clientResult = distributionClient.sendComponentDoneStatus(message, errorReason); } - final StringBuilder loggerMessage = new StringBuilder(); + final var loggerMessage = new StringBuilder(); loggerMessage.append("component done status to SDC with values - ").append("DistributionId") .append(distributionId).append(" Status: ").append(status.name()); if (errorReason != null) { diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java index ca15bfb3..8ad293c3 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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,7 +52,7 @@ public abstract class AbstractReceptionHandler implements ReceptionHandler { */ @Override public void initialize(final String parameterGroupName) throws PluginInitializationException { - final ReceptionHandlerParameters receptionHandlerParameters = ParameterService.get(parameterGroupName); + final var receptionHandlerParameters = (ReceptionHandlerParameters) ParameterService.get(parameterGroupName); pluginHandler = new PluginHandler(receptionHandlerParameters.getPluginHandlerParameters().getName()); initializeReception(receptionHandlerParameters.getReceptionHandlerConfigurationName()); } diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java index 95767a42..c2ea8009 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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. @@ -115,7 +115,7 @@ public class PluginHandler { try { final Class<PolicyForwarder> policyForwarderClass = (Class<PolicyForwarder>) Class.forName(forwarderParameters.getForwarderClassName()); - final PolicyForwarder policyForwarder = policyForwarderClass.getDeclaredConstructor().newInstance(); + final var policyForwarder = policyForwarderClass.getDeclaredConstructor().newInstance(); policyForwarder.configure(forwarderParameters.getForwarderConfigurationName()); policyForwarders.add(policyForwarder); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java index 64ffa135..aedf357e 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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. @@ -46,7 +46,7 @@ public class PolicyDecoderConfigurationParametersJsonAdapter @Override public PolicyDecoderConfigurationParameterGroup deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) { - final JsonObject jsonObject = json.getAsJsonObject(); + final var jsonObject = json.getAsJsonObject(); final String policyDecoderParameterClassName = getParameterGroupClassName(jsonObject); final Class<?> policyDecoderParameterClass = getParameterGroupClass(policyDecoderParameterClassName); @@ -55,7 +55,7 @@ public class PolicyDecoderConfigurationParametersJsonAdapter } private String getParameterGroupClassName(final JsonObject jsonObject) { - final JsonPrimitive classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME)); + final var classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME)); if (classNameJsonPrimitive == null || classNameJsonPrimitive.getAsString().length() == 0) { final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \"" diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java index 6cdbf28b..bc2e0e0c 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Copyright (C) 2019 Nordix Foundation. - * Modifications Copyright (C) 2020 AT&T Inc. + * Modifications Copyright (C) 2020-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. @@ -45,7 +45,7 @@ public class ReceptionHandlerConfigurationParametersJsonAdapter @Override public ReceptionHandlerConfigurationParameterGroup deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) { - final JsonObject jsonObject = json.getAsJsonObject(); + final var jsonObject = json.getAsJsonObject(); final String receptionHandlerParameterClassName = getParameterGroupClassName(jsonObject); final Class<?> receptionHandlerParameterClass = getParameterGroupClass(receptionHandlerParameterClassName); @@ -54,7 +54,7 @@ public class ReceptionHandlerConfigurationParametersJsonAdapter } private String getParameterGroupClassName(final JsonObject jsonObject) { - final JsonPrimitive classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME)); + final var classNameJsonPrimitive = ((JsonPrimitive) jsonObject.get(PARAMETER_CLASS_NAME)); if (classNameJsonPrimitive == null || classNameJsonPrimitive.getAsString().length() == 0) { final String errorMessage = "parameter \"" + PARAMETER_CLASS_NAME + "\" value \"" |