use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class ProjectAPI method get.
@GET
@Timed
@Path("{id}")
@Produces(APPLICATION_JSON_WITH_CHARSET)
public String get(@Context GraphManager manager, @PathParam("graph") String graph, @PathParam("id") String id) {
LOG.debug("Graph [{}] get project: {}", graph, id);
HugeGraph g = graph(manager, graph);
HugeProject project;
try {
project = manager.authManager().getProject(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid project id: " + id);
}
return manager.serializer(g).writeAuthElement(project);
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class ProjectAPI 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, @QueryParam("action") String action, JsonProject jsonProject) {
LOG.debug("Graph [{}] update {} project: {}", graph, action, jsonProject);
checkUpdatingBody(jsonProject);
HugeGraph g = graph(manager, graph);
HugeProject project;
Id projectId = UserAPI.parseId(id);
AuthManager authManager = manager.authManager();
try {
project = authManager.getProject(projectId);
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid project id: " + id);
}
if (ProjectAPI.isAddGraph(action)) {
project = jsonProject.buildAddGraph(project);
} else if (ProjectAPI.isRemoveGraph(action)) {
project = jsonProject.buildRemoveGraph(project);
} else {
E.checkArgument(StringUtils.isEmpty(action), "The action parameter can only be either " + "%s or %s or '', but got '%s'", ProjectAPI.ACTION_ADD_GRAPH, ProjectAPI.ACTION_REMOVE_GRAPH, action);
project = jsonProject.buildUpdateDescription(project);
}
authManager.updateProject(project);
return manager.serializer(g).writeAuthElement(project);
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class ProjectAPI 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 project: {}", graph, id);
// just check if the graph exists
@SuppressWarnings("unused") HugeGraph g = graph(manager, graph);
try {
manager.authManager().deleteProject(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid project id: " + id);
}
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class TargetAPI 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, JsonTarget jsonTarget) {
LOG.debug("Graph [{}] update target: {}", graph, jsonTarget);
checkUpdatingBody(jsonTarget);
HugeGraph g = graph(manager, graph);
HugeTarget target;
try {
target = manager.authManager().getTarget(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid target id: " + id);
}
target = jsonTarget.build(target);
manager.authManager().updateTarget(target);
return manager.serializer(g).writeAuthElement(target);
}
use of com.baidu.hugegraph.exception.NotFoundException in project incubator-hugegraph by apache.
the class UserAPI 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, JsonUser jsonUser) {
LOG.debug("Graph [{}] update user: {}", graph, jsonUser);
checkUpdatingBody(jsonUser);
HugeGraph g = graph(manager, graph);
HugeUser user;
try {
user = manager.authManager().getUser(UserAPI.parseId(id));
} catch (NotFoundException e) {
throw new IllegalArgumentException("Invalid user id: " + id);
}
user = jsonUser.build(user);
manager.authManager().updateUser(user);
return manager.serializer(g).writeAuthElement(user);
}
Aggregations