Package org.ametys.plugins.cart
Class Cart
-
- All Implemented Interfaces:
ACLAmetysObject,AmetysObject,JCRAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableACLAmetysObject,ModifiableAmetysObject,RemovableAmetysObject,DataAndVersionAwareAmetysObject,ModifiableDataAwareVersionableAmetysObject,VersionableAmetysObject,VersionAwareAmetysObject
public class Cart extends DefaultAmetysObject<CartFactory>
Class representing a cart, backed by a JCR node.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCart.CartElementTypeTypes of CartElementstatic classCart.CartProfileRights profilesstatic classCart.VisibilityVisibility of a Cart
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger_loggerprivate static StringAUTHORprivate static StringCONTENT_CART_ELEMENTSprivate static StringDESCRIPTIONprivate static StringGROUPSprivate static StringPROFILE_READ_ACCESSprivate static StringPROFILE_WRITE_ACCESSprivate static StringQUERIES_CART_ELEMENTSprivate static StringQUERY_AUTHOR_PROPERTYprivate static StringQUERY_DATE_PROPERTYprivate static StringQUERY_DESCRIPTION_PROPERTYprivate static StringQUERY_ID_PROPERTYprivate static StringQUERY_TITLE_PROPERTYprivate static StringRESOURCE_CART_ELEMENTSprivate static StringTITLEprivate static StringUSERSprivate static StringVISIBILITY-
Fields inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
PROTECTED_PROPERTIES
-
-
Constructor Summary
Constructors Constructor Description Cart(Node node, String parentPath, CartFactory factory)Creates anCart.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Node_getOrCreateNode(Node parent, String name, String type)private Node_getOrCreateQueriesNode()protected void_removeContent(String contentIdToRemove)Remove a content from the cartprotected void_removeQuery(String queryIdToRemove)Remove a query from the cartprotected void_removeResource(String resourceIdToRemove)Remove a resource from the cartvoidaddContent(String contentId)Add a content to the cartvoidaddQuery(UserIdentity author, String title, String description)Add a query to the cartvoidaddResource(String resourceId)Add a resource to the cartbooleancanRead(UserIdentity user)Determines if an user has READ access to this cart.booleancanWrite(UserIdentity user)Determines if an user has WRITE access to this cart.UserIdentitygetAuthor()Get the author of the cartList<ContentElement>getContentCartElements()Get the contents of the cartStringgetDescription()Get the description of the cartList<CartElement>getElements()Get the elements of the cartSet<GroupIdentity>getGrantedGroups(Cart.CartProfile profile)Get the granted groupsSet<UserIdentity>getGrantedUsers(Cart.CartProfile profile)Get the granted usersList<QueryElement>getQueryCartElements()Get the queries of the cartList<ResourceElement>getResourceCartElements()Get the resources of the cartStringgetTitle()Get the title of the cartCart.VisibilitygetVisibility()Get the visibility of the cartvoidremoveElement(String elmtId, Cart.CartElementType elmtType)Delete an elementvoidsetAuthor(UserIdentity author)Set the author of this cart.voidsetDescription(String description)Set the description of this cart.voidsetGrantedGroups(Cart.CartProfile profile, Set<GroupIdentity> groups)Set the granted groupsvoidsetGrantedUsers(Cart.CartProfile profile, Set<UserIdentity> users)Set the granted usersvoidsetTitle(String title)Set the title of this cart.voidsetVisibility(Cart.Visibility visibility)Set the cart visibility-
Methods inherited from class org.ametys.plugins.repository.jcr.DefaultAmetysObject
addAllowedGroups, addAllowedProfilesForAnonymous, addAllowedProfilesForAnyConnectedUser, addAllowedUsers, addDeniedGroups, addDeniedProfilesForAnonymous, addDeniedProfilesForAnyConnectedUser, addDeniedUsers, addLabel, checkpoint, copyNode, disallowInheritance, getAllLabels, getAllRevisions, getBaseNode, getBaseVersion, getLabels, getLabels, getNode, getProfilesForAnonymousAndAnyConnectedUser, getProfilesForGroups, getProfilesForUsers, getRevision, getRevisionTimestamp, getRevisionTimestamp, getUnversionedDataHolder, getVersionHistory, isInheritanceDisallowed, removeAllowedGroups, removeAllowedGroups, removeAllowedProfilesForAnonymous, removeAllowedProfilesForAnyConnectedUser, removeAllowedUsers, removeAllowedUsers, removeDeniedGroups, removeDeniedGroups, removeDeniedProfilesForAnonymous, removeDeniedProfilesForAnyConnectedUser, removeDeniedUsers, removeDeniedUsers, removeLabel, restoreFromLabel, restoreFromNode, restoreFromRevision, switchToLabel, switchToRevision
-
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getMetadataHolder, getName, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
-
Methods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCode
-
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
-
-
-
-
Field Detail
-
TITLE
private static final String TITLE
- See Also:
- Constant Field Values
-
DESCRIPTION
private static final String DESCRIPTION
- See Also:
- Constant Field Values
-
AUTHOR
private static final String AUTHOR
- See Also:
- Constant Field Values
-
VISIBILITY
private static final String VISIBILITY
- See Also:
- Constant Field Values
-
PROFILE_READ_ACCESS
private static final String PROFILE_READ_ACCESS
- See Also:
- Constant Field Values
-
PROFILE_WRITE_ACCESS
private static final String PROFILE_WRITE_ACCESS
- See Also:
- Constant Field Values
-
GROUPS
private static final String GROUPS
- See Also:
- Constant Field Values
-
USERS
private static final String USERS
- See Also:
- Constant Field Values
-
CONTENT_CART_ELEMENTS
private static final String CONTENT_CART_ELEMENTS
- See Also:
- Constant Field Values
-
RESOURCE_CART_ELEMENTS
private static final String RESOURCE_CART_ELEMENTS
- See Also:
- Constant Field Values
-
QUERIES_CART_ELEMENTS
private static final String QUERIES_CART_ELEMENTS
- See Also:
- Constant Field Values
-
QUERY_ID_PROPERTY
private static final String QUERY_ID_PROPERTY
- See Also:
- Constant Field Values
-
QUERY_DESCRIPTION_PROPERTY
private static final String QUERY_DESCRIPTION_PROPERTY
- See Also:
- Constant Field Values
-
QUERY_AUTHOR_PROPERTY
private static final String QUERY_AUTHOR_PROPERTY
- See Also:
- Constant Field Values
-
QUERY_TITLE_PROPERTY
private static final String QUERY_TITLE_PROPERTY
- See Also:
- Constant Field Values
-
QUERY_DATE_PROPERTY
private static final String QUERY_DATE_PROPERTY
- See Also:
- Constant Field Values
-
_logger
private static org.slf4j.Logger _logger
-
-
Constructor Detail
-
Cart
public Cart(Node node, String parentPath, CartFactory factory)
Creates anCart.- Parameters:
node- the node backing thisAmetysObjectparentPath- the parentPath in the Ametys hierarchyfactory- the DefaultAmetysObjectFactory which created the AmetysObject
-
-
Method Detail
-
setTitle
public void setTitle(String title)
Set the title of this cart.- Parameters:
title- the description
-
setDescription
public void setDescription(String description)
Set the description of this cart.- Parameters:
description- the description
-
setAuthor
public void setAuthor(UserIdentity author)
Set the author of this cart.- Parameters:
author- the author
-
setVisibility
public void setVisibility(Cart.Visibility visibility)
Set the cart visibility- Parameters:
visibility- the visibility
-
getDescription
public String getDescription()
Get the description of the cart- Returns:
- The description
-
getAuthor
public UserIdentity getAuthor()
Get the author of the cart- Returns:
- The author
-
getVisibility
public Cart.Visibility getVisibility()
Get the visibility of the cart- Returns:
- The visibility
-
getGrantedUsers
public Set<UserIdentity> getGrantedUsers(Cart.CartProfile profile)
Get the granted users- Parameters:
profile- the cart's profile- Returns:
- the granted users
-
getGrantedGroups
public Set<GroupIdentity> getGrantedGroups(Cart.CartProfile profile)
Get the granted groups- Parameters:
profile- the cart's profile- Returns:
- the logins of granted groups
-
canRead
public boolean canRead(UserIdentity user)
Determines if an user has READ access to this cart.- Parameters:
user- The user- Returns:
trueif the user has read access,falseotherwise
-
canWrite
public boolean canWrite(UserIdentity user)
Determines if an user has WRITE access to this cart.- Parameters:
user- The user- Returns:
trueif the user has write access,falseotherwise
-
setGrantedUsers
public void setGrantedUsers(Cart.CartProfile profile, Set<UserIdentity> users)
Set the granted users- Parameters:
profile- the cart's profileusers- the granted users
-
setGrantedGroups
public void setGrantedGroups(Cart.CartProfile profile, Set<GroupIdentity> groups)
Set the granted groups- Parameters:
profile- the cart's profilegroups- the granted groups
-
addContent
public void addContent(String contentId)
Add a content to the cart- Parameters:
contentId- The content id
-
addResource
public void addResource(String resourceId)
Add a resource to the cart- Parameters:
resourceId- The resource id
-
addQuery
public void addQuery(UserIdentity author, String title, String description)
Add a query to the cart- Parameters:
author- The author of the querytitle- The title of the querydescription- The query as string
-
_getOrCreateQueriesNode
private Node _getOrCreateQueriesNode() throws RepositoryException
- Throws:
RepositoryException
-
removeElement
public void removeElement(String elmtId, Cart.CartElementType elmtType)
Delete an element- Parameters:
elmtId- The id of element to removeelmtType- The type of element to remove
-
_removeResource
protected void _removeResource(String resourceIdToRemove)
Remove a resource from the cart- Parameters:
resourceIdToRemove- The id of the resource to remove
-
_removeContent
protected void _removeContent(String contentIdToRemove)
Remove a content from the cart- Parameters:
contentIdToRemove- The id of the content to remove
-
_removeQuery
protected void _removeQuery(String queryIdToRemove)
Remove a query from the cart- Parameters:
queryIdToRemove- The id of the query to remove
-
getElements
public List<CartElement> getElements()
Get the elements of the cart- Returns:
- The elements of the cart
-
getContentCartElements
public List<ContentElement> getContentCartElements() throws RepositoryException
Get the contents of the cart- Returns:
- The elements of the cart
- Throws:
RepositoryException- if an exception occurs while exploring the repository
-
getResourceCartElements
public List<ResourceElement> getResourceCartElements() throws RepositoryException
Get the resources of the cart- Returns:
- The elements of the cart
- Throws:
RepositoryException- if an exception occurs while exploring the repository
-
getQueryCartElements
public List<QueryElement> getQueryCartElements() throws RepositoryException
Get the queries of the cart- Returns:
- The elements of the cart
- Throws:
RepositoryException- if an exception occurs while exploring the repository
-
_getOrCreateNode
private Node _getOrCreateNode(Node parent, String name, String type) throws RepositoryException
- Throws:
RepositoryException
-
-