Hey all,

I'm new here.  We're planning on running GeoServer on top of MongoDB Atlas.  
We're successfully doing it with the addition of a patch, attached and shown 
below.  It's very basic, just adds support for the URI scheme that starts with 
mongodb+srv:// in addition to the mongodb:// prefix.  I'm hoping someone with 
commit access would be willing to add it to main for others as well.  I'm happy 
to write tests for it (probably in  MongoSchemaDBStoreTest.java), but didn't 
see any tests specifically focused on the prefix(s), so I haven't up to this 
point.

Thanks!
-Karl

diff --git 
a/modules/plugin/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java
 
b/modules/plugin/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java
index 5c710b4233..299194e5c5 100644
--- 
a/modules/plugin/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java
+++ 
b/modules/plugin/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java
@@ -185,9 +185,10 @@ public class MongoDataStore extends ContentDataStore {
         if (dataStoreURI == null) {
             throw new IllegalArgumentException("dataStoreURI may not be null");
         }
-        if (!dataStoreURI.startsWith("mongodb://")) {
+        if (!dataStoreURI.startsWith("mongodb://")
+             && !dataStoreURI.startsWith("mongodb+srv://")) {
             throw new IllegalArgumentException(
-                    "incorrect scheme for URI, expected to begin with 
\"mongodb://\", found URI of \""
+                    "incorrect scheme for URI, expected to begin with 
\"mongodb://\" or \"mongodb+srv://\", found URI of \""
                             + dataStoreURI
                             + "\"");
         }
@@ -223,7 +224,8 @@ public class MongoDataStore extends ContentDataStore {
                                 + "\"",
                         e);
             }
-        } else if (schemaStoreURI.startsWith("mongodb:")) {
+        } else if (schemaStoreURI.startsWith("mongodb:")
+                || schemaStoreURI.startsWith("mongodb+srv:")) {
             try {
                 return new MongoSchemaDBStore(schemaStoreURI);
             } catch (IOException e) {


Attachment: mongodbsrv.patch
Description: mongodbsrv.patch

_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to