UserRestViewV1.java
936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package fi.codecrew.moya.rest.meta.v1;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.User;
@RequestScoped
@Path("/meta/v1/user")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
public class UserRestViewV1 extends AbstractRestViewV1 {
@EJB
UserBeanLocal userBean;
@GET
@Path("/{id}/{path:.*}")
public String getMeta(@PathParam("id") Integer id,
@PathParam("path") List<PathSegment> path) {
User user = userBean.getUser(id);
return getEntityMeta(user, path);
}
// There is no way to merge/save User entity through the UserBean.
}