1 package com.atlassian.plugins.rest.validation;
2
3 import javax.ws.rs.Consumes;
4 import javax.ws.rs.POST;
5 import javax.ws.rs.Path;
6 import javax.ws.rs.Produces;
7
8 import com.atlassian.plugins.rest.common.interceptor.InterceptorChain;
9 import com.atlassian.plugins.rest.common.transaction.TransactionInterceptor;
10 import com.atlassian.plugins.rest.common.validation.ValidationInterceptor;
11
12 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
13 import static javax.ws.rs.core.MediaType.APPLICATION_XML;
14
15 @Path("/validatedResource")
16 @InterceptorChain({ValidationInterceptor.class, TransactionInterceptor.class})
17 public class ValidatedResource {
18 @POST
19 @Consumes({APPLICATION_XML, APPLICATION_JSON})
20 @Produces({APPLICATION_XML, APPLICATION_JSON})
21 public PersonResponse addPerson(Person person) {
22 PersonResponse res = new PersonResponse();
23 res.setName(person.getName());
24 return res;
25 }
26 }