23
23
import com .mongodb .MongoClientSettings ;
24
24
import com .mongodb .MongoCredential ;
25
25
import com .mongodb .ServerAddress ;
26
- import org .bson .BsonDocument ;
27
26
import org .bson .Document ;
28
27
29
28
public class MongoController {
@@ -204,7 +203,8 @@ public void setProfile(UserProfile up) {
204
203
Document replacement = new Document ("user" , user );
205
204
if (up .getProfile () != null ) {
206
205
if (up .getProfile ().asJsonNode ().isObject ()) {
207
- replacement .put ("profile" , BsonDocument .parse (up .getProfile ().asJsonNode ().toString ()));
206
+ System .out .println ("jsonString1: " + up .getProfile ().asJsonNode ().toString ());
207
+ replacement .put ("profile" , Document .parse (up .getProfile ().asJsonNode ().toString ()));
208
208
} else {
209
209
throw new RuntimeException ("Profile must be an object if defined." );
210
210
}
@@ -223,7 +223,8 @@ public void setProfile(UserProfile up) {
223
223
Document profile = new Document ("user" , user );
224
224
if (up .getProfile () != null ) {
225
225
if (up .getProfile ().asJsonNode ().isObject ()) {
226
- profile .put ("profile" , BsonDocument .parse (up .getProfile ().asJsonNode ().toString ()));
226
+ System .out .println ("jsonString2: " + up .getProfile ().asJsonNode ().toString ());
227
+ profile .put ("profile" , Document .parse (up .getProfile ().asJsonNode ().toString ()));
227
228
} else {
228
229
throw new RuntimeException ("Profile must be an object if defined." );
229
230
}
@@ -255,7 +256,7 @@ public void updateProfile(UserProfile up) {
255
256
Iterator <Entry <String , JsonNode >> fields = profileNode .fields ();
256
257
while (fields .hasNext ()) {
257
258
Entry <String ,JsonNode > e = fields .next ();
258
- update .put ("profile." + e .getKey (), BsonDocument .parse (e .getValue ().toString ()));
259
+ update .put ("profile." + e .getKey (), Document .parse (e .getValue ().toString ()));
259
260
}
260
261
} else {
261
262
throw new RuntimeException ("Profile must be an object if defined." );
@@ -273,7 +274,7 @@ public void updateProfile(UserProfile up) {
273
274
Document profile = new Document ("user" , user );
274
275
if (up .getProfile () != null ) {
275
276
if (up .getProfile ().asJsonNode ().isObject ()) {
276
- profile .put ("profile" , BsonDocument .parse (up .getProfile ().asJsonNode ().toString ()));
277
+ profile .put ("profile" , Document .parse (up .getProfile ().asJsonNode ().toString ()));
277
278
} else {
278
279
throw new RuntimeException ("Profile must be an object if defined." );
279
280
}
0 commit comments