I need to filter out some documents from being pushed to the sync gateway from the client. To that I’ve created a filter function as follows and assign it to my push replication,
I do not want to replicate documents with “type” attribute equal to “Section”
My filter function is…
database.setFilter(“myFilter”,new ReplicationFilter() {
@Override
public boolean filter(SavedRevision revision, Map<String, Object> params) {
if(revision.getProperty(“type”).equals(“Section”)){
return false;
}else{
return true;
}
}
});
Replication pushReplication = database.createPushReplication(syncUrl);
pushReplication.setContinuous(true);
pushReplication.setAuthenticator(auth);
pushReplication.setFilter("myFilter");
But my problem is, other documents also (type attribute is not equal to “Section”) do not replicate to the sync gateway. In fact I cannot see any other doc is being replicated to the server. What I’m doing wrong here?
I get this exception in the following line…
…" if(revision.getProperty(“type”).equals(“Section”)){"…
08-11 20:22:40.692 12220-12390/cz.zcu.kiv.eeg.mobile.base E/Sync﹕ PullerInternal stopGraceful.run() finished
08-11 20:22:40.692 12220-12381/cz.zcu.kiv.eeg.mobile.base E/RemoteRequest﹕ RemoteRequestCompletionBlock throw Exception
java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.lang.Object.equals(java.lang.Object)’ on a null object reference
at cz.zcu.kiv.eeg.mobile.base.ui.NavigationActivity$5.filter(NavigationActivity.java:415)
at com.couchbase.lite.Database.runFilter(Database.java:2033)
at com.couchbase.lite.Database.changesSince(Database.java:2004)
at com.couchbase.lite.replicator.PusherInternal.beginReplicating(PusherInternal.java:272)
at com.couchbase.lite.replicator.ReplicationInternal$9.onCompletion(ReplicationInternal.java:823)
at com.couchbase.lite.support.RemoteRequestRetry$1.completed(RemoteRequestRetry.java:178)
at com.couchbase.lite.support.RemoteRequestRetry$1.onCompletion(RemoteRequestRetry.java:214)
at com.couchbase.lite.support.RemoteRequest.respondWithResult(RemoteRequest.java:310)
at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:224)
at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:104)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)