use of io.prestosql.queryeditorui.protocol.queries.CreateSavedQueryBuilder in project hetu-core by openlookeng.
the class QueryResource method saveQuery.
@POST
@Path("saved")
@Produces(MediaType.APPLICATION_JSON)
public Response saveQuery(@FormParam("description") String description, @FormParam("name") String name, @FormParam("query") String query, @Context HttpServletRequest servletRequest) throws IOException {
String user = AccessControlUtil.getUser(accessControl, new HttpRequestSessionContext(servletRequest, groupProvider));
CreateSavedQueryBuilder createFeaturedQueryRequest = CreateSavedQueryBuilder.notFeatured().description(description).name(name).query(query);
if (user != null) {
SavedQuery savedQuery = createFeaturedQueryRequest.user(user).build();
if (queryStore.saveQuery((UserSavedQuery) savedQuery)) {
return Response.ok(savedQuery.getUuid()).build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
return Response.status(Response.Status.UNAUTHORIZED).build();
}
Aggregations