- All Implemented Interfaces:
PersistenceMechanism
- Author:
- AO Industries, Inc.
-
Field Summary
Modifier and TypeFieldDescriptionprotected List
<CreditCard> The list of credit cards in the database.protected List
<Transaction> The list of transactions in the database.protected final String
The properties file path is obtained at creation time just in case the configuration mapping changes values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
authorizeCompleted
(Principal principal, Transaction transaction) Updates a transaction in the database after the authorize has completed.void
deleteCreditCard
(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.void
saleCompleted
(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.void
updateCardNumber
(Principal principal, CreditCard creditCard, String cardNumber, byte expirationMonth, short expirationYear) Card numbers are not persisted to the properties files - encrypted local storage not supported.void
updateCreditCard
(Principal principal, CreditCard creditCard) Updates the stored credit card details, all except the card number, expiration, and card security code, for a credit card.void
updateExpiration
(Principal principal, CreditCard creditCard, byte expirationMonth, short expirationYear) Encrypted local storage not supported.void
voidCompleted
(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:PersistenceMechanism
Stores a credit card and returns its persistenceUniqueId.- Specified by:
storeCreditCard
in interfacePersistenceMechanism
- Throws:
SQLException
- See Also:
-
getCreditCard
public CreditCard getCreditCard(Principal principal, String persistenceUniqueId) throws SQLException Description copied from interface:PersistenceMechanism
Gets a defensive copy of a stored card given itspersistenceUniqueId
.- Specified by:
getCreditCard
in interfacePersistenceMechanism
- Parameters:
persistenceUniqueId
- The card'spersistenceUniqueId
- Returns:
- The stored
CreditCard
ornull
if not found. - Throws:
SQLException
-
getCreditCards
Description copied from interface:PersistenceMechanism
Gets 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:
getCreditCards
in 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:PersistenceMechanism
Gets 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:
getCreditCards
in 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:
updateCreditCard
in 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:
updateCardNumber
in 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:
updateExpiration
in interfacePersistenceMechanism
- Throws:
SQLException
- See Also:
-
deleteCreditCard
Description copied from interface:PersistenceMechanism
Deletes the credit card from the credit card list.- Specified by:
deleteCreditCard
in interfacePersistenceMechanism
- Throws:
SQLException
- See Also:
-
insertTransaction
public String insertTransaction(Principal principal, Group group, Transaction transaction) throws SQLException Description copied from interface:PersistenceMechanism
Inserts a new transaction into the database and returns its persistenceUniqueId.- Specified by:
insertTransaction
in interfacePersistenceMechanism
- Parameters:
principal
-null
is acceptablegroup
-null
is acceptable- Throws:
SQLException
- See Also:
-
saleCompleted
Description copied from interface:PersistenceMechanism
Updates 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:
saleCompleted
in interfacePersistenceMechanism
- Throws:
SQLException
- See Also:
-
authorizeCompleted
Description copied from interface:PersistenceMechanism
Updates 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:
authorizeCompleted
in interfacePersistenceMechanism
- Throws:
SQLException
- See Also:
-
voidCompleted
Description copied from interface:PersistenceMechanism
Updates a transaction in the database after the void has completed.- Specified by:
voidCompleted
in interfacePersistenceMechanism
- Throws:
SQLException
- See Also:
-