From: James Forsyth Date: Thu, 15 Aug 2019 13:44:40 +0000 (+0000) Subject: Merge "Sonar Fix : Added logger" X-Git-Tag: 1.6.0~3 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=14830110a1fdf7c7ccc4a45f3e8b3e1573726a99;hp=a55cf0fe1999e5aeccb535a29f3cec496afb1ef7;p=aai%2Fchamp.git Merge "Sonar Fix : Added logger" --- diff --git a/champ-lib/champ-janus/src/main/java/org/onap/aai/champjanus/graph/impl/GraphSON.java b/champ-lib/champ-janus/src/main/java/org/onap/aai/champjanus/graph/impl/GraphSON.java index 20b993c..93744b1 100644 --- a/champ-lib/champ-janus/src/main/java/org/onap/aai/champjanus/graph/impl/GraphSON.java +++ b/champ-lib/champ-janus/src/main/java/org/onap/aai/champjanus/graph/impl/GraphSON.java @@ -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. @@ -20,27 +21,30 @@ */ 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();