public class ODFCartManager extends AbstractLogEnabled implements Serviceable, Component, Contextualizable
Modifier and Type | Class and Description |
---|---|
(package private) class |
ODFCartManager.ODFCartItem |
Modifier and Type | Field and Description |
---|---|
private Context |
_context |
private ContentTypeExtensionPoint |
_cTypeEP |
private ContentTypesHelper |
_cTypesHelper |
private I18nUtils |
_i18nUtils |
private OdfPageResolver |
_odfPageResolver |
private ODFCartUserPreferencesStorage |
_odfUserPrefStorage |
private RenderingContextHandler |
_renderingContextHandler |
private AmetysObjectResolver |
_resolver |
private SiteManager |
_siteManager |
private SourceResolver |
_srcResolver |
private UserHelper |
_userHelper |
private UserPreferencesManager |
_userPrefManager |
static String |
CART_USER_PREF_CONTENT_IDS
The id of user preference for cart's elements
|
static String |
ROLE
The avalon role
|
Constructor and Description |
---|
ODFCartManager() |
Modifier and Type | Method and Description |
---|---|
boolean |
addCartItem(UserIdentity owner,
String itemId,
String siteName)
Add a content to the cart
|
Map<String,Object> |
cartItem2Json(ODFCartManager.ODFCartItem item,
String siteName,
String viewName)
Get the JSON representation of a cart item
|
void |
contextualize(Context context) |
ODFCartManager.ODFCartItem |
getCartItem(String itemId)
Get a cart item from its id
|
List<String> |
getCartItemIds(UserIdentity user,
String siteName)
Get the id of ODF's cart items for a given user
|
List<ODFCartManager.ODFCartItem> |
getCartItems(UserIdentity owner,
String siteName)
Get the ODF's cart items for a given user
|
protected String |
getMailBody(List<ODFCartManager.ODFCartItem> items,
String message,
UserIdentity owner,
String siteName,
String language,
boolean text)
Get the mail body to sharing cart
|
protected String |
getMailSubject(String siteName,
String language)
Get the mail subject for sharing cart
|
protected Page |
getPage(ODFCartManager.ODFCartItem item,
String siteName)
Get the page associated to this cart's item
|
void |
saxCartItem(ContentHandler contentHandler,
ODFCartManager.ODFCartItem item,
String siteName)
SAX a cart's item
|
void |
saxCartItems(ContentHandler contentHandler,
UserIdentity owner,
String siteName)
SAX the cart's items
|
protected void |
saxContent(ContentHandler handler,
Content content,
String metadataSetName)
SAX the content view
|
protected void |
saxPage(ContentHandler handler,
ODFCartManager.ODFCartItem item,
String siteName)
Sax the content's page
|
protected void |
saxTypes(ContentHandler handler,
String[] types)
Sax the content types
|
void |
service(ServiceManager serviceManager) |
void |
setCartItems(UserIdentity owner,
List<String> itemIds,
String siteName)
Set the cart's items
|
Map<String,Object> |
shareCartItems(UserIdentity owner,
List<String> itemIds,
List<String> recipients,
String siteName,
String language,
String message)
Share the cart's items by mail
|
getLogger, setLogger
public static final String CART_USER_PREF_CONTENT_IDS
private UserPreferencesManager _userPrefManager
private AmetysObjectResolver _resolver
private SourceResolver _srcResolver
private OdfPageResolver _odfPageResolver
private ContentTypeExtensionPoint _cTypeEP
private ContentTypesHelper _cTypesHelper
private ODFCartUserPreferencesStorage _odfUserPrefStorage
private I18nUtils _i18nUtils
private UserHelper _userHelper
private SiteManager _siteManager
private RenderingContextHandler _renderingContextHandler
public ODFCartManager()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public List<String> getCartItemIds(UserIdentity user, String siteName) throws UserPreferencesException
user
- the usersiteName
- the current site nameUserPreferencesException
- if failed to get cart itemspublic List<ODFCartManager.ODFCartItem> getCartItems(UserIdentity owner, String siteName) throws UserPreferencesException
owner
- the usersiteName
- the current site nameUserPreferencesException
- if failed to get cart itemspublic ODFCartManager.ODFCartItem getCartItem(String itemId)
itemId
- the item's idpublic void setCartItems(UserIdentity owner, List<String> itemIds, String siteName) throws UserPreferencesException
owner
- The cart owneritemIds
- the id of items to set in the cartsiteName
- the site nameUserPreferencesException
- if failed to save cartpublic boolean addCartItem(UserIdentity owner, String itemId, String siteName) throws UserPreferencesException
owner
- the cart owneritemId
- the id of content to add into the cartsiteName
- the site nameUserPreferencesException
- if failed to save cartpublic Map<String,Object> shareCartItems(UserIdentity owner, List<String> itemIds, List<String> recipients, String siteName, String language, String message)
owner
- The cart owneritemIds
- the id of contents to set in the cartrecipients
- the mails to share withsiteName
- the site namelanguage
- the languagemessage
- the message to add to selectionprotected String getMailSubject(String siteName, String language)
siteName
- The site namelanguage
- the languageprotected String getMailBody(List<ODFCartManager.ODFCartItem> items, String message, UserIdentity owner, String siteName, String language, boolean text) throws IOException
items
- The cart's itemsmessage
- The messageowner
- The cart's ownersiteName
- The site namelanguage
- the languagetext
- true to get the body to text body (html otherwise)IOException
- if failed to mail bodypublic void saxCartItems(ContentHandler contentHandler, UserIdentity owner, String siteName) throws SAXException, IOException, UserPreferencesException
contentHandler
- The content handler to sax intoowner
- the cart ownersiteName
- the site nameSAXException
- if an error occurred while saxingIOException
- if an I/O exception occurredUserPreferencesException
- if failed to get cart itemspublic void saxCartItem(ContentHandler contentHandler, ODFCartManager.ODFCartItem item, String siteName) throws SAXException, IOException
contentHandler
- The content handler to sax intoitem
- the cart's itemsiteName
- the site nameSAXException
- if an error occurred while saxingIOException
- if an I/O exception occurredpublic Map<String,Object> cartItem2Json(ODFCartManager.ODFCartItem item, String siteName, String viewName) throws IOException
item
- The cart's itemsiteName
- The site nameviewName
- The name of content view to useIOException
- if failed to read content viewprotected void saxTypes(ContentHandler handler, String[] types) throws SAXException
handler
- The content handler to sax intotypes
- The content typesSAXException
- if an error occurred while saxingprotected void saxContent(ContentHandler handler, Content content, String metadataSetName) throws SAXException, IOException
handler
- The content handler to sax intocontent
- The contentmetadataSetName
- The viewSAXException
- if an error occurred while saxingIOException
- if an I/O exception occurredprotected void saxPage(ContentHandler handler, ODFCartManager.ODFCartItem item, String siteName) throws SAXException
handler
- The content handler to sax intoitem
- The cart's itemsiteName
- The current site nameSAXException
- if an error occurred while saxingprotected Page getPage(ODFCartManager.ODFCartItem item, String siteName)
item
- The itemsiteName
- The site namenull
if not found