I hereby claim:
- I am lefloh on github.
- I am lefloh (https://keybase.io/lefloh) on keybase.
- I have a public key whose fingerprint is D227 63CD 4436 14D4 DAAD EC68 8ED9 9EE7 0F85 6738
To claim this, I am signing this object:
| @Retention(RetentionPolicy.RUNTIME) | |
| @Target(ElementType.TYPE) | |
| public @interface Linked { | |
| Class<?> resource(); | |
| String method() default ""; | |
| String rel() default ""; | |
| public class LinkedSerializer extends JsonSerializer<Object> { | |
| private static final Pattern PARAM_PATTERN = Pattern.compile("\\{(.+?)\\}"); | |
| @Override | |
| public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { | |
| Linked linked = value.getClass().getAnnotation(Linked.class); | |
| if (linked == null) { | |
| jgen.writeNull(); | |
| return; |
| import static org.junit.Assert.assertTrue; | |
| import java.io.IOException; | |
| import java.net.BindException; | |
| import java.net.InetAddress; | |
| import org.ice4j.Transport; | |
| import org.ice4j.TransportAddress; | |
| import org.ice4j.ice.Agent; | |
| import org.ice4j.ice.Component; |
| public class Product { | |
| private Long id; | |
| private String name; | |
| private Brand brand; | |
| } | |
| public class Brand { | |
| private Long id; | |
| private String name; | |
| } |
| { | |
| "id": 4711, | |
| "name": "iPhone", | |
| "brand": { | |
| "id": 1174, | |
| "name": "Apple" | |
| } | |
| } |
| { | |
| "id": 4711, | |
| "name": "iPhone", | |
| "brand": { | |
| "rel": "brand", | |
| "href": "http://foo.bar.com/brands/1174" | |
| } | |
| } |
I hereby claim:
To claim this, I am signing this object:
| 08:04:35,731 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-1) RESTEASY002010: Failed to execute: javax.ws.rs.WebApplicationException: No customer with id 4711 found | |
| at com.foo.bar.CustomerResource.get(CustomerResource.java:48) | |
| at com.foo.bar.CustomerResource$Proxy$_$$_WeldClientProxy.get(Unknown Source) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
| at java.lang.reflect.Method.invoke(Method.java:498) | |
| at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139) | |
| at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295) | |
| at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249) |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import javax.ws.rs.WebApplicationException; | |
| import javax.ws.rs.core.Response; | |
| import javax.ws.rs.ext.ExceptionMapper; | |
| import javax.ws.rs.ext.Provider; | |
| @Provider | |
| public class WebApplicationExceptionMapper implements ExceptionMapper<WebApplicationException> { |
| public Customer getCustomer(@PathParam("id") long id, @Context UriInfo uriInfo) { | |
| Optional<Customer> customer = findCustomer(id); | |
| if (!customer.isPresent()) { | |
| throw new NotFoundException( | |
| String.format("No customer with id %d found. RequestUri was %s", | |
| id, uriInfo.getRequestUri())); | |
| } | |
| return customer.get(); | |
| } |