Commit 8c0322bd by Juho Juopperi

rest annotations and return types

1 parent 83117e3f
package fi.codecrew.moya.rest.pojo.util.v1;
import com.wordnik.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@ApiModel
public class ErrorRoot {
private String error;
......
......@@ -310,7 +310,7 @@ public class UserRestView {
@POST
@Path("/{userid}/check-password")
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Check user password")
@ApiOperation(value = "Check user password", response = EventUserRestPojo.class)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response checkPassword(@PathParam("userid") @ApiParam("User ID") Integer userId,
@FormParam("password") @ApiParam("Password") String password) {
......@@ -337,7 +337,7 @@ public class UserRestView {
@POST
@Path("/{userid}/reset-password")
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Reset user password")
@ApiOperation(value = "Reset user password", response = EventUserRestPojo.class)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response resetPassword(@PathParam("userid") @ApiParam("User ID") Integer userId,
@FormParam("password") @ApiParam("New password") String password) {
......@@ -352,24 +352,28 @@ public class UserRestView {
}
}
/**
* Post forma parameter "image" with the image data in it.
* @param request
* @param userId
* @return
* @throws IOException
*/
@PUT
@Path("/{userId}/image")
@ApiOperation(value = "Upload image")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/{userid}/image")
@ApiOperation(value = "Upload image", response = EventUserRestPojo.class)
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateUserImage(@Context HttpServletRequest request,
@PathParam("userId") @ApiParam("User ID") Integer userId) throws IOException {
@PathParam("userid") @ApiParam("User ID") Integer userId) throws IOException {
try {
Part imagePart = request.getPart("image");
User user = userbean.getUser(userId);
EventUser eventUser = userbean.getEventUser(user, true);
EventUser eventUser = userbean.findByUserId(userId, true);
UserImage userImage = userbean.uploadImage(eventUser, imagePart.getContentType(),
imagePart.getInputStream(), imagePart.getSubmittedFileName(), null);
return Response.ok().build();
return Response.ok(PojoUtils.initEventUserRestPojo(eventUser)).build();
} catch (ServletException e) {
logger.error("Updating user image failed", e);
return Response.serverError().build();
return Response.serverError().entity(PojoUtils.initErrorPojo("Updating user image failed")).build();
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!