Search in sources :

Example 6 with ThumbnailManager

use of gov.usgs.cida.coastalhazards.jpa.ThumbnailManager 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;
}
Also used : Response(javax.ws.rs.core.Response) ThumbnailManager(gov.usgs.cida.coastalhazards.jpa.ThumbnailManager) Thumbnail(gov.usgs.cida.coastalhazards.model.Thumbnail) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

ThumbnailManager (gov.usgs.cida.coastalhazards.jpa.ThumbnailManager)6 Response (javax.ws.rs.core.Response)5 ItemManager (gov.usgs.cida.coastalhazards.jpa.ItemManager)4 StatusManager (gov.usgs.cida.coastalhazards.jpa.StatusManager)4 Status (gov.usgs.cida.coastalhazards.model.util.Status)4 RolesAllowed (javax.annotation.security.RolesAllowed)4 Path (javax.ws.rs.Path)4 BadRequestException (gov.usgs.cida.coastalhazards.exception.BadRequestException)3 Item (gov.usgs.cida.coastalhazards.model.Item)3 Consumes (javax.ws.rs.Consumes)3 Produces (javax.ws.rs.Produces)3 Thumbnail (gov.usgs.cida.coastalhazards.model.Thumbnail)2 PUT (javax.ws.rs.PUT)2 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1