use of gov.usgs.cida.coastalhazards.model.Thumbnail in project coastal-hazards by USGS-CIDA.
the class ThumbnailResource method getList.
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getList(@QueryParam("dirty") @DefaultValue("false") boolean dirty) {
Response response = null;
try (ThumbnailManager manager = new ThumbnailManager()) {
List<Thumbnail> thumbnails = manager.loadAll(dirty);
Gson gson = GsonUtil.getDefault();
response = Response.ok(gson.toJson(thumbnails, List.class), MediaType.APPLICATION_JSON_TYPE).build();
}
return response;
}
use of gov.usgs.cida.coastalhazards.model.Thumbnail in project coastal-hazards by USGS-CIDA.
the class ThumbnailResource method putImage.
@RolesAllowed({ CoastalHazardsTokenBasedSecurityFilter.CCH_ADMIN_ROLE })
@PUT
@Path("/item/{id}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public Response putImage(@PathParam("id") String id, String content, @Context HttpServletRequest request) {
Response response = null;
Thumbnail thumb = new Thumbnail();
thumb.setItemId(id);
thumb.setImage(content);
thumb.setDirty(false);
try (ThumbnailManager manager = new ThumbnailManager()) {
response = Response.ok(manager.save(thumb), MediaType.APPLICATION_JSON_TYPE).build();
manager.updateDirtyBits(id);
}
return response;
}
use of gov.usgs.cida.coastalhazards.model.Thumbnail in project coastal-hazards by USGS-CIDA.
the class ThumbnailManager method loadAll.
public List<Thumbnail> loadAll(boolean dirtyOnly) {
String sql = "select t from Thumbnail t";
if (dirtyOnly) {
sql += " where t.dirty = TRUE";
}
Query query = em.createQuery(sql);
List<Thumbnail> resultList = query.getResultList();
return resultList;
}
Aggregations