Remove 3.x deprecations.

Removed all deprecations that have accumulated in the 3.x timeline so far.
This commit is contained in:
Oliver Drotbohm
2021-07-15 08:20:11 +02:00
parent 161a3a9499
commit 8a1d147009
8 changed files with 2 additions and 276 deletions

View File

@@ -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<EntityModel<?>> EMPTY_RESOURCE_LIST = Collections.emptyList();
public static <R extends RepresentationModel<?>> ResponseEntity<RepresentationModel<?>> toResponseEntity(
HttpStatus status, HttpHeaders headers, Optional<R> resource) {

View File

@@ -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);

View File

@@ -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<HandlerMapping>, Ordered {
private final List<HandlerMapping> delegates;
private final @Nullable PathPatternParser parser;

View File

@@ -189,10 +189,8 @@ public class DomainObjectReader {
* @param target
* @param mapper
* @return
* @deprecated
*/
@Deprecated
public <T> T merge(ObjectNode source, T target, ObjectMapper mapper) {
<T> T merge(ObjectNode source, T target, ObjectMapper mapper) {
try {
return doMerge(source, target, mapper);

View File

@@ -47,17 +47,6 @@ public class Patch implements Streamable<PatchOperation> {
return operations.size();
}
/**
* Returns all underlying {@link PatchOperation}s.
*
* @return
* @deprecated since 3.2, prefer streaming via {@link #stream()}.
*/
@Deprecated
public List<PatchOperation> 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.

View File

@@ -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<Link> 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<Link>();
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<? extends PersistentProperty<?>> 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);
}
}
}
}
}

View File

@@ -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<Link> links = new ArrayList<Link>();
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<Link> getLinks() {
return this.links;
}
/*
* (non-Javadoc)
* @see org.springframework.data.mapping.SimpleAssociationHandler#doWithAssociation(org.springframework.data.mapping.Association)
*/
@Override
public void doWithAssociation(Association<? extends PersistentProperty<?>> 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()));
}
}
}

View File

@@ -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<HandlerMapping> {
/**
* Returns all delegate {@link HandlerMapping}s. Prefer simply iterating over this instance itself.
*
* @return will never be {@literal null}.
*/
List<HandlerMapping> getDelegates();
}