001
014
015 package com.liferay.portlet.journal.workflow;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.workflow.BaseWorkflowHandler;
021 import com.liferay.portal.kernel.workflow.WorkflowConstants;
022 import com.liferay.portal.security.permission.ResourceActionsUtil;
023 import com.liferay.portal.service.ServiceContext;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portal.util.PortalUtil;
026 import com.liferay.portal.util.PortletKeys;
027 import com.liferay.portlet.journal.model.JournalArticle;
028 import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
029
030 import java.io.Serializable;
031
032 import java.util.Locale;
033 import java.util.Map;
034
035
041 public class JournalArticleWorkflowHandler extends BaseWorkflowHandler {
042
043 public static final String CLASS_NAME = JournalArticle.class.getName();
044
045 public String getClassName() {
046 return CLASS_NAME;
047 }
048
049 public String getType(Locale locale) {
050 return ResourceActionsUtil.getModelResource(locale, CLASS_NAME);
051 }
052
053 public JournalArticle updateStatus(
054 int status, Map<String, Serializable> workflowContext)
055 throws PortalException, SystemException {
056
057 long userId = GetterUtil.getLong(
058 (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
059 long classPK = GetterUtil.getLong(
060 (String)workflowContext.get(
061 WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
062
063 JournalArticle article = JournalArticleLocalServiceUtil.getArticle(
064 classPK);
065
066 ServiceContext serviceContext = (ServiceContext)workflowContext.get(
067 "serviceContext");
068
069 String articleURL = PortalUtil.getControlPanelFullURL(
070 serviceContext.getScopeGroupId(), PortletKeys.JOURNAL, null);
071
072 return JournalArticleLocalServiceUtil.updateStatus(
073 userId, article, status, articleURL, serviceContext);
074 }
075
076 @Override
077 protected String getIconPath(ThemeDisplay themeDisplay) {
078 return themeDisplay.getPathThemeImages() + "/common/history.png";
079 }
080
081 }