Fixed bugs/vulnerabilities reported by SonarQube
Change-Id: Idc4be0d050d27fd419915210167b044b90fa2f0a
Issue-ID: CCSDK-1483
Signed-off-by: Eliezio Oliveira <eliezio.oliveira@est.tech>
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 16eb418..6bb6a26 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 @@
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 60837e8..331a44d 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 @@
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 abf7749..38216a6 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 @@
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 148d0c0..77f3ea5 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 @@
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 7a95969..4f31003 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 @@
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 @@
@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 446fdc0..a8e60c2 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 @@
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();
}