diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2019-08-08 11:57:01 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-08 11:57:01 +0000 |
commit | f697af873b2ced50e2f23a2170a1d1889f0b6ab1 (patch) | |
tree | 156bbe647939766e9700be9d9ec3e2e7aa04a368 /bpmn/so-bpmn-building-blocks/src | |
parent | 9848e069a23396a67631df71270fa5c51f9c1afb (diff) | |
parent | 1b6cf61e10678539215aa95247ac59a7ab7143eb (diff) |
Merge "Added null check for listFiles() result to prevent crash at iterating through file list; replaced System.out.println calls with logger calls"
Diffstat (limited to 'bpmn/so-bpmn-building-blocks/src')
-rw-r--r-- | bpmn/so-bpmn-building-blocks/src/main/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecs.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/main/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecs.java b/bpmn/so-bpmn-building-blocks/src/main/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecs.java index e4f1998c40..12f30cfa58 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecs.java +++ b/bpmn/so-bpmn-building-blocks/src/main/java/org/onap/so/bpmn/infrastructure/bpmn/activity/DeployActivitySpecs.java @@ -31,6 +31,8 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.stereotype.Component; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Component public class DeployActivitySpecs { @@ -38,10 +40,12 @@ public class DeployActivitySpecs { private static final String ACTIVITY_SPEC_URI = "/activityspec-api/v1.0/activity-spec"; private static final String CONTENT_TYPE_JSON = "application/json"; + private static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class); + public static void main(String[] args) throws Exception { if (args == null || args.length == 0) { - System.out.println("Please specify hostname argument"); + logger.info("Please specify hostname argument"); return; } @@ -49,20 +53,23 @@ public class DeployActivitySpecs { File dir = new File(ACTIVITY_FILE_LOCATION); if (!dir.isDirectory()) { - System.out.println("ActivitySpec store is not a directory"); + logger.debug("ActivitySpec store is not a directory"); return; } - for (File f : dir.listFiles()) { - String activitySpecName = f.getName(); - String errorMessage = deployActivitySpec(hostname, activitySpecName); - if (errorMessage == null) { - System.out.println("Deployed Activity Spec: " + activitySpecName); - } else { - System.out.println("Error deploying Activity Spec: " + activitySpecName + " : " + errorMessage); + if (dir.listFiles() != null) { + for (File f : dir.listFiles()) { + String activitySpecName = f.getName(); + String errorMessage = deployActivitySpec(hostname, activitySpecName); + if (errorMessage == null) { + logger.debug("Deployed Activity Spec: " + activitySpecName); + } else { + logger.error("Error deploying Activity Spec: " + activitySpecName + " : " + errorMessage); + } } + } else { + logger.error("Null file list for Activity Specs."); } - return; } protected static String deployActivitySpec(String hostname, String activitySpecName) throws Exception { |