Permalink
Browse files

Add new resource to update user profile.

  • Loading branch information...
1 parent a262f45 commit 947a6f78778734b47064fc60319a7099a44cd012 @shsu committed Mar 1, 2014
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/main/java/ca/bcit/infosys/comp4911/services/UserResource.java
@@ -20,6 +20,7 @@
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
@@ -47,14 +48,26 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
- public Response retrieveAuthenticatedUserInfo(
+ public Response retrieveUserProfile(
@HeaderParam(SH.AUTHORIZATION_STRING) final String headerToken,
@QueryParam(SH.TOKEN_STRING) final String queryToken) {
int userId = userTokens.verifyTokenAndReturnUserID(headerToken, queryToken);
return SH.responseWithEntity(200, userDao.read(userId));
}
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response updateUserProfile(
+ @HeaderParam(SH.AUTHORIZATION_STRING) final String headerToken,
+ @QueryParam(SH.TOKEN_STRING) final String queryToken,
+ final User user) {
+ int userId = userTokens.verifyTokenAndReturnUserID(headerToken, queryToken);
+
+ userDao.update(user);
+ return SH.response(200);
+ }
+
@Path("/token")
@GET
@Produces(MediaType.APPLICATION_JSON)

0 comments on commit 947a6f7

Please sign in to comment.