use of org.opennms.features.graphml.model.GraphML in project opennms by OpenNMS.
the class GraphMLRestService method createGraph.
@POST
@Path("{graph-name}")
public Response createGraph(@PathParam("graph-name") String graphname, GraphmlType graphmlType) throws IOException {
return runWithGraphmlRepositoryBlock(graphmlRepository -> {
if (graphmlRepository.exists(graphname)) {
return Response.status(500).entity("Graph with name " + graphname + " already exists").build();
}
try {
GraphML convertedGraphML = GraphMLReader.convert(graphmlType);
String label = convertedGraphML.getProperty("label", graphname);
graphmlRepository.save(graphname, label, graphmlType);
return Response.status(Response.Status.CREATED).build();
} catch (InvalidGraphException ex) {
return Response.status(500).entity(ex.getMessage()).build();
}
});
}
Aggregations