Skip to content

Commit e63013d

Browse files
Remove previously deprecated API.
This commit removes and moves off deprecated API. Additionally some blocks got deprecated due to changes in MongoDB server API. Resolves: #3952
1 parent 2367379 commit e63013d

File tree

117 files changed

+541
-4147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+541
-4147
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDbFactory.java

-57
This file was deleted.

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/AbstractMongoClientConfiguration.java

+1-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2021 the original author or authors.
2+
* Copyright 2018-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,9 +25,7 @@
2525
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
2626
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
2727
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
28-
import org.springframework.data.mongodb.core.mapping.Document;
2928
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
30-
import org.springframework.lang.Nullable;
3129

3230
import com.mongodb.MongoClientSettings;
3331
import com.mongodb.MongoClientSettings.Builder;
@@ -80,24 +78,6 @@ public MongoDatabaseFactory mongoDbFactory() {
8078
return new SimpleMongoClientDatabaseFactory(mongoClient(), getDatabaseName());
8179
}
8280

83-
/**
84-
* Return the base package to scan for mapped {@link Document}s. Will return the package name of the configuration
85-
* class' (the concrete class, not this one here) by default. So if you have a {@code com.acme.AppConfig} extending
86-
* {@link AbstractMongoClientConfiguration} the base package will be considered {@code com.acme} unless the method is
87-
* overridden to implement alternate behavior.
88-
*
89-
* @return the base package to scan for mapped {@link Document} classes or {@literal null} to not enable scanning for
90-
* entities.
91-
* @deprecated use {@link #getMappingBasePackages()} instead.
92-
*/
93-
@Deprecated
94-
@Nullable
95-
protected String getMappingBasePackage() {
96-
97-
Package mappingBasePackage = getClass().getPackage();
98-
return mappingBasePackage == null ? null : mappingBasePackage.getName();
99-
}
100-
10181
/**
10282
* Creates a {@link MappingMongoConverter} using the configured {@link #mongoDbFactory()} and
10383
* {@link #mongoMappingContext(MongoCustomConversions)}. Will get {@link #customConversions()} applied.

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParsingUtils.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2021 the original author or authors.
2+
* Copyright 2011-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,6 @@
4040
* @author Christoph Strobl
4141
* @author Mark Paluch
4242
*/
43-
@SuppressWarnings("deprecation")
4443
abstract class MongoParsingUtils {
4544

4645
private MongoParsingUtils() {}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2021 the original author or authors.
2+
* Copyright 2010-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,20 +47,6 @@ public class CollectionOptions {
4747
private ValidationOptions validationOptions;
4848
private @Nullable TimeSeriesOptions timeSeriesOptions;
4949

50-
/**
51-
* Constructs a new <code>CollectionOptions</code> instance.
52-
*
53-
* @param size the collection size in bytes, this data space is preallocated. Can be {@literal null}.
54-
* @param maxDocuments the maximum number of documents in the collection. Can be {@literal null}.
55-
* @param capped true to created a "capped" collection (fixed size with auto-FIFO behavior based on insertion order),
56-
* false otherwise. Can be {@literal null}.
57-
* @deprecated since 2.0 please use {@link CollectionOptions#empty()} as entry point.
58-
*/
59-
@Deprecated
60-
public CollectionOptions(@Nullable Long size, @Nullable Long maxDocuments, @Nullable Boolean capped) {
61-
this(size, maxDocuments, capped, null, ValidationOptions.none(), null);
62-
}
63-
6450
private CollectionOptions(@Nullable Long size, @Nullable Long maxDocuments, @Nullable Boolean capped,
6551
@Nullable Collation collation, ValidationOptions validationOptions,
6652
@Nullable TimeSeriesOptions timeSeriesOptions) {

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoClientFactoryBean.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ private MongoClient createMongoClient(MongoClientSettings settings) throws Unkno
337337
}
338338

339339
private String getOrDefault(Object value, String defaultValue) {
340-
return !StringUtils.isEmpty(value) ? value.toString() : defaultValue;
340+
341+
if(value == null) {
342+
return defaultValue;
343+
}
344+
String sValue = value.toString();
345+
return StringUtils.hasText(sValue) ? sValue : defaultValue;
341346
}
342347
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbFactorySupport.java

-50
This file was deleted.

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

+8-40
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.stream.Stream;
2424

2525
import org.bson.Document;
26-
2726
import org.springframework.data.geo.GeoResults;
2827
import org.springframework.data.mongodb.core.BulkOperations.BulkMode;
2928
import org.springframework.data.mongodb.core.aggregation.Aggregation;
@@ -34,8 +33,6 @@
3433
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
3534
import org.springframework.data.mongodb.core.convert.MongoConverter;
3635
import org.springframework.data.mongodb.core.index.IndexOperations;
37-
import org.springframework.data.mongodb.core.mapreduce.GroupBy;
38-
import org.springframework.data.mongodb.core.mapreduce.GroupByResults;
3936
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
4037
import org.springframework.data.mongodb.core.mapreduce.MapReduceResults;
4138
import org.springframework.data.mongodb.core.query.BasicQuery;
@@ -431,43 +428,6 @@ public <T> T execute(SessionCallback<T> action, Consumer<ClientSession> onComple
431428
*/
432429
<T> List<T> findAll(Class<T> entityClass, String collectionName);
433430

434-
/**
435-
* Execute a group operation over the entire collection. The group operation entity class should match the 'shape' of
436-
* the returned object that takes int account the initial document structure as well as any finalize functions.
437-
*
438-
* @param inputCollectionName the collection where the group operation will read from
439-
* @param groupBy the conditions under which the group operation will be performed, e.g. keys, initial document,
440-
* reduce function.
441-
* @param entityClass The parametrized type of the returned list
442-
* @return The results of the group operation
443-
* @deprecated since 2.2. The {@code group} command has been removed in MongoDB Server 4.2.0. <br />
444-
* Please use {@link #aggregate(TypedAggregation, String, Class) } with a
445-
* {@link org.springframework.data.mongodb.core.aggregation.GroupOperation} instead.
446-
*/
447-
@Deprecated
448-
<T> GroupByResults<T> group(String inputCollectionName, GroupBy groupBy, Class<T> entityClass);
449-
450-
/**
451-
* Execute a group operation restricting the rows to those which match the provided Criteria. The group operation
452-
* entity class should match the 'shape' of the returned object that takes int account the initial document structure
453-
* as well as any finalize functions.
454-
*
455-
* @param criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are
456-
* considered.
457-
* @param inputCollectionName the collection where the group operation will read from
458-
* @param groupBy the conditions under which the group operation will be performed, e.g. keys, initial document,
459-
* reduce function.
460-
* @param entityClass The parametrized type of the returned list
461-
* @return The results of the group operation
462-
* @deprecated since 2.2. The {@code group} command has been removed in MongoDB Server 4.2.0. <br />
463-
* Please use {@link #aggregate(TypedAggregation, String, Class) } with a
464-
* {@link org.springframework.data.mongodb.core.aggregation.GroupOperation} and
465-
* {@link org.springframework.data.mongodb.core.aggregation.MatchOperation} instead.
466-
*/
467-
@Deprecated
468-
<T> GroupByResults<T> group(@Nullable Criteria criteria, String inputCollectionName, GroupBy groupBy,
469-
Class<T> entityClass);
470-
471431
/**
472432
* Execute an aggregation operation. The raw results will be mapped to the given entity class. The name of the
473433
* inputCollection is derived from the inputType of the aggregation.
@@ -606,7 +566,9 @@ <T> GroupByResults<T> group(@Nullable Criteria criteria, String inputCollectionN
606566
* @param reduceFunction The JavaScript reduce function
607567
* @param entityClass The parametrized type of the returned list. Must not be {@literal null}.
608568
* @return The results of the map reduce operation
569+
* @deprecated since MongoDB server version 5.0
609570
*/
571+
@Deprecated
610572
<T> MapReduceResults<T> mapReduce(String inputCollectionName, String mapFunction, String reduceFunction,
611573
Class<T> entityClass);
612574

@@ -619,7 +581,9 @@ <T> MapReduceResults<T> mapReduce(String inputCollectionName, String mapFunction
619581
* @param mapReduceOptions Options that specify detailed map-reduce behavior.
620582
* @param entityClass The parametrized type of the returned list. Must not be {@literal null}.
621583
* @return The results of the map reduce operation
584+
* @deprecated since MongoDB server version 5.0
622585
*/
586+
@Deprecated
623587
<T> MapReduceResults<T> mapReduce(String inputCollectionName, String mapFunction, String reduceFunction,
624588
@Nullable MapReduceOptions mapReduceOptions, Class<T> entityClass);
625589

@@ -633,7 +597,9 @@ <T> MapReduceResults<T> mapReduce(String inputCollectionName, String mapFunction
633597
* @param reduceFunction The JavaScript reduce function
634598
* @param entityClass The parametrized type of the returned list. Must not be {@literal null}.
635599
* @return The results of the map reduce operation
600+
* @deprecated since MongoDB server version 5.0
636601
*/
602+
@Deprecated
637603
<T> MapReduceResults<T> mapReduce(Query query, String inputCollectionName, String mapFunction, String reduceFunction,
638604
Class<T> entityClass);
639605

@@ -647,7 +613,9 @@ <T> MapReduceResults<T> mapReduce(Query query, String inputCollectionName, Strin
647613
* @param mapReduceOptions Options that specify detailed map-reduce behavior
648614
* @param entityClass The parametrized type of the returned list. Must not be {@literal null}.
649615
* @return The results of the map reduce operation
616+
* @deprecated since MongoDB server version 5.0
650617
*/
618+
@Deprecated
651619
<T> MapReduceResults<T> mapReduce(Query query, String inputCollectionName, String mapFunction, String reduceFunction,
652620
@Nullable MapReduceOptions mapReduceOptions, Class<T> entityClass);
653621

0 commit comments

Comments
 (0)