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.portlet.journal.model.JournalArticle;
026 import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
027
028 import java.io.Serializable;
029
030 import java.util.Locale;
031 import java.util.Map;
032
033
039 public class JournalArticleWorkflowHandler extends BaseWorkflowHandler {
040
041 public static final String CLASS_NAME = JournalArticle.class.getName();
042
043 public String getClassName() {
044 return CLASS_NAME;
045 }
046
047 public String getType(Locale locale) {
048 return ResourceActionsUtil.getModelResource(locale, CLASS_NAME);
049 }
050
051 public JournalArticle updateStatus(
052 int status, Map<String, Serializable> workflowContext)
053 throws PortalException, SystemException {
054
055 long userId = GetterUtil.getLong(
056 (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
057 long resourcePrimKey = GetterUtil.getLong(
058 (String)workflowContext.get(
059 WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
060
061 ServiceContext serviceContext = (ServiceContext)workflowContext.get(
062 "serviceContext");
063
064 JournalArticle article =
065 JournalArticleLocalServiceUtil.getLatestArticle(
066 resourcePrimKey, WorkflowConstants.STATUS_ANY, false);
067
068 return JournalArticleLocalServiceUtil.updateStatus(
069 userId, article, status, null, serviceContext);
070 }
071
072 protected String getIconPath(ThemeDisplay themeDisplay) {
073 return themeDisplay.getPathThemeImages() + "/common/history.png";
074 }
075
076 }