Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import com.couchbase.lite.ReplicatorType
import java.security.cert.X509Certificate

abstract class AbstractWorkManagerReplicatorConfiguration(protected val replConfig: ReplicatorConfiguration) {
val collections: Set<Collection> by replConfig::collections

var type: ReplicatorType by replConfig::type
var authenticator: Authenticator? by replConfig::authenticator
var headers: Map<String, String>? by replConfig::headers
Expand All @@ -34,5 +36,20 @@ abstract class AbstractWorkManagerReplicatorConfiguration(protected val replConf
}

fun getConfig() = ReplicatorConfiguration(replConfig)

fun addCollection(collection: Collection, collectionConfig: CollectionConfiguration? = null) {
replConfig.addCollection(collection, collectionConfig)
}

fun addCollections(
collections: kotlin.collections.Collection<Collection>,
collectionConfig: CollectionConfiguration? = null
) {
replConfig.addCollections(collections, collectionConfig)
}

fun removeCollection(collection: Collection) {
replConfig.removeCollection(collection)
}
}

364 changes: 348 additions & 16 deletions common/main/java/com/couchbase/lite/AbstractDatabase.java

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions common/main/java/com/couchbase/lite/AbstractQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ public ListenerToken addChangeListener(@Nullable Executor executor, @NonNull Que
return token;
}

/**
* Removes a change listener wih the given listener token.
*
* @param token The listener token.
* @deprecated use ListenerToken.remove()
*/
@Deprecated
@Override
public void removeChangeListener(@NonNull ListenerToken token) { removeListener(token); }

@Nullable
protected abstract AbstractDatabase getDatabase();
Expand Down
48 changes: 48 additions & 0 deletions common/main/java/com/couchbase/lite/AbstractReplicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,18 @@ public List<Certificate> getServerCertificates() {
: new ArrayList<>(serverCerts);
}

/**
* Get a best effort list of documents in the default collection, that are still pending replication.
*
* @return a set of ids for documents in the default collection still awaiting replication.
* @deprecated Use getPendingDocumentIds(Collection)
*/
@Deprecated
@NonNull
public Set<String> getPendingDocumentIds() throws CouchbaseLiteException {
return getPendingDocIds(Scope.DEFAULT_NAME, Collection.DEFAULT_NAME);
}

/**
* Get a best effort list of documents in the passed collection that are still pending replication.
*
Expand All @@ -347,6 +359,19 @@ public Set<String> getPendingDocumentIds(@NonNull Collection collection) throws
return getPendingDocIds(collection.getScope().getName(), collection.getName());
}

/**
* Best effort check to see if the document whose ID is passed is still pending replication.
*
* @param docId Document id
* @return true if the document is pending
* @deprecated Use isDocumentPending(String, Collection)
*/
@Deprecated
public boolean isDocumentPending(@NonNull String docId)
throws CouchbaseLiteException {
return isDocPending(docId, Scope.DEFAULT_NAME, Collection.DEFAULT_NAME);
}

/**
* Best effort check to see if the document whose ID is passed is still pending replication.
*
Expand Down Expand Up @@ -438,6 +463,29 @@ public ListenerToken addDocumentReplicationListener(
return token;
}

/**
* Remove the given ReplicatorChangeListener or DocumentReplicationListener from the this replicator.
*
* @param token returned by a previous call to addChangeListener or addDocumentListener.
* @deprecated use ListenerToken.remove
*/
@Deprecated
public void removeChangeListener(@NonNull ListenerToken token) {
Preconditions.assertNotNull(token, "token");
synchronized (getReplicatorLock()) {
if (token instanceof ReplicatorChangeListenerToken) {
removeReplicationListener(token);
return;
}

if (token instanceof DocumentReplicationListenerToken) {
removeDocumentReplicationListener(token);
return;
}

throw new IllegalArgumentException("unexpected token: " + token);
}
}

// I've thought a lot about how to implement this. The problem is that you cannot, fundamentally,
// close a replicator(discard its resources before this method returns). If it is not stopped,
Expand Down
Loading