use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class TargetAPI method delete.
@DELETE
@Timed
@Path("{id}")
@Consumes(APPLICATION_JSON)
public void delete(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String id) {
LOG.debug("Graph [{}] delete target: {}", graph, id);
// just check if the graph exists
@SuppressWarnings("unused") HugeGraph g = graph(manager, graph);
try {
manager.authManager().deleteTarget(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid target id: " + id);
}
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class BelongAPI method update.
@PUT
@Timed
@Path("{id}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String update(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String id, JsonBelong jsonBelong) {
LOG.debug("Graph [{}] update belong: {}", graph, jsonBelong);
checkUpdatingBody(jsonBelong);
HugeGraph g = graph(manager, graph);
HugeBelong belong;
try {
belong = manager.authManager().getBelong(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid belong id: " + id);
}
belong = jsonBelong.build(belong);
manager.authManager().updateBelong(belong);
return manager.serializer(g).writeAuthElement(belong);
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class GraphTransaction method queryVertex.
public Vertex queryVertex(Object vertexId) {
Iterator<Vertex> iter = this.queryVerticesByIds(new Object[] { vertexId }, false, true);
Vertex vertex = QueryResults.one(iter);
if (vertex == null) {
throw new NotFoundException("Vertex '%s' does not exist", vertexId);
}
return vertex;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class GraphTransaction method queryEdge.
public Edge queryEdge(Object edgeId) {
Iterator<Edge> iter = this.queryEdgesByIds(new Object[] { edgeId }, true);
Edge edge = QueryResults.one(iter);
if (edge == null) {
throw new NotFoundException("Edge '%s' does not exist", edgeId);
}
return edge;
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class EdgeAPI method delete.
@DELETE
@Timed
@Path("{id}")
@Consumes(APPLICATION_JSON)
@RolesAllowed({ "admin", "$owner=$graph $action=edge_delete" })
public void delete(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String id, @QueryParam("label") String label) {
LOG.debug("Graph [{}] remove vertex by id '{}'", graph, id);
HugeGraph g = graph(manager, graph);
commit(g, () -> {
try {
g.removeEdge(label, id);
} catch (NotFoundException e) {
throw new IllegalArgumentException(String.format("No such edge with id: '%s', %s", id, e));
} catch (NoSuchElementException e) {
throw new IllegalArgumentException(String.format("No such edge with id: '%s'", id));
}
});
}
Aggregations