Merge "Reduce the number of raw-type related warnings in aai-common"
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / serialization / queryformats / GraphSON.java
index 609f6b0..c0ba860 100644 (file)
@@ -28,7 +28,10 @@ import com.google.gson.JsonParser;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -37,13 +40,16 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
 import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
 import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported;
 import org.onap.aai.serialization.queryformats.exceptions.AAIFormatVertexException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class GraphSON implements FormatMapper {
 
+    private static final Logger logger = LoggerFactory.getLogger(GraphSON.class);
+
     private final GraphSONMapper mapper =
             GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create();
     private final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create();
-    protected JsonParser parser = new JsonParser();
 
     @Override
     public Optional<JsonObject> formatObject(Object v) {
@@ -54,11 +60,10 @@ public class GraphSON implements FormatMapper {
 
             result = os.toString();
         } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            logger.debug("GraphSON writeVertex error : {}", e.getMessage());
         }
 
-        JsonObject jsonObject = parser.parse(result).getAsJsonObject();
+        JsonObject jsonObject = JsonParser.parseString(result).getAsJsonObject();
 
         if (jsonObject != null) {
 
@@ -79,7 +84,8 @@ public class GraphSON implements FormatMapper {
     }
 
     @Override
-    public Optional<JsonObject> formatObject(Object o, Map<String, List<String>> properties) throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
+    public Optional<JsonObject> formatObject(Object obj, Map<String, List<String>> properties)
+            throws AAIFormatVertexException, AAIFormatQueryResultFormatNotSupported {
         return Optional.empty();
     }
 
@@ -98,7 +104,7 @@ public class GraphSON implements FormatMapper {
      */
     private void removePrivateEdges(JsonObject jsonObject, JsonObject edges, String edgeDirection) {
 
-        Iterator it = edges.entrySet().iterator();
+        Iterator<Map.Entry<String, JsonElement>> it = edges.entrySet().iterator();
         while (it.hasNext()) {
             Map.Entry<String, JsonElement> outEntry = (Map.Entry<String, JsonElement>) it.next();
             JsonArray edgePropertiesArray = outEntry.getValue().getAsJsonArray();