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

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

Introduction

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

Prototype

String CONTEXT_SERVICE_CONTEXT

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

Click Source Link

Usage

From source file:com.liferay.portlet.directory.workflow.UserWorkflowHandler.java

License:Open Source License

public Object updateStatus(int status, Map<String, Serializable> workflowContext)
        throws PortalException, SystemException {

    long userId = GetterUtil.getLong((String) workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));

    ServiceContext serviceContext = (ServiceContext) workflowContext
            .get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT);

    User user = UserLocalServiceUtil.getUser(userId);

    if (((user.getStatus() == WorkflowConstants.STATUS_DRAFT)
            || (user.getStatus() == WorkflowConstants.STATUS_PENDING))
            && (status == WorkflowConstants.STATUS_APPROVED)) {

        UserLocalServiceUtil.completeUserRegistration(user, serviceContext);

        serviceContext.setAttribute("passwordUnencrypted", user.getPasswordUnencrypted());
    }//from   w  ww .  j  ava 2  s .c  om

    return UserLocalServiceUtil.updateStatus(userId, status);
}

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

License:Open Source License

/**
 * Add the article to workflow./*from   w  w  w. j  a v  a  2  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);
    }
}