java.lang.Object
com.aoapps.payments.PropertiesPersistenceMechanism
- All Implemented Interfaces:
PersistenceMechanism
Stores everything in a simple on-disk properties file. This is not a scalable solution
and is intended for debugging purposes only.
- Author:
- AO Industries, Inc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<CreditCard> The list of credit cards in the database.protected List<Transaction> The list of transactions in the database.protected final StringThe properties file path is obtained at creation time just in case the configuration mapping changes values. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthorizeCompleted(Principal principal, Transaction transaction) Updates a transaction in the database after the authorize has completed.voiddeleteCreditCard(Principal principal, CreditCard creditCard) Deletes the credit card from the credit card list.getCreditCard(Principal principal, String persistenceUniqueId) Gets a defensive copy of a stored card given itspersistenceUniqueId.getCreditCards(Principal principal) Gets all the stored cards.getCreditCards(Principal principal, String providerId) Gets all the stored cards for a givenproviderId.getInstance(String propertiesFilePath) For intra-JVM reusability, only one instance is made per unique path.insertTransaction(Principal principal, Group group, Transaction transaction) Inserts a new transaction into the database and returns its persistenceUniqueId.voidsaleCompleted(Principal principal, Transaction transaction) Updates a transaction in the database after the sale has completed.storeCreditCard(Principal principal, CreditCard creditCard) Stores a credit card and returns its persistenceUniqueId.voidupdateCardNumber(Principal principal, CreditCard creditCard, String cardNumber, byte expirationMonth, short expirationYear) Card numbers are not persisted to the properties files - encrypted local storage not supported.voidupdateCreditCard(Principal principal, CreditCard creditCard) Updates the stored credit card details, all except the card number, expiration, and card security code, for a credit card.voidupdateExpiration(Principal principal, CreditCard creditCard, byte expirationMonth, short expirationYear) Encrypted local storage not supported.voidvoidCompleted(Principal principal, Transaction transaction) Updates a transaction in the database after the void has completed.
-
Field Details
-
propertiesFilePath
The properties file path is obtained at creation time just in case the configuration mapping changes values. The properties file will remain the same. -
internalCreditCards
The list of credit cards in the database. -
internalTransactions
The list of transactions in the database.
-
-
Method Details
-
getInstance
For intra-JVM reusability, only one instance is made per unique path. However, different paths resolving to the same file (symlink in Unix is one example) or multiple processes accessing the same file are not guaranteed to interoperate properly. In fact, there are no mechanisms in this code to control that in any way. Once again, this is intended for development and debugging use only. -
storeCreditCard
Description copied from interface:PersistenceMechanismStores a credit card and returns its persistenceUniqueId.- Specified by:
storeCreditCardin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
getCreditCard
public CreditCard getCreditCard(Principal principal, String persistenceUniqueId) throws SQLException Description copied from interface:PersistenceMechanismGets a defensive copy of a stored card given itspersistenceUniqueId.- Specified by:
getCreditCardin interfacePersistenceMechanism- Parameters:
persistenceUniqueId- The card'spersistenceUniqueId- Returns:
- The stored
CreditCardornullif not found. - Throws:
SQLException
-
getCreditCards
Description copied from interface:PersistenceMechanismGets all the stored cards.Each element is a defensive copy. Modifications will not update the underling persistence.
The returned map must be modifiable. Modifications to the returned map will not update the underlying persistence.
- Specified by:
getCreditCardsin interfacePersistenceMechanism- Returns:
- The modifiable mapping from
CreditCard.getPersistenceUniqueId()to defensive copies of the stored card - Throws:
SQLException- See Also:
-
getCreditCards
public Map<String,CreditCard> getCreditCards(Principal principal, String providerId) throws SQLException Description copied from interface:PersistenceMechanismGets all the stored cards for a givenproviderId.Each element is a defensive copy. Modifications will not update the underling persistence.
The returned map must be modifiable. Modifications to the returned map will not update the underlying persistence.
- Specified by:
getCreditCardsin interfacePersistenceMechanism- Parameters:
principal- The entity performing the query (person, software component, ...)providerId- The ID of the provider to get all cards for- Returns:
- The modifiable mapping from
CreditCard.getProviderUniqueId()to defensive copies of the stored card - Throws:
SQLException- See Also:
-
updateCreditCard
Updates the stored credit card details, all except the card number, expiration, and card security code, for a credit card.Card numbers are not persisted to the properties files - encrypted local storage not supported.
- Specified by:
updateCreditCardin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
updateCardNumber
public void updateCardNumber(Principal principal, CreditCard creditCard, String cardNumber, byte expirationMonth, short expirationYear) throws SQLException Card numbers are not persisted to the properties files - encrypted local storage not supported.- Specified by:
updateCardNumberin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
updateExpiration
public void updateExpiration(Principal principal, CreditCard creditCard, byte expirationMonth, short expirationYear) throws SQLException Encrypted local storage not supported.- Specified by:
updateExpirationin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
deleteCreditCard
Description copied from interface:PersistenceMechanismDeletes the credit card from the credit card list.- Specified by:
deleteCreditCardin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
insertTransaction
public String insertTransaction(Principal principal, Group group, Transaction transaction) throws SQLException Description copied from interface:PersistenceMechanismInserts a new transaction into the database and returns its persistenceUniqueId.- Specified by:
insertTransactionin interfacePersistenceMechanism- Parameters:
principal-nullis acceptablegroup-nullis acceptable- Throws:
SQLException- See Also:
-
saleCompleted
Description copied from interface:PersistenceMechanismUpdates a transaction in the database after the sale has completed. The following transaction fields have been updated and must be stored:- authorizationResult
- captureTime
- capturePrincipalName
- captureResult
- status
- Specified by:
saleCompletedin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
authorizeCompleted
Description copied from interface:PersistenceMechanismUpdates a transaction in the database after the authorize has completed. The following transaction fields have been updated and must be stored:- authorizationResult
- status
- Specified by:
authorizeCompletedin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
voidCompleted
Description copied from interface:PersistenceMechanismUpdates a transaction in the database after the void has completed.- Specified by:
voidCompletedin interfacePersistenceMechanism- Throws:
SQLException- See Also:
-
