Package org.ametys.cms.workflow
Class WorkflowTasksComponent
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.workflow.WorkflowTasksComponent
- All Implemented Interfaces:
Component
,Configurable
,LogEnabled
,Serviceable
,ThreadSafe
- Direct Known Subclasses:
AbstractOdfWorkflowTasksComponent
,WorkflowTasksComponent
public class WorkflowTasksComponent
extends AbstractLogEnabled
implements Component, ThreadSafe, Configurable, Serviceable
Component for saxing tasks specific to an user.
The algorithm is the following :
The algorithm is the following :
- First, we get all granted sites for the user with the right manager.
- If there is at least one site allowed, we get all workflows associated with the granted sites.
- Then for each step of each task from the configuration, we get all workflows where this step is in current steps and where the workflow is contains in the previous list.
- For each workflow matching the previous conditions we test if the user has all the rights associated with the step (from the configuration) and then we get the content from this workflow.
- Finally, for each content, we sax its first page in order to access it directly from an URL.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Compares two contents on the last modified date.class
Class representing a task.class
Class representing a task step. -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Allow user querying ?protected ContentHelper
The content helperprotected ContentTypesHelper
Helper for content typesprotected ContentTypeExtensionPoint
The content type extension point.protected LanguagesManager
The languages managerprotected AmetysObjectResolver
The ametys object resolver.protected RightManager
The rights manager.protected Map<String,
WorkflowTasksComponent.Task> The configured task map, indexed by id.protected UserManager
The users manager.protected WorkflowProvider
TheWorkflowProvider
static final String
The avalon role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_configureAdditional
(WorkflowTasksComponent.Task task, Configuration taskConf) Configure additional configurationprotected void
_configureStep
(WorkflowTasksComponent.Task task, Configuration taskConf) Configure the steps._configureStepIds
(Configuration stepConf) Configure the step IDs.protected Map<String,
WorkflowTasksComponent.Task> _configureTasks
(Configuration tasksConf) Configure the tasks.protected AmetysObjectIterable<Content>
_getContents
(WorkflowTasksComponent.TaskStep step, User user) Get the contents for a step.protected List<Expression>
Get the AND expressions to request on contentsprotected Map<WorkflowTasksComponent.Task,
Collection<Content>> Get the workflows for a user.protected Collection<Content>
_getTaskContents
(User user, WorkflowTasksComponent.Task task) Get a task's contents.protected Collection<Content>
_getTaskContents
(User user, WorkflowTasksComponent.Task task, int limit) Get a task's contents.protected void
_saxAdditionalAttributes
(Content content, WorkflowTasksComponent.Task task, AttributesImpl attrs) SAX additional attributesprotected void
SAX additional attributesprotected void
_saxAdditionalData
(ContentHandler ch, Content content, WorkflowTasksComponent.Task task) SAX additional dataprotected void
_saxContent
(ContentHandler ch, Content content, WorkflowTasksComponent.Task task) SAX a content.protected void
_saxContentCurrentState
(ContentHandler ch, WorkflowAwareContent content) SAX workflow current step of aContent
protected void
_saxTask
(ContentHandler ch, WorkflowTasksComponent.Task task, Collection<Content> contents) SAX a taskprotected boolean
_testContent
(Content content, UserIdentity user, Set<String> rights) Test if the content is valid.boolean
Allow user query ?void
configure
(Configuration configuration) Configure the tasks and steps handled by this component.
Need the following configuration:
<tasks>
<task label="i18n-label">
<step id="3" rights="proposal,validation">
<step id="4" rights="validation">
...
</task>
...
</tasks>getContents
(User user, String taskId, int limit) Get the list of contents for a given user and task.getTasks()
Get the list of tasks managed by this component.void
service
(ServiceManager manager) void
toSAX
(ContentHandler ch, User user) SAX the contents for given uservoid
toSAX
(ContentHandler ch, User user, String taskId) SAX the contents for given user and taskMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
The avalon role. -
_objectResolver
The ametys object resolver. -
_rightManager
The rights manager. -
_userManager
The users manager. -
_cTypeEP
The content type extension point. -
_contentTypesHelper
Helper for content types -
_workflowProvider
TheWorkflowProvider
-
_contentHelper
The content helper -
_languagesManager
The languages manager -
_tasks
The configured task map, indexed by id. -
_allowUserQuery
Allow user querying ?
-
-
Constructor Details
-
WorkflowTasksComponent
public WorkflowTasksComponent()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
Configure the tasks and steps handled by this component.
Need the following configuration:
<tasks>
<task label="i18n-label">
<step id="3" rights="proposal,validation">
<step id="4" rights="validation">
...
</task>
...
</tasks>- Specified by:
configure
in interfaceConfigurable
- Parameters:
configuration
- The configuration as described above.- Throws:
ConfigurationException
- If the configuration is invalid.
-
allowUserQuery
Allow user query ?- Returns:
- true if allowed user querying, false otherwise.
-
toSAX
SAX the contents for given user- Parameters:
ch
- the content handler to SAX intouser
- the user- Throws:
SAXException
- If an error occurred
-
toSAX
SAX the contents for given user and task- Parameters:
ch
- the content handler to SAX intouser
- the usertaskId
- the task id- Throws:
SAXException
- If an error occurred
-
getTasks
Get the list of tasks managed by this component.- Returns:
- the task list.
-
getContents
public Collection<Content> getContents(User user, String taskId, int limit) throws AmetysRepositoryException Get the list of contents for a given user and task.- Parameters:
user
- the user.taskId
- the task ID.limit
- the maximum number of results, 0 for all.- Returns:
- the contents as an iterable collection of contents.
- Throws:
AmetysRepositoryException
- If an error occurred
-
_saxTask
protected void _saxTask(ContentHandler ch, WorkflowTasksComponent.Task task, Collection<Content> contents) throws SAXException SAX a task- Parameters:
ch
- the content handler to SAX intotask
- the task to SAXcontents
- the contents- Throws:
SAXException
- if an error occurred while SAXing
-
_saxAdditionalAttributes
protected void _saxAdditionalAttributes(WorkflowTasksComponent.Task task, AttributesImpl attrs) throws SAXException SAX additional attributes- Parameters:
task
- the taskattrs
- the attributes- Throws:
SAXException
- If an error occurred
-
_saxContent
protected void _saxContent(ContentHandler ch, Content content, WorkflowTasksComponent.Task task) throws SAXException, javax.jcr.RepositoryException SAX a content.- Parameters:
ch
- the content handler.content
- the content to sax.task
- the task- Throws:
SAXException
- If an error occurredjavax.jcr.RepositoryException
- If an error occurred
-
_saxAdditionalAttributes
protected void _saxAdditionalAttributes(Content content, WorkflowTasksComponent.Task task, AttributesImpl attrs) throws SAXException SAX additional attributes- Parameters:
content
- the contenttask
- the taskattrs
- the attributes- Throws:
SAXException
- If an error occurred
-
_saxAdditionalData
protected void _saxAdditionalData(ContentHandler ch, Content content, WorkflowTasksComponent.Task task) throws SAXException SAX additional data- Parameters:
ch
- the content handler.content
- the contenttask
- the task- Throws:
SAXException
- If an error occurred
-
_getCorrespondingWorkflows
protected Map<WorkflowTasksComponent.Task,Collection<Content>> _getCorrespondingWorkflows(User user) Get the workflows for a user.- Parameters:
user
- the user.- Returns:
- the list of contents for each task.
-
_getTaskContents
Get a task's contents.- Parameters:
user
- the user.task
- the task.- Returns:
- the content collection.
-
_getTaskContents
protected Collection<Content> _getTaskContents(User user, WorkflowTasksComponent.Task task, int limit) Get a task's contents.- Parameters:
user
- the user.task
- the task.limit
- the maximum number of contents (0 to return all).- Returns:
- the content collection.
-
_getContents
protected AmetysObjectIterable<Content> _getContents(WorkflowTasksComponent.TaskStep step, User user) Get the contents for a step.- Parameters:
step
- the step.user
- the user.- Returns:
- an iterable collection of contents.
-
_getContentsAndExpressions
protected List<Expression> _getContentsAndExpressions(WorkflowTasksComponent.TaskStep step, User user) Get the AND expressions to request on contents- Parameters:
step
- the step.user
- the user.- Returns:
- The content's expressions
-
_testContent
Test if the content is valid.- Parameters:
content
- the content to test.user
- the user.rights
- the rights to test.- Returns:
- true/false.
-
_configureTasks
protected Map<String,WorkflowTasksComponent.Task> _configureTasks(Configuration tasksConf) throws ConfigurationException Configure the tasks.- Parameters:
tasksConf
- the tasks root configuration.- Returns:
- the task list.
- Throws:
ConfigurationException
- if a configuration error occurs.
-
_configureStep
protected void _configureStep(WorkflowTasksComponent.Task task, Configuration taskConf) throws ConfigurationException Configure the steps.- Parameters:
task
- the current tasktaskConf
- the task configuration.- Throws:
ConfigurationException
- if a configuration error occurs.
-
_configureAdditional
protected void _configureAdditional(WorkflowTasksComponent.Task task, Configuration taskConf) throws ConfigurationException Configure additional configuration- Parameters:
task
- task the current tasktaskConf
- the task configuration.- Throws:
ConfigurationException
- if a configuration error occurs.
-
_configureStepIds
Configure the step IDs.- Parameters:
stepConf
- the step configuration.- Returns:
- the step IDs as a Set of Integer.
- Throws:
ConfigurationException
- If an error occurred
-
_saxContentCurrentState
protected void _saxContentCurrentState(ContentHandler ch, WorkflowAwareContent content) throws SAXException, javax.jcr.RepositoryException SAX workflow current step of aContent
- Parameters:
ch
- the content handler.content
- The content- Throws:
SAXException
- if an error occurs while SAXingjavax.jcr.RepositoryException
- if an error occurs while retrieving current step
-