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 :- 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
Nested Classes Modifier and Type Class Description class
WorkflowTasksComponent.LastModifiedDateComparator
Compares two contents on the last modified date.class
WorkflowTasksComponent.Task
Class representing a task.class
WorkflowTasksComponent.TaskStep
Class representing a task step.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_allowUserQuery
Allow user querying ?protected ContentHelper
_contentHelper
The content helperprotected ContentTypesHelper
_contentTypesHelper
Helper for content typesprotected ContentTypeExtensionPoint
_cTypeEP
The content type extension point.protected LanguagesManager
_languagesManager
The languages managerprotected AmetysObjectResolver
_objectResolver
The ametys object resolver.protected RightManager
_rightManager
The rights manager.protected Map<String,WorkflowTasksComponent.Task>
_tasks
The configured task map, indexed by id.protected UserManager
_userManager
The users manager.protected WorkflowProvider
_workflowProvider
TheWorkflowProvider
static String
ROLE
The avalon role.
-
Constructor Summary
Constructors Constructor Description WorkflowTasksComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_configureAdditional(WorkflowTasksComponent.Task task, Configuration taskConf)
Configure additional configurationprotected void
_configureStep(WorkflowTasksComponent.Task task, Configuration taskConf)
Configure the steps.protected Set<Integer>
_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>
_getContentsAndExpressions(WorkflowTasksComponent.TaskStep step, User user)
Get the AND expressions to request on contentsprotected Map<WorkflowTasksComponent.Task,Collection<Content>>
_getCorrespondingWorkflows(User user)
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
_saxAdditionalAttributes(WorkflowTasksComponent.Task task, AttributesImpl attrs)
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
allowUserQuery()
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>Collection<Content>
getContents(User user, String taskId, int limit)
Get the list of contents for a given user and task.Map<String,WorkflowTasksComponent.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 task-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_objectResolver
protected AmetysObjectResolver _objectResolver
The ametys object resolver.
-
_rightManager
protected RightManager _rightManager
The rights manager.
-
_userManager
protected UserManager _userManager
The users manager.
-
_cTypeEP
protected ContentTypeExtensionPoint _cTypeEP
The content type extension point.
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
Helper for content types
-
_workflowProvider
protected WorkflowProvider _workflowProvider
TheWorkflowProvider
-
_contentHelper
protected ContentHelper _contentHelper
The content helper
-
_languagesManager
protected LanguagesManager _languagesManager
The languages manager
-
_tasks
protected Map<String,WorkflowTasksComponent.Task> _tasks
The configured task map, indexed by id.
-
_allowUserQuery
protected boolean _allowUserQuery
Allow user querying ?
-
-
Constructor Detail
-
WorkflowTasksComponent
public WorkflowTasksComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
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
public boolean allowUserQuery()
Allow user query ?- Returns:
- true if allowed user querying, false otherwise.
-
toSAX
public void toSAX(ContentHandler ch, User user) throws SAXException
SAX the contents for given user- Parameters:
ch
- the content handler to SAX intouser
- the user- Throws:
SAXException
- If an error occurred
-
toSAX
public void toSAX(ContentHandler ch, User user, String taskId) throws SAXException
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
public Map<String,WorkflowTasksComponent.Task> 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, RepositoryException
SAX a content.- Parameters:
ch
- the content handler.content
- the content to sax.task
- the task- Throws:
SAXException
- If an error occurredRepositoryException
- 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
protected Collection<Content> _getTaskContents(User user, WorkflowTasksComponent.Task task)
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
protected boolean _testContent(Content content, UserIdentity user, Set<String> rights)
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
protected Set<Integer> _configureStepIds(Configuration stepConf) throws ConfigurationException
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, RepositoryException
SAX workflow current step of aContent
- Parameters:
ch
- the content handler.content
- The content- Throws:
SAXException
- if an error occurs while SAXingRepositoryException
- if an error occurs while retrieving current step
-
-