Example usage for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_USER_ID

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_USER_ID

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_USER_ID.

Prototype

String CONTEXT_USER_ID

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_USER_ID.

Click Source Link

Usage

From source file:se.gothiaforum.actorsarticle.util.ActorsServiceUtil.java

License:Open Source License

/**
 * Add the article to workflow./*from  w ww.  j  a  va2 s  .  c  om*/
 * 
 * @param article
 * @param userId
 * @param serviceContext
 * @param groupId
 */
public void addWorkFlow(long userId, JournalArticle article, long groupId, ServiceContext serviceContext) {
    try {

        User user = userService.getUser(userId);
        WorkflowHandler workflowHandler = WorkflowHandlerRegistryUtil
                .getWorkflowHandler(JournalArticle.class.getName());
        Map<String, Serializable> workflowContext = new HashMap<String, Serializable>();
        workflowContext.put(WorkflowConstants.CONTEXT_COMPANY_ID, String.valueOf(article.getCompanyId()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_NAME,
                String.valueOf(article.getClass().getName()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK, String.valueOf(article.getPrimaryKey()));
        workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_TYPE, String.valueOf(article.getType()));
        workflowContext.put(WorkflowConstants.CONTEXT_GROUP_ID, String.valueOf(article.getGroupId()));
        workflowContext.put(WorkflowConstants.CONTEXT_USER_ID, String.valueOf(article.getUserId()));
        workflowContext.put(WorkflowConstants.CONTEXT_SERVICE_CONTEXT, serviceContext);

        workflowHandler.startWorkflowInstance(article.getCompanyId(), groupId, user.getUserId(),
                article.getPrimaryKey(), article.getClass().getName(), workflowContext);
    } catch (PortalException e) {
        throw new RuntimeException("Unable to add workflow", e);
    } catch (SystemException e) {
        throw new RuntimeException("Unable to add workflow", e);
    }
}