Class JCREventHelper
- java.lang.Object
-
- org.ametys.plugins.repository.events.JCREventHelper
-
- All Implemented Interfaces:
Component
public final class JCREventHelper extends Object implements Component
Helper for implementingEventHolder
in JCR.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__EVENT_HOLDER_NODE_NAME
private static String
__EVENT_NAME_PREFIX
private static String
__NODETYPE_EVENT
private static String
__NODETYPE_EVENT_ELEMENT
-
Constructor Summary
Constructors Modifier Constructor Description private
JCREventHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static String[]
_getHashedPath(String name)
Computes a hashed path in the JCR tree from the name of the child object.
Subclasses may override this method to provide a more suitable hash function.
This implementation relies on the buzhash algorithm.static Node
addEventNode(EventHolder eventHolder, Date eventDate, String eventType, UserIdentity author)
Add an event nodestatic NodeIterator
getEvents(EventHolder eventHolder)
Returns the event child nodesstatic NodeIterator
getEvents(EventHolder eventHolder, String[] types)
Returns the events sorted by ascending datestatic Node
getEventsRootNode(Node node)
Get the node holding the JCR events under the given nodestatic String
getEventXPathQuery(EventHolder eventHolder, Expression eventExpression, SortCriteria sortCriteria)
Creates the XPath query corresponding to specifiedExpression
.
-
-
-
Field Detail
-
__EVENT_HOLDER_NODE_NAME
private static final String __EVENT_HOLDER_NODE_NAME
- See Also:
- Constant Field Values
-
__NODETYPE_EVENT
private static final String __NODETYPE_EVENT
- See Also:
- Constant Field Values
-
__NODETYPE_EVENT_ELEMENT
private static final String __NODETYPE_EVENT_ELEMENT
- See Also:
- Constant Field Values
-
__EVENT_NAME_PREFIX
private static final String __EVENT_NAME_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JCREventHelper
private JCREventHelper()
-
-
Method Detail
-
getEventsRootNode
public static Node getEventsRootNode(Node node) throws RepositoryException
Get the node holding the JCR events under the given node- Parameters:
node
- The parent node- Returns:
- the events' root node
- Throws:
RepositoryException
- if an error occurred
-
getEvents
public static NodeIterator getEvents(EventHolder eventHolder) throws RepositoryException
Returns the event child nodes- Parameters:
eventHolder
- The event holder- Returns:
- The event child nodes
- Throws:
RepositoryException
- if an error occurred
-
getEvents
public static NodeIterator getEvents(EventHolder eventHolder, String[] types) throws RepositoryException
Returns the events sorted by ascending date- Parameters:
eventHolder
- The event holdertypes
- The types of events to return. Can benull
to get all events- Returns:
- The event child nodes
- Throws:
RepositoryException
- if an error occurred
-
getEventXPathQuery
public static String getEventXPathQuery(EventHolder eventHolder, Expression eventExpression, SortCriteria sortCriteria) throws RepositoryException
Creates the XPath query corresponding to specifiedExpression
.- Parameters:
eventHolder
- the event holdereventExpression
- the query predicates.sortCriteria
- the sort criteria.- Returns:
- the created XPath query.
- Throws:
RepositoryException
- if an error occurred
-
addEventNode
public static Node addEventNode(EventHolder eventHolder, Date eventDate, String eventType, UserIdentity author) throws RepositoryException
Add an event node- Parameters:
eventHolder
- The event holdereventDate
- The event's dateeventType
- The event's typeauthor
- The event's author- Returns:
- The created event node
- Throws:
RepositoryException
- if an error occurred
-
_getHashedPath
private static String[] _getHashedPath(String name)
Computes a hashed path in the JCR tree from the name of the child object.
Subclasses may override this method to provide a more suitable hash function.
This implementation relies on the buzhash algorithm. This method MUST return an array of the same length for each name.- Parameters:
name
- the name of the child object- Returns:
- a hashed path of the name.
-
-