diff options
Diffstat (limited to 'src/main/java/org/onap/dcae/commonFunction')
3 files changed, 30 insertions, 26 deletions
diff --git a/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java b/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java index b974ed53..fe3ba325 100644 --- a/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java +++ b/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java @@ -194,11 +194,14 @@ public class CommonStartup extends NsaBaseEndpoint implements Runnable { executor = Executors.newFixedThreadPool(20); executor.execute(ep); - } catch (loadException | missingReqdSetting | IOException | invalidSettingValue | ServletException - | InterruptedException e) { + } catch (loadException | missingReqdSetting | IOException | invalidSettingValue | ServletException | InterruptedException e) { CommonStartup.eplog.error("FATAL_STARTUP_ERROR" + e.getMessage()); throw new RuntimeException(e); - } finally { + } catch (Throwable e) { + System.err.println("Uncaught exception - " + e.getMessage()); + CommonStartup.eplog.error("FATAL_ERROR" + e.getMessage() ); + e.printStackTrace(System.err); + } finally { // This will make the executor accept no new threads // and finish all existing threads in the queue if (executor != null) { diff --git a/src/main/java/org/onap/dcae/commonFunction/CustomExceptionLoader.java b/src/main/java/org/onap/dcae/commonFunction/CustomExceptionLoader.java index 10a1db47..fbeba2f6 100644 --- a/src/main/java/org/onap/dcae/commonFunction/CustomExceptionLoader.java +++ b/src/main/java/org/onap/dcae/commonFunction/CustomExceptionLoader.java @@ -77,9 +77,8 @@ public class CustomExceptionLoader { } log.debug("CustomExceptionLoader.LoadMap --> Map loaded - " + map); - } catch (JsonIOException|JsonSyntaxException|FileNotFoundException e) { + } catch (JsonIOException|JsonSyntaxException|FileNotFoundException e) { log.error("Exception in LoadMap:" + e.getMessage()); - //e.printStackTrace(); map = null; } finally { diff --git a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java index 2bc5e45b..05e5f0ba 100644 --- a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java +++ b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java @@ -30,6 +30,7 @@ import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; import java.io.FileReader; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -117,20 +118,6 @@ public class EventProcessor implements Runnable { final SimpleDateFormat sdf = new SimpleDateFormat("EEE, MM dd yyyy hh:mm:ss z"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); - /*JSONArray additionalParametersarray = new JSONArray().put(new JSONObject().put("collectorTimeStamp", sdf.format(currentTime))); - JSONObject additionalParameter = new JSONObject().put("additionalParameters",additionalParametersarray ); - JSONObject commonEventHeaderkey = event.getJSONObject("event").getJSONObject("commonEventHeader"); - commonEventHeaderkey.put("internalHeaderFields", additionalParameter);*/ - - -/* "event": { - "commonEventHeader": { - "internalHeaderFields": { - "collectorTimeStamp": "Fri, 04 21 2017 04:11:52 GMT" - }, -*/ - - //JSONArray additionalParametersarray = new JSONArray().put(new JSONObject().put("collectorTimeStamp", sdf.format(currentTime))); JSONObject collectorTimeStamp = new JSONObject() .put("collectorTimeStamp", sdf.format(currentTime)); JSONObject commonEventHeaderkey = event.getJSONObject(EVENT_LITERAL) @@ -141,9 +128,10 @@ public class EventProcessor implements Runnable { if (CommonStartup.eventTransformFlag == 1) { // read the mapping json file final JsonParser parser = new JsonParser(); + FileReader fr = null; try { - final JsonArray jo = (JsonArray) parser - .parse(new FileReader("./etc/eventTransform.json")); + fr = new FileReader ( "./etc/eventTransform.json" ); + final JsonArray jo = (JsonArray) parser.parse(fr); log.info("parse eventTransform.json"); // now convert to org.json final String jsonText = jo.toString(); @@ -183,11 +171,25 @@ public class EventProcessor implements Runnable { } catch (Exception e) { - log.error("EventProcessor Exception" + e.getMessage() + e); - log.error("EventProcessor Exception" + e.getCause()); + log.error("EventProcessor Exception" + e.getMessage() + e + e.getCause() ); } - } - log.debug("Modified event:" + event); + finally { + //close the file + if (fr != null) { + try { + fr.close(); + } catch (IOException e) { + log.error("Error closing file reader stream : " + e.toString()); + } + + } + } + } + //Remove VESversion from event. This field is for internal use and must be removed after use. + if (event.has("VESversion")) + event.remove("VESversion"); - } + log.debug("Modified event:" + event); + + } } |