try {
cr = objectMapper.readValue(body, CreateSavedSearchRequest.class);
} catch(IOException e) {
LOG.error("Error while parsing JSON", e);
throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
}
// Create saved search
Map<String, Object> searchData = Maps.newHashMap();
searchData.put("title", cr.title);
searchData.put("query", cr.query);
searchData.put("creator_user_id", getCurrentUser().getName());
searchData.put("created_at", Tools.iso8601());
SavedSearch search = new SavedSearchImpl(searchData);
String id;
try {
id = savedSearchService.save(search);
} catch (ValidationException e) {
LOG.error("Validation error.", e);
throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
}
Map<String, Object> result = Maps.newHashMap();
result.put("search_id", id);