Class GraphicsRestService

Object
GraphicsRestService

@DeclareRoles("player") @RolesAllowed("player") @Path("/graphics") public class GraphicsRestService extends Object
Contains all rest calls used by the graphical client, with authentication and authorization. You can find them at /karchangame/resources/graphics.
Author:
maartenl
  • Constructor Details

    • GraphicsRestService

      public GraphicsRestService()
  • 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
    • getTransform

      @GET @Path("persons/{name}/transform") @Produces("application/json") public String getTransform(@PathParam("name") String name)
      Returns the transform of a person.
      Parameters:
      name - the name of the user
      Returns:
      a JSON-ified Transform object.
    • setTransform

      @PUT @Path("persons/{name}/transform") @Consumes("application/json") public Response setTransform(@PathParam("name") String name, String json)
      Adds or updates your current character transform (position, rotation, scale).
      Parameters:
      name - the name of the user
      json - the object containing the new stuff to update.
      Returns:
      Response.ok if everything is okay.
      Throws:
      WebApplicationException - UNAUTHORIZED, if the authorisation failed. BAD_REQUEST if an unexpected exception crops up.
    • getRoom

      @GET @Path("persons/{name}/room") @Produces("application/json") public String getRoom(@PathParam("name") String name)
      Retrieved the room number where a person is.
      Parameters:
      name - the name of the user
      Returns:
      room.
    • getRoom

      @GET @Path("rooms/{id}") @Produces("application/json") public String getRoom(@PathParam("id") Long id)
      Retrieved the room by room number.
      Parameters:
      id - the id of the room
      Returns:
      room.
    • setRoom

      @PUT @Path("persons/{name}/room") @Consumes("application/json") public Response setRoom(@PathParam("name") String name, String json)
      Adds or updates your current characters room.
      Parameters:
      name - the name of the user
      json - the object containing the new stuff to update.
      Returns:
      Response.ok if everything is okay.
      Throws:
      WebApplicationException - UNAUTHORIZED, if the authorisation failed. BAD_REQUEST if an unexpected exception crops up.
    • getRooms

      @GET @Path("rooms") @Produces("application/json") public String getRooms()
      Returns:
      list of room ids, including coordinates.
    • createResponse

      protected Response createResponse()
    • setLogService

      public void setLogService(LogService logService)
    • setPlayerAuthenticationService

      public void setPlayerAuthenticationService(PlayerAuthenticationService playerAuthenticationService)