From c15af9a019ae786bc6970fa1184361c1be96693a Mon Sep 17 00:00:00 2001 From: Eliezio Oliveira Date: Sat, 13 Jul 2019 19:33:24 +0100 Subject: Fixed bugs/vulnerabilities reported by SonarQube Change-Id: Idc4be0d050d27fd419915210167b044b90fa2f0a Issue-ID: CCSDK-1483 Signed-off-by: Eliezio Oliveira --- .../blueprintsprocessor/BlueprintGRPCServer.java | 2 +- .../filters/ApplicationLoggingFilter.java | 2 +- .../service/common/SwaggerGenerator.java | 13 +++--- .../sdclistener/service/ListenerServiceImpl.java | 4 +- .../sdclistener/status/ComponentStatusMessage.java | 46 ++++++++++++++++++---- .../cds/sdclistener/status/SdcListenerStatus.java | 12 +++--- 6 files changed, 55 insertions(+), 24 deletions(-) (limited to 'ms') diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java index 16eb4182e..6bb6a2697 100644 --- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java +++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java @@ -61,7 +61,7 @@ public class BlueprintGRPCServer implements ApplicationListener innerType = Optional.empty(); if (propertyDefinition.getEntrySchema() != null) { String entrySchema = propertyDefinition.getEntrySchema().getType(); if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema)) { - Property innerType = new RefProperty("#/definitions/" + entrySchema); - arrayProperty.setItems(innerType); - } else { - Property innerType = new StringProperty(); - arrayProperty.setItems(innerType); + innerType = Optional.of(new RefProperty("#/definitions/" + entrySchema)); } - defProperty = arrayProperty; } - + ArrayProperty arrayProperty = new ArrayProperty(); + arrayProperty.setItems(innerType.orElseGet(StringProperty::new)); + defProperty = arrayProperty; } else { defProperty = new RefProperty("#/definitions/" + propertyDefinition.getType()); } diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java index 148d0c028..77f3ea536 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java @@ -119,7 +119,9 @@ public class ListenerServiceImpl implements ListenerService { File targetZipFile = new File(targetLocation.toString()); try { - targetZipFile.createNewFile(); + if (! targetZipFile.createNewFile()) { + LOGGER.warn("Overwriting zip file {}", targetLocation); + } } catch (IOException e) { LOGGER.error("Could not able to create file {}", targetZipFile, e); } diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java index 7a959692a..4f31003b0 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java @@ -21,17 +21,17 @@ import org.onap.sdc.utils.DistributionStatusEnum; public class ComponentStatusMessage implements IComponentDoneStatusMessage, IDistributionStatusMessage { - public String componentName; + private String componentName; - public String consumerID; + private String consumerID; - public String distributionID; + private String distributionID; - public DistributionStatusEnum status; + private DistributionStatusEnum status; - public long timeStamp; + private long timeStamp; - public String artifactUrl; + private String artifactUrl; @Override public String getDistributionID() { @@ -55,11 +55,43 @@ public class ComponentStatusMessage implements IComponentDoneStatusMessage, IDi @Override public String getArtifactURL() { - return artifactUrl; + return getArtifactUrl(); } @Override public long getTimestamp() { + return getTimeStamp(); + } + + public void setComponentName(String componentName) { + this.componentName = componentName; + } + + public void setConsumerID(String consumerID) { + this.consumerID = consumerID; + } + + public void setDistributionID(String distributionID) { + this.distributionID = distributionID; + } + + public void setStatus(DistributionStatusEnum status) { + this.status = status; + } + + public long getTimeStamp() { return timeStamp; } + + public void setTimeStamp(long timeStamp) { + this.timeStamp = timeStamp; + } + + public String getArtifactUrl() { + return artifactUrl; + } + + public void setArtifactUrl(String artifactUrl) { + this.artifactUrl = artifactUrl; + } } diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java index 446fdc068..a8e60c29a 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java @@ -93,12 +93,12 @@ public class SdcListenerStatus { private ComponentStatusMessage buildStatusMessage(String distributionId, DistributionStatusEnum status, String url, String componentName) { return new BuilderUtil<>(new ComponentStatusMessage()).build(builder -> { - builder.distributionID = distributionId; - builder.status = status; - builder.consumerID = consumerId; - builder.componentName = componentName; - builder.timeStamp = System.currentTimeMillis(); - builder.artifactUrl = url; + builder.setDistributionID(distributionId); + builder.setStatus(status); + builder.setConsumerID(consumerId); + builder.setComponentName(componentName); + builder.setTimeStamp(System.currentTimeMillis()); + builder.setArtifactUrl(url); }).create(); } -- cgit 1.2.3-korg