DATAREST-99 - Non-public repositories are not exported by default anymore.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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> {}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user