use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class VertexAPI method delete.
@DELETE
@Timed
@Path("{id}")
@Consumes(APPLICATION_JSON)
@RolesAllowed({ "admin", "$owner=$graph $action=vertex_delete" })
public void delete(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String idValue, @QueryParam("label") String label) {
LOG.debug("Graph [{}] remove vertex by id '{}'", graph, idValue);
Id id = checkAndParseVertexId(idValue);
HugeGraph g = graph(manager, graph);
commit(g, () -> {
try {
g.removeVertex(label, id);
} catch (NotFoundException e) {
throw new IllegalArgumentException(String.format("No such vertex with id: '%s', %s", id, e));
} catch (NoSuchElementException e) {
throw new IllegalArgumentException(String.format("No such vertex with id: '%s'", id));
}
});
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class BelongAPI 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 belong: {}", graph, id);
// just check if the graph exists
@SuppressWarnings("unused") HugeGraph g = graph(manager, graph);
try {
manager.authManager().deleteBelong(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid belong id: " + id);
}
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class AccessAPI 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, JsonAccess jsonAccess) {
LOG.debug("Graph [{}] update access: {}", graph, jsonAccess);
checkUpdatingBody(jsonAccess);
HugeGraph g = graph(manager, graph);
HugeAccess access;
try {
access = manager.authManager().getAccess(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid access id: " + id);
}
access = jsonAccess.build(access);
manager.authManager().updateAccess(access);
return manager.serializer(g).writeAuthElement(access);
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class AccessAPI 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 access: {}", graph, id);
// just check if the graph exists
@SuppressWarnings("unused") HugeGraph g = graph(manager, graph);
try {
manager.authManager().deleteAccess(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid access id: " + id);
}
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class GroupAPI 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, JsonGroup jsonGroup) {
LOG.debug("Graph [{}] update group: {}", graph, jsonGroup);
checkUpdatingBody(jsonGroup);
HugeGraph g = graph(manager, graph);
HugeGroup group;
try {
group = manager.authManager().getGroup(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid group id: " + id);
}
group = jsonGroup.build(group);
manager.authManager().updateGroup(group);
return manager.serializer(g).writeAuthElement(group);
}
Aggregations