Class GuildRestService
Object
GuildRestService
@DeclareRoles({"player","guildmaster","guildmember"})
@RolesAllowed("player")
@Path("/private/{name}/guild")
public class GuildRestService
extends Object
Takes care of the guilds. All the REST services in this bean, can be
subdivided into two categories:
- persons who are a member of the guild, can view information of the guild
- guildmasters (who are also member of the guild) can change/delete/add information to the guild
- Author:
- maartenl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected User
Response
createGuild
(String name, PrivateGuild cinfo) Creates a new guild.Response
createGuildRank
(String name, PrivateRank rank) Create a rank of the guild of the user.Response
createMember
(String name, PrivatePerson member) Adds a member to the guild of the user.Response
deleteGuildHopeful
(String name, String hopefulname) Remove a hopeful of the guild of the user.Response
deleteGuildRank
(String name, Integer guildlevel) Delete a rank of the guild of the user.Response
deleteGuildRest
(String name) Deletes the guild.Response
deleteMember
(String name, String membername) Removes a member from the guild.protected EntityManager
Returns the entity manager of JPA.getGuildHopefuls
(String name) Get the hopefuls of the guild of the user.getGuildHopefuls
(Guild aGuild) returns a list of persons that wish to become a member of a guild.getGuildInfo
(String name) Get the guild of the user.getGuildRank
(String name, Integer guildlevel) Get the ranks of the guild of the user.getGuildRanks
(String name) Get the ranks of the guild of the user.Get the member of the guild of the user.getMembers
(String name) Get all members of the guild of the user.void
setPlayerAuthenticationService
(PlayerAuthenticationService playerAuthenticationService) Response
updateGuild
(String name, PrivateGuild cinfo) Updates the guild.Response
updateGuildRank
(String name, Integer guildlevel, PrivateRank rank) Update a rank of the guild of the user.Response
updateMember
(String name, String membername, PrivatePerson member) Set or deletes the rank of a member of the guild of the user.
-
Constructor Details
-
GuildRestService
public GuildRestService()
-
-
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
-
getGuildHopefuls
returns a list of persons that wish to become a member of a guild.- Parameters:
aGuild
- the guild- Returns:
- list of guild hopefuls.
- Throws:
MudException
- if something goes wrong.
-
getGuildInfo
@GET @RolesAllowed("guildmember") @Consumes("application/json") public PrivateGuild getGuildInfo(@PathParam("name") String name) Get the guild of the user.- Parameters:
name
- the name of the user- Returns:
- the guild
-
updateGuild
@PUT @RolesAllowed("guildmaster") @Consumes("application/json") public Response updateGuild(@PathParam("name") String name, PrivateGuild cinfo) Updates the guild.- Parameters:
name
- the name of the usercinfo
- the guild 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.
-
createGuild
@POST @RolesAllowed("player") @Consumes("application/json") public Response createGuild(@PathParam("name") String name, PrivateGuild cinfo) Creates a new guild.- Parameters:
name
- the name of the usercinfo
- the guild object containing the new stuff to create.- Returns:
- Response.ok if everything is okay.
- Throws:
WebApplicationException
- UNAUTHORIZED, if the authorisation failed. BAD_REQUEST if an unexpected exception crops up.
-
deleteGuildRest
@DELETE @RolesAllowed("guildmaster") @Consumes("application/json") public Response deleteGuildRest(@PathParam("name") String name) Deletes the guild.- Parameters:
name
- the name of the user- Returns:
- Response.ok if everything is okay.
- Throws:
WebApplicationException
- UNAUTHORIZED, if the authorisation failed. BAD_REQUEST if an unexpected exception crops up.
-
getMembers
@GET @Path("members") @RolesAllowed("guildmember") @Consumes("application/json") public List<PrivatePerson> getMembers(@PathParam("name") String name) Get all members of the guild of the user.- Parameters:
name
- the name of the user- Returns:
- list of guild members
-
getMember
@GET @Path("members/{membername}") @RolesAllowed("guildmember") @Consumes("application/json") public PrivatePerson getMember(@PathParam("name") String name, @PathParam("membername") String membername) Get the member of the guild of the user.- Parameters:
name
- the name of the usermembername
- the name of the guild member- Returns:
- member
-
deleteMember
@DELETE @Path("members/{membername}") @RolesAllowed("guildmaster") @Consumes("application/json") public Response deleteMember(@PathParam("name") String name, @PathParam("membername") String membername) Removes a member from the guild.- Parameters:
name
- the name of the usermembername
- the name of the guild member to remove- Returns:
- member
-
createMember
@POST @Path("members") @RolesAllowed("guildmaster") @Consumes("application/json") public Response createMember(@PathParam("name") String name, PrivatePerson member) Adds a member to the guild of the user. There are some checks made:- possible member should exist
- should be a user, not a bot
- should not be a member of a guild
- should have a guildwish corresponding to the name of the guild>/li>
- Parameters:
name
- the name of the usermember
- the member to add, really should contain only the name, that's enough- Returns:
- Response.ok if everything is okay.
-
updateMember
@PUT @Path("members/{membername}") @RolesAllowed("guildmaster") @Consumes("application/json") public Response updateMember(@PathParam("name") String name, @PathParam("membername") String membername, PrivatePerson member) Set or deletes the rank of a member of the guild of the user.- Parameters:
name
- the name of the usermembername
- the name of the guild member, to set the guild rank formember
- the member object that contains the changes- Returns:
- Response.ok() if everything's okay.
-
getGuildHopefuls
@GET @Path("hopefuls") @RolesAllowed("guildmember") @Consumes("application/json") public List<PrivatePerson> getGuildHopefuls(@PathParam("name") String name) Get the hopefuls of the guild of the user.- Parameters:
name
- the name of the user- Returns:
- list of hopefuls, i.e. people who wish to join the guild
-
deleteGuildHopeful
@DELETE @Path("hopefuls/{hopefulname}") @RolesAllowed("guildmaster") @Consumes("application/json") public Response deleteGuildHopeful(@PathParam("name") String name, @PathParam("hopefulname") String hopefulname) Remove a hopeful of the guild of the user.- Parameters:
name
- the name of the userhopefulname
- the name of the hopeful to reject- Returns:
- Response.Status.ok if everything's okay.
-
getGuildRanks
@GET @Path("ranks") @RolesAllowed("guildmember") @Consumes("application/json") public List<PrivateRank> getGuildRanks(@PathParam("name") String name) Get the ranks of the guild of the user.- Parameters:
name
- the name of the user- Returns:
- list of hopefuls
-
getGuildRank
@GET @Path("ranks/{guildlevel}") @RolesAllowed("guildmember") @Consumes("application/json") public PrivateRank getGuildRank(@PathParam("name") String name, @PathParam("guildlevel") Integer guildlevel) Get the ranks of the guild of the user.- Parameters:
name
- the name of the userguildlevel
- the id of the guild rank- Returns:
- list of hopefuls
-
createGuildRank
@POST @RolesAllowed("guildmaster") @Path("ranks") @Consumes("application/json") public Response createGuildRank(@PathParam("name") String name, PrivateRank rank) Create a rank of the guild of the user.- Parameters:
name
- the name of the userrank
- the rank to add- Returns:
- Response.ok if everything is okay.
-
updateGuildRank
@PUT @RolesAllowed("guildmaster") @Path("ranks/{guildlevel}") @Consumes("application/json") public Response updateGuildRank(@PathParam("name") String name, @PathParam("guildlevel") Integer guildlevel, PrivateRank rank) Update a rank of the guild of the user.- Parameters:
name
- the name of the userguildlevel
- the guildlevel of the rankrank
- the rank to update- Returns:
- Response.ok if everything is okay.
-
deleteGuildRank
@DELETE @RolesAllowed("guildmaster") @Path("ranks/{guildlevel}") @Consumes("application/json") public Response deleteGuildRank(@PathParam("name") String name, @PathParam("guildlevel") Integer guildlevel) Delete a rank of the guild of the user.- Parameters:
name
- the name of the userguildlevel
- the guildlevel of the rank- Returns:
- Response.ok if everything is okay.
-
authenticateGuildMaster
-
setPlayerAuthenticationService
-