Because Android devices don't always have access to a reliable network connection, Nuxeo Android Connector manages local caching.
The cache data is maintained by a SQLite DB and Filesystem storage.
Several types of caches are managed :
ResponseCache: the server response is simply stored on the device so that it can be reused in case the server is unreachable.
Typical use case is caching the result of a query so that you can continue browsing the list of documents, even if the network has gone.
TransientState: because you have the ability to create or update documents from the Android device, you need to be able to store your changes locally
Typical use case is that you update a document and you want to keep this local change until your are able to send it back to the server and get a fresh copy
DeferedUpdate: creating or updating a document also means calling an operation on the server side. The create/update operation will be stored locally and replayed when the server is available.

ResponseCache
Automation Responses can be cached.
This basically means that the JSON response sent by the Nuxeo server is stored on the local filesystem and is associated with a DB record that maintains metadata.
The extra meta-data in the SQL DB are used to be able to match a response with the corresponding request. The DB also contains the informations to be able to reconstruct the request, so that the cache can be refreshed.
Compared to the "standard Automation Client API", when calling a Operation you can specify expected caching behavior.
TransientState
This cache stores Document deltaset (changes done in the Document).
This includes newly created Documents that do only exist in local.
The TransientState manager is mainly updated via Events (AndroidTransientStateManager is a BroadcastReceiver).
This design helps making the TransientState management as transparent as possible.
When a Document is created or update in local, a event is sent : TransientStateManager stores the delta
When the create/update operation has been processed by the server a new event will be fired and the TransientStateManager will delete the local storage.
To reflect the synchronization status, the Document has a getStatusFlag() that returns an Enum :
"new"means that the Document only exists in local for now"updated"means that the Document hold local modifications that have not yet been pushed to the server""means that the Document is synchrozed with the server"conflict"means that the push on the server resulted in a conflict
TransientStateManager exposes an API to automatically fetch and merge deltasets on a List of Documents, but in most of the cases this is already encapsulated by the DocumentProviders.
Defered Updates
This caches keeps track of the Create/Update/Delete operations that are pending and should be sent to the server when network is accessible.
Each cached operation is indirectly linked to a set of TransientState.
In addition, pending Request can have dependencies :
- dependencies between update requests
- dependencies with pending Uploads
Defered Updates system is exposed via DeferredUpdateManager service interface.
This service can be used to send an update request :