com.worklight.jsonstore.api

Class WLJSONStore

  • java.lang.Object
    • com.worklight.jsonstore.api.WLJSONStore


  • public class WLJSONStore
    extends java.lang.Object
    This class is the public JSONStore API for native Android applications.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void changePassword(java.lang.String username, java.lang.String old_password, java.lang.String new_password)
      Change the password.
      void changePassword(java.lang.String username, java.lang.String old_password, java.lang.String new_password, int pbkdf2Iterations)
      Change the password.
      void closeAll()
      Locks access to all the collections until the init method is called.
      boolean commitTransaction()
      Commit a transaction.
      void destroy()
      Permanently deletes all data for all users, clears security artifacts, and removes accessors.
      void destroy(java.lang.String username)
      Permanently deletes all data, clears security artifacts, and removes the accessor for a specific user.
      JSONStoreCollection getCollectionByName(java.lang.String collectionName)
      Provides an accessor to the collection if the collection exists.
      java.util.List getFileInfo()
      Returns a list of objects with information about all the stores in the device.
      static WLJSONStore getInstance(android.content.Context android_context)
      Responsible for retrieving a WLJSONStore instance that is unique to the application's Android context object.
      void openCollections(java.util.List collections)
      Provides access to the collections that are inside the store, and creates them if they do not already exist.
      void openCollections(java.util.List collections, JSONStoreInitOptions initOptions)
      Provides access to the collections that are inside the store, and creates them if they do not already exist.
      boolean rollbackTransaction()
      Roll back a transaction.
      void setAnalyticsEnabled(boolean isAnalyticsEnabled)
      Enable or disable the collection of analytic data for JSONStore.
      void startTransaction()
      Begin a new transaction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static WLJSONStore getInstance(android.content.Context android_context)
        Responsible for retrieving a WLJSONStore instance that is unique to the application's Android context object.
        Parameters:
        android_context - The current Android context object that is associated with this application.
        Returns:
        A WLJSONStore object that can be used to initialize and manipulate collections.
      • openCollections

        public void openCollections(java.util.List collections,
                           JSONStoreInitOptions initOptions)
                             throws JSONStoreInvalidSchemaException,
                                    JSONStoreFileAccessException,
                                    JSONStoreMigrationException,
                                    JSONStoreCloseAllException,
                                    JSONStoreInvalidPasswordException,
                                    JSONStoreSchemaMismatchException,
                                    JSONStoreTransactionDuringInitException
        Provides access to the collections that are inside the store, and creates them if they do not already exist.
        Parameters:
        collections - An array of collection definitions (JSONStoreCollection objects) that are to be initialized (either reopened or created).
        initOptions - Specific set of options to initialize the collection with (such as security credentials).
        Throws:
        JSONStoreInvalidSchemaException
        JSONStoreCollectionExistsException
        JSONStoreSchemaMismatchException
        JSONStoreInvalidPasswordException
        JSONStoreCloseAllException
        JSONStoreMigrationException
        JSONStoreFileAccessException
        JSONStoreTransactionDuringInitException
        java.lang.Exception
      • openCollections

        public void openCollections(java.util.List collections)
                             throws JSONStoreInvalidSchemaException,
                                    JSONStoreFileAccessException,
                                    JSONStoreMigrationException,
                                    JSONStoreCloseAllException,
                                    JSONStoreInvalidPasswordException,
                                    JSONStoreSchemaMismatchException,
                                    JSONStoreTransactionDuringInitException
        Provides access to the collections that are inside the store, and creates them if they do not already exist.
        Parameters:
        collections - An array of collection definitions (JSONStoreCollection objects) that are to be initialized (either reopened or created).
        Throws:
        JSONStoreCollectionExistsException
        JSONStoreSchemaMismatchException
        JSONStoreInvalidPasswordException
        JSONStoreCloseAllException
        JSONStoreMigrationException
        JSONStoreFileAccessException
        JSONStoreInvalidSchemaException
        JSONStoreTransactionDuringInitException
        java.lang.Exception
      • closeAll

        public void closeAll()
                      throws JSONStoreCloseAllException,
                             JSONStoreDatabaseClosedException,
                             JSONStoreTransactionFailureException
        Locks access to all the collections until the init method is called.
        Throws:
        JSONStoreCloseAllException - An unexpected error occurred when trying to close access to all collections.
        JSONStoreDatabaseClosedException - The database is already closed, so this operation is futile.
        JSONStoreTransactionFailureException
      • getCollectionByName

        public JSONStoreCollection getCollectionByName(java.lang.String collectionName)
        Provides an accessor to the collection if the collection exists. This method depends on the init method being called first, with the requested collection name.
        Parameters:
        collectionName - The name of the initialized JSONStore collection to retrieve.
        Returns:
        A JSONStoreCollection object of an already initialized collection. Returns null if a collection by that name does not exist.
      • destroy

        public void destroy(java.lang.String username)
                     throws JSONStoreTransactionFailureException,
                            JSONStoreDestroyFailureException,
                            JSONStoreDestroyFileError,
                            JSONStoreMetadataRemovalFailure
        Permanently deletes all data, clears security artifacts, and removes the accessor for a specific user.
        Throws:
        JSONStoreDestroyFailureException - Unexpected failure.
        JSONStoreTransactionFailureException - Transaction in progress.
        JSONStoreDestroyFileError - Failure to remove the file.
        JSONStoreMetadataRemovalFailure - Failure to remove metadata.
      • destroy

        public void destroy()
                     throws JSONStoreDestroyFailureException,
                            JSONStoreTransactionFailureException
        Permanently deletes all data for all users, clears security artifacts, and removes accessors.
        Throws:
        JSONStoreDestroyFailureException - When a system failure occurs (such as lack of file permissions). The destroy has failed completely.
        JSONStoreTransactionFailureException
      • getFileInfo

        public java.util.List getFileInfo()
        Returns a list of objects with information about all the stores in the device. It contains the name of the store, the size, and whether they are encrypted or not.
        Returns:
        A JSONStoreFileInfo list that contains the file information.
      • startTransaction

        public void startTransaction()
                              throws JSONStoreTransactionInProgressException,
                                     JSONStoreTransactionFailureException,
                                     JSONStoreDatabaseClosedException
        Begin a new transaction. After starting the transaction, the following methods will not work until the transaction is committed or rolled back: open, destroy, closeAll, and removeCollection.
        Throws:
        JSONStoreTransactionInProgressException - occurs if a transaction is already in progress.
        JSONStoreTransactionFailureException - occurs if there was an error while starting the transaction.
        JSONStoreDatabaseClosedException - occurs if the collection has not been opened.
      • commitTransaction

        public boolean commitTransaction()
                                  throws JSONStoreNoTransactionInProgressException,
                                         JSONStoreTransactionFailureException,
                                         JSONStoreDatabaseClosedException
        Commit a transaction.
        Returns:
        true if the transaction finished successfully.
        Throws:
        JSONStoreNoTransactionInProgressException - occurs if there is no transaction that is currently in progress.
        JSONStoreTransactionFailureException - occurs if there is a problem while committing the transaction.
        JSONStoreDatabaseClosedException - occurs if the collection has not been opened.
      • rollbackTransaction

        public boolean rollbackTransaction()
                                    throws JSONStoreNoTransactionInProgressException,
                                           JSONStoreDatabaseClosedException,
                                           JSONStoreTransactionFailureException
        Roll back a transaction.
        Returns:
        true if the transaction rollback was successful.
        Throws:
        JSONStoreNoTransactionInProgressException - occurs if there is no transaction that is currently in progress.
        JSONStoreDatabaseClosedException - occurs if the collection has not been opened.
        JSONStoreTransactionFailureException - occurs if there is a problem while rolling back the transaction.
      • changePassword

        public void changePassword(java.lang.String username,
                          java.lang.String old_password,
                          java.lang.String new_password,
                          int pbkdf2Iterations)
                            throws JSONStoreDatabaseClosedException,
                                   JSONStoreChangePasswordException
        Change the password.
        Parameters:
        username - The user name.
        old_password - The old password.
        new_password - The new password.
        pbkdf2Iterations - The number of iterations used by the Password-Based Key Derivation Function 2 algorithm used to secure the password.
        Throws:
        JSONStoreDatabaseClosedException
        JSONStoreChangePasswordException - if there was a problem changing the password, usually because the provided password was wrong
      • changePassword

        public void changePassword(java.lang.String username,
                          java.lang.String old_password,
                          java.lang.String new_password)
                            throws JSONStoreDatabaseClosedException,
                                   JSONStoreChangePasswordException
        Change the password.
        Parameters:
        username - The user name.
        old_password - The old password.
        new_password - The new password.
        Throws:
        JSONStoreDatabaseClosedException
        JSONStoreChangePasswordException - if there was a problem changing the password, usually because the provided password was wrong
      • setAnalyticsEnabled

        public void setAnalyticsEnabled(boolean isAnalyticsEnabled)
        Enable or disable the collection of analytic data for JSONStore.
        Parameters:
        isAnalyticsEnabled - should be true if analytic data should be collected


© Copyright IBM Corp. 2006, 2015. All Rights Reserved.