org.eclipse.higgins.icard
Interface CardStoreStrategy


public interface CardStoreStrategy

Strategy for storing and retrieving data from a CardStore. The strategy must be initialized to be functional. The exportCards() method is to store the cards under the same paradigm the strategy uses for storing cards. E.g., if the strategy stores ICards in a encrypted CRDS file, the exportCards() method will also store the exported cards in such a CRDS file.

Author:
Anthony Bussani, Thomas Gross

Method Summary
 void changePassword(char[] oldPassword, char[] newPassword)
          Changes the password of a password protected CardStore.
 void exportCards(CallbackHandler authHandler, Iterator cards, OutputStream out)
          Exports the cards provided as Iterator cards to stream out.
 Map importStore(CallbackHandler authHandler, String asciiStore)
          This should be part of a future CardManager
 void initialize(CallbackHandler authHandler, ICardProvider cardProvider, String filename, PasswordCallback passwordCallback, org.eclipse.higgins.registry.IConfiguration configuration)
          Initializes the ICardStoreStrategy before it is used.
 boolean isPasswordProtected()
          Determines whether this strategy is capable of protecting its ICards by a password.
 void synchFromMap(CallbackHandler authHandler, Map icards)
          Synchronizes the CardStore from the provided in-memory Map icards.
 void synchFromStore(CallbackHandler authHandler, Map icards)
          Synchronizes the CardStore from the disk representation.
 

Method Detail

initialize

public void initialize(CallbackHandler authHandler,
                       ICardProvider cardProvider,
                       String filename,
                       PasswordCallback passwordCallback,
                       org.eclipse.higgins.registry.IConfiguration configuration)
                throws CardStoreException
Initializes the ICardStoreStrategy before it is used. The ICardStoreStrategy SHOULD throw a ICardStoreException if other functions are leveraged before the strategy is initialized. If the File with filename does not exist the strategy assumes that the CardStore needs to be newly generated and initiates a new CardStore at the designated location.

Parameters:
authHandler - CallbackHandler for handling password events
filename - target location of the CardStore. Can refer to a directory for directory-based CardStores or a single File.
passwordCallback - the password handler to use if password is required by the type of implemented store
Throws:
ICardStoreException
CardStoreException

synchFromMap

public void synchFromMap(CallbackHandler authHandler,
                         Map icards)
                  throws CardStoreException
Synchronizes the CardStore from the provided in-memory Map icards. The icards are transfered to the disk CardStore.

Parameters:
authHandler -
icards - Map with the memory representation of the CardStore
Throws:
ICardStoreException
CardStoreException

synchFromStore

public void synchFromStore(CallbackHandler authHandler,
                           Map icards)
                    throws CardStoreException
Synchronizes the CardStore from the disk representation. The icards are transfered from the disk CardStore to the provided in-memory map.

Parameters:
authHandler -
icards - icards Map with the memory representation of the CardStore
Throws:
ICardStoreException
CardStoreException

exportCards

public void exportCards(CallbackHandler authHandler,
                        Iterator cards,
                        OutputStream out)
                 throws CardException
Exports the cards provided as Iterator cards to stream out. The strategy leverages the very same paradigm for the export as for normal storing of cards.

Parameters:
authHandler -
cards - Iterator of cards to be exported
out - OutputStream where the cards are stored.
Throws:
ICardException
CardException

isPasswordProtected

public boolean isPasswordProtected()
Determines whether this strategy is capable of protecting its ICards by a password. Implicitly assumes that the password is changeable.

Returns:
true if the strategy handles passwords.

changePassword

public void changePassword(char[] oldPassword,
                           char[] newPassword)
                    throws CardStoreException
Changes the password of a password protected CardStore.

Parameters:
oldPassword -
newPassword -
Throws:
UnsupportedOperationException - if the CardStore does not support passwords.
ICardStoreException - if the oldPassword is not correct.
CardStoreException

importStore

public Map importStore(CallbackHandler authHandler,
                       String asciiStore)
                throws CardStoreException
This should be part of a future CardManager

Parameters:
asciiStore -
Throws:
CardStoreException