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;
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) {
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) {
}
@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();
}
*/
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();