Class Vote3Resource
java.lang.Object
org.ctan.site.resources.catalogue.Vote3Resource
@Path("/3.0")
@Produces({"application/json","application/xml"})
public class Vote3Resource
extends Object
The class
Vote3Resource
contains the controller for the vote
resource.-
Constructor Summary
ConstructorsConstructorDescriptionVote3Resource
(@NonNull VoteStore voteStore, @NonNull VoteService voteService, @NonNull PkgStore pkgStore, @NonNull UserStore userStore) This is the constructor forVote3Resource
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
deleteVote
(String pkg, String account) The methoddeleteVote
provides means to delete a vote.listVotesByAccount
(String uid, long page, long size) The methodlistVotesByAccount
provides means to retrieve a list of votes for a user.listVotesByPkg
(String pkgKey, long page, long size) The methodlistVotesByPkg
provides means to retrieve a list of votes for a package.The methodvote
provides means to update a vote.
-
Constructor Details
-
Vote3Resource
public Vote3Resource(@NonNull @NonNull VoteStore voteStore, @NonNull @NonNull VoteService voteService, @NonNull @NonNull PkgStore pkgStore, @NonNull @NonNull UserStore userStore) This is the constructor forVote3Resource
.- Parameters:
voteStore
- the vote storevoteService
- the vote servicepkgStore
- the package storeuserStore
- the user store
-
-
Method Details
-
deleteVote
@DELETE @Path("/vote") @PermitAll @UnitOfWork("siteDb") public boolean deleteVote(String pkg, String account) The methoddeleteVote
provides means to delete a vote.- Parameters:
pkg
- the name of the packageaccount
- the account name- Returns:
true
iff the deletion was successful
-
listVotesByAccount
@GET @Path("/votes/by/{user}") @PermitAll @UnitOfWork("siteDb") public VoteService.VoteSummaryTo listVotesByAccount(@PathParam("user") String uid, @DefaultValue("0") @QueryParam("page") long page, @DefaultValue("16") @QueryParam("size") long size) The methodlistVotesByAccount
provides means to retrieve a list of votes for a user.- Parameters:
uid
- the user idpage
- the pagesize
- the page size- Returns:
- a list of matching author summaries
-
listVotesByPkg
@GET @Path("/votes/{pkg}") @PermitAll @UnitOfWork("siteDb") public VoteService.VoteSummaryTo listVotesByPkg(@PathParam("pkg") String pkgKey, @DefaultValue("0") @QueryParam("page") long page, @DefaultValue("16") @QueryParam("size") long size) The methodlistVotesByPkg
provides means to retrieve a list of votes for a package.- Parameters:
pkgKey
- the package namepage
- the pagesize
- the page size- Returns:
- a list of matching author summaries
-
vote
@POST @Path("/vote") @PermitAll @UnitOfWork("siteDb") public VoteService.VoteTo vote(String pkg, int rating, int expertise, String comment, String account) The methodvote
provides means to update a vote.- Parameters:
pkg
- the package namerating
- the rating in the range [1, 5]expertise
- the expertise in the range [0, 4]comment
- the commentaccount
- the account name of the user- Returns:
- the updated vote record
-