DATAREST-39: Modified the DELETEing of links so that an attempt to delete a required relationship will result in a 405 Method Not Allowed. Had to change the entities and tests to accommodate the new required relationship on the Address entity, which pingponged into a number of changes.

This commit is contained in:
Jon Brisbin
2012-08-17 13:37:26 -05:00
committed by Jon Brisbin
parent 2dd0511f8f
commit b9b6a8fe92
11 changed files with 130 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
package org.springframework.data.rest.repository;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -90,6 +91,27 @@ public interface AttributeMetadata {
*/
Map asMap(Object target);
/**
* Does this attribute have the given annotation on it?
*
* @param annoType
* The type of annotation to search for.
*
* @return {@literal true} if this annotation exists on this attribute, {@literal false} otherwise.
*/
boolean hasAnnotation(Class<? extends Annotation> annoType);
/**
* Get the given annotation.
*
* @param annoType
* The type of annotation to get.
* @param <A>
*
* @return The annotation, or {@literal null} if it doesn't exist.
*/
<A extends Annotation> A annotation(Class<A> annoType);
/**
* Get the path of this attribute.
*

View File

@@ -1,6 +1,7 @@
package org.springframework.data.rest.repository.jpa;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -126,6 +127,14 @@ public class JpaAttributeMetadata implements AttributeMetadata {
return (Map)get(target);
}
@Override public boolean hasAnnotation(Class<? extends Annotation> annoType) {
return field.isAnnotationPresent(annoType);
}
@Override public <A extends Annotation> A annotation(Class<A> annoType) {
return field.getAnnotation(annoType);
}
@Override public Object get(Object target) {
try {
if(null != getter) {