From 0c08b7789b4b36b16b97814d0e5dfc56ef74a0c7 Mon Sep 17 00:00:00 2001 From: seshukm Date: Mon, 18 Sep 2017 13:00:32 +0530 Subject: Fixed issues in bpmn package. Issue-Id: SO-141 Change-Id: Ie08e5a03f1448071ce0d31ca0829b28d791c05fd Signed-off-by: seshukm --- .../openecomp/mso/bpmn/core/CamundaDBSetup.java | 11 +++++++++-- .../mso/bpmn/core/PropertyConfiguration.java | 22 +++++++++++----------- .../openecomp/mso/bpmn/core/ReadConfigTask.java | 3 ++- .../org/openecomp/mso/bpmn/core/ReadFileTask.java | 5 +++-- .../openecomp/mso/bpmn/core/XQueryScriptTask.java | 7 ++++--- .../openecomp/mso/bpmn/core/json/JsonUtils.java | 20 +++++++++----------- .../org/openecomp/mso/bpmn/core/xml/XmlTool.java | 15 ++++++++------- 7 files changed, 46 insertions(+), 37 deletions(-) (limited to 'bpmn/MSOCoreBPMN') diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java index 74bb59c908..d505210abd 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/CamundaDBSetup.java @@ -13,12 +13,19 @@ import org.openecomp.mso.logger.MsoLogger; public class CamundaDBSetup { private static boolean isDBConfigured = false; private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); + + private CamundaDBSetup() { + /** + * Constructor. + */ + } + public static synchronized void configure() throws SQLException { if (isDBConfigured) { return; } - System.out.println("Configuring the Camunda H2 database for MSO"); + LOGGER.debug ("Configuring the Camunda H2 database for MSO"); Connection connection = null; PreparedStatement stmt = null; @@ -67,7 +74,7 @@ public class CamundaDBSetup { isDBConfigured = true; } catch (SQLException e) { - System.out.println("CamundaDBSetup caught " + e.getClass().getSimpleName()); + LOGGER.debug ("CamundaDBSetup caught " + e.getClass().getSimpleName()); LOGGER.debug("SQLException :",e); } finally { if (stmt != null) { diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java index 70f67a5a77..4e67bd171d 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/PropertyConfiguration.java @@ -85,14 +85,21 @@ public class PropertyConfiguration { private volatile String msoConfigPath = null; private final ConcurrentHashMap> propFileCache = - new ConcurrentHashMap>(); + new ConcurrentHashMap<>(); private final Object CACHELOCK = new Object(); private FileWatcherThread fileWatcherThread = null; // The key is the file name - private Map timerTaskMap = new HashMap(); + private Map timerTaskMap = new HashMap<>(); + /** + * Private Constructor. + */ + private PropertyConfiguration() { + startUp(); + } + /** * Singleton holder pattern eliminates locking when accessing the instance * and still provides for lazy initialization. @@ -112,14 +119,7 @@ public class PropertyConfiguration { * Returns the list of supported files. */ public static List supportedFiles() { - return new ArrayList(SUPPORTED_FILES); - } - - /** - * Private Constructor. - */ - private PropertyConfiguration() { - startUp(); + return new ArrayList<>(SUPPORTED_FILES); } /** @@ -245,7 +245,7 @@ public class PropertyConfiguration { String fileName = file.getName(); LOGGER.debug("Reading " + fileName); - Map properties = new HashMap(); + Map properties = new HashMap<>(); Properties newProperties = new Properties(); FileReader reader = null; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java index e9110eb88c..6249040342 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadConfigTask.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +87,7 @@ public class ReadConfigTask extends BaseTask { try { stream.close(); } catch (Exception e) { - // Do nothing + msoLogger.debug("Exception:", e); } } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java index 041b3e3d03..6b3cb5a1db 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/ReadFileTask.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,14 +103,14 @@ public class ReadFileTask extends BaseTask { try { xmlStream.close(); } catch (Exception e) { - // Do nothing + msoLogger.debug("Exception ", e); } } } } execution.setVariable(theInputVariable, value); execution.setVariable(theOutputVariable, value); - System.out.println("ServiceInput - " + execution.getVariable("gServiceInput")); + msoLogger.debug ("ServiceInput - " + execution.getVariable("gServiceInput")); if (msoLogger.isDebugEnabled()) { msoLogger.debug("Done Executing " + getTaskName()); } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java index b454450a63..4b34ddf0f0 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/XQueryScriptTask.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,7 +86,7 @@ public class XQueryScriptTask extends BaseTask { getStringField(outputVariable, execution, "outputVariable"); if (msoLogger.isDebugEnabled()) { - System.out.println("scriptFile = " + theScriptFile + msoLogger.debug ("scriptFile = " + theScriptFile + " xmlInputVariables = " + theXmlInputVariables + " atomicInputVariables = " + theAtomicInputVariables + "outputVariable = " + theOutputVariable); @@ -141,7 +142,7 @@ public class XQueryScriptTask extends BaseTask { for (String atomicInputVariable : atomicInputVariableArray) { if (msoLogger.isDebugEnabled()) { - System.out.println("Injecting object variable '" + msoLogger.debug ("Injecting object variable '" + atomicInputVariable + "'"); } @@ -235,7 +236,7 @@ public class XQueryScriptTask extends BaseTask { try { xqStream.close(); } catch (Exception e) { - // Do nothing + msoLogger.debug ("Exception:", e); } } } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java index 54a5732e1c..9dbd4b171d 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/json/JsonUtils.java @@ -144,7 +144,7 @@ public class JsonUtils { jsonObj = (JSONObject) obj; keys = jsonObj.keys(); while (keys.hasNext()) { - key = keys.next().toString(); + key = keys.next(); // msoLogger.debug("toXMLString(): key is " + k); curObj = jsonObj.opt(key); if (curObj == null) { @@ -327,7 +327,7 @@ public class JsonUtils { return null; } else { if (rawValue instanceof String) { - msoLogger.debug("getJsonValue(): the raw value is a String Object=" + ((String) rawValue).toString()); + msoLogger.debug("getJsonValue(): the raw value is a String Object=" + ((String) rawValue)); return (String) rawValue; } else { msoLogger.debug("getJsonValue(): the raw value is NOT a String Object=" + rawValue.toString()); @@ -356,7 +356,7 @@ public class JsonUtils { return null; } else { if (rawValue instanceof String) { - msoLogger.debug("getJsonNodeValue(): the raw value is a String Object=" + ((String) rawValue).toString()); + msoLogger.debug("getJsonNodeValue(): the raw value is a String Object=" + ((String) rawValue)); return (String) rawValue; } else { msoLogger.debug("getJsonNodeValue(): the raw value is NOT a String Object=" + rawValue.toString()); @@ -410,14 +410,13 @@ public class JsonUtils { * @return boolean field value associated with keys - default is false */ public static boolean getJsonBooleanValue(String jsonStr, String keys) { - String isDebugLogEnabled = "true"; try { Object rawValue = getJsonRawValue(jsonStr, keys); if (rawValue == null) { return false; } else { if (rawValue instanceof Boolean) { - msoLogger.debug("getJsonValue(): the raw value is a Boolean Object=" + ((String) rawValue).toString()); + msoLogger.debug("getJsonValue(): the raw value is a Boolean Object=" + ((String) rawValue)); return (Boolean) rawValue; } else { msoLogger.debug("getJsonValue(): the raw value is NOT an Boolean Object=" + rawValue.toString()); @@ -590,7 +589,7 @@ public class JsonUtils { try { if (jsonObj.has(key)) { msoLogger.debug("getJsonValueForKey(): found value for key=" + key); - return ((Integer) jsonObj.get(key)); + return (Integer) jsonObj.get(key); } else { msoLogger.debug("getJsonValueForKey(): iterating over the keys"); Iterator itr = jsonObj.keys(); @@ -628,12 +627,11 @@ public class JsonUtils { * @return String field value associated with key */ public static Boolean getJsonBooleanValueForKey(JSONObject jsonObj, String key) { - String isDebugLogEnabled = "true"; Boolean keyValue = false; try { if (jsonObj.has(key)) { msoLogger.debug("getJsonBooleanValueForKey(): found value for key=" + key); - return ((Boolean) jsonObj.get(key)); + return (Boolean) jsonObj.get(key); } else { msoLogger.debug("getJsonBooleanValueForKey(): iterating over the keys"); Iterator itr = jsonObj.keys(); @@ -863,7 +861,7 @@ public class JsonUtils { public Map entryArrayToMap(Execution execution, String entryArray) { msoLogger.debug("Started Entry Array To Map Util Method"); - Map map = new HashMap(); + Map map = new HashMap<>(); //Populate Map String entryListJson = "{ \"entry\":" + entryArray + "}"; @@ -895,7 +893,7 @@ public class JsonUtils { public Map entryArrayToMap(Execution execution, String entryArray, String keyNode, String valueNode) { msoLogger.debug("Started Entry Array To Map Util Method"); - Map map = new HashMap(); + Map map = new HashMap<>(); //Populate Map String entryListJson = "{ \"entry\":" + entryArray + "}"; JSONObject obj = new JSONObject(entryListJson); @@ -926,7 +924,7 @@ public class JsonUtils { public List StringArrayToList(Execution execution, String jsonArrayOfStrings) { msoLogger.debug("Started String Array To List Util Method"); - List list = new ArrayList(); + List list = new ArrayList<>(); //Populate List String stringListJson = "{ \"strings\":" + jsonArrayOfStrings + "}"; JSONObject obj = new JSONObject(stringListJson); diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java index 7b6d429912..1cf434052c 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/xml/XmlTool.java @@ -3,6 +3,7 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +61,7 @@ import org.xml.sax.SAXException; */ public final class XmlTool { - private static final Map ENTITIES = new HashMap(); + private static final Map ENTITIES = new HashMap<>(); private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.BPEL); static { ENTITIES.put("amp", new Integer(38)); @@ -69,6 +70,12 @@ public final class XmlTool { ENTITIES.put("gt", new Integer(62)); } + /** + * Instantiation is not allowed. + */ + private XmlTool() { + } + /** * Normalizes and formats XML. This method consolidates and moves all namespace * declarations to the root element. The result will not have an XML prolog or @@ -377,10 +384,4 @@ public final class XmlTool { // return the modified String representation of the XML return Optional.of(writer.toString().trim()); } - - /** - * Instantiation is not allowed. - */ - private XmlTool() { - } } -- cgit 1.2.3-korg