DendriteGraphTx tx = graph.buildTransaction().readOnly().start();
try {
if (format.equalsIgnoreCase("GraphSON")) {
headers.setContentType(new MediaType("application", "vnd.rexster+json"));
headers.set("Content-Disposition", "attachment; filename=\"graph.json\"");
GraphSONWriter.outputGraph(tx, byteArrayOutputStream);
} else if (format.equalsIgnoreCase("GraphML")) {
headers.setContentType(new MediaType("application", "vnd.rexster+xml"));
headers.set("Content-Disposition", "attachment; filename=\"graph.xml\"");
GraphMLWriter.outputGraph(tx, byteArrayOutputStream);
} else if (format.equalsIgnoreCase("GML")) {
headers.setContentType(new MediaType("application", "vnd.rexster+gml"));
headers.set("Content-Disposition", "attachment; filename=\"graph.gml\"");
GMLWriter.outputGraph(tx, byteArrayOutputStream);
} else {
tx.rollback();