android - RxJava and Firebase database -


i'm trying refactor synchronization procedure rxjava support. i've faced strange (for me) error.

initially, execute 'sync' procedure. in 'oncompleted' execute syncpart2. it's same procedure (but others nodes sync)

in 'syncpart2' 'error=databaseerror: permission denied'. database rules ok, error appears on different nodes (and current sync works fine).

basically, have 16 nodes sync 1 one, in specific order. maybe i've chosen wrong rx operation that? way, if use 1 'concat' ok! have more 9 (max size of 'concat' args) nodes sync.

public class rxfirebasedatabase {      @nonnull     public static observable<datasnapshot> observesinglevalueevent(@nonnull final query query) {         return observable.create(new observable.onsubscribe<datasnapshot>() {             @override             public void call(final subscriber<? super datasnapshot> subscriber) {                 query.addlistenerforsinglevalueevent(new valueeventlistener() {                     @override                     public void ondatachange(datasnapshot datasnapshot) {                         if (!subscriber.isunsubscribed()) {                             subscriber.onnext(datasnapshot);                             subscriber.oncompleted();                         }                     }                      @override                     public void oncancelled(databaseerror error) {                         if (!subscriber.isunsubscribed()) {                             subscriber.onerror(new rxfirebasedataexception(error));                         }                     }                 });             }         });     }  }     public static void sync() {          observable.concat(                  rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.deleted_objects_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.msi_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.courses_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.allergies_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.phones_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.medicines_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.profiles_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.analyses_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.diagnoses_node))          )                 .observeon(schedulers.io())                 .subscribe(new subscriber<datasnapshot>() {                     @override                     public void oncompleted() {                          syncpart2();                      }                      @override                     public void onerror(throwable e) {                          log.d(appconstants.tag_sync, "the error appears: " + e.getmessage());                      }                      @override                     public void onnext(datasnapshot datasnapshot) {                          genericclass genericclass = retrieveinfoaboutnode(datasnapshot);                          if (genericclass.getmytype() == deletedobject.class) {                              handledeletedobjects(datasnapshot);                          } else if (genericclass.getmytype() == medicinescheduleritem.class) {                              handlemsi(datasnapshot);                          } else if (genericclass.getmytype() == medicinecourse.class) {                              handlemedicinecourse(datasnapshot);                          } else {                              handle(datasnapshot, genericclass);                          }                      }                 });     }      public static void syncpart2() {          observable.concat(                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.hospitals_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.recommendations_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.user_files_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.specializations_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.doctors_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.doctor_visits_node)),                 rxfirebasedatabase.observesinglevalueevent(getfirebasereference(appconstants.firebase_constants.photos_node))         )                 .subscribe(new subscriber<datasnapshot>() {                     @override                     public void oncompleted() {                          eventbus.getdefault().post(new firebaseevents().new syncfinished().new alltasksfinished());                      }                      @override                     public void onerror(throwable e) {                          log.d(appconstants.tag_sync, "the error appears: " + e.getmessage());                      }                      @override                     public void onnext(datasnapshot datasnapshot) {                          genericclass genericclass = retrieveinfoaboutnode(datasnapshot);                          handle(datasnapshot, genericclass);                      }                 });     } 

actually, permissions not cause of issue.

i've had 'invocationtargetexception' because of realm incorrect thread. why error 'permissions denied' still puzzle me.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -