use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.
the class TaskAPI method update.
@PUT
@Timed
@Path("{id}")
@Status(Status.ACCEPTED)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public Map<String, Object> update(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") long id, @QueryParam("action") String action) {
LOG.debug("Graph [{}] cancel task: {}", graph, id);
if (!ACTION_CANCEL.equals(action)) {
throw new NotSupportedException(String.format("Not support action '%s'", action));
}
TaskScheduler scheduler = graph(manager, graph).taskScheduler();
HugeTask<?> task = scheduler.task(IdGenerator.of(id));
if (!task.completed() && !task.cancelling()) {
scheduler.cancel(task);
if (task.cancelling() || task.cancelled()) {
return task.asMap();
}
}
assert task.completed() || task.cancelling();
throw new BadRequestException(String.format("Can't cancel task '%s' which is completed or cancelling", id));
}
use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.
the class BelongAPI method create.
@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonBelong jsonBelong) {
LOG.debug("Graph [{}] create belong: {}", graph, jsonBelong);
checkCreatingBody(jsonBelong);
HugeGraph g = graph(manager, graph);
HugeBelong belong = jsonBelong.build();
belong.id(manager.authManager().createBelong(belong));
return manager.serializer(g).writeAuthElement(belong);
}
use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.
the class AccessAPI method create.
@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonAccess jsonAccess) {
LOG.debug("Graph [{}] create access: {}", graph, jsonAccess);
checkCreatingBody(jsonAccess);
HugeGraph g = graph(manager, graph);
HugeAccess access = jsonAccess.build();
access.id(manager.authManager().createAccess(access));
return manager.serializer(g).writeAuthElement(access);
}
use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.
the class VertexAPI method create.
@POST
@Timed(name = "single-create")
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed({ "admin", "$owner=$graph $action=vertex_write" })
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonVertex jsonVertex) {
LOG.debug("Graph [{}] create vertex: {}", graph, jsonVertex);
checkCreatingBody(jsonVertex);
HugeGraph g = graph(manager, graph);
Vertex vertex = commit(g, () -> g.addVertex(jsonVertex.properties()));
return manager.serializer(g).writeVertex(vertex);
}
use of com.baidu.hugegraph.api.filter.StatusFilter.Status in project incubator-hugegraph by apache.
the class GroupAPI method create.
@POST
@Timed
@Status(Status.CREATED)
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String create(@Context GraphManager manager, @PathParam("graph") String graph, JsonGroup jsonGroup) {
LOG.debug("Graph [{}] create group: {}", graph, jsonGroup);
checkCreatingBody(jsonGroup);
HugeGraph g = graph(manager, graph);
HugeGroup group = jsonGroup.build();
group.id(manager.authManager().createGroup(group));
return manager.serializer(g).writeAuthElement(group);
}
Aggregations