Fixed bugs/vulnerabilities reported by SonarQube 07/91407/1
authorEliezio Oliveira <eliezio.oliveira@est.tech>
Sat, 13 Jul 2019 18:33:24 +0000 (19:33 +0100)
committerEliezio Oliveira <eliezio.oliveira@est.tech>
Sat, 13 Jul 2019 18:34:58 +0000 (19:34 +0100)
Change-Id: Idc4be0d050d27fd419915210167b044b90fa2f0a
Issue-ID: CCSDK-1483
Signed-off-by: Eliezio Oliveira <eliezio.oliveira@est.tech>
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintGRPCServer.java
ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/cds/controllerblueprints/filters/ApplicationLoggingFilter.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/cds/controllerblueprints/service/common/SwaggerGenerator.java
ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java
ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/ComponentStatusMessage.java
ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/status/SdcListenerStatus.java

index 16eb418..6bb6a26 100644 (file)
@@ -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);
         }
     }
 }
index 60837e8..331a44d 100644 (file)
@@ -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);
index abf7749..38216a6 100644 (file)
@@ -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());
         }
index 148d0c0..77f3ea5 100644 (file)
@@ -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);
         }
index 7a95969..4f31003 100644 (file)
@@ -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;
+    }
 }
index 446fdc0..a8e60c2 100644 (file)
@@ -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();
     }