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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionResponse
createWikipage
(String json) Create a new wikipage.Response
deleteWikipage
(String title) Deletes a wikipage.protected EntityManager
Returns the entity manager of JPA.getWikipage
(String title) Returns a wikipage with that specific title.Response
updateWikipage
(String title, String json) Adds or updates a wikipage.
-
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
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
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.
-