diff options
author | Eliezio Oliveira <eliezio.oliveira@est.tech> | 2019-07-13 19:33:24 +0100 |
---|---|---|
committer | Eliezio Oliveira <eliezio.oliveira@est.tech> | 2019-07-13 19:34:58 +0100 |
commit | c15af9a019ae786bc6970fa1184361c1be96693a (patch) | |
tree | c81b3f44e19927c1d079a1f911f47710cb4a1856 /ms | |
parent | 7d58591a2dd41b9e2655f5d06a1eb344146d8e76 (diff) |
Fixed bugs/vulnerabilities reported by SonarQube
Change-Id: Idc4be0d050d27fd419915210167b044b90fa2f0a
Issue-ID: CCSDK-1483
Signed-off-by: Eliezio Oliveira <eliezio.oliveira@est.tech>
Diffstat (limited to 'ms')
6 files changed, 55 insertions, 24 deletions
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<ContextRefreshed log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort()); server.awaitTermination(); } catch (Exception e) { - e.printStackTrace(); + log.error("*** Error ***", e); } } } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java index 60837e8a7..331a44d83 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -79,7 +79,7 @@ public class ApplicationLoggingFilter implements WebFilter { header.add(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]); header.add(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion); } catch (Exception e) { - e.printStackTrace(); + log.error("*** Error ***", e); } return webFilterChain.filter(serverWebExchange); diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SwaggerGenerator.java index abf774981..38216a616 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SwaggerGenerator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SwaggerGenerator.java @@ -155,19 +155,16 @@ public class SwaggerGenerator { defProperty = new StringProperty(); } } else if (BluePrintTypes.validCollectionTypes().contains(propertyDefinition.getType())) { - ArrayProperty arrayProperty = new ArrayProperty(); + Optional<Property> 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(); } |