@ SuppressWarnings ( "unchecked" ) public boolean updateDoc ( Map < String , Object > jsonFields , String collName , String docId ) { if ( mCollections . containsKey ( collName ) ) { Map < String , Map < String , Object > > collection = mCollections . get ( collName ) ; Map < String , Object > doc = collection . get ( docId ) ; if ( doc != null ) { // take care of field updates Map < String , Object > fields = ( Map < String , Object > ) jsonFields . get ( DdpMessageField . FIELDS ) ; if ( fields != null ) { for ( Map . Entry < String , Object > field : fields . entrySet ( ) ) { String fieldname = field . getKey ( ) ; doc . put ( fieldname , field . getValue ( ) ) ; } } // take care of clearing fields List < String > clearfields = ( ( List < String > ) jsonFields . get ( DdpMessageField . CLEARED ) ) ; if ( clearfields != null ) { for ( String fieldname : clearfields ) { if ( doc . containsKey ( fieldname ) ) { doc . remove ( fieldname ) ; } } } return true ; } } else { log . warn ( "Received invalid changed msg for collection " + collName ) ; } return false ; }
Handles updating a document in a collection . Override if you want to use your own collection data store .