diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java index 6f1567421..3514127a5 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/config/RepositoryRestConfiguration.java @@ -378,7 +378,9 @@ public class RepositoryRestConfiguration { * * @param domainType The {@link Class} of the domain type to configure a mapping for. * @return A new {@link ResourceMapping} for configuring how a domain type is mapped. + * @deprecated for removal in 3.5 */ + @Deprecated public ResourceMapping setResourceMappingForDomainType(Class domainType) { return domainMappings.setResourceMappingFor(domainType); } @@ -388,7 +390,9 @@ public class RepositoryRestConfiguration { * * @param domainType The {@link Class} of the domain type. * @return A {@link ResourceMapping} for that domain type or {@literal null} if none exists. + * @deprecated for removal in 3.5 */ + @Deprecated public ResourceMapping getResourceMappingForDomainType(Class domainType) { return domainMappings.getResourceMappingFor(domainType); } @@ -398,7 +402,9 @@ public class RepositoryRestConfiguration { * * @param domainType The domain type to find a {@link ResourceMapping} for. * @return {@literal true} if a {@link ResourceMapping} exists for this domain class, {@literal false} otherwise. + * @deprecated for removal in 3.5 */ + @Deprecated public boolean hasResourceMappingForDomainType(Class domainType) { return domainMappings.hasResourceMappingFor(domainType); } @@ -407,7 +413,9 @@ public class RepositoryRestConfiguration { * Get the {@link ResourceMappingConfiguration} that is currently configured. * * @return + * @deprecated for removal in 3.5 */ + @Deprecated public ResourceMappingConfiguration getDomainTypesResourceMappingConfiguration() { return domainMappings; } @@ -417,7 +425,9 @@ public class RepositoryRestConfiguration { * * @param repositoryInterface The {@link Class} of the repository interface to configure a mapping for. * @return A new {@link ResourceMapping} for configuring how a repository interface is mapped. + * @deprecated for removal in 3.5 */ + @Deprecated public ResourceMapping setResourceMappingForRepository(Class repositoryInterface) { return repoMappings.setResourceMappingFor(repositoryInterface); } @@ -427,7 +437,9 @@ public class RepositoryRestConfiguration { * * @param repositoryInterface The {@link Class} of the repository interface. * @return A {@link ResourceMapping} for that repository interface or {@literal null} if none exists. + * @deprecated for removal in 3.5 */ + @Deprecated public ResourceMapping getResourceMappingForRepository(Class repositoryInterface) { return repoMappings.getResourceMappingFor(repositoryInterface); } @@ -437,11 +449,17 @@ public class RepositoryRestConfiguration { * * @param repositoryInterface * @return + * @deprecated for removal in 3.5 */ + @Deprecated public boolean hasResourceMappingForRepository(Class repositoryInterface) { return repoMappings.hasResourceMappingFor(repositoryInterface); } + /** + * @deprecated for removal in 3.5 + */ + @Deprecated public ResourceMapping findRepositoryMappingForPath(String path) { Class type = repoMappings.findTypeForPath(path); if (null == type) { diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/ResourceMappingUtils.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/ResourceMappingUtils.java index 274295f58..3ed4be8f3 100644 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/ResourceMappingUtils.java +++ b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/support/ResourceMappingUtils.java @@ -15,8 +15,8 @@ */ package org.springframework.data.rest.core.support; -import static org.springframework.data.rest.core.support.ResourceStringUtils.*; import static org.springframework.core.annotation.AnnotationUtils.*; +import static org.springframework.data.rest.core.support.ResourceStringUtils.*; import static org.springframework.util.StringUtils.*; import java.lang.reflect.Method; @@ -34,6 +34,7 @@ import org.springframework.data.rest.core.config.ResourceMapping; * @author Jon Brisbin * @author Florent Biville * @author Oliver Gierke + * @deprecated for removal in 3.5 */ @Deprecated public abstract class ResourceMappingUtils { @@ -77,7 +78,7 @@ public abstract class ResourceMappingUtils { ResourceMapping propertyMapping = entityMapping.getResourceMappingFor(persistentProperty.getName()); return String.format("%s.%s.%s", repoMapping.getRel(), entityMapping.getRel(), - (null != propertyMapping ? propertyMapping.getRel() : persistentProperty.getName())); + null != propertyMapping ? propertyMapping.getRel() : persistentProperty.getName()); } public static String findPath(Class type) { @@ -121,7 +122,7 @@ public abstract class ResourceMappingUtils { return null; } Class repoType = repoInfo.getRepositoryInterface(); - ResourceMapping mapping = (null != config ? config.getResourceMappingForRepository(repoType) : null); + ResourceMapping mapping = null != config ? config.getResourceMappingForRepository(repoType) : null; return merge(repoType, mapping); } @@ -131,16 +132,16 @@ public abstract class ResourceMappingUtils { return null; } Class domainType = persistentEntity.getType(); - ResourceMapping mapping = (null != config ? config.getResourceMappingForDomainType(domainType) : null); + ResourceMapping mapping = null != config ? config.getResourceMappingForDomainType(domainType) : null; return merge(domainType, mapping); } public static ResourceMapping merge(Method method, ResourceMapping mapping) { ResourceMapping defaultMapping = new ResourceMapping(findRel(method), findPath(method), findExported(method)); if (null != mapping) { - return new ResourceMapping((null != mapping.getRel() ? mapping.getRel() : defaultMapping.getRel()), - (null != mapping.getPath() ? mapping.getPath() : defaultMapping.getPath()), - (mapping.isExported() != defaultMapping.isExported() ? mapping.isExported() : defaultMapping.isExported())); + return new ResourceMapping(null != mapping.getRel() ? mapping.getRel() : defaultMapping.getRel(), + null != mapping.getPath() ? mapping.getPath() : defaultMapping.getPath(), + mapping.isExported() != defaultMapping.isExported() ? mapping.isExported() : defaultMapping.isExported()); } return defaultMapping; } @@ -148,10 +149,10 @@ public abstract class ResourceMappingUtils { public static ResourceMapping merge(Class type, ResourceMapping mapping) { ResourceMapping defaultMapping = new ResourceMapping(findRel(type), findPath(type), findExported(type)); if (null != mapping) { - return new ResourceMapping((null != mapping.getRel() ? mapping.getRel() : defaultMapping.getRel()), - (null != mapping.getPath() ? mapping.getPath() : defaultMapping.getPath()), - (mapping.isExported() != defaultMapping.isExported() ? mapping.isExported() : defaultMapping.isExported())) - .addResourceMappings(mapping.getResourceMappings()); + return new ResourceMapping(null != mapping.getRel() ? mapping.getRel() : defaultMapping.getRel(), + null != mapping.getPath() ? mapping.getPath() : defaultMapping.getPath(), + mapping.isExported() != defaultMapping.isExported() ? mapping.isExported() : defaultMapping.isExported()) + .addResourceMappings(mapping.getResourceMappings()); } return defaultMapping; } diff --git a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java b/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java deleted file mode 100644 index fe1f5c4eb..000000000 --- a/spring-data-rest-core/src/main/java/org/springframework/data/rest/core/util/Java8PluginRegistry.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.core.util; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.springframework.plugin.core.Plugin; -import org.springframework.plugin.core.PluginRegistry; - -/** - * @author Oliver Gierke - * @deprecated since 3.2, for removal 3.3. - */ -@Deprecated -public class Java8PluginRegistry, S> { - - private final PluginRegistry registry; - - public Java8PluginRegistry(PluginRegistry registry) { - this.registry = registry; - } - - public static , S> Java8PluginRegistry of(List plugins) { - return Java8PluginRegistry.of(PluginRegistry.of(plugins)); - } - - public static , S> Java8PluginRegistry of(PluginRegistry plugins) { - return new Java8PluginRegistry<>(plugins); - } - - public static , S> Java8PluginRegistry empty() { - return Java8PluginRegistry.of(Collections.emptyList()); - } - - public Optional getPluginFor(S delimiter) { - return registry.getPluginFor(delimiter); - } - - public T getPluginOrDefaultFor(S delimiter, T fallback) { - return getPluginFor(delimiter).orElse(fallback); - } -} diff --git a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/LegacyRepresentationConfigIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/LegacyRepresentationConfigIntegrationTests.java deleted file mode 100755 index 8608deba6..000000000 --- a/spring-data-rest-tests/spring-data-rest-tests-mongodb/src/test/java/org/springframework/data/rest/webmvc/config/LegacyRepresentationConfigIntegrationTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2013-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.webmvc.config; - -import static org.hamcrest.CoreMatchers.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import java.util.Arrays; - -import org.junit.Test; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.tests.mongodb.MongoDbRepositoryConfig; -import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; - -/** - * Integration tests to check the legacy representation is rendered if HAL is not the default media type. - * - * @author Oliver Gierke - */ -@ContextConfiguration -public class LegacyRepresentationConfigIntegrationTests extends AbstractRepositoryRestMvcConfigurationIntegrationTests { - - @Configuration - @Import({ MongoDbRepositoryConfig.class, RepositoryRestMvcConfiguration.class }) - static class Config extends RepositoryRestConfigurerAdapter { - - @Override - public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { - config.setDefaultMediaType(MediaType.APPLICATION_JSON); - config.useHalAsDefaultJsonMediaType(false); - } - } - - @Test // DATAREST-213, DATAREST-617 - public void returnsJsonIfConfiguredAndRequested() throws Exception { - - for (String resource : Arrays.asList("/", "/users")) { - - mvc.perform(get(resource).accept(MediaType.APPLICATION_JSON)). // - andExpect(jsonPath("links", is(notNullValue()))); - } - } - - @Test // DATAREST-213, DATAREST-617 - public void returnsJsonIfConfigured() throws Exception { - - for (String resource : Arrays.asList("/", "/users")) { - - mvc.perform(get(resource).accept(MediaType.ALL)). // - andExpect(jsonPath("links", is(notNullValue()))); - } - } -} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestConfigurerAdapter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestConfigurerAdapter.java deleted file mode 100644 index 53f214b89..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestConfigurerAdapter.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2015-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.rest.webmvc.config; - -import java.util.List; - -import org.springframework.core.convert.support.ConfigurableConversionService; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.core.event.ValidatingRepositoryEventListener; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Convenience adapter for {@link RepositoryRestConfigurer} to allow selective override of configuration methods. - * - * @author Oliver Gierke - * @since 2.4 - * @soundtrack Florian Reichelt & Max Ender - Abschlusskonzert (https://www.youtube.com/watch?v=5WP0P-ndinY) - * @deprecated since 3.1, implement {@link RepositoryRestConfigurer} directly. - */ -@Deprecated -public class RepositoryRestConfigurerAdapter implements RepositoryRestConfigurer { - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureRepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration) - */ - @Override - public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {} - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureConversionService(org.springframework.core.convert.support.ConfigurableConversionService) - */ - @Override - public void configureConversionService(ConfigurableConversionService conversionService) {} - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureValidatingRepositoryEventListener(org.springframework.data.rest.core.event.ValidatingRepositoryEventListener) - */ - @Override - public void configureValidatingRepositoryEventListener(ValidatingRepositoryEventListener validatingListener) {} - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureExceptionHandlerExceptionResolver(org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver) - */ - @Override - public void configureExceptionHandlerExceptionResolver(ExceptionHandlerExceptionResolver exceptionResolver) {} - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureHttpMessageConverters(java.util.List) - */ - @Override - public void configureHttpMessageConverters(List> messageConverters) {} - - /* - * (non-Javadoc) - * @see org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer#configureJacksonObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) - */ - @Override - public void configureJacksonObjectMapper(ObjectMapper objectMapper) {} -}