Class DefaultCMSWorkflowFacade
- java.lang.Object
-
- de.hybris.platform.cmsfacades.workflow.impl.DefaultCMSWorkflowFacade
-
- All Implemented Interfaces:
CMSWorkflowFacade
public class DefaultCMSWorkflowFacade extends java.lang.Object implements CMSWorkflowFacade
Default implementation of theCMSWorkflowFacade.
-
-
Constructor Summary
Constructors Constructor Description DefaultCMSWorkflowFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCommentToAction(WorkflowActionModel action, CMSWorkflowCommentModel comment)Adds a comment to an action.protected CMSWorkflowDatacancelWorkflow(WorkflowModel workflow)Cancels the workflow for the providedWorkflowModel.CMSWorkflowDatacreateAndStartWorkflow(CMSWorkflowData requestData)Creates and starts a workflow in the given catalog version with the workflow data provided.protected WorkflowItemAttachmentModelcreateAttachment(WorkflowModel workflow, CMSItemModel cmsItem)Creates a new attachment from a given cmsItem and adds it to the given workflow.protected CMSWorkflowCommentModelcreateComment(WorkflowDecisionModel decision, CommentTypeModel commentType, ComponentModel component, java.lang.String subject, java.lang.String text)Creates a comment and assigns a decision to it.protected voidcreateDecisionComments(WorkflowDecisionModel decision, java.lang.String subject, java.lang.String text)Creates a comment and adds it to incoming and non-automated outgoing actions.protected voidcreateVersion(CMSItemModel cmsItem, java.lang.String versionLabel)This method creates a new version of the given cmsItem.protected voidcreateVersionsForItems(java.util.List<CMSItemModel> items, java.lang.String versionLabel)Creates versions for a list of items.protected WorkflowModelcreateWorkflow(CMSWorkflowData requestData)This method creates and saves a new workflow.protected WorkflowModeleditWorkflow(CMSWorkflowData requestData, WorkflowModel workflow)Updates theWorkflowModelwith the data fromCMSWorkflowData.CMSWorkflowDataeditWorkflow(java.lang.String workflowCode, CMSWorkflowData workflowData)Updates the workflow with the provided data.SearchResult<CMSWorkflowData>findAllWorkflows(CMSWorkflowData workflowData, PageableData pageableData)Finds all workflows containing the given attachment for the specified workflow statuses.protected WorkflowActionModelfindNextAction(WorkflowActionModel action)Finds the next non-automated outgoing workflow action where a comment should be added to.protected java.util.function.Predicate<WorkflowActionModel>getAutomatedWorkflowActionTypePredicate()protected CMSAdminItemServicegetCmsAdminItemService()protected CMSItemModelgetCMSItemByUid(java.lang.String uid)Returns anCMSItemModelfor a given uid.protected CMSItemModelgetCmsItemByUUID(java.lang.String cmsItemUuid)This method retrieves the cmsItem identified by the given uuid.protected CMSVersionServicegetCmsVersionService()protected Converter<WorkflowModel,CMSWorkflowData>getCmsWorkflowDataConverter()protected PersistentKeyGeneratorgetCommentsCodeGenerator()protected CommentServicegetCommentService()protected org.springframework.validation.ValidatorgetCreateWorkflowValidator()protected org.springframework.validation.ValidatorgetEditWorkflowValidator()protected FacadeValidationServicegetFacadeValidationService()protected org.springframework.validation.ValidatorgetFindWorkflowValidator()protected ModelServicegetModelService()protected AbstractPageTypePredicategetPageTypePredicate()protected PermissionCRUDServicegetPermissionCRUDService()protected java.util.List<PostWorkflowAction>getPostWorkflowActions()protected SearchResultConvertergetSearchResultConverter()protected CMSWorkflowEditableItemDatagetSessionUserEditableItemData(CMSItemModel itemModel, boolean editableByCurrentUser)GeneratesCMSWorkflowEditableItemDatafromCMSItemModeland editableByCurrentUser attribute.java.util.List<CMSWorkflowEditableItemData>getSessionUserEditableItems(java.util.List<java.lang.String> itemUids)Returns a list ofCMSWorkflowEditableItemDatathat informs whether each item is editable or not by the session user.protected org.springframework.transaction.PlatformTransactionManagergetTransactionManager()protected UniqueIdentifierAttributeToDataContentConverter<ItemModel>getUniqueIdentifierAttributeToDataContentConverter()protected UniqueItemIdentifierServicegetUniqueItemIdentifierService()protected UserServicegetUserService()protected CMSWorkflowActionServicegetWorkflowActionService()protected java.util.List<CMSItemModel>getWorkflowAttachments(WorkflowModel workflow)Returns a list of workflow attachments.CMSWorkflowDatagetWorkflowForCode(java.lang.String workflowCode)Returns the workflow by its code.protected WorkflowProcessingServicegetWorkflowProcessingService()protected CMSWorkflowServicegetWorkflowService()protected WorkflowTemplateServicegetWorkflowTemplateService()protected CMSWorkflowDatamakeDecision(WorkflowModel workflow, java.lang.String actionCode, java.lang.String decisionCode, java.lang.String comment)Makes decision for providedWorkflowModelCMSWorkflowDataperformOperation(java.lang.String workflowCode, CMSWorkflowOperationData data)Performs different operations defined byCMSWorkflowOperationon the workflow.protected voidprocessPostWorkflowActions(WorkflowModel workflow, CMSWorkflowOperationData data)Performs additional logic after the operation is successfully executed.voidsetAutomatedWorkflowActionTypePredicate(java.util.function.Predicate<WorkflowActionModel> automatedWorkflowActionTypePredicate)voidsetCmsAdminItemService(CMSAdminItemService cmsAdminItemService)voidsetCmsVersionService(CMSVersionService cmsVersionService)voidsetCmsWorkflowDataConverter(Converter<WorkflowModel,CMSWorkflowData> cmsWorkflowDataConverter)voidsetCommentsCodeGenerator(PersistentKeyGenerator commentsCodeGenerator)voidsetCommentService(CommentService commentService)voidsetCreateWorkflowValidator(org.springframework.validation.Validator createWorkflowValidator)voidsetEditWorkflowValidator(org.springframework.validation.Validator editWorkflowValidator)voidsetFacadeValidationService(FacadeValidationService facadeValidationService)voidsetFindWorkflowValidator(org.springframework.validation.Validator findWorkflowValidator)voidsetModelService(ModelService modelService)voidsetPageTypePredicate(AbstractPageTypePredicate pageTypePredicate)voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService)voidsetPostWorkflowActions(java.util.List<PostWorkflowAction> postWorkflowActions)voidsetSearchResultConverter(SearchResultConverter searchResultConverter)voidsetTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)voidsetUniqueIdentifierAttributeToDataContentConverter(UniqueIdentifierAttributeToDataContentConverter<ItemModel> uniqueIdentifierAttributeToDataContentConverter)voidsetUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)voidsetUserService(UserService userService)voidsetWorkflowActionService(CMSWorkflowActionService workflowActionService)voidsetWorkflowProcessingService(WorkflowProcessingService workflowProcessingService)voidsetWorkflowService(CMSWorkflowService workflowService)voidsetWorkflowTemplateService(WorkflowTemplateService workflowTemplateService)protected voidthrowAttributePermissionException(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier)This method creates and throws a newAttributePermissionException.protected voidthrowTypePermissionException(java.lang.String permissionName, java.lang.String typeCode)This method creates and throws a newTypePermissionException.protected voidupdatePageApprovalStatus(java.util.List<CMSItemModel> items)Updates the approval status of the page attachments to CHECK.protected voidvalidateAttributePermission(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier, java.util.function.BiPredicate<java.lang.String,java.lang.String> permissionCheck)Validates that the current principal has the permission to execute an operation on the given attribute.protected voidvalidateTypePermission(java.lang.String permissionName, java.lang.String typeCode, java.util.function.Predicate<java.lang.String> permissionCheck)Validates that the current principal has the permission to execute an operation on the given type.
-
-
-
Method Detail
-
createAndStartWorkflow
public CMSWorkflowData createAndStartWorkflow(CMSWorkflowData requestData)
Description copied from interface:CMSWorkflowFacadeCreates and starts a workflow in the given catalog version with the workflow data provided.- Specified by:
createAndStartWorkflowin interfaceCMSWorkflowFacade- Parameters:
requestData- - the data used to create the workflow.- Returns:
- The data of the newly created and started workflow
-
editWorkflow
public CMSWorkflowData editWorkflow(java.lang.String workflowCode, CMSWorkflowData workflowData)
Description copied from interface:CMSWorkflowFacadeUpdates the workflow with the provided data.- Specified by:
editWorkflowin interfaceCMSWorkflowFacade- Parameters:
workflowCode- - the code corresponding to theWorkflowModelworkflowData- - the workflow dto to be updated.- Returns:
- the updated workflow data.
-
getWorkflowForCode
public CMSWorkflowData getWorkflowForCode(java.lang.String workflowCode)
Description copied from interface:CMSWorkflowFacadeReturns the workflow by its code.- Specified by:
getWorkflowForCodein interfaceCMSWorkflowFacade- Parameters:
workflowCode- - the workflow code- Returns:
- the workflow data
-
editWorkflow
protected WorkflowModel editWorkflow(CMSWorkflowData requestData, WorkflowModel workflow)
Updates theWorkflowModelwith the data fromCMSWorkflowData.- Parameters:
requestData- - the object that contains the data about the new workflow to create.workflow- - the workflow which needs to be updated.- Returns:
- the updated
WorkflowModel.
-
performOperation
public CMSWorkflowData performOperation(java.lang.String workflowCode, CMSWorkflowOperationData data)
Description copied from interface:CMSWorkflowFacadePerforms different operations defined byCMSWorkflowOperationon the workflow.- Specified by:
performOperationin interfaceCMSWorkflowFacade- Parameters:
workflowCode- - the code corresponding to theWorkflowModeldata- - the DTO object containing all the information about operation to be performed- Returns:
- The data of the modified workflow.
-
processPostWorkflowActions
protected void processPostWorkflowActions(WorkflowModel workflow, CMSWorkflowOperationData data)
Performs additional logic after the operation is successfully executed.- Parameters:
workflow- the workflow for which extra operation will be executeddata- the DTO containing the information about the operation that was just performed successfully
-
cancelWorkflow
protected CMSWorkflowData cancelWorkflow(WorkflowModel workflow)
Cancels the workflow for the providedWorkflowModel.- Parameters:
workflow- - theWorkflowModel- Returns:
- The data of the cancelled workflow
-
makeDecision
protected CMSWorkflowData makeDecision(WorkflowModel workflow, java.lang.String actionCode, java.lang.String decisionCode, java.lang.String comment)
Makes decision for providedWorkflowModel- Parameters:
workflow- - theWorkflowModelactionCode- - the action codedecisionCode- - the decision code- Returns:
- The data of the changed workflow
-
createDecisionComments
protected void createDecisionComments(WorkflowDecisionModel decision, java.lang.String subject, java.lang.String text)
Creates a comment and adds it to incoming and non-automated outgoing actions. The comment itself has a reference to the outgoing action.- Parameters:
decision- - theWorkflowDecisionModelsubject- - the subject of the commenttext- - the text of the comment
-
findNextAction
protected WorkflowActionModel findNextAction(WorkflowActionModel action)
Finds the next non-automated outgoing workflow action where a comment should be added to.- Parameters:
action- the action just being completed- Returns:
- the next action to be activated
-
addCommentToAction
protected void addCommentToAction(WorkflowActionModel action, CMSWorkflowCommentModel comment)
Adds a comment to an action.- Parameters:
action- - theWorkflowActionModelcomment- - theCMSWorkflowCommentModel
-
createComment
protected CMSWorkflowCommentModel createComment(WorkflowDecisionModel decision, CommentTypeModel commentType, ComponentModel component, java.lang.String subject, java.lang.String text)
Creates a comment and assigns a decision to it.- Parameters:
decision- - theWorkflowDecisionModelto assigncommentType- - theCommentTypeModelcomponent- - theComponentModelsubject- - the subject of the commenttext- - the text of the comment- Returns:
- the
CMSWorkflowCommentModel
-
validateTypePermission
protected void validateTypePermission(java.lang.String permissionName, java.lang.String typeCode, java.util.function.Predicate<java.lang.String> permissionCheck)Validates that the current principal has the permission to execute an operation on the given type.- Parameters:
permissionName- - The name of the permission to check.typeCode- - The code of the type for which to check the principal permission.permissionCheck- - Predicate to execute the permission check.- Throws:
TypePermissionException- if the user does not have the expected permission on the given type.
-
validateAttributePermission
protected void validateAttributePermission(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier, java.util.function.BiPredicate<java.lang.String,java.lang.String> permissionCheck)Validates that the current principal has the permission to execute an operation on the given attribute.- Parameters:
permissionName- - The name of the permission to check.typeCode- - The code of the type for which to check the principal permission.qualifier- - The qualifier of the attribute.permissionCheck- - Predicate to execute the permission check.- Throws:
TypePermissionException- if the user does not have the expected permission on the given attribute.
-
throwTypePermissionException
protected void throwTypePermissionException(java.lang.String permissionName, java.lang.String typeCode)This method creates and throws a newTypePermissionException.- Parameters:
permissionName- - the name of the permission that triggered the exception.typeCode- - the type for which the principal does not have permission and that triggered the exception.
-
throwAttributePermissionException
protected void throwAttributePermissionException(java.lang.String permissionName, java.lang.String typeCode, java.lang.String qualifier)This method creates and throws a newAttributePermissionException.- Parameters:
permissionName- - the name of the permission that triggered the exception.typeCode- - the type for which the principal does not have permission and that triggered the exception.
-
createWorkflow
protected WorkflowModel createWorkflow(CMSWorkflowData requestData)
This method creates and saves a new workflow. If the given request data has the createVersion flag enabled, this method will also create a new version for each of the attached items.- Parameters:
requestData- - the object that contains the data about the new workflow to create.- Returns:
- the newly created
WorkflowModel.
-
createVersionsForItems
protected void createVersionsForItems(java.util.List<CMSItemModel> items, java.lang.String versionLabel)
Creates versions for a list of items.- Parameters:
items- - the list ofCMSItemModelversionLabel- - the version label
-
updatePageApprovalStatus
protected void updatePageApprovalStatus(java.util.List<CMSItemModel> items)
Updates the approval status of the page attachments to CHECK.- Parameters:
items- - the list ofCMSItemModel
-
getCmsItemByUUID
protected CMSItemModel getCmsItemByUUID(java.lang.String cmsItemUuid)
This method retrieves the cmsItem identified by the given uuid.- Parameters:
cmsItemUuid- - The uuid uniquely identifying the cmsItem to retrieve.- Returns:
- the
CMSItemModelfound.
-
createVersion
protected void createVersion(CMSItemModel cmsItem, java.lang.String versionLabel)
This method creates a new version of the given cmsItem.- Parameters:
cmsItem- - The cmsItem for which to create a new version.versionLabel- - The label used to identify the new version to create.
-
createAttachment
protected WorkflowItemAttachmentModel createAttachment(WorkflowModel workflow, CMSItemModel cmsItem)
Creates a new attachment from a given cmsItem and adds it to the given workflow.- Parameters:
workflow- - the workflow to which the new attachment will be added.cmsItem- - the CmsItem for which to create the new attachment.- Returns:
- the newly created
WorkflowItemAttachmentModel.
-
findAllWorkflows
public SearchResult<CMSWorkflowData> findAllWorkflows(CMSWorkflowData workflowData, PageableData pageableData)
Description copied from interface:CMSWorkflowFacadeFinds all workflows containing the given attachment for the specified workflow statuses.- Specified by:
findAllWorkflowsin interfaceCMSWorkflowFacade- Parameters:
workflowData- - the workflow dto containing the attachment uuid and the workflow statuses that will be used to filter the result set.pageableData- - the pageable dto determining the page size and index.- Returns:
- the paginated result of workflow data
-
getWorkflowAttachments
protected java.util.List<CMSItemModel> getWorkflowAttachments(WorkflowModel workflow)
Returns a list of workflow attachments. Filters out non CMSItemModel items.- Parameters:
workflow- theWorkflowModel- Returns:
- the list of
CMSItemModelattachments.
-
getSessionUserEditableItems
public java.util.List<CMSWorkflowEditableItemData> getSessionUserEditableItems(java.util.List<java.lang.String> itemUids)
Description copied from interface:CMSWorkflowFacadeReturns a list ofCMSWorkflowEditableItemDatathat informs whether each item is editable or not by the session user.- Specified by:
getSessionUserEditableItemsin interfaceCMSWorkflowFacade- Parameters:
itemUids- the list of item uids to verify.- Returns:
- the list of
CMSWorkflowEditableItemData
-
getSessionUserEditableItemData
protected CMSWorkflowEditableItemData getSessionUserEditableItemData(CMSItemModel itemModel, boolean editableByCurrentUser)
GeneratesCMSWorkflowEditableItemDatafromCMSItemModeland editableByCurrentUser attribute.- Parameters:
itemModel- theCMSItemModeleditableByCurrentUser- the attribute tells whether the item is editable or not- Returns:
- the
CMSWorkflowEditableItemData
-
getCMSItemByUid
protected CMSItemModel getCMSItemByUid(java.lang.String uid)
Returns anCMSItemModelfor a given uid.- Parameters:
uid- the uid of anCMSItemModel- Returns:
- the
CMSItemModel - Throws:
UnknownIdentifierException- if an item model cannot be found for the provided uid.
-
getCreateWorkflowValidator
protected org.springframework.validation.Validator getCreateWorkflowValidator()
-
setCreateWorkflowValidator
public void setCreateWorkflowValidator(org.springframework.validation.Validator createWorkflowValidator)
-
getFindWorkflowValidator
protected org.springframework.validation.Validator getFindWorkflowValidator()
-
setFindWorkflowValidator
public void setFindWorkflowValidator(org.springframework.validation.Validator findWorkflowValidator)
-
getTransactionManager
protected org.springframework.transaction.PlatformTransactionManager getTransactionManager()
-
setTransactionManager
public void setTransactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager)
-
getFacadeValidationService
protected FacadeValidationService getFacadeValidationService()
-
setFacadeValidationService
public void setFacadeValidationService(FacadeValidationService facadeValidationService)
-
getWorkflowTemplateService
protected WorkflowTemplateService getWorkflowTemplateService()
-
setWorkflowTemplateService
public void setWorkflowTemplateService(WorkflowTemplateService workflowTemplateService)
-
getUniqueItemIdentifierService
protected UniqueItemIdentifierService getUniqueItemIdentifierService()
-
setUniqueItemIdentifierService
public void setUniqueItemIdentifierService(UniqueItemIdentifierService uniqueItemIdentifierService)
-
getUserService
protected UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getWorkflowProcessingService
protected WorkflowProcessingService getWorkflowProcessingService()
-
setWorkflowProcessingService
public void setWorkflowProcessingService(WorkflowProcessingService workflowProcessingService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getCmsVersionService
protected CMSVersionService getCmsVersionService()
-
setCmsVersionService
public void setCmsVersionService(CMSVersionService cmsVersionService)
-
getCmsWorkflowDataConverter
protected Converter<WorkflowModel,CMSWorkflowData> getCmsWorkflowDataConverter()
-
setCmsWorkflowDataConverter
public void setCmsWorkflowDataConverter(Converter<WorkflowModel,CMSWorkflowData> cmsWorkflowDataConverter)
-
getPermissionCRUDService
protected PermissionCRUDService getPermissionCRUDService()
-
setPermissionCRUDService
public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
-
getWorkflowService
protected CMSWorkflowService getWorkflowService()
-
setWorkflowService
public void setWorkflowService(CMSWorkflowService workflowService)
-
getSearchResultConverter
protected SearchResultConverter getSearchResultConverter()
-
setSearchResultConverter
public void setSearchResultConverter(SearchResultConverter searchResultConverter)
-
getEditWorkflowValidator
protected org.springframework.validation.Validator getEditWorkflowValidator()
-
setEditWorkflowValidator
public void setEditWorkflowValidator(org.springframework.validation.Validator editWorkflowValidator)
-
getCommentService
protected CommentService getCommentService()
-
setCommentService
public void setCommentService(CommentService commentService)
-
getUniqueIdentifierAttributeToDataContentConverter
protected UniqueIdentifierAttributeToDataContentConverter<ItemModel> getUniqueIdentifierAttributeToDataContentConverter()
-
setUniqueIdentifierAttributeToDataContentConverter
public void setUniqueIdentifierAttributeToDataContentConverter(UniqueIdentifierAttributeToDataContentConverter<ItemModel> uniqueIdentifierAttributeToDataContentConverter)
-
getCmsAdminItemService
protected CMSAdminItemService getCmsAdminItemService()
-
setCmsAdminItemService
public void setCmsAdminItemService(CMSAdminItemService cmsAdminItemService)
-
getCommentsCodeGenerator
protected PersistentKeyGenerator getCommentsCodeGenerator()
-
setCommentsCodeGenerator
public void setCommentsCodeGenerator(PersistentKeyGenerator commentsCodeGenerator)
-
getPostWorkflowActions
protected java.util.List<PostWorkflowAction> getPostWorkflowActions()
-
setPostWorkflowActions
public void setPostWorkflowActions(java.util.List<PostWorkflowAction> postWorkflowActions)
-
getWorkflowActionService
protected CMSWorkflowActionService getWorkflowActionService()
-
setWorkflowActionService
public void setWorkflowActionService(CMSWorkflowActionService workflowActionService)
-
getAutomatedWorkflowActionTypePredicate
protected java.util.function.Predicate<WorkflowActionModel> getAutomatedWorkflowActionTypePredicate()
-
setAutomatedWorkflowActionTypePredicate
public void setAutomatedWorkflowActionTypePredicate(java.util.function.Predicate<WorkflowActionModel> automatedWorkflowActionTypePredicate)
-
getPageTypePredicate
protected AbstractPageTypePredicate getPageTypePredicate()
-
setPageTypePredicate
public void setPageTypePredicate(AbstractPageTypePredicate pageTypePredicate)
-
-