|
|
|
|
@ -140,8 +140,8 @@ public class SimpleMongoDbFactory implements DisposableBean, MongoDbFactory {
@@ -140,8 +140,8 @@ public class SimpleMongoDbFactory implements DisposableBean, MongoDbFactory {
|
|
|
|
|
|
|
|
|
|
Assert.notNull(mongo, "Mongo must not be null"); |
|
|
|
|
Assert.hasText(databaseName, "Database name must not be empty"); |
|
|
|
|
Assert.isTrue(databaseName.matches("[\\w-]+"), |
|
|
|
|
"Database name must only contain letters, numbers, underscores and dashes!"); |
|
|
|
|
Assert.isTrue(databaseName.matches("[^/\\\\.$\"]+"), |
|
|
|
|
"Database name must not contain any of the symbols[" + "[^/\\\\.$\"]+" + "]"); |
|
|
|
|
|
|
|
|
|
this.mongo = mongo; |
|
|
|
|
this.databaseName = databaseName; |
|
|
|
|
@ -163,8 +163,13 @@ public class SimpleMongoDbFactory implements DisposableBean, MongoDbFactory {
@@ -163,8 +163,13 @@ public class SimpleMongoDbFactory implements DisposableBean, MongoDbFactory {
|
|
|
|
|
*/ |
|
|
|
|
private SimpleMongoDbFactory(MongoClient client, String databaseName, boolean mongoInstanceCreated) { |
|
|
|
|
|
|
|
|
|
Boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows"); |
|
|
|
|
String validNamePattern = isWindows ? "[^/\\\\.$*<>:|?\"]+" : "[^/\\\\.$\"]+"; |
|
|
|
|
|
|
|
|
|
Assert.notNull(client, "MongoClient must not be null!"); |
|
|
|
|
Assert.hasText(databaseName, "Database name must not be empty!"); |
|
|
|
|
Assert.isTrue(databaseName.matches(validNamePattern), |
|
|
|
|
"Database name must not contain any of the symbols[" + (isWindows ? "/\\.$*<>:|?\"" : "/\\.$\"") + "]"); |
|
|
|
|
|
|
|
|
|
this.mongo = client; |
|
|
|
|
this.databaseName = databaseName; |
|
|
|
|
|