1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.journal.workflow;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.workflow.BaseWorkflowHandler;
21  import com.liferay.portal.kernel.workflow.WorkflowConstants;
22  import com.liferay.portal.service.ServiceContext;
23  import com.liferay.portal.theme.ThemeDisplay;
24  import com.liferay.portlet.asset.model.AssetRenderer;
25  import com.liferay.portlet.journal.asset.JournalArticleAssetRenderer;
26  import com.liferay.portlet.journal.model.JournalArticle;
27  import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
28  
29  import java.io.Serializable;
30  
31  import java.util.Map;
32  
33  /**
34   * <a href="JournalArticleWorkflowHandler.java.html"><b><i>View Source</i></b>
35   * </a>
36   *
37   * @author Bruno Farache
38   * @author Marcellus Tavares
39   * @author Juan Fernández
40   */
41  public class JournalArticleWorkflowHandler extends BaseWorkflowHandler {
42  
43      public static final String CLASS_NAME = JournalArticle.class.getName();
44  
45      public String getClassName() {
46          return CLASS_NAME;
47      }
48  
49      public String getType() {
50          return TYPE_CONTENT;
51      }
52  
53      public JournalArticle updateStatus(
54              int status, Map<String, Serializable> workflowContext)
55          throws PortalException, SystemException {
56  
57          long userId = GetterUtil.getLong(
58              (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
59          long classPK = GetterUtil.getLong(
60              (String)workflowContext.get(
61                  WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
62  
63          ServiceContext serviceContext = (ServiceContext)workflowContext.get(
64              "serviceContext");
65  
66          return JournalArticleLocalServiceUtil.updateStatus(
67              userId, classPK, status, serviceContext);
68      }
69  
70      protected AssetRenderer getAssetRenderer(long classPK)
71          throws PortalException, SystemException {
72  
73          JournalArticle article = JournalArticleLocalServiceUtil.getArticle(
74              classPK);
75  
76          return new JournalArticleAssetRenderer(article);
77      }
78  
79      protected String getIconPath(ThemeDisplay themeDisplay) {
80          return themeDisplay.getPathThemeImages() + "/common/history.png";
81      }
82  
83  }