DATAREST-99 - Non-public repositories are not exported by default anymore.

This commit is contained in:
Oliver Gierke
2013-06-29 13:27:07 +02:00
parent 0127ca8d46
commit 310c2f1106
3 changed files with 18 additions and 5 deletions

View File

@@ -15,6 +15,8 @@
*/
package org.springframework.data.rest.repository.mapping;
import java.lang.reflect.Modifier;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.data.rest.core.Path;
import org.springframework.data.rest.repository.annotation.RestResource;
@@ -78,7 +80,7 @@ public class TypeBasedCollectionResourceMapping implements CollectionResourceMap
*/
@Override
public Boolean isExported() {
return annotation == null ? true : annotation.exported();
return annotation == null ? Modifier.isPublic(type.getModifiers()) : annotation.exported();
}
/*

View File

@@ -64,12 +64,12 @@ public class RepositoryCollectionResourceMappingUnitTests {
assertThat(mapping.isExported(), is(true));
}
static class Person {}
public static class Person {}
@RestResource(path = "bar", rel = "foo", exported = false)
static class AnnotatedPerson {}
interface PersonRepository extends Repository<Person, Long> {}
public interface PersonRepository extends Repository<Person, Long> {}
interface AnnotatedPersonRepository extends Repository<AnnotatedPerson, Long> {}

View File

@@ -51,12 +51,23 @@ public class TypeBasedCollectionResourceMappingUnitTest {
assertThat(mapping.isExported(), is(true));
}
class Sample {
/**
* @see DATAREST-99
*/
@Test
public void doesNotExportNonPublicTypesByDefault() {
CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(HiddenSample.class);
assertThat(mapping.isExported(), is(false));
}
public interface Sample {}
interface HiddenSample {}
@RestResource(rel = "myRel")
class CustomizedSample {
interface CustomizedSample {
}
}