fr.paris.lutece.plugins.stock.service
Class PurchaseSessionManager

java.lang.Object
  extended by fr.paris.lutece.plugins.stock.service.PurchaseSessionManager
All Implemented Interfaces:
IPurchaseSessionManager

public class PurchaseSessionManager
extends Object
implements IPurchaseSessionManager

Singleton spring. Store active purchase (not yet stored into database) and allow to reserve some.

Author:
aBataille

Field Summary
static org.apache.log4j.Logger LOG
           
 
Constructor Summary
PurchaseSessionManager()
           
 
Method Summary
 void checkReserved(String sessionId, IPurchaseDTO purchase)
          Check that purchase has been reserved before to save it.
 void clearPurchase(Integer minutes)
          Delete all purchase create more than "minute" minutes ago
 void release(String sessionId, IPurchaseDTO purchase)
          Remove purchase from session
 void releaseAll(String sessionId)
          Remove all active purchases for a session id
 void reserve(String sessionId, IPurchaseDTO purchase)
          Reserves an offer quantity for a session.
 Integer updateQuantityWithSession(Integer quantity, Integer offerId)
          Update offer quantity with quantity in session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.log4j.Logger LOG
Constructor Detail

PurchaseSessionManager

public PurchaseSessionManager()
Method Detail

reserve

public void reserve(String sessionId,
                    IPurchaseDTO purchase)
             throws PurchaseUnavailable
Reserves an offer quantity for a session. Check if offer is available (quantity remaining in database + purchases in session) and add purchase in session

Specified by:
reserve in interface IPurchaseSessionManager
Parameters:
sessionId - session id
purchase - purchase (offer id, quantity and user)
Throws:
PurchaseUnavailable - exception thrown if purchase is impossible

checkReserved

public void checkReserved(String sessionId,
                          IPurchaseDTO purchase)
                   throws PurchaseSessionExpired
Check that purchase has been reserved before to save it.

Specified by:
checkReserved in interface IPurchaseSessionManager
Parameters:
sessionId - session id
purchase - purchase
Throws:
PurchaseSessionExpired - the purchase session expired

release

public void release(String sessionId,
                    IPurchaseDTO purchase)
Remove purchase from session

Specified by:
release in interface IPurchaseSessionManager
Parameters:
sessionId - session id
purchase - purchase

releaseAll

public void releaseAll(String sessionId)
Remove all active purchases for a session id

Specified by:
releaseAll in interface IPurchaseSessionManager
Parameters:
sessionId - session id

updateQuantityWithSession

public Integer updateQuantityWithSession(Integer quantity,
                                         Integer offerId)
Description copied from interface: IPurchaseSessionManager
Update offer quantity with quantity in session

Specified by:
updateQuantityWithSession in interface IPurchaseSessionManager
Parameters:
quantity - the quantity
offerId - the offer id
Returns:
the quantity update

clearPurchase

public void clearPurchase(Integer minutes)
Description copied from interface: IPurchaseSessionManager
Delete all purchase create more than "minute" minutes ago

Specified by:
clearPurchase in interface IPurchaseSessionManager
Parameters:
minutes - the number max of minutes for keeping purchase in session


Copyright © 2014 Mairie de Paris. All Rights Reserved.