├── .github
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .idea
└── codeStyleSettings.xml
├── .travis.yml
├── AndroidExec.gradle
├── AndroidTest
├── app
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── assets
│ │ └── icudt46l.zip
│ │ ├── java
│ │ └── cloudant
│ │ │ └── com
│ │ │ └── androidtest
│ │ │ ├── AndroidTestUtil.java
│ │ │ └── TestActivity.java
│ │ ├── jniLibs
│ │ ├── armeabi-v7a
│ │ │ ├── libdatabase_sqlcipher.so
│ │ │ ├── libsqlcipher_android.so
│ │ │ └── libstlport_shared.so
│ │ ├── armeabi
│ │ │ ├── libdatabase_sqlcipher.so
│ │ │ ├── libsqlcipher_android.so
│ │ │ └── libstlport_shared.so
│ │ └── x86
│ │ │ ├── libdatabase_sqlcipher.so
│ │ │ ├── libsqlcipher_android.so
│ │ │ └── libstlport_shared.so
│ │ └── res
│ │ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── layout
│ │ ├── activity_my.xml
│ │ ├── activity_test_information.xml
│ │ └── list_view_text.xml
│ │ ├── menu
│ │ ├── my.xml
│ │ └── test_information.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── build.gradle
├── gradle.properties
└── settings.gradle
├── CHANGES.md
├── CONTRIBUTING.md
├── CONTRIBUTORS
├── DCO1.1.txt
├── Jenkinsfile
├── LICENSE
├── README.md
├── VERSION
├── build.gradle
├── build.rb
├── cloudant-sync-datastore-android-encryption
├── build.gradle
├── libs
│ └── sqlcipher.jar
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── cloudant
│ │ └── sync
│ │ ├── datastore
│ │ └── encryption
│ │ │ ├── AndroidKeyProvider.java
│ │ │ ├── DPKEncryptionUtil.java
│ │ │ ├── DPKException.java
│ │ │ ├── KeyData.java
│ │ │ ├── KeyManager.java
│ │ │ └── KeyStorage.java
│ │ └── internal
│ │ └── sqlite
│ │ └── android
│ │ └── AndroidSQLCipherSQLite.java
│ └── test
│ └── java
│ └── com
│ └── cloudant
│ └── sync
│ └── datastore
│ └── encryption
│ ├── AndroidKeyProviderTests.java
│ ├── CachingKeyProviderTests.java
│ ├── EndToEndEncryptionTest.java
│ ├── KeyDataTests.java
│ ├── KeyManagerTests.java
│ ├── KeyStorageTests.java
│ └── ProviderTestUtil.java
├── cloudant-sync-datastore-android
├── build.gradle
├── findbugs_excludes.xml
├── libs
│ └── android-support-v4.jar
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── cloudant
│ │ └── sync
│ │ ├── internal
│ │ └── sqlite
│ │ │ └── android
│ │ │ ├── AndroidSQLite.java
│ │ │ └── AndroidSQLiteCursor.java
│ │ └── replication
│ │ ├── PeriodicReplicationReceiver.java
│ │ ├── PeriodicReplicationService.java
│ │ ├── ReplicationService.java
│ │ └── WifiPeriodicReplicationReceiver.java
│ └── test
│ └── java
│ └── com
│ └── cloudant
│ ├── android
│ ├── Base64OutputStreamFactoryTest.java
│ └── TestReplicationService.java
│ └── sync
│ └── replication
│ ├── ReplicationServiceTest.java
│ └── WifiPeriodicReplicationReceiverTest.java
├── cloudant-sync-datastore-core
├── build.gradle
├── findbugs_excludes.xml
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── cloudant
│ │ │ └── sync
│ │ │ ├── documentstore
│ │ │ ├── Attachment.java
│ │ │ ├── AttachmentException.java
│ │ │ ├── AttachmentNotSavedException.java
│ │ │ ├── Changes.java
│ │ │ ├── ConflictException.java
│ │ │ ├── ConflictResolver.java
│ │ │ ├── Database.java
│ │ │ ├── DocumentBody.java
│ │ │ ├── DocumentBodyFactory.java
│ │ │ ├── DocumentException.java
│ │ │ ├── DocumentNotFoundException.java
│ │ │ ├── DocumentRevision.java
│ │ │ ├── DocumentStore.java
│ │ │ ├── DocumentStoreException.java
│ │ │ ├── DocumentStoreNotDeletedException.java
│ │ │ ├── DocumentStoreNotOpenedException.java
│ │ │ ├── InvalidDocumentException.java
│ │ │ ├── LocalDocument.java
│ │ │ ├── UnsavedFileAttachment.java
│ │ │ ├── UnsavedStreamAttachment.java
│ │ │ ├── advanced
│ │ │ │ ├── Database.java
│ │ │ │ └── package-info.java
│ │ │ └── encryption
│ │ │ │ ├── CachingKeyProvider.java
│ │ │ │ ├── EncryptionKey.java
│ │ │ │ ├── KeyProvider.java
│ │ │ │ ├── NullKeyProvider.java
│ │ │ │ └── SimpleKeyProvider.java
│ │ │ ├── event
│ │ │ ├── EventBus.java
│ │ │ ├── Subscribe.java
│ │ │ └── notifications
│ │ │ │ ├── DocumentCreated.java
│ │ │ │ ├── DocumentDeleted.java
│ │ │ │ ├── DocumentModified.java
│ │ │ │ ├── DocumentStoreClosed.java
│ │ │ │ ├── DocumentStoreCreated.java
│ │ │ │ ├── DocumentStoreDeleted.java
│ │ │ │ ├── DocumentStoreModified.java
│ │ │ │ ├── DocumentStoreOpened.java
│ │ │ │ ├── DocumentUpdated.java
│ │ │ │ ├── Notification.java
│ │ │ │ ├── ReplicationCompleted.java
│ │ │ │ └── ReplicationErrored.java
│ │ │ ├── internal
│ │ │ ├── android
│ │ │ │ ├── Base64InputStreamFactory.java
│ │ │ │ ├── Base64OutputStreamFactory.java
│ │ │ │ └── ContentValues.java
│ │ │ ├── common
│ │ │ │ ├── ChangeNotifyingMap.java
│ │ │ │ ├── CouchConstants.java
│ │ │ │ ├── CouchUtils.java
│ │ │ │ ├── PropertyFilterMixIn.java
│ │ │ │ ├── RetriableTask.java
│ │ │ │ ├── RetryException.java
│ │ │ │ ├── SimpleChangeNotifyingMap.java
│ │ │ │ └── ValueListMap.java
│ │ │ ├── documentstore
│ │ │ │ ├── AttachmentManager.java
│ │ │ │ ├── AttachmentStreamFactory.java
│ │ │ │ ├── ChangesImpl.java
│ │ │ │ ├── DatabaseImpl.java
│ │ │ │ ├── DatastoreConstants.java
│ │ │ │ ├── DocumentBodyImpl.java
│ │ │ │ ├── DocumentRevisionBuilder.java
│ │ │ │ ├── DocumentRevisionTree.java
│ │ │ │ ├── DocumentRevsList.java
│ │ │ │ ├── DocumentRevsUtils.java
│ │ │ │ ├── ForceInsertItem.java
│ │ │ │ ├── InternalDocumentRevision.java
│ │ │ │ ├── MultipartAttachmentWriter.java
│ │ │ │ ├── PreparedAttachment.java
│ │ │ │ ├── ProjectedDocumentRevision.java
│ │ │ │ ├── RevisionHistoryHelper.java
│ │ │ │ ├── SavedAttachment.java
│ │ │ │ ├── callables
│ │ │ │ │ ├── AttachmentsForRevisionCallable.java
│ │ │ │ │ ├── CallableSQLConstants.java
│ │ │ │ │ ├── ChangesCallable.java
│ │ │ │ │ ├── CompactCallable.java
│ │ │ │ │ ├── DeleteAllRevisionsCallable.java
│ │ │ │ │ ├── DeleteDocumentCallable.java
│ │ │ │ │ ├── DeleteLocalDocumentCallable.java
│ │ │ │ │ ├── DoForceInsertExistingDocumentWithHistoryCallable.java
│ │ │ │ │ ├── DoForceInsertNewDocumentWithHistoryCallable.java
│ │ │ │ │ ├── ForceInsertCallable.java
│ │ │ │ │ ├── GetAllDocumentIdsCallable.java
│ │ │ │ │ ├── GetAllDocumentsCallable.java
│ │ │ │ │ ├── GetAllRevisionsOfDocumentCallable.java
│ │ │ │ │ ├── GetConflictedDocumentIdsCallable.java
│ │ │ │ │ ├── GetDocumentCallable.java
│ │ │ │ │ ├── GetDocumentCountCallable.java
│ │ │ │ │ ├── GetDocumentsWithIdsCallable.java
│ │ │ │ │ ├── GetDocumentsWithInternalIdsCallable.java
│ │ │ │ │ ├── GetLastSequenceCallable.java
│ │ │ │ │ ├── GetLocalDocumentCallable.java
│ │ │ │ │ ├── GetNumericIdCallable.java
│ │ │ │ │ ├── GetPossibleAncestorRevisionIdsCallable.java
│ │ │ │ │ ├── GetPublicIdentifierCallable.java
│ │ │ │ │ ├── GetSequenceCallable.java
│ │ │ │ │ ├── InsertDocumentHistoryIntoExistingTreeCallable.java
│ │ │ │ │ ├── InsertDocumentHistoryToNewTreeCallable.java
│ │ │ │ │ ├── InsertDocumentIDCallable.java
│ │ │ │ │ ├── InsertLocalDocumentCallable.java
│ │ │ │ │ ├── InsertRevisionCallable.java
│ │ │ │ │ ├── PickWinningRevisionCallable.java
│ │ │ │ │ ├── ResolveConflictsForDocumentCallable.java
│ │ │ │ │ ├── RevsDiffBatchCallable.java
│ │ │ │ │ ├── SetCurrentCallable.java
│ │ │ │ │ ├── UpdateDocumentBodyCallable.java
│ │ │ │ │ └── UpdateDocumentFromRevisionCallable.java
│ │ │ │ ├── encryption
│ │ │ │ │ ├── EncryptedAttachmentInputStream.java
│ │ │ │ │ ├── EncryptedAttachmentOutputStream.java
│ │ │ │ │ ├── EncryptionConstants.java
│ │ │ │ │ └── KeyUtils.java
│ │ │ │ ├── helpers
│ │ │ │ │ ├── GetFullRevisionFromCurrentCursor.java
│ │ │ │ │ ├── GetRevisionsFromRawQuery.java
│ │ │ │ │ ├── InsertNewWinnerRevisionAdaptor.java
│ │ │ │ │ └── InsertStubRevisionAdaptor.java
│ │ │ │ └── migrations
│ │ │ │ │ ├── MigrateDatabase100To200.java
│ │ │ │ │ ├── MigrateDatabase6To100.java
│ │ │ │ │ ├── Migration.java
│ │ │ │ │ └── SchemaOnlyMigration.java
│ │ │ ├── mazha
│ │ │ │ ├── BulkGetRequest.java
│ │ │ │ ├── BulkGetResponse.java
│ │ │ │ ├── ChangesResult.java
│ │ │ │ ├── CouchClient.java
│ │ │ │ ├── CouchDbInfo.java
│ │ │ │ ├── CouchException.java
│ │ │ │ ├── CouchURIHelper.java
│ │ │ │ ├── DBOperationResponse.java
│ │ │ │ ├── Document.java
│ │ │ │ ├── DocumentConflictException.java
│ │ │ │ ├── DocumentRevs.java
│ │ │ │ ├── GetOpenRevisionsResponse.java
│ │ │ │ ├── HierarchicalUriComponents.java
│ │ │ │ ├── MissingOpenRevision.java
│ │ │ │ ├── NoResourceException.java
│ │ │ │ ├── OkOpenRevision.java
│ │ │ │ ├── OpenRevision.java
│ │ │ │ ├── Response.java
│ │ │ │ ├── ServerException.java
│ │ │ │ └── json
│ │ │ │ │ └── OpenRevisionDeserializer.java
│ │ │ ├── query
│ │ │ │ ├── AndQueryNode.java
│ │ │ │ ├── ChildrenQueryNode.java
│ │ │ │ ├── IndexCreator.java
│ │ │ │ ├── IndexUpdater.java
│ │ │ │ ├── OperatorExpressionNode.java
│ │ │ │ ├── OrQueryNode.java
│ │ │ │ ├── QueryConstants.java
│ │ │ │ ├── QueryExecutor.java
│ │ │ │ ├── QueryImpl.java
│ │ │ │ ├── QueryNode.java
│ │ │ │ ├── QuerySqlTranslator.java
│ │ │ │ ├── QueryValidator.java
│ │ │ │ ├── SqlParts.java
│ │ │ │ ├── SqlQueryNode.java
│ │ │ │ ├── TokenizerHelper.java
│ │ │ │ ├── TranslatorState.java
│ │ │ │ ├── UnindexedMatcher.java
│ │ │ │ ├── ValueExtractor.java
│ │ │ │ └── callables
│ │ │ │ │ ├── CreateIndexCallable.java
│ │ │ │ │ ├── DeleteIndexCallable.java
│ │ │ │ │ ├── ListIndexesCallable.java
│ │ │ │ │ ├── SequenceNumberForIndexCallable.java
│ │ │ │ │ ├── UpdateIndexCallable.java
│ │ │ │ │ └── UpdateMetadataForIndexCallable.java
│ │ │ ├── replication
│ │ │ │ ├── AttachmentPullProcessor.java
│ │ │ │ ├── BulkGetRequest.java
│ │ │ │ ├── ChangesResultWrapper.java
│ │ │ │ ├── CouchClientWrapper.java
│ │ │ │ ├── CouchDB.java
│ │ │ │ ├── DatastoreWrapper.java
│ │ │ │ ├── GetRevisionTaskBulk.java
│ │ │ │ ├── GetRevisionTaskThreaded.java
│ │ │ │ ├── PullStrategy.java
│ │ │ │ ├── PushStrategy.java
│ │ │ │ ├── QueuingExecutorCompletionService.java
│ │ │ │ ├── RemoteCheckpointDoc.java
│ │ │ │ ├── ReplicationListener.java
│ │ │ │ ├── ReplicationStrategy.java
│ │ │ │ ├── ReplicationStrategyCompleted.java
│ │ │ │ ├── ReplicationStrategyErrored.java
│ │ │ │ └── ReplicatorImpl.java
│ │ │ ├── sqlite
│ │ │ │ ├── Cursor.java
│ │ │ │ ├── SQLCallable.java
│ │ │ │ ├── SQLDatabase.java
│ │ │ │ ├── SQLDatabaseFactory.java
│ │ │ │ ├── SQLDatabaseQueue.java
│ │ │ │ ├── SQLQueueCallable.java
│ │ │ │ └── sqlite4java
│ │ │ │ │ ├── DBUtils.java
│ │ │ │ │ ├── QueryBuilder.java
│ │ │ │ │ ├── SQLiteCursor.java
│ │ │ │ │ └── Tuple.java
│ │ │ └── util
│ │ │ │ ├── AbstractTreeNode.java
│ │ │ │ ├── CollectionUtils.java
│ │ │ │ ├── DatabaseUtils.java
│ │ │ │ ├── JSONUtils.java
│ │ │ │ ├── JacksonModule.java
│ │ │ │ ├── Misc.java
│ │ │ │ └── ThreadUtils.java
│ │ │ ├── query
│ │ │ ├── FieldSort.java
│ │ │ ├── Index.java
│ │ │ ├── IndexType.java
│ │ │ ├── Query.java
│ │ │ ├── QueryException.java
│ │ │ ├── QueryResult.java
│ │ │ └── Tokenizer.java
│ │ │ └── replication
│ │ │ ├── DatabaseNotFoundException.java
│ │ │ ├── PolicyReplicationsCompletedListener.java
│ │ │ ├── PullFilter.java
│ │ │ ├── PushAttachmentsInline.java
│ │ │ ├── PushFilter.java
│ │ │ ├── ReplicationPolicyManager.java
│ │ │ ├── Replicator.java
│ │ │ └── ReplicatorBuilder.java
│ └── resources
│ │ └── mazha.properties
│ └── test
│ └── java
│ └── com
│ └── cloudant
│ ├── common
│ ├── AdvancedAPITest.java
│ ├── CollectionFactory.java
│ ├── CouchTestBase.java
│ ├── DocumentStoreTestBase.java
│ ├── PerformanceTest.java
│ ├── RequireRunningCouchDB.java
│ ├── RequireRunningProxy.java
│ ├── RetriableTaskTest.java
│ ├── SystemTest.java
│ ├── TestOptions.java
│ └── UnreliableProxyTestBase.java
│ ├── http
│ └── HttpTest.java
│ └── sync
│ ├── advanced
│ └── CreateWithHistoryTest.java
│ ├── datastore
│ └── encryption
│ │ ├── EncryptedAttachmentInputStreamTest.java
│ │ ├── EncryptedAttachmentOutputStreamTest.java
│ │ ├── EncryptionKeyTest.java
│ │ ├── EncryptionTestConstants.java
│ │ ├── HelperSimpleKeyProvider.java
│ │ └── KeyUtilsTest.java
│ ├── documentstore
│ └── LocalDocumentCrud.java
│ ├── event
│ └── EventBusTest.java
│ ├── internal
│ ├── documentstore
│ │ ├── AttachmentManagerTest.java
│ │ ├── AttachmentStreamFactoryTest.java
│ │ ├── AttachmentTest.java
│ │ ├── BasicDBBodyTest.java
│ │ ├── BasicDBCoreObservableTest.java
│ │ ├── BasicDBObjectTest.java
│ │ ├── BasicDatastoreTestBase.java
│ │ ├── ChangesTest.java
│ │ ├── CrudImplDatabaseTest.java
│ │ ├── Database200MigrationTest.java
│ │ ├── DatabaseImplChangesTest.java
│ │ ├── DatabaseImplConflictsTest.java
│ │ ├── DatabaseImplExceptionsTest.java
│ │ ├── DatabaseImplForceInsertTest.java
│ │ ├── DatabaseImplRevsDiffTest.java
│ │ ├── DatabaseManagerTest.java
│ │ ├── DatabaseNotificationsMoreTest.java
│ │ ├── DatabaseNotificationsTest.java
│ │ ├── DatastoreSchemaTests.java
│ │ ├── DatastoreTestBase.java
│ │ ├── DatastoreTestUtils.java
│ │ ├── DocumentNotificationsTest.java
│ │ ├── DocumentRevisionTreeTest.java
│ │ ├── ForceInsertTest.java
│ │ ├── MultipartAttachmentWriterTests.java
│ │ ├── MutableDocumentDeleteTest.java
│ │ ├── MutableDocumentNoInitialAttachmentsTest.java
│ │ ├── NotificationTestUtils.java
│ │ ├── RevisionHistoryHelperTest.java
│ │ ├── SQLDatabaseFactoryTest.java
│ │ └── TimestampBasedConflictsResolver.java
│ ├── mazha
│ │ ├── AnimalDb.java
│ │ ├── BulkAPITest.java
│ │ ├── ChangesFeedTest.java
│ │ ├── ClientTestUtils.java
│ │ ├── CouchClientBasicTest.java
│ │ ├── CouchClientFilteredChangesTest.java
│ │ ├── CouchClientSelectorChangesTest.java
│ │ ├── CouchClientTestBase.java
│ │ ├── CouchConfig.java
│ │ ├── CouchURIHelperTest.java
│ │ ├── DocumentRevsTest.java
│ │ ├── Foo.java
│ │ ├── GetDocumentRevsTest.java
│ │ ├── GetOpenRevisionsTest.java
│ │ ├── HttpRequestsTest.java
│ │ ├── OpenRevisionTest.java
│ │ ├── SpecifiedCouch.java
│ │ ├── json
│ │ │ └── JSONHelperTest.java
│ │ └── matcher
│ │ │ ├── IsNotEmpty.java
│ │ │ └── IsNotEmptyTest.java
│ ├── query
│ │ ├── AbstractIndexTestBase.java
│ │ ├── AbstractQueryTestBase.java
│ │ ├── DelegatingMockQuery.java
│ │ ├── Index2MigrationTest.java
│ │ ├── IndexCreatorTest.java
│ │ ├── IndexMatcherHelpers.java
│ │ ├── IndexTest.java
│ │ ├── IndexUpdaterTest.java
│ │ ├── MockMatcherQuery.java
│ │ ├── MockMatcherQueryExecutor.java
│ │ ├── MockSQLOnlyQuery.java
│ │ ├── MockSQLOnlyQueryExecutor.java
│ │ ├── NumericQueryTest.java
│ │ ├── QueryCoveringIndexesTest.java
│ │ ├── QueryFilterFieldsTest.java
│ │ ├── QueryResultTest.java
│ │ ├── QuerySortTest.java
│ │ ├── QuerySqlTranslatorTest.java
│ │ ├── QueryTest.java
│ │ ├── QueryTextSearchTest.java
│ │ ├── QueryValidatorTest.java
│ │ ├── QueryWithoutCoveringIndexesTest.java
│ │ ├── UnindexedMatcherTest.java
│ │ └── ValueExtractorTest.java
│ └── replication
│ │ ├── AttachmentsConflictsTest.java
│ │ ├── AttachmentsPullTest.java
│ │ ├── AttachmentsPushTest.java
│ │ ├── Bar.java
│ │ ├── BarUtils.java
│ │ ├── BarWithAttachments.java
│ │ ├── BasicPullStrategyTest2.java
│ │ ├── BasicPushStrategyTest2.java
│ │ ├── ChangesResultWrapperTest.java
│ │ ├── CompactedDBReplicationTest.java
│ │ ├── CouchClientWrapperDbUtils.java
│ │ ├── CouchClientWrapperMockTest.java
│ │ ├── CouchClientWrapperTest.java
│ │ ├── DBWithSlashReplicationTest.java
│ │ ├── DatabaseAssert.java
│ │ ├── DatabaseAssertTest.java
│ │ ├── DesignDocsReplicateTest.java
│ │ ├── DocumentRevsListTest.java
│ │ ├── DocumentRevsUtilsTest.java
│ │ ├── Foo.java
│ │ ├── GetRevisionTaskTest.java
│ │ ├── InterceptorCallCounter.java
│ │ ├── MissingRevsReplicationTest.java
│ │ ├── PullReplicationTerminationTest.java
│ │ ├── PullReplicatorTest.java
│ │ ├── PullStrategyDocIdTest.java
│ │ ├── PullStrategyMockTest.java
│ │ ├── PullStrategySelectorTest.java
│ │ ├── PullStrategyTest.java
│ │ ├── PushReplicatorTest.java
│ │ ├── PushStrategyMockTest.java
│ │ ├── PushStrategyTest.java
│ │ ├── RemoteCheckpointDocTest.java
│ │ ├── ReplicationPolicyManagerTest.java
│ │ ├── ReplicationTestBase.java
│ │ ├── ReplicationThreadpoolTest.java
│ │ ├── ReplicatorIdTest.java
│ │ ├── ReplicatorImplMockTest.java
│ │ ├── ResurrectedDocumentTest.java
│ │ ├── TestReplicationListener.java
│ │ ├── TestStrategyListener.java
│ │ ├── UnreliableNetworkPullTest.java
│ │ └── UnreliableNetworkPushTest.java
│ ├── matcher
│ └── CauseMatcher.java
│ ├── sqlite
│ ├── ContentValuesTest.java
│ └── sqlite4java
│ │ ├── SQLiteCursorTest.java
│ │ └── TupleTest.java
│ └── util
│ ├── AbstractTreeNodeTest.java
│ ├── CollectionUtilsTest.java
│ ├── CouchUtilsTest.java
│ ├── JSONUtilsTest.java
│ ├── MiscTest.java
│ ├── MultiThreadedTestHelper.java
│ ├── SQLDatabaseTestUtils.java
│ ├── TestEventListener.java
│ └── TestUtils.java
├── cloudant-sync-datastore-javase
├── build.gradle
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── cloudant
│ │ └── sync
│ │ ├── internal
│ │ └── sqlite
│ │ │ └── sqlite4java
│ │ │ ├── SQLiteWrapper.java
│ │ │ └── SQLiteWrapperUtils.java
│ │ └── replication
│ │ └── IntervalTimerReplicationPolicyManager.java
│ └── test
│ └── java
│ └── com
│ └── cloudant
│ └── sync
│ └── internal
│ └── sqlite
│ └── sqlite4java
│ └── SQLiteWrapperTest.java
├── doc
├── CrudSamples.java
├── code-style.md
├── conflicts.md
├── encryption.md
├── events.md
├── images
│ ├── quickstart
│ │ ├── image00.png
│ │ ├── image01.png
│ │ ├── image02.png
│ │ ├── image03.png
│ │ ├── image04.png
│ │ ├── image05.png
│ │ └── image06.png
│ ├── replication-many.png
│ ├── replication-multi-local.png
│ ├── replication-multi-remote.png
│ ├── replication-push-pull.png
│ └── replication-sync.png
├── interceptors.md
├── logging.md
├── migration.md
├── query.md
├── replication-policies.md
└── replication.md
├── fixture
├── .gitattributes
├── 10K_changes_feeds.json
├── AddImageAttachmentTest_expected.mime
├── EncryptedAttachmentTest_badOnDiskVersion
├── EncryptedAttachmentTest_cipherText_aes128
├── EncryptedAttachmentTest_gzip_cipherText_aes128
├── EncryptedAttachmentTest_plainText
├── EncryptedAttachmentTest_plainText.gz
├── EncryptedAttachmentTest_truncatedIV
├── animaldb
│ ├── animaldb_animal0.json
│ ├── animaldb_animal1.json
│ ├── animaldb_animal2.json
│ ├── animaldb_animal3.json
│ ├── animaldb_animal4.json
│ ├── animaldb_animal5.json
│ ├── animaldb_animal6.json
│ ├── animaldb_animal7.json
│ ├── animaldb_animal8.json
│ ├── animaldb_animal9.json
│ └── animaldb_filter.json
├── attachment_1.txt
├── attachment_2.txt
├── basic_bdbody_test_as_map.json
├── bonsai-boston.jpg
├── bulk_docs_1.json
├── bulk_docs_2.json
├── bulk_docs_3.json
├── bulk_docs_4.json
├── bulk_docs_bad_json.json
├── bulk_docs_rev_not_match.json
├── change_feed_0.json
├── change_feed_1.json
├── datastores-user_version6.zip
├── dbinfo-pre23.json
├── document_1.json
├── document_2.json
├── document_revs_deleted.json
├── document_revs_only_one_revision.json
├── document_revs_only_two_revision.json
├── document_revs_others.json
├── document_revs_with_attachments_1.json
├── document_revs_with_everything.json
├── document_revs_with_unknown_special_field.json
├── empty_changes.json
├── index_0.json
├── index_1.json
├── index_2.json
├── index_3.json
├── index_4.json
├── index_5.json
├── index_6.json
├── index_7.json
├── index_chinese_character.json
├── index_float.json
├── index_really_big_long.json
├── index_special_character.json
├── index_string.json
├── index_with_spaces.json
├── index_with_unsupported_value.json
├── integer_index_invalid_field.json
├── integer_index_valid_field.json
├── integer_index_valid_field_updated.json
├── json_helper.json
├── json_helper_compacted.json
├── json_helper_response.json
├── json_helper_response_list.json
├── json_utils_test.json
├── json_utils_test_boolean.json
├── json_utils_test_number.json
├── legacy_database_with_indexes.zip
├── lorem.txt
├── lorem_long.txt
├── multipart_1000_atts.mime
├── multipart_100_atts_ordered.regex
├── multipart_from_couch_with_gzip.mime
├── open_revisions_empty.json
├── open_revisions_many.json
├── open_revisions_missing.json
├── open_revisions_ok.json
├── open_revisions_ok_and_missing.json
├── string_index_invalid_field.json
├── string_index_unicode_key.json
├── string_index_valid_field.json
├── string_index_valid_field_updated.json
├── testReplicationDocWithEmptyId_changes.json
├── testReplicationDocWithEmptyId_open_revs_1.json
├── testReplicationDocWithEmptyId_open_revs_2.json
├── v100ComplexWithoutDuplicates.zip
├── v100WithDuplicates.zip
├── view_test_0.json
├── view_test_1.json
├── view_test_2.json
├── view_test_3.json
├── view_test_4.json
├── view_test_5.json
├── view_test_6.json
└── view_test_7.json
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── native
├── libsqlite4java-linux-amd64.so
├── libsqlite4java-linux-i386.so
└── libsqlite4java-osx.dylib
├── sample
└── todo-sync
│ ├── AndroidManifest.xml
│ ├── README.md
│ ├── build.gradle
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── ic_launcher-web.png
│ ├── proguard-project.txt
│ ├── proguard.cfg
│ ├── project.properties
│ ├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── layout
│ │ ├── activity_todo.xml
│ │ ├── dialog_loading.xml
│ │ ├── dialog_new_task.xml
│ │ └── task_item.xml
│ ├── menu
│ │ ├── context_menu.xml
│ │ └── todo.xml
│ ├── values-sw600dp
│ │ └── dimens.xml
│ ├── values-sw720dp-land
│ │ └── dimens.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── values-v14
│ │ └── styles.xml
│ ├── values
│ │ ├── dimens.xml
│ │ ├── settings.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── xml
│ │ └── preferences.xml
│ └── src
│ └── com
│ └── cloudant
│ └── todo
│ ├── SettingsActivity.java
│ ├── Task.java
│ ├── TaskAdapter.java
│ ├── TasksModel.java
│ └── TodoActivity.java
└── settings.gradle
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Please [read these guidelines](http://ibm.biz/cdt-issue-guide) before opening an issue.
2 |
3 |
4 |
5 | ## Bug Description
6 |
7 | ### 1. Steps to reproduce and the simplest code sample possible to demonstrate the issue
8 |
12 |
13 | ### 2. What you expected to happen
14 |
15 | ### 3. What actually happened
16 |
17 | ## Environment details
18 |
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/*
2 | bin/*
3 | gen/*
4 | *.iml
5 | local.properties
6 | .project
7 | *~
8 | build
9 | .gradle
10 | *.ipr
11 | *.iws
12 | out
13 | local.gradle
14 | cloudant-sync-datastore-core/fixture
15 | **/.idea/*
16 | !**/.idea/codeStyleSettings.xml
17 |
18 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: trusty
2 | language: java
3 | sudo: false
4 | script: "./gradlew check integrationTest"
5 |
6 | jdk:
7 | - oraclejdk8
8 |
9 | services:
10 | - couchdb
11 |
12 | before_install:
13 | - export TERM=dumb
14 |
15 | cache:
16 | directories:
17 | - $HOME/.m2
18 |
--------------------------------------------------------------------------------
/AndroidTest/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/assets/icudt46l.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/assets/icudt46l.zip
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/java/cloudant/com/androidtest/AndroidTestUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package cloudant.com.androidtest;
16 |
17 | import android.content.Context;
18 |
19 | public class AndroidTestUtil {
20 | public static Context context;
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/armeabi-v7a/libdatabase_sqlcipher.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/armeabi-v7a/libdatabase_sqlcipher.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/armeabi-v7a/libsqlcipher_android.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/armeabi-v7a/libsqlcipher_android.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/armeabi-v7a/libstlport_shared.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/armeabi-v7a/libstlport_shared.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/armeabi/libdatabase_sqlcipher.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/armeabi/libdatabase_sqlcipher.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/armeabi/libsqlcipher_android.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/armeabi/libsqlcipher_android.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/armeabi/libstlport_shared.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/armeabi/libstlport_shared.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/x86/libdatabase_sqlcipher.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/x86/libdatabase_sqlcipher.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/x86/libsqlcipher_android.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/x86/libsqlcipher_android.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/jniLibs/x86/libstlport_shared.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/jniLibs/x86/libstlport_shared.so
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/AndroidTest/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/layout/activity_my.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
18 |
19 |
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/layout/list_view_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/AndroidTest/app/src/main/res/menu/my.xml:
--------------------------------------------------------------------------------
1 |
23 | * Thrown when there is an error saving attachments to local storage.
24 | *
25 | * Returns the last sequence number of this change set.
21 | *
22 | * This number isn't necessarily the same as the sequence number of the
23 | * last {@code DocumentRevision} in the list of changes.
24 | *
25 | * @return last sequence number of the changes set.
26 | */
27 | long getLastSequence();
28 |
29 | /**
30 | * Returns the list of {@code DocumentRevision}s in this change set.
31 | *
32 | * @return the list of {@code DocumentRevision}s in this change set.
33 | */
34 | List getResults();
35 | }
36 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/ConflictException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.documentstore;
18 |
19 | /**
20 | * Thrown when there is a conflict updating a {@link Database}, for example trying
21 | * to update a document but passing in an incorrect revision ID.
22 | */
23 | public class ConflictException extends DocumentException {
24 |
25 | public ConflictException(String message) {
26 | super(message);
27 | }
28 |
29 | public ConflictException(String message, Throwable cause) {
30 | super(message, cause);
31 | }
32 |
33 | public ConflictException(Throwable cause) {
34 | super(cause);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/DocumentException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore;
16 |
17 |
18 | /**
19 | * Created by Rhys Short on 05/02/15.
20 | */
21 |
22 | /**
23 | *
24 | * Thrown when there is a logic or programmer error reading, creating, updating, or deleting
25 | * {@link DocumentRevision}s or their associated {@link Attachment}s
26 | *
27 | *
28 | * Note: these error cases are distinct from {@link DocumentStoreException}s which are thrown
29 | * when an unexpected condition was encountered (for example, an internal SQLite database error).
30 | *
31 | *
32 | * This is the base class of a hierarchy of exceptions. In most cases a more specific
33 | * exception will be thrown. See the documentation for each subclass for specific details.
34 | *
35 | *
36 | * @see DocumentStoreException
37 | */
38 |
39 | public class DocumentException extends Exception {
40 |
41 | public DocumentException(String message) {
42 | super(message);
43 | }
44 |
45 | public DocumentException(String message, Throwable cause) {
46 | super(message, cause);
47 | }
48 |
49 | public DocumentException(Throwable cause) {
50 | super(cause);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/DocumentStoreException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore;
16 |
17 | /**
18 | * Created by Rhys Short on 05/02/15.
19 | */
20 |
21 | /**
22 | *
23 | * Thrown when an unexpected condition was encountered during a {@link DocumentStore} method, for
24 | * example an internal SQLite database error.
25 | *
26 | *
27 | * @see DocumentException
28 | *
29 | */
30 |
31 | public class DocumentStoreException extends Exception {
32 |
33 | public DocumentStoreException(String message){
34 | super(message);
35 | }
36 |
37 | public DocumentStoreException(Throwable causedBy){
38 | super(causedBy);
39 | }
40 |
41 | public DocumentStoreException(String message, Throwable causedBy){
42 | super(message,causedBy);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/DocumentStoreNotDeletedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore;
16 |
17 | /**
18 | * Thrown when the directory containing a {@link DocumentStore} cannot be deleted.
19 | */
20 |
21 | public class DocumentStoreNotDeletedException extends DocumentStoreException {
22 |
23 | public DocumentStoreNotDeletedException(String message){
24 | super(message);
25 | }
26 |
27 | public DocumentStoreNotDeletedException(Throwable causedBy){
28 | super(causedBy);
29 | }
30 |
31 | public DocumentStoreNotDeletedException(String message, Throwable causedBy){
32 | super(message,causedBy);
33 | }
34 |
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/DocumentStoreNotOpenedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore;
16 |
17 | /**
18 | * Thrown when an existing {@link DocumentStore} cannot be opened or a new {@link DocumentStore}
19 | * cannot be created
20 | */
21 |
22 | public class DocumentStoreNotOpenedException extends DocumentStoreException {
23 |
24 | public DocumentStoreNotOpenedException(String message){
25 | super(message);
26 | }
27 |
28 | public DocumentStoreNotOpenedException(Throwable causedBy){
29 | super(causedBy);
30 | }
31 |
32 | public DocumentStoreNotOpenedException(String message, Throwable causedBy){
33 | super(message,causedBy);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/InvalidDocumentException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore;
16 |
17 | /**
18 | * Created by Rhys Short on 05/02/15.
19 | */
20 |
21 | /**
22 | * Thrown when a {@link DocumentRevision} contains errors: for example if it contains top-level
23 | * JSON keys which are prefixed with an underscore ({@code _}).
24 | */
25 | public class InvalidDocumentException extends RuntimeException {
26 |
27 | public InvalidDocumentException(String message){
28 | super(message);
29 | }
30 |
31 | public InvalidDocumentException(Exception causedBy){
32 | super(causedBy);
33 | }
34 |
35 | public InvalidDocumentException(String message, Exception causedBy){
36 | super(message,causedBy);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/LocalDocument.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015, 2018 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore;
16 |
17 | /**
18 | *
19 | * Note: this class is deprecated and will be moved to an internal package in a future
20 | * release. For local documents use a {@link DocumentRevision} with an {@code id} prefixed with
21 | * {@code _local} and a {@code rev} set to {@code null}.
22 | *
23 | *
24 | * A local Document. {@code LocalDocument}s do not have a history, or the concept of revisions
25 | *
26 | */
27 | @Deprecated
28 | public class LocalDocument {
29 |
30 | /**
31 | * The ID of the local document
32 | */
33 | public final String docId;
34 | /**
35 | * The body of the local document
36 | */
37 | public final DocumentBody body;
38 |
39 | /**
40 | * Creates a local document
41 | * @param docId The documentId for this document
42 | * @param body The body of the local document
43 | */
44 | public LocalDocument(String docId, DocumentBody body){
45 | this.docId = docId;
46 | this.body = body;
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/UnsavedFileAttachment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.documentstore;
18 |
19 | import java.io.File;
20 | import java.io.FileInputStream;
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 |
24 | /**
25 | * Created by tomblench on 11/03/2014.
26 | */
27 |
28 | /**
29 | * An Attachment which is read from a file before saving to the database
30 | */
31 | public class UnsavedFileAttachment extends Attachment {
32 |
33 | public UnsavedFileAttachment(File file, String type) {
34 | super(type, Encoding.Plain, file.length());
35 | this.file = file;
36 | }
37 |
38 | public UnsavedFileAttachment(File file, String type, Encoding encoding) {
39 | super(type, encoding, file.length());
40 | this.file = file;
41 | }
42 |
43 | public InputStream getInputStream() throws IOException {
44 | return new FileInputStream(file);
45 | }
46 |
47 | private File file;
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/UnsavedStreamAttachment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.documentstore;
18 |
19 | /**
20 | * Created by tomblench on 28/04/2014.
21 | */
22 |
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | /**
27 | * An Attachment which is read from a stream before saving to the database
28 | */
29 | public class UnsavedStreamAttachment extends Attachment {
30 |
31 | public UnsavedStreamAttachment(InputStream stream, String type) {
32 | super(type, Encoding.Plain, -1);
33 | this.stream = stream;
34 | }
35 |
36 | public UnsavedStreamAttachment(InputStream stream, String type, Encoding encoding) {
37 | super(type, encoding, -1);
38 | this.stream = stream;
39 | }
40 |
41 | public InputStream getInputStream() throws IOException {
42 | return stream;
43 | }
44 |
45 | private InputStream stream;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/advanced/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | /**
16 | *
17 | * ⚠ The interfaces in this package are not needed for typical use of the sync library.
18 | *
19 | *
20 | * ⚠ These interfaces are provided for flexibility to allow interactions with the database that
21 | * would otherwise be prevented by the API, but are necessary for some use cases. An example would
22 | * be writing your own replicator for this library's DocumentStore.
23 | *
24 | *
25 | * ⚠ Use of the APIs in this package is beyond the intended use case of the sync library and by
26 | * their nature they may expose untested edge cases. Incorrect use of the APIs could result in data
27 | * loss or corruption. You should only use these interfaces if you really know what you are doing!
28 | *
29 | */
30 | package com.cloudant.sync.documentstore.advanced;
31 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/EncryptionKey.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore.encryption;
16 |
17 | import java.util.Arrays;
18 |
19 | /**
20 | * Class to enforce restrictions on encryption keys used
21 | * with the DocumentStore.
22 | *
23 | * Note: SQLCipher requires a 32-byte/256-bit key.
24 | */
25 | public class EncryptionKey {
26 |
27 | private final static int REQUIRED_KEY_LENGTH = 32;
28 |
29 | private final byte[] key;
30 |
31 | public EncryptionKey(byte[] key) {
32 | if (key == null) {
33 | throw new IllegalArgumentException("Key array must not be null");
34 | }
35 |
36 | if (key.length != REQUIRED_KEY_LENGTH) {
37 | throw new IllegalArgumentException("Key array must be 32 bytes");
38 | }
39 |
40 | this.key = Arrays.copyOf(key, REQUIRED_KEY_LENGTH);
41 | }
42 |
43 | public byte[] getKey() {
44 | return Arrays.copyOf(key, REQUIRED_KEY_LENGTH);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/KeyProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore.encryption;
16 | /**
17 | * Classes implementing this interface provide encryption
18 | * keys used by the DocumentStore when encryption is enabled.
19 | */
20 | public interface KeyProvider {
21 |
22 | /**
23 | * @return the encryption key used to encrypt DocumentStore data
24 | */
25 | EncryptionKey getEncryptionKey();
26 | }
27 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/NullKeyProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.documentstore.encryption;
16 |
17 | /**
18 | * This implementation of KeyProvider always returns a null
19 | * key.
20 | */
21 | public class NullKeyProvider implements KeyProvider {
22 |
23 | @Override
24 | public EncryptionKey getEncryptionKey() {
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/documentstore/encryption/SimpleKeyProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 | package com.cloudant.sync.documentstore.encryption;
17 |
18 | /**
19 | * SimpleKeyProvider simply takes raw key bytes in its
20 | * constructor and uses these to provide that key to
21 | * DocumentStore methods.
22 | */
23 | public class SimpleKeyProvider implements KeyProvider {
24 |
25 | private EncryptionKey key;
26 |
27 | public SimpleKeyProvider(byte[] key) {
28 | this.key = new EncryptionKey(key);
29 | }
30 |
31 | @Override
32 | public EncryptionKey getEncryptionKey() {
33 | return key;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/Subscribe.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.event;
16 |
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | /**
23 | *
24 | * Annotation to indicate a method should be subscribed to events posted to the {@link EventBus} on
25 | * which the method's owning instance is registered.
26 | *
27 | *
28 | * Methods using this annotation must have only a single parameter and must be visible to the
29 | * EventBus (i.e. the owning class and method itself must be public). The parameter type of the
30 | * annotated method is of the type of event that notifications will be received for.
31 | *
32 | *
33 | * Subscribers are called synchronously so methods using this annotation must not perform long
34 | * running operations and should spawn a separate thread if needed.
35 | *
36 | *
37 | */
38 | @Target(ElementType.METHOD)
39 | @Retention(RetentionPolicy.RUNTIME)
40 | public @interface Subscribe {
41 | }
42 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentCreated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.Database;
20 | import com.cloudant.sync.documentstore.DocumentRevision;
21 |
22 | /**
23 | *
24 | * Event for document create
25 | *
26 | *
27 | * This event is posted by
28 | * {@link Database#create(DocumentRevision)}
29 | *
30 | */
31 | public class DocumentCreated extends DocumentModified {
32 |
33 | /**
34 | * Event for document create
35 | *
36 | * @param newDocument
37 | * New document revision
38 | */
39 | public DocumentCreated(DocumentRevision newDocument) {
40 | super(null, newDocument);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentDeleted.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.Database;
20 | import com.cloudant.sync.documentstore.DocumentRevision;
21 |
22 | /**
23 | *
24 | * Event for document delete
25 | *
26 | *
27 | * This event is posted by
28 | * {@link Database#delete(DocumentRevision)} and {@link Database#delete(String)}.
29 | *
30 | */
31 | public class DocumentDeleted extends DocumentModified {
32 |
33 | /**
34 | * Event for document delete
35 | *
36 | * @param prevDocument
37 | * Previous document revision
38 | * @param newDocument
39 | * New (empty) document revision
40 | *
41 | */
42 | public DocumentDeleted(DocumentRevision prevDocument,
43 | DocumentRevision newDocument) {
44 | super(prevDocument, newDocument);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentModified.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.DocumentRevision;
20 |
21 | /**
22 | * Generic event for {@link DocumentRevision} create, update, and delete
23 | */
24 | public class DocumentModified implements Notification {
25 |
26 | /**
27 | * Generic event for {@link DocumentRevision} create, update, and delete
28 | *
29 | * @param prevDocument
30 | * Previous {@link DocumentRevision} ({@code null} for document create)
31 | * @param newDocument
32 | * New {@link DocumentRevision}
33 | */
34 |
35 | public DocumentModified(DocumentRevision prevDocument,
36 | DocumentRevision newDocument) {
37 | this.prevDocument = prevDocument;
38 | this.newDocument = newDocument;
39 | }
40 |
41 | public final DocumentRevision prevDocument;
42 | public final DocumentRevision newDocument;
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentStoreClosed.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.DocumentStore;
20 |
21 | /**
22 | * Event for DocumentStore closed.
23 | *
24 | * This event is posted by {@link DocumentStore#close()}
25 | */
26 | public class DocumentStoreClosed extends DocumentStoreModified {
27 |
28 | /**
29 | * Event for DocumentStore closed
30 | *
31 | * @param dbName
32 | * The name of the DocumentStore that was closed
33 | */
34 | public DocumentStoreClosed(String dbName) {
35 | super(dbName);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentStoreCreated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.DocumentStore;
20 | import com.cloudant.sync.documentstore.encryption.KeyProvider;
21 |
22 | import java.io.File;
23 |
24 | /**
25 | * Event for DocumentStore created.
26 | *
27 | * The event is posted when the underlying database is created on the disk.
28 | *
29 | * This event is posted by
30 | * {@link DocumentStore#getInstance(File)} and
31 | * {@link DocumentStore#getInstance(File, KeyProvider)}
32 | *
33 | */
34 | public class DocumentStoreCreated extends DocumentStoreModified {
35 |
36 | /**
37 | * Event for DocumentStore created.
38 | *
39 | * @param dbName
40 | * The name of the DocumentStore that was created
41 | */
42 | public DocumentStoreCreated(String dbName) {
43 | super(dbName);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentStoreDeleted.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.DocumentStore;
20 |
21 | /**
22 | * Event for database deleted.
23 | *
24 | * This event is posted by
25 | * {@link DocumentStore#delete()}
26 | */
27 | public class DocumentStoreDeleted extends DocumentStoreModified {
28 |
29 | /**
30 | * Event for DocumentStore deleted.
31 | *
32 | * @param dbName
33 | * The name of the DocumentStore that was deleted
34 | */
35 | public DocumentStoreDeleted(String dbName) {
36 | super(dbName);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentStoreModified.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.DocumentStore;
20 |
21 | /**
22 | * Generic event for {@link DocumentStore} create or delete
23 | */
24 | public class DocumentStoreModified implements Notification {
25 |
26 | /**
27 | * Generic event for {@link DocumentStore} create or delete
28 | *
29 | * @param dbName
30 | * The name of the {@link DocumentStore} that was created or deleted
31 | */
32 | public DocumentStoreModified(String dbName) {
33 | this.dbName = dbName;
34 | }
35 |
36 | public final String dbName;
37 | }
38 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentStoreOpened.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.DocumentStore;
20 | import com.cloudant.sync.documentstore.encryption.KeyProvider;
21 |
22 | import java.io.File;
23 |
24 | /**
25 | * Event for DocumentStore opened.
26 | *
27 | * This event is posted the first time a {@link DocumentStore}
28 | * is opened during the lifetime of a program; or if {@link DocumentStore#close()} is called and a
29 | * DocumentStore is subsequently re-opened.
30 | *
31 | * This event is posted by
32 | * {@link DocumentStore#getInstance(File)} and
33 | * {@link DocumentStore#getInstance(File, KeyProvider)}
34 | *
35 | */
36 | public class DocumentStoreOpened extends DocumentStoreModified {
37 |
38 | /**
39 | * Event for DocumentStore opened.
40 | *
41 | * @param dbName
42 | * The name of the DocumentStore that was opened
43 | */
44 | public DocumentStoreOpened(String dbName) {
45 | super(dbName);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/DocumentUpdated.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.event.notifications;
18 |
19 | import com.cloudant.sync.documentstore.Database;
20 | import com.cloudant.sync.documentstore.DocumentRevision;
21 |
22 | /**
23 | *
24 | * Event for document update
25 | *
26 | *
27 | * This event is posted by
28 | * {@link Database#update(DocumentRevision)}
29 | *
30 | */
31 | public class DocumentUpdated extends DocumentModified {
32 |
33 | /**
34 | * Event for document update
35 | *
36 | * @param prevDocument
37 | * Previous document revision
38 | * @param newDocument
39 | * New document revision
40 | */
41 | public DocumentUpdated(DocumentRevision prevDocument,
42 | DocumentRevision newDocument) {
43 | super(prevDocument, newDocument);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/event/notifications/Notification.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | *
14 | */
15 |
16 | package com.cloudant.sync.event.notifications;
17 |
18 | /**
19 | * Marker interface for events.
20 | */
21 | public interface Notification {
22 | }
23 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/common/ChangeNotifyingMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.common;
16 |
17 | import java.util.Map;
18 |
19 | public interface ChangeNotifyingMap extends Map {
20 |
21 | boolean hasChanged();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/common/PropertyFilterMixIn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | /*
18 | * Code adapted from:
19 | *
20 | * http://stackoverflow.com/questions/8235255/global-property-filter-in-jackson
21 | */
22 |
23 | package com.cloudant.sync.internal.common;
24 |
25 | import com.fasterxml.jackson.annotation.JsonFilter;
26 |
27 | @JsonFilter(PropertyFilterMixIn.SIMPLE_FILTER_NAME)
28 | public class PropertyFilterMixIn {
29 |
30 | public static final String SIMPLE_FILTER_NAME = "couchKeywordsFilter";
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/common/RetryException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.common;
18 |
19 | public class RetryException extends RuntimeException {
20 | public RetryException(String s, Exception e) {
21 | super(s, e);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/callables/DeleteLocalDocumentCallable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.documentstore.callables;
16 |
17 | import com.cloudant.sync.documentstore.DocumentNotFoundException;
18 | import com.cloudant.sync.internal.sqlite.SQLCallable;
19 | import com.cloudant.sync.internal.sqlite.SQLDatabase;
20 |
21 | /**
22 | * Delete a local (non-replicated) Document
23 | */
24 | public class DeleteLocalDocumentCallable implements SQLCallable {
25 |
26 | private String docId;
27 |
28 | public DeleteLocalDocumentCallable(String docId) {
29 | this.docId = docId;
30 | }
31 |
32 | @Override
33 | public Void call(SQLDatabase db) throws DocumentNotFoundException {
34 | String[] whereArgs = {docId};
35 | int rowsDeleted = db.delete("localdocs", "docid=? ", whereArgs);
36 | if (rowsDeleted == 0) {
37 | throw new DocumentNotFoundException(docId, (String) null);
38 | }
39 | return null;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/callables/InsertDocumentIDCallable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.documentstore.callables;
16 |
17 | import com.cloudant.sync.internal.android.ContentValues;
18 | import com.cloudant.sync.documentstore.DocumentStoreException;
19 | import com.cloudant.sync.internal.sqlite.SQLCallable;
20 | import com.cloudant.sync.internal.sqlite.SQLDatabase;
21 |
22 | /**
23 | * Insert a new Document ID into the @{docs} table. Required when inserting the first Revision.
24 | */
25 | public class InsertDocumentIDCallable implements SQLCallable {
26 |
27 | private String docId;
28 |
29 | public InsertDocumentIDCallable(String docId) {
30 | this.docId = docId;
31 | }
32 |
33 | @Override
34 | public Long call(SQLDatabase db) throws DocumentStoreException {
35 | ContentValues args = new ContentValues();
36 | args.put("docid", docId);
37 | long result = db.insert("docs", args);
38 | if (result == -1) {
39 | throw new DocumentStoreException("Failed to insert docid "+docId+" into docs table, check log for details");
40 | }
41 | return result;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/encryption/EncryptionConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.documentstore.encryption;
16 |
17 | /**
18 | * Class to hold encryption related constants.
19 | */
20 | public class EncryptionConstants {
21 |
22 | public static final String CIPHER = "AES/CBC/PKCS5Padding";
23 | public static final String KEY_ALGORITHM = "AES";
24 | public static final byte ATTACHMENT_DISK_VERSION = 1;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/helpers/InsertStubRevisionAdaptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.documentstore.helpers;
16 |
17 | import com.cloudant.sync.internal.documentstore.callables.InsertRevisionCallable;
18 | import com.cloudant.sync.internal.util.JSONUtils;
19 |
20 | /**
21 | * Created by tomblench on 23/08/2017.
22 | */
23 |
24 | public class InsertStubRevisionAdaptor {
25 |
26 | public static InsertRevisionCallable insert(long docNumericId, String revId, long
27 | parentSequence) {
28 | // don't copy attachments
29 | InsertRevisionCallable callable = new InsertRevisionCallable();
30 | callable.docNumericId = docNumericId;
31 | callable.revId = revId;
32 | callable.parentSequence = parentSequence;
33 | callable.deleted = false;
34 | callable.current = false;
35 | callable.data = JSONUtils.emptyJSONObjectAsBytes();
36 | callable.available = false;
37 | return callable;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/migrations/Migration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.documentstore.migrations;
16 |
17 | import com.cloudant.sync.internal.sqlite.SQLDatabase;
18 |
19 | /**
20 | * Interface defining methods for running migration.
21 | */
22 | public interface Migration {
23 |
24 | /**
25 | * Implementors should run all migration steps in this method.
26 | *
27 | * Throw an exception if the migration fails.
28 | *
29 | * @param db The {@link SQLDatabase} to migrate
30 | * @throws Exception an exception was thrown during migration
31 | */
32 | void runMigration(SQLDatabase db) throws Exception;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/documentstore/migrations/SchemaOnlyMigration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.documentstore.migrations;
16 |
17 | import com.cloudant.sync.internal.sqlite.SQLDatabase;
18 |
19 | import java.util.Arrays;
20 |
21 | /**
22 | * Runs a database migration which consists only of SQL statements.
23 | */
24 | public class SchemaOnlyMigration implements Migration {
25 |
26 | private String[] statements;
27 |
28 | public SchemaOnlyMigration(String[] statements) {
29 | this.statements = Arrays.copyOf(statements, statements.length);
30 | }
31 |
32 | public void runMigration(SQLDatabase db) throws Exception {
33 | for (String statement : statements) {
34 | db.execSQL(statement);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/BulkGetRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.mazha;
16 |
17 | import java.util.List;
18 |
19 | /**
20 | * Created by tomblench on 14/10/15.
21 | */
22 |
23 | /**
24 | * Represents a bulk GET request for documents
25 | *
26 | * This is in the format which the _bulk_get endpoint understands, where <doc ID, rev ID>
27 | * pairs are given. If multiple rev IDs are required, then the doc ID needs to be repeated across
28 | * multiple requests.
29 | */
30 | public class BulkGetRequest {
31 | public String id;
32 | public String rev;
33 | public List atts_since;
34 | }
35 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/BulkGetResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.mazha;
16 |
17 | import com.fasterxml.jackson.annotation.JsonProperty;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * Created by tomblench on 19/11/15.
23 | */
24 |
25 | /*
26 | * For deserialising the response from the _bulk_get endpoint
27 | */
28 |
29 | public class BulkGetResponse {
30 |
31 | @JsonProperty
32 | public List results;
33 |
34 | static public class Result {
35 |
36 | @JsonProperty
37 | public String id;
38 |
39 | @JsonProperty
40 | public List docs;
41 | }
42 |
43 | static public class Doc {
44 |
45 | @JsonProperty
46 | public DocumentRevs ok;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/DBOperationResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant
5 | *
6 | * Copyright © 2011 Ahmed Yehia (ahmed.yehia.m@gmail.com)
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 |
21 | package com.cloudant.sync.internal.mazha;
22 |
23 | public class DBOperationResponse {
24 | private boolean ok = Boolean.FALSE;
25 |
26 | public boolean getOk() {
27 | return ok;
28 | }
29 |
30 | public void setOk(boolean ok) {
31 | this.ok = ok;
32 | }
33 |
34 | @Override
35 | public String toString() {
36 | return "Response: [ ok = " + ok + "]";
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/DocumentConflictException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant
5 | *
6 | * Copyright © 2011 Ahmed Yehia (ahmed.yehia.m@gmail.com)
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 |
21 | package com.cloudant.sync.internal.mazha;
22 |
23 | public class DocumentConflictException extends CouchException {
24 |
25 | public DocumentConflictException(String message) {
26 | super(message, 409);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/MissingOpenRevision.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha;
18 |
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import com.fasterxml.jackson.databind.JsonDeserializer;
21 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
22 |
23 | @JsonDeserialize(using = JsonDeserializer.None.class)
24 | public class MissingOpenRevision implements OpenRevision {
25 |
26 | @JsonProperty("missing")
27 | private String revision;
28 |
29 | public String getRevision() {
30 | return revision;
31 | }
32 |
33 | public void setRevision(String revision) {
34 | this.revision = revision;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/NoResourceException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha;
18 |
19 | public class NoResourceException extends CouchException {
20 |
21 | public NoResourceException(String message) {
22 | super(message, 404);
23 | }
24 |
25 | public NoResourceException(String message, Throwable cause) {
26 | super(message, cause, 404);
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/OkOpenRevision.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha;
18 |
19 | import com.fasterxml.jackson.annotation.JsonProperty;
20 | import com.fasterxml.jackson.databind.JsonDeserializer;
21 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
22 |
23 | @JsonDeserialize(using = JsonDeserializer.None.class)
24 | public class OkOpenRevision implements OpenRevision {
25 |
26 | @JsonProperty("ok")
27 | private DocumentRevs documentRevs;
28 |
29 |
30 | public DocumentRevs getDocumentRevs() {
31 | return documentRevs;
32 | }
33 |
34 | public void setDocumentRevs(DocumentRevs documentRevs) {
35 | this.documentRevs = documentRevs;
36 | }
37 |
38 | @Override
39 | public String toString() {return documentRevs.toString();}
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/OpenRevision.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha;
18 |
19 | import com.cloudant.sync.internal.mazha.json.OpenRevisionDeserializer;
20 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21 |
22 | @JsonDeserialize(using = OpenRevisionDeserializer.class)
23 | public interface OpenRevision {
24 | }
25 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/mazha/ServerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant
5 | *
6 | * Copyright © 2011 Ahmed Yehia (ahmed.yehia.m@gmail.com)
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 |
21 | package com.cloudant.sync.internal.mazha;
22 |
23 | public class ServerException extends RuntimeException {
24 |
25 | private int statusCode;
26 |
27 | public ServerException(Exception e) {
28 | super(e);
29 | }
30 |
31 | public ServerException(String errorMsg) {
32 | super(errorMsg);
33 | }
34 |
35 | public ServerException(int code) {
36 | this.statusCode = code;
37 | }
38 |
39 | public int getStatusCode() {
40 | return statusCode;
41 | }
42 |
43 | public void setStatusCode(int statusCode) {
44 | this.statusCode = statusCode;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/AndQueryNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | /**
20 | * An AndQueryNode object is used to specify that document IDs passed up the tree from child
21 | * nodes need to be intersected before being passed to the parent node.
22 | */
23 | class AndQueryNode extends ChildrenQueryNode {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/ChildrenQueryNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | /**
23 | * A ChildrenQueryNode object represents a tree node that is not a leaf,
24 | * specialized further in subclasses.
25 | */
26 | class ChildrenQueryNode implements QueryNode {
27 |
28 | public List children;
29 |
30 | ChildrenQueryNode() {
31 | children = new ArrayList();
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/OperatorExpressionNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | import java.util.Map;
20 |
21 | /**
22 | * An OperatorExpressionNode object is used by the
23 | * {@link UnindexedMatcher}. Since some methods within the
24 | * {@link UnindexedMatcher} class that utilize an OperatorExpressionNode
25 | * object are static in nature, the OperatorExpressionNode class cannot be implemented as an
26 | * inner class to {@link UnindexedMatcher} and must be
27 | * implemented this way instead.
28 | *
29 | * @see UnindexedMatcher
30 | */
31 | class OperatorExpressionNode implements QueryNode {
32 |
33 | final Map expression;
34 |
35 | OperatorExpressionNode(Map expression){
36 | this.expression = expression;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/OrQueryNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | /**
20 | * An OrQueryNode object is used to specify that document IDs passed up the tree from child
21 | * nodes need to be unioned before being passed to the parent node.
22 | */
23 | class OrQueryNode extends ChildrenQueryNode {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/QueryNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | /**
20 | * The QueryNode interface provides a general categorization in the trees generated. When parsing
21 | * selectors into trees we can easily walk to process a query.
22 | */
23 | interface QueryNode {
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/SqlParts.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | class SqlParts {
20 |
21 | public String sqlWithPlaceHolders;
22 | public String[] placeHolderValues;
23 |
24 | public static SqlParts partsForSql(String sql, String[] parameters) {
25 | SqlParts parts = new SqlParts();
26 | parts.sqlWithPlaceHolders = sql;
27 | parts.placeHolderValues = parameters;
28 |
29 | return parts;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/SqlQueryNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | /**
20 | * The SqlQueryNode class is a base level class of
21 | * the {@link QueryNode}.
22 | *
23 | * @see QueryNode
24 | */
25 | class SqlQueryNode implements QueryNode {
26 |
27 | public SqlParts sql;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/query/TranslatorState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2014 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | /**
20 | * The purpose of a TranslatorState object is to track the state of a query translation operation
21 | * performed by method calls in the {@link QuerySqlTranslator}. Since
22 | * all methods within the {@link QuerySqlTranslator} class that
23 | * utilize a TranslatorState object are static in nature, the TranslatorState class cannot be
24 | * implemented as an inner class to {@link QuerySqlTranslator} and must be
25 | * implemented this way instead.
26 | *
27 | * @see QuerySqlTranslator
28 | */
29 | class TranslatorState {
30 |
31 | public boolean atLeastOneIndexUsed;
32 | public boolean atLeastOneIndexMissing;
33 | public boolean atLeastOneORIndexMissing;
34 | public boolean textIndexRequired;
35 | public boolean textIndexMissing;
36 |
37 | TranslatorState() {
38 | atLeastOneIndexUsed = false;
39 | atLeastOneIndexMissing = false;
40 | atLeastOneORIndexMissing = false;
41 | textIndexRequired = false;
42 | textIndexMissing = false;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/replication/ReplicationStrategy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | import com.cloudant.sync.documentstore.DocumentStoreException;
20 | import com.cloudant.sync.event.EventBus;
21 |
22 |
23 | interface ReplicationStrategy extends Runnable {
24 |
25 | void setCancel();
26 |
27 | boolean isReplicationTerminated();
28 |
29 | EventBus getEventBus();
30 |
31 | String getReplicationId() throws DocumentStoreException;
32 |
33 | int getDocumentCounter();
34 |
35 | int getBatchCounter();
36 |
37 | String getRemote();
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/replication/ReplicationStrategyCompleted.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | import com.cloudant.sync.event.notifications.Notification;
20 |
21 | class ReplicationStrategyCompleted implements Notification {
22 |
23 | protected ReplicationStrategyCompleted(ReplicationStrategy replicationStrategy) {
24 | this.replicationStrategy = replicationStrategy;
25 | }
26 |
27 | protected final ReplicationStrategy replicationStrategy;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/replication/ReplicationStrategyErrored.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 |
20 | import com.cloudant.sync.event.notifications.Notification;
21 |
22 | class ReplicationStrategyErrored implements Notification {
23 |
24 | protected ReplicationStrategyErrored(ReplicationStrategy replicationStrategy, Throwable errorInfo) {
25 | this.replicationStrategy = replicationStrategy;
26 | this.errorInfo = errorInfo;
27 | }
28 |
29 | protected final ReplicationStrategy replicationStrategy;
30 | protected final Throwable errorInfo;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/sqlite/SQLCallable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.sqlite;
16 |
17 | /**
18 | * Created by tomblench on 25/08/16.
19 | */
20 | public interface SQLCallable {
21 |
22 | T call(SQLDatabase db) throws Exception;
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/sqlite/sqlite4java/DBUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.sqlite.sqlite4java;
18 |
19 | import com.cloudant.sync.internal.sqlite.Cursor;
20 |
21 | public class DBUtils {
22 |
23 | public static int getTypeOfObject(Object obj) {
24 | if (obj == null) {
25 | return Cursor.FIELD_TYPE_NULL;
26 | } else if (obj instanceof byte[]) {
27 | return Cursor.FIELD_TYPE_BLOB;
28 | } else if (obj instanceof Float || obj instanceof Double) {
29 | return Cursor.FIELD_TYPE_FLOAT;
30 | } else if (obj instanceof Long || obj instanceof Integer
31 | || obj instanceof Short || obj instanceof Byte) {
32 | return Cursor.FIELD_TYPE_INTEGER;
33 | } else {
34 | return Cursor.FIELD_TYPE_STRING;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/util/CollectionUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.util;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Collections;
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | public class CollectionUtils {
23 |
24 | public static List> partition(List list, int partitionSize) {
25 | int subLists = (list.size() / partitionSize) + (list.size() % partitionSize == 0 ? 0 : 1);
26 | ArrayList> lists = new ArrayList>(subLists);
27 | for (int i = 0; i < subLists; i++) {
28 | int minIndex = i * partitionSize;
29 | int maxIndex = i * partitionSize + partitionSize;
30 | maxIndex = (maxIndex < list.size()) ? maxIndex : list.size();
31 | lists.add(Collections.unmodifiableList(list.subList(minIndex, maxIndex)));
32 | }
33 | return Collections.unmodifiableList(lists);
34 | }
35 |
36 | public static List newArrayList(Iterator iterator) {
37 | List list = new ArrayList();
38 | while (iterator.hasNext()) {
39 | list.add(iterator.next());
40 | }
41 | return list;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/util/DatabaseUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.util;
18 |
19 | import com.cloudant.sync.internal.sqlite.Cursor;
20 |
21 | import java.util.logging.Level;
22 | import java.util.logging.Logger;
23 |
24 | public class DatabaseUtils {
25 |
26 | private final static String LOG_TAG = "DatabaseUtils";
27 | private final static Logger logger = Logger.getLogger(DatabaseUtils.class.getCanonicalName());
28 |
29 | public static void closeCursorQuietly(Cursor cursor) {
30 | try {
31 | if (cursor != null) {
32 | cursor.close();
33 | }
34 | } catch (Exception e) {
35 | logger.log(Level.SEVERE,"Error closing cursor",e);
36 | }
37 | }
38 |
39 | public static String makePlaceholders(int len) {
40 | Misc.checkArgument(len >= 1, "len needs to be greater than or equal to 1.");
41 | StringBuilder sb = new StringBuilder(len * 2 - 1);
42 | sb.append("?");
43 | for (int i = 1; i < len; i++) {
44 | sb.append(",?");
45 | }
46 | return sb.toString();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/util/JacksonModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.util;
18 |
19 | import com.cloudant.sync.internal.common.PropertyFilterMixIn;
20 | import com.cloudant.sync.internal.mazha.Document;
21 | import com.fasterxml.jackson.core.Version;
22 | import com.fasterxml.jackson.databind.module.SimpleModule;
23 |
24 | /**
25 | * Internal utility class
26 | *
27 | */
28 | public class JacksonModule extends SimpleModule {
29 |
30 | private static final long serialVersionUID = 5112015974963951685L;
31 |
32 | @SuppressWarnings("deprecation")
33 | public JacksonModule() {
34 | super("JacksonModule", new Version(0,0,1,null));
35 | }
36 |
37 | @Override
38 | public void setupModule(SetupContext context){
39 | // important, it takes advantage of mixin to use filter to filter out couchdb keywords for
40 | // all the serialization, notice is only works for sub-class of DocumentRevisionTree
41 | context.setMixInAnnotations(Document.class, PropertyFilterMixIn.class);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/internal/util/ThreadUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.util;
18 |
19 | /**
20 | * Internal utility class
21 | *
22 | */
23 | public class ThreadUtils {
24 |
25 | public static void checkInterrupted() throws InterruptedException {
26 | if(Thread.currentThread().isInterrupted()) {
27 | throw new InterruptedException("Pulling replication is interrupted");
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/query/IndexType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.query;
16 |
17 | import java.util.Locale;
18 |
19 | /**
20 | * Denotes the type for an query Index.
21 | */
22 | public enum IndexType {
23 |
24 | /**
25 | * JSON Index
26 | */
27 | JSON,
28 | /**
29 | * Text Index
30 | */
31 | TEXT;
32 |
33 | /**
34 | * {@inheritDoc}
35 | */
36 | @Override
37 | public String toString() {
38 | return super.toString().toLowerCase(Locale.ENGLISH);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/query/QueryException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.query;
16 |
17 | import com.cloudant.sync.documentstore.DocumentStoreException;
18 |
19 | /**
20 | *
21 | * Thrown when an unexpected condition was encountered during a {@link Query} method, for
22 | * example an internal SQLite database error.
23 | *
24 |
25 | *
26 | */
27 | public class QueryException extends DocumentStoreException {
28 | public QueryException(Throwable causedBy){
29 | super(causedBy);
30 | }
31 |
32 | public QueryException(String message){
33 | super(message);
34 | }
35 |
36 | public QueryException(String message, Throwable causedBy) {
37 | super(message, causedBy);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/replication/DatabaseNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Part of the library is derived from TouchDB: http://touchdb.org/.
7 | * Original iOS version by Jens Alfke
8 | * Ported to Android by Marty Schoch
9 | *
10 | * Copyright © 2012 Couchbase, Inc. All rights reserved.
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
13 | * except in compliance with the License. You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software distributed under the
18 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
19 | * either express or implied. See the License for the specific language governing permissions
20 | * and limitations under the License.
21 | */
22 |
23 | package com.cloudant.sync.replication;
24 |
25 | /**
26 | * Thrown when a given remote database does not exist.
27 | */
28 | public class DatabaseNotFoundException extends Exception {
29 | public DatabaseNotFoundException(String s) {
30 | super(s);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/java/com/cloudant/sync/replication/PushAttachmentsInline.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015, 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.replication;
16 |
17 | import com.cloudant.sync.internal.documentstore.RevisionHistoryHelper;
18 |
19 | import java.util.Map;
20 |
21 | /**
22 | *
23 | * Strategy to decide whether to push attachments inline:
24 | *
25 | *
26 | *
27 | * - False: Always push attachments separately from JSON body, via multipart/related
28 | * - Small: Push small attachments inline, and large attachments separately.
29 | * Uses SavedAttachment.isLarge() to determine whether attachment is small or large.
30 | * - True: Always push attachments inline in JSON body, as a base64-encoded string.
31 | *
32 | *
33 | *
34 | * Note that all attachments belonging to a pushed revision are either sent via multipart/related,
35 | * or all inline in JSON body, as a base64-encoded string.
36 | * Further details of this can be found at
37 | * {@link RevisionHistoryHelper#shouldInline(Map, PushAttachmentsInline, int)}
38 | *
39 | *
40 | * @see RevisionHistoryHelper
41 | */
42 |
43 | public enum PushAttachmentsInline {
44 | False,
45 | Small,
46 | True
47 | }
48 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/main/resources/mazha.properties:
--------------------------------------------------------------------------------
1 | user.agent=CloudantSync/@version@
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/common/AdvancedAPITest.java:
--------------------------------------------------------------------------------
1 | package com.cloudant.common;
2 |
3 | import com.cloudant.sync.documentstore.advanced.Database;
4 |
5 | import org.junit.Before;
6 |
7 | /**
8 | * Superclass that exposes the "advanced" Database APIs for testing
9 | */
10 | public class AdvancedAPITest extends DocumentStoreTestBase {
11 |
12 | protected Database advancedDatabase;
13 |
14 | @Before
15 | public void setUpAdvanced() throws Exception {
16 | advancedDatabase = documentStore.advanced();
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/common/DocumentStoreTestBase.java:
--------------------------------------------------------------------------------
1 | package com.cloudant.common;
2 |
3 | import com.cloudant.sync.documentstore.DocumentStore;
4 | import com.cloudant.sync.util.TestUtils;
5 |
6 | import org.junit.After;
7 | import org.junit.Before;
8 |
9 | import java.io.File;
10 |
11 | public abstract class DocumentStoreTestBase {
12 |
13 | protected DocumentStore documentStore;
14 |
15 | protected String datastore_manager_dir;
16 |
17 | @Before
18 | public void setUpDocumentStore() throws Exception {
19 | datastore_manager_dir = TestUtils.createTempTestingDir(this.getClass().getName());
20 | this.documentStore = DocumentStore.getInstance(new File
21 | (datastore_manager_dir, getClass().getSimpleName()));
22 |
23 | }
24 |
25 | @After
26 | public void tearDownDocumentStore() {
27 | documentStore.close();
28 | TestUtils.deleteTempTestingDir(datastore_manager_dir);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/common/PerformanceTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.common;
18 |
19 | /**
20 | * JUnit category to label tests which test performance.
21 | */
22 | public class PerformanceTest {
23 | }
24 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/common/RequireRunningCouchDB.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.common;
18 |
19 | /**
20 | * JUnit category to label tests which require a running
21 | * CouchDB instance.
22 | */
23 | public class RequireRunningCouchDB {
24 | }
25 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/common/RequireRunningProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.common;
16 |
17 | /**
18 | * Created by tomblench on 23/07/15.
19 | */
20 | public class RequireRunningProxy {
21 | }
22 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/common/SystemTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.common;
18 |
19 | /**
20 | * This is intended to be used as a JUnit category for
21 | * system level tests.
22 | */
23 | public class SystemTest {
24 | }
25 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/datastore/encryption/HelperSimpleKeyProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 | package com.cloudant.sync.datastore.encryption;
17 |
18 | import com.cloudant.sync.documentstore.encryption.SimpleKeyProvider;
19 |
20 | /**
21 | * Class provides SQLCipher key for test cases.
22 | * Created by estebanmlaver.
23 | */
24 | public class HelperSimpleKeyProvider extends SimpleKeyProvider {
25 |
26 | public HelperSimpleKeyProvider() {
27 | // Create a key provider with a hard-coded key
28 | super(new byte[] { -123, 53, -22, -15, -123, 53, -22, -15, 53, -22, -15,
29 | -123, -22, -15, 53, -22, -123, 53, -22, -15, -123, 53, -22, -15, 53, -22,
30 | -15, -123, -22, -15, 53, -22 });
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/documentstore/DatastoreTestBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.documentstore;
18 |
19 | import com.cloudant.common.DocumentStoreTestBase;
20 |
21 | import org.junit.After;
22 | import org.junit.Before;
23 |
24 | /**
25 | * Test base for any test suite need a DatastoreManager
and Datastore
instance. It
26 | * automatically set up and clean up the temp file directly for you.
27 | */
28 | public abstract class DatastoreTestBase extends DocumentStoreTestBase {
29 |
30 | DatabaseImpl datastore = null;
31 |
32 | @Before
33 | public void setUpDatabaseImpl() throws Exception {
34 | this.datastore = (DatabaseImpl) documentStore.database();
35 |
36 | }
37 |
38 | @After
39 | public void tearDownDatabaseImpl() {
40 | datastore.close();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/documentstore/NotificationTestUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.documentstore;
18 |
19 | import java.util.concurrent.CountDownLatch;
20 | import java.util.concurrent.TimeUnit;
21 |
22 | public class NotificationTestUtils {
23 |
24 | static int timeoutSecs = 2;
25 |
26 | static boolean waitForSignal(CountDownLatch b) {
27 | try {
28 | return b.await(timeoutSecs, TimeUnit.SECONDS);
29 | } catch (InterruptedException ie) {
30 | return false;
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/documentstore/TimestampBasedConflictsResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.documentstore;
18 |
19 | import com.cloudant.sync.documentstore.ConflictResolver;
20 | import com.cloudant.sync.documentstore.DocumentRevision;
21 |
22 | import java.util.List;
23 |
24 | public class TimestampBasedConflictsResolver implements ConflictResolver {
25 |
26 | @Override
27 | public DocumentRevision resolve(String docId, List extends DocumentRevision> conflicts) {
28 | Long timestamp = null;
29 | DocumentRevision winner = null;
30 | for(DocumentRevision revision : conflicts) {
31 | if(revision.isDeleted()) { continue; }
32 | Long newTimestamp = (Long)revision.getBody().asMap().get("timestamp");
33 | if(newTimestamp != null) {
34 | if(timestamp == null || newTimestamp > timestamp) {
35 | timestamp = newTimestamp;
36 | winner = revision;
37 | }
38 | }
39 | }
40 | return winner;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/CouchClientTestBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha;
18 |
19 | import com.cloudant.common.CouchTestBase;
20 |
21 | import org.junit.After;
22 | import org.junit.Before;
23 |
24 | public abstract class CouchClientTestBase extends CouchTestBase {
25 |
26 | String testDb;
27 | CouchConfig couchConfig;
28 | CouchClient client;
29 |
30 | public CouchClientTestBase() {
31 | testDb = "mazha-test"+System.currentTimeMillis();
32 | couchConfig = getCouchConfig(testDb);
33 | client = new CouchClient(couchConfig.getRootUri(), couchConfig.getRequestInterceptors(),
34 | couchConfig.getResponseInterceptors());
35 | }
36 |
37 | @Before
38 | public void setUp() {
39 | makeSureTestDbExistOnServer();
40 | }
41 |
42 | @After
43 | public void tearDown() {
44 | ClientTestUtils.deleteQuietly(client);
45 | }
46 |
47 | private void makeSureTestDbExistOnServer() {
48 | ClientTestUtils.deleteQuietly(client);
49 | client.createDb();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/Foo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha;
18 |
19 | import com.cloudant.sync.internal.mazha.Document;
20 |
21 | public class Foo extends Document {
22 |
23 | private String name;
24 |
25 | // Requried by Jackson
26 | public Foo() {}
27 |
28 | public Foo(String name) {
29 | this.name = name;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/matcher/IsNotEmpty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha.matcher;
18 |
19 | import com.cloudant.sync.internal.util.Misc;
20 |
21 | import org.hamcrest.Description;
22 | import org.hamcrest.Factory;
23 | import org.hamcrest.Matcher;
24 | import org.hamcrest.TypeSafeMatcher;
25 |
26 | public class IsNotEmpty extends TypeSafeMatcher {
27 |
28 | @Override
29 | protected boolean matchesSafely(String item) {
30 | return !Misc.isStringNullOrEmpty(item);
31 | }
32 |
33 | @Override
34 | public void describeTo(Description description) {
35 | description.appendText("not empty");
36 | }
37 |
38 | @Factory()
39 | public static Matcher notEmpty() {
40 | return new IsNotEmpty();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/matcher/IsNotEmptyTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.mazha.matcher;
18 |
19 | import org.junit.Assert;
20 | import org.junit.Test;
21 |
22 | import static com.cloudant.sync.internal.mazha.matcher.IsNotEmpty.notEmpty;
23 | import static org.hamcrest.CoreMatchers.is;
24 |
25 | public class IsNotEmptyTest {
26 |
27 | @Test
28 | public void notEmpty_nonEmptyString() {
29 | Assert.assertThat("a", is(notEmpty()));
30 | }
31 |
32 | @Test(expected = AssertionError.class)
33 | public void notEmpty_emptyString() {
34 | Assert.assertThat("", is(notEmpty()));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/query/MockSQLOnlyQueryExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.query;
18 |
19 | import com.cloudant.sync.documentstore.Database;
20 | import com.cloudant.sync.internal.sqlite.SQLDatabaseQueue;
21 |
22 | import java.util.Map;
23 |
24 | /**
25 | * This sub class of the {@link QueryExecutor} along with
26 | * {@link MockSQLOnlyQuery} is used by query
27 | * executor tests to force the tests to exclusively exercise the SQL engine logic.
28 | * This class is used for testing purposes only.
29 | *
30 | * @see QueryExecutor
31 | * @see MockSQLOnlyQuery
32 | */
33 | public class MockSQLOnlyQueryExecutor extends QueryExecutor{
34 |
35 | MockSQLOnlyQueryExecutor(Database database, SQLDatabaseQueue queue) {
36 | super(database, queue);
37 | }
38 |
39 | @Override
40 | protected UnindexedMatcher matcherForIndexCoverage(Boolean[] indexesCoverQuery, Map selector) {
41 | return null;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/CouchClientWrapperDbUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | public class CouchClientWrapperDbUtils {
20 |
21 | public static void deleteDbQuietly(CouchClientWrapper cloudantDb) {
22 | try {
23 | cloudantDb.deleteDatabase();
24 | } catch (Exception e) {}
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/Foo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | import com.cloudant.sync.internal.mazha.Document;
20 |
21 | public class Foo extends Document {
22 |
23 | private String foo;
24 | public String getFoo() {
25 | return foo;
26 | }
27 | public void setFoo(String foo) {
28 | this.foo = foo;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "Foo [foo=" + foo + "]";
34 | }
35 | }
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/InterceptorCallCounter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.internal.replication;
16 |
17 | import com.cloudant.http.HttpConnectionInterceptorContext;
18 | import com.cloudant.http.HttpConnectionRequestInterceptor;
19 | import com.cloudant.http.HttpConnectionResponseInterceptor;
20 |
21 | /**
22 | * This request and response interceptor counts the number of times the interceptRequest and interceptResponse
23 | * methods get called.
24 | */
25 | public class InterceptorCallCounter implements HttpConnectionRequestInterceptor, HttpConnectionResponseInterceptor {
26 |
27 | public int interceptorRequestTimesCalled = 0;
28 | public int interceptorResponseTimesCalled = 0;
29 |
30 | @Override
31 | public HttpConnectionInterceptorContext interceptRequest(HttpConnectionInterceptorContext context) {
32 | interceptorRequestTimesCalled++;
33 | return context;
34 | }
35 |
36 | @Override
37 | public HttpConnectionInterceptorContext interceptResponse(HttpConnectionInterceptorContext context) {
38 | interceptorResponseTimesCalled++;
39 | return context;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/RemoteCheckpointDocTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | import org.junit.Assert;
20 | import org.junit.Test;
21 |
22 | public class RemoteCheckpointDocTest {
23 |
24 | @Test
25 | public void constructor_mustHaveDefaultConstructor () {
26 | RemoteCheckpointDoc doc = new RemoteCheckpointDoc();
27 | Assert.assertNotNull(doc);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/TestReplicationListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | import com.cloudant.sync.event.Subscribe;
20 | import com.cloudant.sync.event.notifications.ReplicationCompleted;
21 | import com.cloudant.sync.event.notifications.ReplicationErrored;
22 | import com.cloudant.sync.util.TestEventListener;
23 |
24 | public class TestReplicationListener extends TestEventListener {
25 |
26 | @Subscribe
27 | public void complete(ReplicationCompleted rc) {
28 | finishCalled = true;
29 | batchesReplicated = rc.batchesReplicated;
30 | documentsReplicated = rc.documentsReplicated;
31 | }
32 |
33 | @Subscribe
34 | public void error(ReplicationErrored re) {
35 | errorCalled = true;
36 | errorInfo = re.errorInfo;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/TestStrategyListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.internal.replication;
18 |
19 | import com.cloudant.sync.event.Subscribe;
20 | import com.cloudant.sync.util.TestEventListener;
21 |
22 | /**
23 | * Simple implementation of StrategyListener
. It can be checked if the complete() or
24 | * error() has been called or not.
25 | */
26 |
27 | public class TestStrategyListener extends TestEventListener {
28 |
29 | @Subscribe
30 | public void complete(ReplicationStrategyCompleted rc) {
31 | finishCalled = true;
32 | documentsReplicated = rc.replicationStrategy.getDocumentCounter();
33 | batchesReplicated = rc.replicationStrategy.getBatchCounter();
34 | }
35 |
36 | @Subscribe
37 | public void error(ReplicationStrategyErrored re) {
38 | errorCalled = true;
39 | errorInfo = re.errorInfo;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/matcher/CauseMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2015 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.matcher;
16 |
17 | import org.hamcrest.Description;
18 | import org.hamcrest.TypeSafeMatcher;
19 |
20 | /**
21 | * Matcher for use in ExpectedException#expectCause()
22 | *
23 | * Usage:
24 | *
25 | *
26 | * exception.expectCause(new CauseMatcher(IllegalBlockSizeException.class));
27 | *
28 | */
29 | public class CauseMatcher extends TypeSafeMatcher {
30 |
31 | private final Class extends Throwable> type;
32 |
33 | public CauseMatcher(Class extends Throwable> type) {
34 | this.type = type;
35 | }
36 |
37 | @Override
38 | protected boolean matchesSafely(Throwable item) {
39 | return item.getClass().isAssignableFrom(type);
40 | }
41 |
42 | @Override
43 | public void describeTo(Description description) {
44 | description.appendText("expects type ").appendValue(type);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/sqlite/ContentValuesTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2013 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.sync.sqlite;
18 |
19 | import com.cloudant.sync.internal.android.ContentValues;
20 |
21 | import org.junit.Assert;
22 | import org.junit.Test;
23 |
24 | public class ContentValuesTest {
25 |
26 | @Test
27 | public void constructor() {
28 | ContentValues cv = new ContentValues();
29 | Assert.assertNotNull(cv);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/util/TestEventListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2016 IBM Corp. All rights reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 | * except in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the
10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 | * either express or implied. See the License for the specific language governing permissions
12 | * and limitations under the License.
13 | */
14 |
15 | package com.cloudant.sync.util;
16 |
17 | import org.junit.Assert;
18 |
19 | public class TestEventListener {
20 |
21 | public Throwable errorInfo = null;
22 | public boolean errorCalled = false;
23 | public boolean finishCalled = false;
24 | public int documentsReplicated = 0;
25 | public int batchesReplicated = 0;
26 |
27 | public void assertReplicationCompletedOrThrow() throws Exception {
28 | if (errorCalled) {
29 | throw new Exception("Replication errored", errorInfo);
30 | } else {
31 | Assert.assertTrue("The replication should finish.", finishCalled);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/cloudant-sync-datastore-javase/build.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | compile project(':cloudant-sync-datastore-core')
3 |
4 | compile group: 'com.almworks.sqlite4java', name: 'sqlite4java', version: '1.0.392'
5 |
6 | // there are a couple of unit tests in this project
7 | testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
8 | testCompile group: 'junit', name: 'junit', version: '4.11'
9 | testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
10 | // and we depend on some test utilities over in core
11 | testCompile project(':cloudant-sync-datastore-core').sourceSets.test.output
12 |
13 | }
14 |
15 | tasks.withType(Test) {
16 | // the native dir is one directory up from the core project dir
17 | systemProperty "sqlite4java.library.path", "../native"
18 | }
19 |
20 | uploadArchives {
21 | repositories {
22 | mavenDeployer {
23 |
24 | //augment the pom with additional information
25 | pom.project {
26 | name "cloudant-sync-datastore-javase"
27 | description 'Cloudant Sync Datastore for Java SE'
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/doc/code-style.md:
--------------------------------------------------------------------------------
1 | Code Style
2 | =====
3 |
4 | Our code style is enforced using custom formatting options in intellij idea. Intellij will automatically pick up this code style and apply it. However you may wish to format changes lines to ensure you are following the style.
5 |
6 | BasicDocumentRevision
7 | ALongClassName
8 |
9 | For reference the style looks like:
10 |
11 | ```java
12 | class AClass implements InterfaceA, InterfaceB {
13 |
14 | private static final String aLongString = "this is a string that extends beyond" +
15 | " the line limit";
16 |
17 | private long aMethodWithAReallyLongSignature(ALongClassName aLongClassName,
18 | List list,
19 | Long aLong,
20 | AnotherLongClass anotherLongClass,
21 | Map amap) {
22 |
23 | ALongClassName aVariable = aLongClassName.doThing(aLongClassName.getId(), list.get(0));
24 |
25 | for (int i = 1; i < revisions.size(); i++) {
26 | //do something here
27 | }
28 |
29 | if (anotherLongClass != null) {
30 | return anotherLongClass.getReference() + aLongClassName.getId();
31 | } else {
32 | return null;
33 | }
34 | }
35 | }
36 | ```
--------------------------------------------------------------------------------
/doc/images/quickstart/image00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image00.png
--------------------------------------------------------------------------------
/doc/images/quickstart/image01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image01.png
--------------------------------------------------------------------------------
/doc/images/quickstart/image02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image02.png
--------------------------------------------------------------------------------
/doc/images/quickstart/image03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image03.png
--------------------------------------------------------------------------------
/doc/images/quickstart/image04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image04.png
--------------------------------------------------------------------------------
/doc/images/quickstart/image05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image05.png
--------------------------------------------------------------------------------
/doc/images/quickstart/image06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/quickstart/image06.png
--------------------------------------------------------------------------------
/doc/images/replication-many.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/replication-many.png
--------------------------------------------------------------------------------
/doc/images/replication-multi-local.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/replication-multi-local.png
--------------------------------------------------------------------------------
/doc/images/replication-multi-remote.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/replication-multi-remote.png
--------------------------------------------------------------------------------
/doc/images/replication-push-pull.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/replication-push-pull.png
--------------------------------------------------------------------------------
/doc/images/replication-sync.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/doc/images/replication-sync.png
--------------------------------------------------------------------------------
/fixture/.gitattributes:
--------------------------------------------------------------------------------
1 | * -text
2 | EncryptedAttachmentTest* -text -diff
3 |
--------------------------------------------------------------------------------
/fixture/AddImageAttachmentTest_expected.mime:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/AddImageAttachmentTest_expected.mime
--------------------------------------------------------------------------------
/fixture/EncryptedAttachmentTest_badOnDiskVersion:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/EncryptedAttachmentTest_badOnDiskVersion
--------------------------------------------------------------------------------
/fixture/EncryptedAttachmentTest_cipherText_aes128:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/EncryptedAttachmentTest_cipherText_aes128
--------------------------------------------------------------------------------
/fixture/EncryptedAttachmentTest_gzip_cipherText_aes128:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/EncryptedAttachmentTest_gzip_cipherText_aes128
--------------------------------------------------------------------------------
/fixture/EncryptedAttachmentTest_plainText.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/EncryptedAttachmentTest_plainText.gz
--------------------------------------------------------------------------------
/fixture/EncryptedAttachmentTest_truncatedIV:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/EncryptedAttachmentTest_truncatedIV
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal0.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "zebra",
3 | "wiki_page": "http://en.wikipedia.org/wiki/Plains_zebra",
4 | "min_length": 2,
5 | "max_length": 2.5,
6 | "min_weight": 175,
7 | "max_weight": 387,
8 | "class": "mammal",
9 | "diet": "herbivore"
10 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal1.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "aardvark",
3 | "min_weight": 40,
4 | "max_weight": 65,
5 | "min_length": 1,
6 | "max_length": 2.2,
7 | "latin_name": "Orycteropus afer",
8 | "wiki_page": "http://en.wikipedia.org/wiki/Aardvark",
9 | "class": "mammal",
10 | "diet": "omnivore"
11 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal2.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "badger",
3 | "wiki_page": "http://en.wikipedia.org/wiki/Badger",
4 | "min_weight": 7,
5 | "max_weight": 30,
6 | "min_length": 0.6,
7 | "max_length": 0.9,
8 | "latin_name": "Meles meles",
9 | "class": "mammal",
10 | "diet": "omnivore"
11 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal3.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "elephant",
3 | "wiki_page": "http://en.wikipedia.org/wiki/African_elephant",
4 | "min_weight": 4700,
5 | "max_weight": 6050,
6 | "min_length": 3.2,
7 | "max_length": 4,
8 | "class": "mammal",
9 | "diet": "herbivore"
10 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal4.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "giraffe",
3 | "min_weight": 830,
4 | "min_length": 5,
5 | "max_weight": 1600,
6 | "max_length": 6,
7 | "wiki_page": "http://en.wikipedia.org/wiki/Giraffe",
8 | "class": "mammal",
9 | "diet": "herbivore"
10 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal5.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "kookaburra",
3 | "min_length": 0.28,
4 | "max_length": 0.42,
5 | "wiki_page": "http://en.wikipedia.org/wiki/Kookaburra",
6 | "class": "bird",
7 | "diet": "carnivore",
8 | "latin_name": "Dacelo novaeguineae"
9 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal6.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "lemur",
3 | "wiki_page": "http://en.wikipedia.org/wiki/Ring-tailed_lemur",
4 | "min_weight": 2.2,
5 | "max_weight": 2.2,
6 | "min_length": 0.95,
7 | "max_length": 1.1,
8 | "class": "mammal",
9 | "diet": "omnivore"
10 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal7.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "llama",
3 | "min_weight": 130,
4 | "max_weight": 200,
5 | "min_length": 1.7,
6 | "max_length": 1.8,
7 | "latin_name": "Lama glama",
8 | "wiki_page": "http://en.wikipedia.org/wiki/Llama",
9 | "class": "mammal",
10 | "diet": "herbivore"
11 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal8.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "panda",
3 | "wiki_page": "http://en.wikipedia.org/wiki/Panda",
4 | "min_weight": 73,
5 | "max_weight": 115,
6 | "min_length": 1.2,
7 | "max_length": 1.8,
8 | "class": "mammal",
9 | "chinese_name": "熊猫",
10 | "diet": "carnivore"
11 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_animal9.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "snipe",
3 | "min_weight": 0.08,
4 | "max_weight": 0.14,
5 | "min_length": 0.25,
6 | "max_length": 0.27,
7 | "latin_name": "Gallinago gallinago",
8 | "wiki_page": "http://en.wikipedia.org/wiki/Common_Snipe",
9 | "class": "bird",
10 | "diet": "omnivore"
11 | }
--------------------------------------------------------------------------------
/fixture/animaldb/animaldb_filter.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "_design/animal",
3 | "filters": {
4 | "bird": "function(doc, req) { if(doc.class && doc.class == 'bird') { return true; } return false; }",
5 | "mammal": "function(doc, req) { if(doc.class && doc.class == 'mammal') { return true; } return false; }",
6 | "by_class": "function(doc, req) { if(doc.class && doc.class == req.query.class) { return true; } return false; }",
7 | "small": "function(doc, req) { if(doc.max_length && doc.max_length <= req.query.max_length) { return true; } return false; }",
8 | "by_chinese_name": "function(doc, req) { if(doc.chinese_name && doc.chinese_name == req.query.chinese_name) { return true; } return false; }"
9 | }
10 | }
--------------------------------------------------------------------------------
/fixture/basic_bdbody_test_as_map.json:
--------------------------------------------------------------------------------
1 | {
2 | "StringValue": "-101",
3 | "IntegerValue": 2147483647,
4 | "LongValue": 2147483648
5 | }
--------------------------------------------------------------------------------
/fixture/bonsai-boston.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/bonsai-boston.jpg
--------------------------------------------------------------------------------
/fixture/bulk_docs_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "1",
3 | "_rev": "1-1a",
4 | "_revisions": {
5 | "start": 1,
6 | "ids": [
7 | "1a"
8 | ]
9 | },
10 | "name": "Tom",
11 | "age": 30
12 | }
--------------------------------------------------------------------------------
/fixture/bulk_docs_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "2",
3 | "_rev": "3-2c",
4 | "_revisions": {
5 | "start": 3,
6 | "ids": [
7 | "2c",
8 | "2b",
9 | "2a"
10 | ]
11 | },
12 | "name": "Jerry",
13 | "age": 22
14 | }
--------------------------------------------------------------------------------
/fixture/bulk_docs_3.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "2",
3 | "_rev": "3-2d",
4 | "_revisions": {
5 | "start": 3,
6 | "ids": [
7 | "2d",
8 | "2b",
9 | "2a"
10 | ]
11 | },
12 | "name": "David",
13 | "age": 50
14 | }
--------------------------------------------------------------------------------
/fixture/bulk_docs_4.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "2",
3 | "_rev": "3-2z",
4 | "_revisions": {
5 | "start": 3,
6 | "ids": [
7 | "2z",
8 | "2y",
9 | "2x"
10 | ]
11 | },
12 | "name": "Craig",
13 | "age": 90
14 | }
--------------------------------------------------------------------------------
/fixture/bulk_docs_bad_json.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "2",
3 | "_rev": "3-2m",
4 | "_revisions": {
5 | "start": 3,
6 | "ids": [
7 | "2z",
8 | "2y",
9 | "2x"
10 | ]
11 | },
12 | "name": "Hanson",
13 | "age": 91,
14 | }
--------------------------------------------------------------------------------
/fixture/bulk_docs_rev_not_match.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "2",
3 | "_rev": "3-2m",
4 | "_revisions": {
5 | "start": 3,
6 | "ids": [
7 | "2z",
8 | "2y",
9 | "2x"
10 | ]
11 | },
12 | "name": "Hanson",
13 | "age": 91
14 | }
--------------------------------------------------------------------------------
/fixture/change_feed_0.json:
--------------------------------------------------------------------------------
1 | {
2 | "last_seq": "7-g1AAAADfeJzLYWBgYMlgTmGQS0lKzi9KdUhJMjTUyyrNSS3QS87JL01JzCvRy0styQGqY0pkSLL___9_ViIbmg5jXDqSHIBkUj1YEwOx1uSxAEmGBiAF1LcfU6MJfo0HIBqBNjJmAQBtaklG",
3 | "results": [
4 | {
5 | "changes": [
6 | {
7 | "rev": "2-9fb189e316ea9eab813494195f0c0423"
8 | }
9 | ],
10 | "id": "c65f7da7a699454e8087153b7dc692df",
11 | "seq": "5-g1AAAAFReJzLYWBgYMtgTmGQS0lKzi9KdUhJMjTUyyrNSS3QS87JL01JzCvRy0styQGqY0pkSLL___9_ViIrmg5jXDqSHIBkUj1YEwOx1uSxAEmGBiAF1LcfU6MRfo0HIBqx2IjTmYQ0mhCtMQsATTVvGQ"
12 | },
13 | {
14 | "changes": [
15 | {
16 | "rev": "1-d8781f0c88d21fe9b98cfe7b02e32e3e"
17 | }
18 | ],
19 | "id": "c2b329f4dbe6d44499dfa25b3a8e6910",
20 | "seq": "6-g1AAAADfeJzLYWBgYMlgTmGQS0lKzi9KdUhJMjTUyyrNSS3QS87JL01JzCvRy0styQGqY0pkSLL___9_ViIrmg5jXDqSHIBkUj1YEwOx1uSxAEmGBiAF1LcfU6MJfo0HIBqBNjJmAQBswUlF",
21 | "deleted": true
22 | },
23 | {
24 | "changes": [
25 | {
26 | "rev": "4-47d7102726fc89914431cb217ab7bace"
27 | }
28 | ],
29 | "id": "cdb1a2fec33d146fe07a44ea823bf3ae",
30 | "seq": "7-g1AAAADfeJzLYWBgYMlgTmGQS0lKzi9KdUhJMjTUyyrNSS3QS87JL01JzCvRy0styQGqY0pkSLL___9_ViIbmg5jXDqSHIBkUj1YEwOx1uSxAEmGBiAF1LcfU6MJfo0HIBqBNjJmAQBtaklG"
31 | }
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/fixture/change_feed_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "last_seq": 35,
3 | "results": [
4 | {
5 | "changes": [
6 | {
7 | "rev": "1-bd42b942b8b672f0289cf3cd1f67044c"
8 | }
9 | ],
10 | "id": "tom@gamil.com",
11 | "seq": 27
12 | },
13 | {
14 | "changes": [
15 | {
16 | "rev": "29-3f4dabfb32290e557ac1d16b2e8f069c"
17 | },
18 | {
19 | "rev": "29-01fcbf8a3f1457eff21e18f7766d3b45"
20 | },
21 | {
22 | "rev": "26-30722da17ad35cf1860f126dba391d67"
23 | }
24 | ],
25 | "id": "jerry@gmail.com",
26 | "seq": 35
27 | }
28 | ]
29 | }
--------------------------------------------------------------------------------
/fixture/datastores-user_version6.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/datastores-user_version6.zip
--------------------------------------------------------------------------------
/fixture/dbinfo-pre23.json:
--------------------------------------------------------------------------------
1 | {
2 | "db_name": "test",
3 | "update_seq": "4-g1AAAAFTeJzLYWBg4MhgTmEQTM4vTc5ISXLIyU9OzMnILy7JAUoxJTIkyf___z8rkQGPoiQFIJlkD1bHiE-dA0hdPFgdEz51CSB19QTtzWMBkgwNQAqodD4xahdA1O4nRu0BiNr7-P0EUfsAohbk3iwA10dvMg",
4 | "sizes": {
5 | "file": 161030,
6 | "external": 112978,
7 | "active": 113762
8 | },
9 | "purge_seq": 0,
10 | "other": {
11 | "data_size": 112978
12 | },
13 | "doc_del_count": 0,
14 | "doc_count": 3,
15 | "disk_size": 161030,
16 | "disk_format_version": 6,
17 | "data_size": 113762,
18 | "compact_running": false,
19 | "instance_start_time": "0"
20 | }
--------------------------------------------------------------------------------
/fixture/document_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "Sunrise":true,
3 | "Sunset":false,
4 | "Data": "A run to the head of the blood",
5 | "FullHours":[1,2,3,4,5,6,7,8,9,10],
6 | "Activities": [
7 | {"Name":"Football", "Duration":2, "DurationUnit":"Hours"},
8 | {"Name":"Breakfast", "Duration":40, "DurationUnit":"Minutes", "Attendees":["Jan", "Damien", "Laura", "Gwendolyn", "Roseanna"]}
9 | ]
10 | }
--------------------------------------------------------------------------------
/fixture/document_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "Subject":"I like Plankton",
3 | "Author":"Rusty",
4 | "PostedDate":"2006-08-15T17:30:12-04:00",
5 | "Tags":["plankton", "baseball", "decisions"],
6 | "Body":"I decided today that I don't like baseball. I like plankton."
7 | }
--------------------------------------------------------------------------------
/fixture/document_revs_deleted.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "cdb1a2fec33d146fe07a44ea823bf3ae",
3 | "_rev": "1-47d7102726fc89914431cb217ab7bace",
4 | "_revisions": {
5 | "start": 1,
6 | "ids": [
7 | "47d7102726fc89914431cb217ab7bace"
8 | ]
9 | },
10 | "_deleted": true,
11 | "album": "A Flush Of Blood To My Head",
12 | "title": "Trouble Two"
13 | }
--------------------------------------------------------------------------------
/fixture/document_revs_only_one_revision.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "cdb1a2fec33d146fe07a44ea823bf3ae",
3 | "_rev": "1-47d7102726fc89914431cb217ab7bace",
4 | "_revisions": {
5 | "start": 1,
6 | "ids": [
7 | "47d7102726fc89914431cb217ab7bace"
8 | ]
9 | },
10 | "album": "A Flush Of Blood To My Head",
11 | "title": "Trouble Two"
12 | }
--------------------------------------------------------------------------------
/fixture/document_revs_only_two_revision.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "cdb1a2fec33d146fe07a44ea823bf3ae",
3 | "_rev": "1-47d7102726fc89914431cb217ab7bace",
4 | "_revisions": {
5 | "start": 3,
6 | "ids": [
7 | "47d7102726fc89914431cb217ab7bace",
8 | "b7d7102726fc89914431cb217ab7bace"
9 | ]
10 | },
11 | "album": "A Flush Of Blood To My Head",
12 | "title": "Trouble Two"
13 | }
--------------------------------------------------------------------------------
/fixture/document_revs_others.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id":"a",
3 | "_rev":"1-a",
4 | "a":"A",
5 | "b":"B"
6 | }
7 |
--------------------------------------------------------------------------------
/fixture/document_revs_with_everything.json:
--------------------------------------------------------------------------------
1 | {
2 | "_id": "cdb1a2fec33d146fe07a44ea823bf3ae",
3 | "_rev": "4-47d7102726fc89914431cb217ab7bace",
4 | "_revisions": {
5 | "start": 4,
6 | "ids": [
7 | "47d7102726fc89914431cb217ab7bace",
8 | "d8e1fb8127d8dd732d9ae46a6c38ae3c",
9 | "74e0572530e3b4cd4776616d2f591a96",
10 | "421ff3d58df47ea6c5e83ca65efb2fa9"
11 | ]
12 | },
13 | "album": "A Flush Of Blood To My Head",
14 | "title": "Trouble Two"
15 | }
--------------------------------------------------------------------------------
/fixture/document_revs_with_unknown_special_field.json:
--------------------------------------------------------------------------------
1 | {
2 | "_someMockedSpecialField":"Mocked value",
3 | "_id":"a",
4 | "_rev":"1-a"
5 | }
6 |
--------------------------------------------------------------------------------
/fixture/empty_changes.json:
--------------------------------------------------------------------------------
1 | {
2 | "last_seq": "10-d9e5b0147af143e5b6d1979378ad957b",
3 | "pending": 0,
4 | "results": []
5 | }
6 |
--------------------------------------------------------------------------------
/fixture/index_0.json:
--------------------------------------------------------------------------------
1 | {
2 | "user": "dongshengcn"
3 | }
--------------------------------------------------------------------------------
/fixture/index_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Politik",
3 | "album": "A rush of blood to my head",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Rock"],
7 | "class": 1,
8 | "year": 2001
9 | }
--------------------------------------------------------------------------------
/fixture/index_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Amsterdam",
3 | "album": "A rush of blood to my head",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Rock"],
7 | "class": 200088689,
8 | "year": 2002
9 | }
--------------------------------------------------------------------------------
/fixture/index_3.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "X And Y",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": 1,
8 | "year": 2003
9 | }
--------------------------------------------------------------------------------
/fixture/index_4.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "The hardest part",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Pop"],
7 | "class": 4,
8 | "year": 2004
9 | }
--------------------------------------------------------------------------------
/fixture/index_5.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Speed of Sound",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Rock"],
7 | "class": 0,
8 | "year": 2005
9 | }
--------------------------------------------------------------------------------
/fixture/index_6.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Fire",
3 | "album": "Hall of fame",
4 | "artist": "Big Sean",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": -1,
8 | "year": 2006
9 | }
--------------------------------------------------------------------------------
/fixture/index_7.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Hall of fame",
3 | "album": "Hall of fame",
4 | "artist": "Big Sean",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": -10000,
8 | "year": 2008
9 | }
--------------------------------------------------------------------------------
/fixture/index_chinese_character.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Hall of fame",
3 | "album": "东方红,太阳升",
4 | "artist": "东升",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": -10000,
8 | "year": 2008
9 | }
--------------------------------------------------------------------------------
/fixture/index_float.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "X And Y",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": 1000.99
8 | }
--------------------------------------------------------------------------------
/fixture/index_really_big_long.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "X And Y",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": 100000000000000000000000000000000
8 | }
--------------------------------------------------------------------------------
/fixture/index_special_character.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Hall of fame",
3 | "album": "\\\\//",
4 | "artist": "Tom's nick name is \"tommy\"",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": -10000,
8 | "year": 2008
9 | }
--------------------------------------------------------------------------------
/fixture/index_string.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "X And Y",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop"],
7 | "class": "100"
8 | }
--------------------------------------------------------------------------------
/fixture/index_with_spaces.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Hall of fame",
3 | "album": "东方红,太阳升",
4 | "artist": "东升",
5 | "description": "None",
6 | "Genre": [" Pop", 100, "Rock ", " R & B "],
7 | "class": -10000,
8 | "year": 2008
9 | }
--------------------------------------------------------------------------------
/fixture/index_with_unsupported_value.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Hall of fame",
3 | "album": "东方红,太阳升",
4 | "artist": "东升",
5 | "description": "None",
6 | "Genre": ["Pop", 100, "Rock", ""],
7 | "class": -10000,
8 | "year": 2008
9 | }
--------------------------------------------------------------------------------
/fixture/integer_index_invalid_field.json:
--------------------------------------------------------------------------------
1 | {
2 | "integerIndex": { "name": "X&Y" }
3 | }
--------------------------------------------------------------------------------
/fixture/integer_index_valid_field.json:
--------------------------------------------------------------------------------
1 | {
2 | "integerIndex": 100
3 | }
--------------------------------------------------------------------------------
/fixture/integer_index_valid_field_updated.json:
--------------------------------------------------------------------------------
1 | {
2 | "integerIndex": 1001
3 | }
--------------------------------------------------------------------------------
/fixture/json_helper.json:
--------------------------------------------------------------------------------
1 | {
2 | "Activities": [
3 | {"Duration":2, "DurationUnit":"Hours","Name":"Football"},
4 | {"Attendees":["Jan", "Damien", "Laura", "Gwendolyn", "Roseanna"], "Duration":40, "DurationUnit":"Minutes", "Name":"Breakfast"}
5 | ],
6 | "Data": "A run to the head of the blood",
7 | "FullHours":[1,2,3,4,5,6,7,8,9,10],
8 | "Organizer": { "Name": "Tom", "Sex": "Male" },
9 | "Sunrise":true,
10 | "Sunset":false
11 | }
--------------------------------------------------------------------------------
/fixture/json_helper_compacted.json:
--------------------------------------------------------------------------------
1 | {"Activities":[{"Duration":2,"DurationUnit":"Hours","Name":"Football"},{"Attendees":["Jan","Damien","Laura","Gwendolyn","Roseanna"],"Duration":40,"DurationUnit":"Minutes","Name":"Breakfast"}],"Data":"A run to the head of the blood","FullHours":[1,2,3,4,5,6,7,8,9,10],"Organizer":{"Name":"Tom","Sex":"Male"},"Sunrise":true,"Sunset":false}
--------------------------------------------------------------------------------
/fixture/json_helper_response.json:
--------------------------------------------------------------------------------
1 | {
2 | "ok":true,
3 | "id":"myId",
4 | "rev":"1-IPromiseIamARevision"
5 | }
--------------------------------------------------------------------------------
/fixture/json_helper_response_list.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ok":true,
4 | "id":"myId",
5 | "rev":"1-IPromiseIamARevision"
6 | },
7 | {
8 | "ok":false,
9 | "error":"403",
10 | "reason":"Forbidden"
11 | }
12 |
13 | ]
--------------------------------------------------------------------------------
/fixture/json_utils_test.json:
--------------------------------------------------------------------------------
1 | {
2 | "Sunrise":true,
3 | "Sunset":false,
4 | "Data": "A run to the head of the blood",
5 | "Organizer": { "Name": "Tom", "Sex": "Male" },
6 | "FullHours":[1,2,3,4,5,6,7,8,9,10],
7 | "Activities": [
8 | {"Name":"Football", "Duration":2, "DurationUnit":"Hours"},
9 | {"Name":"Breakfast", "Duration":40, "DurationUnit":"Minutes", "Attendees":["Jan", "Damien", "Laura", "Gwendolyn", "Roseanna"]}
10 | ]
11 | }
--------------------------------------------------------------------------------
/fixture/json_utils_test_boolean.json:
--------------------------------------------------------------------------------
1 | {
2 | "boolean1":true,
3 | "boolean2":false
4 | }
--------------------------------------------------------------------------------
/fixture/json_utils_test_number.json:
--------------------------------------------------------------------------------
1 | {
2 | "number":1,
3 | "number1":30000000000000000,
4 | "number2":12.0909
5 |
6 | }
--------------------------------------------------------------------------------
/fixture/legacy_database_with_indexes.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/legacy_database_with_indexes.zip
--------------------------------------------------------------------------------
/fixture/multipart_from_couch_with_gzip.mime:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/multipart_from_couch_with_gzip.mime
--------------------------------------------------------------------------------
/fixture/open_revisions_empty.json:
--------------------------------------------------------------------------------
1 | []
--------------------------------------------------------------------------------
/fixture/open_revisions_missing.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "missing" : "2-x"
3 | } ]
--------------------------------------------------------------------------------
/fixture/open_revisions_ok.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ok": {
4 | "_id": "a",
5 | "_rev": "1-a"
6 | }
7 | }
8 | ]
--------------------------------------------------------------------------------
/fixture/open_revisions_ok_and_missing.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ok": {
4 | "_id": "a",
5 | "_rev": "1-a"
6 | }
7 | },
8 | {
9 | "missing" : "2-x"
10 | }
11 | ]
--------------------------------------------------------------------------------
/fixture/string_index_invalid_field.json:
--------------------------------------------------------------------------------
1 | {
2 | "stringIndex": { "name": "X&Y" }
3 | }
--------------------------------------------------------------------------------
/fixture/string_index_unicode_key.json:
--------------------------------------------------------------------------------
1 | {
2 | "☀": "Sun",
3 | "🐶": "Dawg"
4 | }
5 |
--------------------------------------------------------------------------------
/fixture/string_index_valid_field.json:
--------------------------------------------------------------------------------
1 | {
2 | "stringIndex": "X&Y"
3 | }
--------------------------------------------------------------------------------
/fixture/string_index_valid_field_updated.json:
--------------------------------------------------------------------------------
1 | {
2 | "stringIndex": "X&Y Updated"
3 | }
--------------------------------------------------------------------------------
/fixture/testReplicationDocWithEmptyId_changes.json:
--------------------------------------------------------------------------------
1 | {
2 | "last_seq": 27,
3 | "results": [
4 | {
5 | "changes":[
6 | {
7 | "rev": "1-bd42b942b8b672f0289cf3cd1f67044c"
8 | }
9 | ],
10 | "id": "",
11 | "seq": 27
12 | },
13 | {
14 | "seq": 28,
15 | "id": "4d3b3f01362649d79b31d9092799a7e0",
16 | "changes": [
17 | {
18 | "rev": "1-13d33701a0954729ad029adf8fdc5a04"
19 | }
20 | ]
21 | }
22 | ]
23 | }
--------------------------------------------------------------------------------
/fixture/testReplicationDocWithEmptyId_open_revs_1.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ok":{
4 | "_id":"",
5 | "_rev":"1-bd42b942b8b672f0289cf3cd1f67044c",
6 | "hello":"foo",
7 | "_revisions": {
8 | "start": 1,
9 | "ids": [
10 | "bd42b942b8b672f0289cf3cd1f67044c"
11 | ]
12 | }
13 | }
14 | }
15 | ]
16 |
--------------------------------------------------------------------------------
/fixture/testReplicationDocWithEmptyId_open_revs_2.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "ok": {
4 | "_id":"4d3b3f01362649d79b31d9092799a7e0",
5 | "_rev":"1-13d33701a0954729ad029adf8fdc5a04",
6 | "hello":"world",
7 | "foo":"bar",
8 | "_revisions": {
9 | "start": 1,
10 | "ids": ["13d33701a0954729ad029adf8fdc5a04"]
11 | }
12 | }
13 | }
14 | ]
15 |
--------------------------------------------------------------------------------
/fixture/v100ComplexWithoutDuplicates.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/v100ComplexWithoutDuplicates.zip
--------------------------------------------------------------------------------
/fixture/v100WithDuplicates.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/fixture/v100WithDuplicates.zip
--------------------------------------------------------------------------------
/fixture/view_test_0.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Politik",
3 | "album": "A rush of blood to my head",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Rock"]
7 | }
--------------------------------------------------------------------------------
/fixture/view_test_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "In my place",
3 | "album": "A rush of blood to my head",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Rock"]
7 | }
--------------------------------------------------------------------------------
/fixture/view_test_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "A rush of blood to my head",
3 | "album": "A rush of blood to my head",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Rock"]
7 | }
--------------------------------------------------------------------------------
/fixture/view_test_3.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Amsterdam",
3 | "album": "A rush of blood to my head",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop", "Rock"]
7 |
8 | }
--------------------------------------------------------------------------------
/fixture/view_test_4.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "White Shadows",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Rock"]
7 | }
--------------------------------------------------------------------------------
/fixture/view_test_5.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "Speed of Sound",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Rock"]
7 | }
--------------------------------------------------------------------------------
/fixture/view_test_6.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "X And Y",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop"]
7 | }
--------------------------------------------------------------------------------
/fixture/view_test_7.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "The hardest part",
3 | "album": "X&Y",
4 | "artist": "cold play",
5 | "description": "None",
6 | "Genre": ["Pop"]
7 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jul 19 15:55:23 BST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/native/libsqlite4java-linux-amd64.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/native/libsqlite4java-linux-amd64.so
--------------------------------------------------------------------------------
/native/libsqlite4java-linux-i386.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/native/libsqlite4java-linux-i386.so
--------------------------------------------------------------------------------
/native/libsqlite4java-osx.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/native/libsqlite4java-osx.dylib
--------------------------------------------------------------------------------
/sample/todo-sync/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
19 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/sample/todo-sync/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/sample/todo-sync/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample/todo-sync/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue May 03 10:40:03 BST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/sample/todo-sync/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/sample/todo-sync/ic_launcher-web.png
--------------------------------------------------------------------------------
/sample/todo-sync/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/sample/todo-sync/proguard.cfg:
--------------------------------------------------------------------------------
1 | # Proguard file preserving attributes and classes needed for
2 | # serialization etc
3 |
4 | -keepattributes Signature,*Annotation*,EnclosingMethod
5 | -keepattributes InnerClasses
6 | -keepattributes SourceFile,LineNumberTable
7 |
8 | -dontwarn sun.misc.Unsafe
9 | -dontwarn org.w3c.dom.bootstrap.DOMImplementationRegistry
10 | -dontwarn javax.annotation.**
11 | -dontwarn javax.inject.**
12 | # okhttp is an optional dependency of cloudant-http
13 | -dontwarn com.squareup.okhttp.**
14 |
15 | -keepnames class com.fasterxml.jackson.** { *; }
16 |
17 | -keep class org.w3c.dom.bootstrap.DOMImplementationRegistry
18 | -keep class javax.inject.** { *; }
19 | -keep class com.cloudant.** { *; }
20 |
--------------------------------------------------------------------------------
/sample/todo-sync/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-14
15 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/sample/todo-sync/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/todo-sync/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/sample/todo-sync/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/todo-sync/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/sample/todo-sync/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/todo-sync/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudant/sync-android/a72b3fcf2c2f4ff89c7d1eb9c3bfea75c4024ddd/sample/todo-sync/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/todo-sync/res/layout/activity_todo.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/layout/dialog_loading.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/layout/dialog_new_task.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/layout/task_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
24 |
25 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/menu/context_menu.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/menu/todo.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | TodoSync
5 | Settings
6 | Create
7 | Cancel
8 | New
9 | Settings
10 | Download (Pull)
11 | Upload (Push)
12 | Delete
13 | New Task
14 | Enter task description
15 | Task not created because description is empty
16 | COMPLETED
17 | Replication is running
18 | Replication completed
19 | Replication error
20 | The api key used to replicate to/from your cloudant account.
21 | API Key
22 | The api password used to replicate to/from your cloudant account.
23 | API Password
24 | You cloudant user name, and it is also used to determine your cloudant server url.
25 | Cloudant user name
26 | You cloudant db name, and this is the db used in replication.
27 | Cloudant db name
28 |
29 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/sample/todo-sync/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
14 |
19 |
24 |
25 |
--------------------------------------------------------------------------------
/sample/todo-sync/src/com/cloudant/todo/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright © 2017 IBM Corp. All rights reserved.
3 | *
4 | * Copyright © 2015 Cloudant, Inc. All rights reserved.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
7 | * except in compliance with the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software distributed under the
12 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 | * either express or implied. See the License for the specific language governing permissions
14 | * and limitations under the License.
15 | */
16 |
17 | package com.cloudant.todo;
18 |
19 | import android.os.Bundle;
20 | import android.preference.PreferenceActivity;
21 |
22 | public class SettingsActivity extends PreferenceActivity {
23 |
24 | @Override
25 | public void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | addPreferencesFromResource(R.xml.preferences);
28 | }
29 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'cloudant-sync-datastore-core'
2 | include 'cloudant-sync-datastore-android'
3 | include 'cloudant-sync-datastore-android-encryption'
4 | include 'cloudant-sync-datastore-javase'
5 |
--------------------------------------------------------------------------------