org.opencms.workflow
Class CmsExtendedWorkflowManager

java.lang.Object
  extended by org.opencms.workflow.A_CmsWorkflowManager
      extended by org.opencms.workflow.CmsDefaultWorkflowManager
          extended by org.opencms.workflow.CmsExtendedWorkflowManager
All Implemented Interfaces:
I_CmsWorkflowManager

public class CmsExtendedWorkflowManager
extends CmsDefaultWorkflowManager

The default workflow manager implementation, which supports 2 basic actions, Release and Publish.


Field Summary
static java.lang.String ACTION_RELEASE
          The release workflow action.
static java.lang.String PARAM_NOTIFICATION_CONTENT
          The parameter which points to the XML content used for notifications.
static java.lang.String PARAM_WORKFLOW_PROJECT_MANAGER_GROUP
          The key for the configurable workflow project manager group.
static java.lang.String PARAM_WORKFLOW_PROJECT_USER_GROUP
          The key for the configurable workflow project user group.
static java.lang.String WORKFLOW_RELEASE
          The key for the 'release' workflow.
 
Fields inherited from class org.opencms.workflow.CmsDefaultWorkflowManager
ACTION_FORCE_PUBLISH, ACTION_PUBLISH, WORKFLOW_PUBLISH
 
Fields inherited from class org.opencms.workflow.A_CmsWorkflowManager
m_adminCms, m_parameters
 
Constructor Summary
CmsExtendedWorkflowManager()
           
 
Method Summary
protected  CmsWorkflowResponse actionRelease(CmsObject userCms, java.util.List<CmsResource> resources)
          Implementation of the 'release' workflow action.
protected  void checkNewParentsInList(CmsObject userCms, java.util.List<CmsResource> resources)
          Checks that the parent folders of new resources which are released are either not new or are also released.
protected  void cleanupEmptyWorkflowProjects(java.util.List<CmsProject> projects)
          Cleans up empty workflow projects.
protected  void cleanupProjectIfEmpty(CmsProject project)
          Removes a project if there are no longer any resources which have been last modified in that project.
protected  void clearLocks(CmsProject project, java.util.List<CmsResource> resources)
          Ensures that the resources to be released are unlocked.
 CmsWorkflowResponse executeAction(CmsObject userCms, CmsWorkflowAction action, CmsPublishOptions options, java.util.List<CmsResource> resources)
          Executes a workflow action in the context of the current user.
protected  boolean existsProject(java.lang.String projectName)
          Helper method to check whether a project exists.
protected  java.lang.String generateProjectDescription(CmsObject userCms)
          Generates the description for a new workflow project based on the user for whom it is created.
protected  java.lang.String generateProjectName(CmsObject userCms)
          Generates the name for a new workflow project based on the user for whom it is created.
protected  java.lang.String generateProjectName(CmsObject userCms, boolean shortTime)
          Generates the name for a new workflow project based on the user for whom it is created.
protected  java.util.List<CmsUser> getNotificationMailRecipients()
          Gets the list of recipients for the notifications.
protected  java.lang.String getNotificationResource()
          Gets the resource notification content path.
protected  CmsWorkflowResponse getPublishBrokenRelationsResponse(CmsObject userCms, java.util.List<CmsPublishResource> publishResources)
          Helper method for generating the workflow response which should be sent when publishing the resources would break relations.
protected  CmsWorkflowResponse getSuccessResponse()
          Gets the workflow response which should be sent when the resources have successfully been published.
 java.lang.String getWorkflowProjectManagerGroup()
          Gets the name of the group which should be used as the 'manager' group for newly created workflow projects.
 java.lang.String getWorkflowProjectUserGroup()
          Gets the name of the group which should be used as the 'user' group for newly created workflow projects.
 java.util.List<CmsPublishResource> getWorkflowPublishResources(CmsObject cms, CmsWorkflow workflow, CmsPublishOptions options)
          Returns the publish resource beans for the given workflow and project.
 java.util.List<CmsResource> getWorkflowResources(CmsObject cms, CmsWorkflow workflow, CmsPublishOptions options)
          Returns the resources for the given workflow and project.
 java.util.Map<java.lang.String,CmsWorkflow> getWorkflows(CmsObject cms)
          Returns the available workflows for the current user.
 void initialize(CmsObject adminCms)
          Initializes this workflow manager instance.
protected  boolean isProjectEmpty(CmsProject project)
          Checks whether there are resources which have last been modified in a given project.
protected  boolean isProjectManager(CmsObject userCms)
          Checks whether the user for a given CMS context can manage workflow projects.
protected  void onFinishPublishJob(CmsPublishJobRunning publishJob)
          Handles finished publish jobs by removing projects of resources in the publish job if they are empty workflow projects.
protected  void onStartPublishJob(CmsPublishJobEnqueued publishJob)
          This is called when a publish job is started.
protected  void sendNotification(CmsObject userCms, CmsUser recipient, CmsProject workflowProject, java.util.List<CmsResource> resources)
          Sends the notification for released resources.
 
Methods inherited from class org.opencms.workflow.CmsDefaultWorkflowManager
actionForcePublish, actionPublish, getLabel
 
Methods inherited from class org.opencms.workflow.A_CmsWorkflowManager
getLocale, getParameter, getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORKFLOW_RELEASE

public static final java.lang.String WORKFLOW_RELEASE
The key for the 'release' workflow.

See Also:
Constant Field Values

ACTION_RELEASE

public static final java.lang.String ACTION_RELEASE
The release workflow action.

See Also:
Constant Field Values

PARAM_WORKFLOW_PROJECT_MANAGER_GROUP

public static final java.lang.String PARAM_WORKFLOW_PROJECT_MANAGER_GROUP
The key for the configurable workflow project manager group.

See Also:
Constant Field Values

PARAM_NOTIFICATION_CONTENT

public static final java.lang.String PARAM_NOTIFICATION_CONTENT
The parameter which points to the XML content used for notifications.

See Also:
Constant Field Values

PARAM_WORKFLOW_PROJECT_USER_GROUP

public static final java.lang.String PARAM_WORKFLOW_PROJECT_USER_GROUP
The key for the configurable workflow project user group.

See Also:
Constant Field Values
Constructor Detail

CmsExtendedWorkflowManager

public CmsExtendedWorkflowManager()
Method Detail

executeAction

public CmsWorkflowResponse executeAction(CmsObject userCms,
                                         CmsWorkflowAction action,
                                         CmsPublishOptions options,
                                         java.util.List<CmsResource> resources)
                                  throws CmsException
Description copied from interface: I_CmsWorkflowManager
Executes a workflow action in the context of the current user.

Specified by:
executeAction in interface I_CmsWorkflowManager
Overrides:
executeAction in class CmsDefaultWorkflowManager
Parameters:
userCms - the current user's CMS context
action - the workflow action
options - the publish options
resources - the resources to be processed
Returns:
the workflow response for the executed action
Throws:
CmsException - if something goes wrong
See Also:
CmsDefaultWorkflowManager.executeAction(org.opencms.file.CmsObject, org.opencms.ade.publish.shared.CmsWorkflowAction, org.opencms.ade.publish.shared.CmsPublishOptions, java.util.List)

getWorkflowProjectManagerGroup

public java.lang.String getWorkflowProjectManagerGroup()
Gets the name of the group which should be used as the 'manager' group for newly created workflow projects.

Returns:
a group name

getWorkflowProjectUserGroup

public java.lang.String getWorkflowProjectUserGroup()
Gets the name of the group which should be used as the 'user' group for newly created workflow projects.

Returns:
a group name

getWorkflowPublishResources

public java.util.List<CmsPublishResource> getWorkflowPublishResources(CmsObject cms,
                                                                      CmsWorkflow workflow,
                                                                      CmsPublishOptions options)
Description copied from interface: I_CmsWorkflowManager
Returns the publish resource beans for the given workflow and project.

Specified by:
getWorkflowPublishResources in interface I_CmsWorkflowManager
Overrides:
getWorkflowPublishResources in class CmsDefaultWorkflowManager
Parameters:
cms - the user cms context
workflow - the workflow
options - the resource options
Returns:
the workflow publish resource beans
See Also:
CmsDefaultWorkflowManager.getWorkflowPublishResources(org.opencms.file.CmsObject, org.opencms.ade.publish.shared.CmsWorkflow, org.opencms.ade.publish.shared.CmsPublishOptions)

getWorkflowResources

public java.util.List<CmsResource> getWorkflowResources(CmsObject cms,
                                                        CmsWorkflow workflow,
                                                        CmsPublishOptions options)
Description copied from interface: I_CmsWorkflowManager
Returns the resources for the given workflow and project.

Specified by:
getWorkflowResources in interface I_CmsWorkflowManager
Overrides:
getWorkflowResources in class CmsDefaultWorkflowManager
Parameters:
cms - the user cms context
workflow - the workflow
options - the resource options
Returns:
the workflow resources
See Also:
CmsDefaultWorkflowManager.getWorkflowResources(org.opencms.file.CmsObject, org.opencms.ade.publish.shared.CmsWorkflow, org.opencms.ade.publish.shared.CmsPublishOptions)

getWorkflows

public java.util.Map<java.lang.String,CmsWorkflow> getWorkflows(CmsObject cms)
Description copied from interface: I_CmsWorkflowManager
Returns the available workflows for the current user.

Specified by:
getWorkflows in interface I_CmsWorkflowManager
Overrides:
getWorkflows in class CmsDefaultWorkflowManager
Parameters:
cms - the user cms context
Returns:
the available workflows
See Also:
I_CmsWorkflowManager.getWorkflows(org.opencms.file.CmsObject)

initialize

public void initialize(CmsObject adminCms)
Description copied from interface: I_CmsWorkflowManager
Initializes this workflow manager instance.

Specified by:
initialize in interface I_CmsWorkflowManager
Overrides:
initialize in class A_CmsWorkflowManager
Parameters:
adminCms - the CMS context with admin privileges
See Also:
A_CmsWorkflowManager.initialize(org.opencms.file.CmsObject)

actionRelease

protected CmsWorkflowResponse actionRelease(CmsObject userCms,
                                            java.util.List<CmsResource> resources)
                                     throws CmsException
Implementation of the 'release' workflow action.

Parameters:
userCms - the current user's CMS context
resources - the resources which should be released
Returns:
the workflow response for this action
Throws:
CmsException - if something goes wrong

checkNewParentsInList

protected void checkNewParentsInList(CmsObject userCms,
                                     java.util.List<CmsResource> resources)
                              throws CmsException
Checks that the parent folders of new resources which are released are either not new or are also released.

Parameters:
userCms - the user CMS context
resources - the resources to check
Throws:
CmsException - if the check fails

cleanupEmptyWorkflowProjects

protected void cleanupEmptyWorkflowProjects(java.util.List<CmsProject> projects)
                                     throws CmsException
Cleans up empty workflow projects.

Parameters:
projects - the workflow projects to clean up
Throws:
CmsException - if something goes wrong

cleanupProjectIfEmpty

protected void cleanupProjectIfEmpty(CmsProject project)
                              throws CmsException
Removes a project if there are no longer any resources which have been last modified in that project.

Parameters:
project - the project
Throws:
CmsException

clearLocks

protected void clearLocks(CmsProject project,
                          java.util.List<CmsResource> resources)
                   throws CmsException
Ensures that the resources to be released are unlocked.

Parameters:
project - the project in which to operate
resources - the resources for which the locks should be removed
Throws:
CmsException - if something goes wrong

existsProject

protected boolean existsProject(java.lang.String projectName)
Helper method to check whether a project exists.

Parameters:
projectName - the project name
Returns:
true if the project exists

generateProjectDescription

protected java.lang.String generateProjectDescription(CmsObject userCms)
Generates the description for a new workflow project based on the user for whom it is created.

Parameters:
userCms - the user's current CMS context
Returns:
the workflow project description

generateProjectName

protected java.lang.String generateProjectName(CmsObject userCms)
Generates the name for a new workflow project based on the user for whom it is created.

Parameters:
userCms - the user's current CMS context
Returns:
the workflow project name

generateProjectName

protected java.lang.String generateProjectName(CmsObject userCms,
                                               boolean shortTime)
Generates the name for a new workflow project based on the user for whom it is created.

Parameters:
userCms - the user's current CMS context
shortTime - if true, the short time format will be used, else the medium time format
Returns:
the workflow project name

getNotificationMailRecipients

protected java.util.List<CmsUser> getNotificationMailRecipients()
Gets the list of recipients for the notifications.

Returns:
the list of users which should be notified when resources are released

getNotificationResource

protected java.lang.String getNotificationResource()
Gets the resource notification content path.

Returns:
the resource notification content path

getPublishBrokenRelationsResponse

protected CmsWorkflowResponse getPublishBrokenRelationsResponse(CmsObject userCms,
                                                                java.util.List<CmsPublishResource> publishResources)
Helper method for generating the workflow response which should be sent when publishing the resources would break relations.

Parameters:
userCms - the user's CMS context
publishResources - the resources whose links would be broken
Returns:
the workflow response

getSuccessResponse

protected CmsWorkflowResponse getSuccessResponse()
Gets the workflow response which should be sent when the resources have successfully been published.

Returns:
the successful workflow response

isProjectEmpty

protected boolean isProjectEmpty(CmsProject project)
                          throws CmsException
Checks whether there are resources which have last been modified in a given project.

Parameters:
project - the project which should be checked
Returns:
true if there are no resources which have been last modified inside the project
Throws:
CmsException - if something goes wrong

isProjectManager

protected boolean isProjectManager(CmsObject userCms)
                            throws CmsException
Checks whether the user for a given CMS context can manage workflow projects.

Parameters:
userCms - the user CMS Context
Returns:
true if this user can manage workflow projects
Throws:
CmsException - if something goes wrong

onFinishPublishJob

protected void onFinishPublishJob(CmsPublishJobRunning publishJob)
Handles finished publish jobs by removing projects of resources in the publish job if they are empty workflow projects.

Parameters:
publishJob - the finished published job

onStartPublishJob

protected void onStartPublishJob(CmsPublishJobEnqueued publishJob)
This is called when a publish job is started.

Parameters:
publishJob - the publish job being started

sendNotification

protected void sendNotification(CmsObject userCms,
                                CmsUser recipient,
                                CmsProject workflowProject,
                                java.util.List<CmsResource> resources)
Sends the notification for released resources.

Parameters:
userCms - the user's CMS context
recipient - the OpenCms user to whom the notification should be sent
workflowProject - the workflow project which
resources - the resources which have been affected by a workflow action