diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java index cb0ad156e..ffaeccc62 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/ControllerUtils.java @@ -15,11 +15,8 @@ */ package org.springframework.data.rest.webmvc; -import java.util.Collections; import java.util.Optional; -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.RepresentationModel; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -32,13 +29,6 @@ import org.springframework.util.Assert; */ public class ControllerUtils { - /** - * Use {@link CollectionModel#empty()} instead. - * - * @deprecated since 3.3 - */ - @Deprecated public static final Iterable> EMPTY_RESOURCE_LIST = Collections.emptyList(); - public static > ResponseEntity> toResponseEntity( HttpStatus status, HttpHeaders headers, Optional resource) { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RestMediaTypes.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RestMediaTypes.java index c3042e7d1..c2f659581 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RestMediaTypes.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RestMediaTypes.java @@ -26,24 +26,11 @@ import org.springframework.http.MediaType; */ public class RestMediaTypes { - public static final MediaType HAL_JSON = MediaTypes.HAL_JSON; public static final MediaType JSON_PATCH_JSON = MediaType.valueOf("application/json-patch+json"); public static final MediaType MERGE_PATCH_JSON = MediaType.valueOf("application/merge-patch+json"); - /** - * @deprecated Migrate to {@link MediaTypes#ALPS_JSON_VALUE}. - */ - @Deprecated - public static final String ALPS_JSON_VALUE = "application/alps+json"; - - /** - * @deprecated Migrate to {@link MediaTypes#ALPS_JSON}. - */ - @Deprecated - public static final MediaType ALPS_JSON = MediaType.parseMediaType(MediaTypes.ALPS_JSON_VALUE); - public static final String SCHEMA_JSON_VALUE = "application/schema+json"; public static final MediaType SCHEMA_JSON = MediaType.valueOf(SCHEMA_JSON_VALUE); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/DelegatingHandlerMapping.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/DelegatingHandlerMapping.java index 932d77d0d..2d633d11a 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/DelegatingHandlerMapping.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/DelegatingHandlerMapping.java @@ -41,8 +41,7 @@ import org.springframework.web.util.pattern.PathPatternParser; * @author Oliver Gierke * @soundtrack Benny Greb - Stabila (Moving Parts) */ -class DelegatingHandlerMapping - implements org.springframework.data.rest.webmvc.support.DelegatingHandlerMapping, Ordered { +class DelegatingHandlerMapping implements MatchableHandlerMapping, Iterable, Ordered { private final List delegates; private final @Nullable PathPatternParser parser; diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java index c47bdd31a..8a7c1f3a9 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java @@ -189,10 +189,8 @@ public class DomainObjectReader { * @param target * @param mapper * @return - * @deprecated */ - @Deprecated - public T merge(ObjectNode source, T target, ObjectMapper mapper) { + T merge(ObjectNode source, T target, ObjectMapper mapper) { try { return doMerge(source, target, mapper); diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/Patch.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/Patch.java index f858752c6..484762da5 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/Patch.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/patch/Patch.java @@ -47,17 +47,6 @@ public class Patch implements Streamable { return operations.size(); } - /** - * Returns all underlying {@link PatchOperation}s. - * - * @return - * @deprecated since 3.2, prefer streaming via {@link #stream()}. - */ - @Deprecated - public List getOperations() { - return operations; - } - /** * Applies the Patch to a given Object graph. Makes a copy of the given object so that it will remain unchanged after * application of the patch and in case any errors occur while performing the patch. diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/LinkCollectingAssociationHandler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/LinkCollectingAssociationHandler.java deleted file mode 100644 index bdb14dc68..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/LinkCollectingAssociationHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2014-2021 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.mapping; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.data.mapping.Association; -import org.springframework.data.mapping.MappingException; -import org.springframework.data.mapping.PersistentProperty; -import org.springframework.data.mapping.SimpleAssociationHandler; -import org.springframework.data.mapping.context.PersistentEntities; -import org.springframework.data.rest.core.Path; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.Links; -import org.springframework.util.Assert; - -/** - * {@link SimpleAssociationHandler} that will collect {@link Link}s for all linkable associations. - * - * @author Oliver Gierke - * @since 2.1 - * @deprecated no replacement, internal usage only. For removal in 3.5. - * @see LinkCollector - */ -@Deprecated -public class LinkCollectingAssociationHandler implements SimpleAssociationHandler { - - private static final String AMBIGUOUS_ASSOCIATIONS = "Detected multiple association links with same relation type! Disambiguate association %s using @RestResource!"; - - private final PersistentEntities entities; - private final Associations associations; - private final Path basePath; - private final boolean nested; - - private final List links; - - /** - * Creates a new {@link LinkCollectingAssociationHandler} for the given {@link PersistentEntities}, {@link Path} and - * {@link Associations}. - * - * @param entities must not be {@literal null}. - * @param path must not be {@literal null}. - * @param associations must not be {@literal null}. - */ - public LinkCollectingAssociationHandler(PersistentEntities entities, Path path, Associations associations) { - this(entities, path, associations, false); - } - - private LinkCollectingAssociationHandler(PersistentEntities entities, Path path, Associations associations, - boolean nested) { - - Assert.notNull(entities, "PersistentEntities must not be null!"); - Assert.notNull(path, "Path must not be null!"); - Assert.notNull(associations, "AssociationLinks must not be null!"); - - this.entities = entities; - this.associations = associations; - this.basePath = path; - - this.links = new ArrayList(); - this.nested = nested; - } - - public LinkCollectingAssociationHandler nested() { - return nested ? this : new LinkCollectingAssociationHandler(entities, basePath, associations, true); - } - - /** - * Returns the links collected after the {@link Association} has been traversed. - * - * @return the links - */ - public Links getLinks() { - return Links.of(links); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mapping.SimpleAssociationHandler#doWithAssociation(org.springframework.data.mapping.Association) - */ - @Override - public void doWithAssociation(final Association> association) { - - PersistentProperty property = association.getInverse(); - - if (associations.isLinkableAssociation(property)) { - - Links existingLinks = Links.of(links); - - for (Link link : associations.getLinksFor(association, basePath)) { - if (existingLinks.hasLink(link.getRel())) { - throw new MappingException(String.format(AMBIGUOUS_ASSOCIATIONS, property.toString())); - } else { - links.add(link); - } - } - } - } -} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java deleted file mode 100644 index 788ea2d7b..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/mapping/NestedLinkCollectingAssociationHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -// Generated by delombok at Tue Aug 11 12:51:25 CEST 2020 -/* - * Copyright 2016-2021 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.mapping; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.springframework.data.mapping.Association; -import org.springframework.data.mapping.IdentifierAccessor; -import org.springframework.data.mapping.PersistentEntity; -import org.springframework.data.mapping.PersistentProperty; -import org.springframework.data.mapping.PersistentPropertyAccessor; -import org.springframework.data.mapping.SimpleAssociationHandler; -import org.springframework.data.mapping.context.PersistentEntities; -import org.springframework.data.rest.core.mapping.ResourceMapping; -import org.springframework.data.rest.core.mapping.ResourceMappings; -import org.springframework.data.rest.core.mapping.ResourceMetadata; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.server.EntityLinks; - -/** - * @author Oliver Gierke - * @deprecated no replacement, internal usage only. For removal in 3.5 - * @see LinkCollector - */ -@Deprecated -public class NestedLinkCollectingAssociationHandler implements SimpleAssociationHandler { - private final EntityLinks entityLinks; - private final PersistentEntities entities; - private final PersistentPropertyAccessor accessor; - private final ResourceMappings mappings; - private final List links = new ArrayList(); - - public NestedLinkCollectingAssociationHandler(final EntityLinks entityLinks, final PersistentEntities entities, - final PersistentPropertyAccessor accessor, final ResourceMappings mappings) { - this.entityLinks = entityLinks; - this.entities = entities; - this.accessor = accessor; - this.mappings = mappings; - } - - public List getLinks() { - return this.links; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mapping.SimpleAssociationHandler#doWithAssociation(org.springframework.data.mapping.Association) - */ - @Override - public void doWithAssociation(Association> association) { - PersistentProperty property = association.getInverse(); - Object propertyValue = accessor.getProperty(property); - ResourceMetadata metadata = mappings.getMetadataFor(property.getOwner().getType()); - ResourceMapping propertyMapping = metadata.getMappingFor(property); - if (property.isCollectionLike()) { - for (Object element : (Collection) propertyValue) { - PersistentEntity entity = entities.getRequiredPersistentEntity(element.getClass()); - IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(element); - links.add(entityLinks.linkForItemResource(element.getClass(), identifierAccessor.getIdentifier()) - .withRel(propertyMapping.getRel())); - } - } else { - PersistentEntity entity = entities.getRequiredPersistentEntity(propertyValue.getClass()); - IdentifierAccessor identifierAccessor = entity.getIdentifierAccessor(propertyValue); - links.add(entityLinks.linkForItemResource(propertyValue.getClass(), identifierAccessor.getIdentifier()) - .withRel(propertyMapping.getRel())); - } - } -} diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/DelegatingHandlerMapping.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/DelegatingHandlerMapping.java deleted file mode 100644 index e96f10e9d..000000000 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/DelegatingHandlerMapping.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020-2021 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.support; - -import java.util.List; - -import org.springframework.web.servlet.HandlerMapping; -import org.springframework.web.servlet.handler.MatchableHandlerMapping; - -/** - * A {@link HandlerMapping} that exposes its delegates. - * - * @author Oliver Drotbohm - * @deprecated since 3.4. Prefer handling {@link HandlerMapping}s that implement {@link Iterable} of - * {@link HandlerMapping} and consume the delegates that way. - */ -@Deprecated -public interface DelegatingHandlerMapping extends MatchableHandlerMapping, Iterable { - - /** - * Returns all delegate {@link HandlerMapping}s. Prefer simply iterating over this instance itself. - * - * @return will never be {@literal null}. - */ - List getDelegates(); -}