aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-05-06 16:39:17 -0400
committerJim Hahn <jrh3@att.com>2021-05-06 16:48:30 -0400
commit8cd519ee397bd6661eddfeea1b989a99d1caac2e (patch)
tree0770d461c5afd76ecf7e603885cb7f2e936c654c /plugins/reception-plugins/src/main
parenta05cc62b6426d31c23f60dbe4a6f367331431ea4 (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>
Diffstat (limited to 'plugins/reception-plugins/src/main')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java6
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java16
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java16
3 files changed, 19 insertions, 19 deletions
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) {