Sonar Fix : Added logger 18/90218/1
authorSudarshan Kumar <sudars19@in.ibm.com>
Thu, 20 Jun 2019 07:29:07 +0000 (12:59 +0530)
committerSudarshan Kumar <sudars19@in.ibm.com>
Thu, 20 Jun 2019 07:30:04 +0000 (13:00 +0530)
Sonar Fix : Added logger

Issue-ID: AAI-2371
Change-Id: I61d43ceb174c848707ab95c84145890d4a707b25
Signed-off-by: Sudarshan Kumar <sudars19@in.ibm.com>
champ-lib/champ-janus/src/main/java/org/onap/aai/champjanus/graph/impl/GraphSON.java

index 20b993c..93744b1 100644 (file)
@@ -4,6 +4,7 @@
  * ===================================================================
  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
  * Copyright © 2017-2018 Amdocs
+ * Modifications Copyright (C) 2019 IBM
  * ===================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 package org.onap.aai.champjanus.graph.impl;
 
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-// import com.thinkaurelius.titan.graphdb.tinkerpop.TitanIoRegistry;
-import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
+import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
 import org.onap.aai.champcore.FormatMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 
 public class GraphSON implements FormatMapper {
+    private static final Logger LOGGER = LoggerFactory.getLogger(GraphSON.class);
     private final GraphSONMapper mapper;
     private final GraphSONWriter writer;
     protected JsonParser parser;
 
     public GraphSON() {
-        this.mapper = GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance ()).create();
+        this.mapper = GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create();
         this.writer = GraphSONWriter.build().mapper(this.mapper).create();
         this.parser = new JsonParser();
     }
@@ -50,10 +54,10 @@ public class GraphSON implements FormatMapper {
         String result = "";
 
         try {
-            this.writer.writeVertex(os, (Vertex)v, Direction.BOTH);
+            this.writer.writeVertex(os, (Vertex) v, Direction.BOTH);
             result = os.toString();
         } catch (IOException var5) {
-            var5.printStackTrace();
+            LOGGER.debug("Exception occured while formatting object : " + var5.getMessage());
         }
 
         return this.parser.parse(result).getAsJsonObject();