polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [11/50] [abbrv] zest-qi4j git commit: MongoDB EntityStore now use Mongo Driver 2.12.2
Date Fri, 24 Apr 2015 06:36:24 GMT
MongoDB EntityStore now use Mongo Driver 2.12.2


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/a4cf8c75
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/a4cf8c75
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/a4cf8c75

Branch: refs/heads/master
Commit: a4cf8c7583c5de40e0c2000b31091830a36ca23d
Parents: b430b0a
Author: Paul Merlin <paul@nosphere.org>
Authored: Thu Jun 12 14:55:41 2014 +0200
Committer: Paul Merlin <paul@nosphere.org>
Committed: Thu Jun 12 14:55:41 2014 +0200

----------------------------------------------------------------------
 .../mongodb/MongoEntityStoreConfiguration.java  |  2 --
 .../mongodb/MongoMapEntityStoreMixin.java       | 27 ++++++++------------
 libraries.gradle                                |  2 +-
 3 files changed, 11 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/a4cf8c75/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoEntityStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoEntityStoreConfiguration.java
b/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoEntityStoreConfiguration.java
index 92763ac..6b26cab 100644
--- a/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoEntityStoreConfiguration.java
+++ b/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoEntityStoreConfiguration.java
@@ -58,8 +58,6 @@ public interface MongoEntityStoreConfiguration
 
         /** Exceptions are raised for network issues, but not server errors */
         NORMAL,
-        /** No exceptions are raised, even for network issues */
-        NONE,
         /** Exceptions are raised for network issues, and server errors; waits on a server
for the write operation */
         SAFE,
         /** Exceptions are raised for network issues, and server errors; waits on a majority
of servers for the write operation */

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/a4cf8c75/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoMapEntityStoreMixin.java
b/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoMapEntityStoreMixin.java
index fc77f54..361f953 100644
--- a/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoMapEntityStoreMixin.java
+++ b/extensions/entitystore-mongodb/src/main/java/org/qi4j/entitystore/mongodb/MongoMapEntityStoreMixin.java
@@ -23,6 +23,7 @@ import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
 import com.mongodb.DBObject;
 import com.mongodb.MongoClient;
+import com.mongodb.MongoCredential;
 import com.mongodb.ServerAddress;
 import com.mongodb.WriteConcern;
 import com.mongodb.util.JSON;
@@ -47,8 +48,6 @@ import org.qi4j.io.Sender;
 import org.qi4j.spi.entitystore.EntityNotFoundException;
 import org.qi4j.spi.entitystore.EntityStoreException;
 import org.qi4j.spi.entitystore.helpers.MapEntityStore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * MongoDB implementation of MapEntityStore.
@@ -56,10 +55,9 @@ import org.slf4j.LoggerFactory;
 public class MongoMapEntityStoreMixin
     implements ServiceActivation, MapEntityStore, MongoAccessors
 {
-    private static final Logger LOGGER = LoggerFactory.getLogger( "org.qi4j.entitystore.mongodb"
);
     private static final String DEFAULT_DATABASE_NAME = "qi4j:entitystore";
     private static final String DEFAULT_COLLECTION_NAME = "qi4j:entitystore:entities";
-    public static final String IDENTITY_COLUMN = "identity";
+    public static final String IDENTITY_COLUMN = "_id";
     public static final String STATE_COLUMN = "state";
     @This
     private Configuration<MongoEntityStoreConfiguration> configuration;
@@ -79,18 +77,16 @@ public class MongoMapEntityStoreMixin
         loadConfiguration();
 
         // Create Mongo driver and open the database
-        mongo = new MongoClient( serverAddresses );
-        db = mongo.getDB( databaseName );
-
-        // Authenticate if needed
-        if( !username.isEmpty() )
+        if( username.isEmpty() )
         {
-            if( !db.authenticate( username, password ) )
-            {
-                LOGGER.warn( "Authentication against MongoDB with username '" + username
+ "' failed. "
-                             + "Subsequent requests will be made 'anonymously'." );
-            }
+            mongo = new MongoClient( serverAddresses );
         }
+        else
+        {
+            MongoCredential credential = MongoCredential.createMongoCRCredential( username,
databaseName, password );
+            mongo = new MongoClient( serverAddresses, Arrays.asList( credential ) );
+        }
+        db = mongo.getDB( databaseName );
 
         // Create index if needed
         db.requestStart();
@@ -152,9 +148,6 @@ public class MongoMapEntityStoreMixin
             case MAJORITY:
                 writeConcern = WriteConcern.MAJORITY;
                 break;
-            case NONE:
-                writeConcern = WriteConcern.NONE;
-                break;
             case REPLICAS_SAFE:
                 writeConcern = WriteConcern.REPLICAS_SAFE;
                 break;

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/a4cf8c75/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index eb9da0c..f162e44 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -37,8 +37,8 @@ def leveldbVersion = '0.7'
 def leveldbJniVersion = '1.8'
 def liquibaseVersion = '3.2.0'
 def log4jVersion = '1.2.17'
-def mongodbVersion = '2.11.3'
 def logbackVersion = '1.1.2'
+def mongodbVersion = '2.12.2'
 def mysqlVersion = '5.1.31'
 def neoVersion = '1.3' // 1.9.4 Fails to compile! - 2.1.2 exists
 def neoIndexVersion = '1.3-1.3.M01' // Do not exist anymore!


Mime
View raw message