Class PicturesRestService
Object
PicturesRestService
@DeclareRoles("player")
@RolesAllowed("player")
@Path("/private/{name}/pictures")
public class PicturesRestService
extends Object
Allows getting pictures and creating new ones. You can find them at /karchangame/resources/private/{playername}/images.
The pictures themselves will be put at the url : /images/players/{playername}/{path}.
- Author:
- maartenl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionResponse
createPicture
(String player, String json) Create a new picture.Response
deletePicture
(String player, Long id) Delete an existing picture.protected EntityManager
Returns the entity manager of JPA.getPicture
(String name, Long id) Returns a single image and its stats of a player.getPictures
(String name) Returns all images of a player.
-
Constructor Details
-
PicturesRestService
public PicturesRestService()
-
-
Method Details
-
getEntityManager
protected EntityManager getEntityManager()Returns the entity manager of JPA. This is defined in build/web/WEB-INF/classes/META-INF/persistence.xml.- Returns:
- EntityManager
-
getPictures
Returns all images of a player. Not all fields are provided, as that would swamp the server. For example, the actual images are not transferred.- Parameters:
name
- the player in question- Returns:
- a list of images in json format
- Throws:
WebApplicationException
-- UNAUTHORIZED, if the authorization failed.
- NOT_FOUND if this wikipage does not exist.
- BAD_REQUEST if an unexpected exception crops up.
-
getPicture
@GET @Path("/{id}") @Produces("application/json") public String getPicture(@PathParam("name") String name, @PathParam("id") Long id) Returns a single image and its stats of a player.- Parameters:
name
- the player in questionid
- the id of the picture to retrieve- Returns:
- an image in json format
- Throws:
WebApplicationException
-- UNAUTHORIZED, if the authorization failed.
- NOT_FOUND if this wikipage does not exist.
- BAD_REQUEST if an unexpected exception crops up.
-
createPicture
@POST @Consumes("application/json") public Response createPicture(@PathParam("name") String player, String json) throws UnsupportedEncodingException Create a new picture.- Parameters:
player
- the name of the playerjson
- the new picture to store in json format.- Returns:
- Response.ok if everything's okay.
- Throws:
UnsupportedEncodingException
- in case the content cannot be decoded into a byte array.WebApplicationException
- UNAUTHORIZED, if the authorization failed. BAD_REQUEST if an unexpected exception crops up.
-
deletePicture
@DELETE @Path("{id}") public Response deletePicture(@PathParam("name") String player, @PathParam("id") Long id) Delete an existing picture. Due to the way this was setup, there is a lot of browser caching involved. This means a picture is cached in your browser, therefore a deleted picture might still be available (in your browser).- Parameters:
player
- the name of the player- Returns:
- Response.ok if everything's okay.
- Throws:
WebApplicationException
- UNAUTHORIZED, if the authorization failed. BAD_REQUEST if an unexpected exception crops up.
-