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 class
Cart.CartElementType
Types of CartElementstatic class
Cart.CartProfile
Rights profilesstatic class
Cart.Visibility
Visibility of a Cart
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
_logger
private static String
AUTHOR
private static String
CONTENT_CART_ELEMENTS
private static String
DESCRIPTION
private static String
GROUPS
private static String
PROFILE_READ_ACCESS
private static String
PROFILE_WRITE_ACCESS
private static String
QUERIES_CART_ELEMENTS
private static String
QUERY_AUTHOR_PROPERTY
private static String
QUERY_DATE_PROPERTY
private static String
QUERY_DESCRIPTION_PROPERTY
private static String
QUERY_ID_PROPERTY
private static String
QUERY_TITLE_PROPERTY
private static String
RESOURCE_CART_ELEMENTS
private static String
TITLE
private static String
USERS
private static String
VISIBILITY
-
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 cartvoid
addContent(String contentId)
Add a content to the cartvoid
addQuery(UserIdentity author, String title, String description)
Add a query to the cartvoid
addResource(String resourceId)
Add a resource to the cartboolean
canRead(UserIdentity user)
Determines if an user has READ access to this cart.boolean
canWrite(UserIdentity user)
Determines if an user has WRITE access to this cart.UserIdentity
getAuthor()
Get the author of the cartList<ContentElement>
getContentCartElements()
Get the contents of the cartString
getDescription()
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 cartString
getTitle()
Get the title of the cartCart.Visibility
getVisibility()
Get the visibility of the cartvoid
removeElement(String elmtId, Cart.CartElementType elmtType)
Delete an elementvoid
setAuthor(UserIdentity author)
Set the author of this cart.void
setDescription(String description)
Set the description of this cart.void
setGrantedGroups(Cart.CartProfile profile, Set<GroupIdentity> groups)
Set the granted groupsvoid
setGrantedUsers(Cart.CartProfile profile, Set<UserIdentity> users)
Set the granted usersvoid
setTitle(String title)
Set the title of this cart.void
setVisibility(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, getAllowedGroups, getAllowedProfilesForAnonymous, getAllowedProfilesForAnyConnectedUser, getAllowedProfilesForGroups, getAllowedProfilesForUser, getAllowedProfilesForUsers, getAllowedUsers, getAllRevisions, getBaseNode, getBaseVersion, getDeniedGroups, getDeniedProfilesForAnonymous, getDeniedProfilesForAnyConnectedUser, getDeniedProfilesForGroups, getDeniedProfilesForUser, getDeniedProfilesForUsers, getDeniedUsers, getLabels, getLabels, getNode, 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 thisAmetysObject
parentPath
- 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:
true
if the user has read access,false
otherwise
-
canWrite
public boolean canWrite(UserIdentity user)
Determines if an user has WRITE access to this cart.- Parameters:
user
- The user- Returns:
true
if the user has write access,false
otherwise
-
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
-
-