Class WikipageRestService

Object
WikipageRestService

@DeclareRoles("player") @RolesAllowed("player") @Path("/wikipages") public class WikipageRestService extends Object
Allows getting wikipages, creating new ones and editing them. You can find them at /karchangame/resources/wikipages.
Author:
maartenl
  • Constructor Details

    • WikipageRestService

      public WikipageRestService()
  • 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
    • getWikipage

      @GET @Path("{title}") @Produces("application/json") public String getWikipage(@PathParam("title") String title)
      Returns a wikipage with that specific title.
      Parameters:
      title - the (unique) title of the wikipage
      Returns:
      a wikipage 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.
    • createWikipage

      @POST @Consumes("application/json") public Response createWikipage(String json)
      Create a new wikipage.
      Parameters:
      json - the new wikipage to store in json format.
      Returns:
      Response.ok if everything's okay.
      Throws:
      WebApplicationException - UNAUTHORIZED, if the authorization failed. BAD_REQUEST if an unexpected exception crops up.
    • updateWikipage

      @PUT @Path("{title}") @Consumes("application/json") public Response updateWikipage(@PathParam("title") String title, String json)
      Adds or updates a wikipage.
      Parameters:
      title - the (unique) title of the wikpage, should not exist yet.
      json - the updated wikipage to store in json format.
      Returns:
      Response.ok if everything is okay.
      Throws:
      WebApplicationException - UNAUTHORIZED, if the authorisation failed. BAD_REQUEST if an unexpected exception crops up.
    • deleteWikipage

      @DELETE @Path("{title}") public Response deleteWikipage(@PathParam("title") String title)
      Deletes a wikipage.
      Parameters:
      title - the (unique) title of the wikpage to delete.
      Returns:
      Response.ok if everything is okay.
      Throws:
      WebApplicationException - UNAUTHORIZED, if the authorisation failed. This is only available to deps. BAD_REQUEST if an unexpected exception crops up.