aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2018-07-25 16:45:20 +0900
committerTal Gitelman <tg851x@intl.att.com>2018-08-05 10:50:55 +0000
commitd05277df22ddde79458cd853f98e7ab3a4d98913 (patch)
treee910c585a48f1f70e95f759a221fa8868f72075a /asdctool/src/main/java/org/openecomp
parent517d06a213dd00f919c17d023718ed2d85d424bc (diff)
Fix sonar issues
Fix try-with-resources and NPE issue Issue-ID: SDC-1529 Change-Id: Ia1071608528493e0a1a2985c458998d1197a8c0b Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'asdctool/src/main/java/org/openecomp')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java25
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java37
2 files changed, 27 insertions, 35 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
index 863f920b47..e533c31082 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/GraphMLDataAnalyzer.java
@@ -53,30 +53,31 @@ public class GraphMLDataAnalyzer {
try {
String mlFileLocation = args[0];
result = _analyzeGraphMLData(mlFileLocation);
- System.out.println("Analyzed ML file=" + mlFileLocation + ", XLS result=" + result);
+ log.info("Analyzed ML file=" + mlFileLocation + ", XLS result=" + result);
} catch (Exception e) {
- log.info("analyze GraphML Data failed - {}" , e);
+ log.error("analyze GraphML Data failed - {}" , e);
return null;
}
return result;
}
private String _analyzeGraphMLData(String mlFileLocation) throws Exception {
-
// Parse ML file
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File(mlFileLocation);
Document document = (Document) builder.build(xmlFile);
-
+
// XLS data file name
String outputFile = mlFileLocation.replace(".graphml", ".xls");
Workbook wb = new HSSFWorkbook();
- FileOutputStream fileOut = new FileOutputStream(outputFile);
- writeComponents(wb, document);
- writeComponentInstances(wb, document);
- wb.write(fileOut);
- fileOut.close();
- return outputFile;
+ try(FileOutputStream fileOut = new FileOutputStream(outputFile)){
+ writeComponents(wb, document);
+ writeComponentInstances(wb, document);
+ wb.write(fileOut);
+ }catch(Exception e){
+ log.error("analyze GraphML Data failed - {}" , e);
+ }
+ return outputFile;
}
private void writeComponents(Workbook wb, Document document) {
@@ -132,13 +133,11 @@ public class GraphMLDataAnalyzer {
IteratorIterable<Element> dataNodes = edge.getDescendants(filter);
for (Element data : dataNodes) {
String attributeValue = data.getAttributeValue("key");
- switch (attributeValue) {
- case "labelE":
+ if( attributeValue.equals("labelE")) {
String edgeLabel = data.getText();
if (edgeLabel.equals("REQUIREMENT") || edgeLabel.equals("CAPABILITY")) {
componentsHavingReqOrCap.add(edge.getAttributeValue("source"));
}
- break;
}
}
}
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java
index 5546300740..4bc21b38ca 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/RemoveUtils.java
@@ -31,31 +31,24 @@ public class RemoveUtils {
if (args == null || args.length < 1) {
removeUsage();
- }
-
- String operation = args[0];
-
- switch (operation.toLowerCase()) {
-
- case "remove-products":
-
- boolean isValid = verifyParamsLength(args, 5);
- if (false == isValid) {
+ }else {
+ String operation = args[0];
+ if(operation.equalsIgnoreCase("remove-products")) {
+ boolean isValid = verifyParamsLength(args, 5);
+ if (!isValid) {
+ removeUsage();
+ System.exit(1);
+ }
+ ProductLogic productLogic = new ProductLogic();
+ boolean result = productLogic.deleteAllProducts(args[1], args[2], args[3], args[4]);
+
+ if (!result) {
+ System.exit(2);
+ }
+ }else {
removeUsage();
- System.exit(1);
}
-
- ProductLogic productLogic = new ProductLogic();
- boolean result = productLogic.deleteAllProducts(args[1], args[2], args[3], args[4]);
-
- if (result == false) {
- System.exit(2);
- }
- break;
- default:
- removeUsage();
}
-
}
private static void removeUsage() {