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.workflowtasks.action;
16  
17  import com.liferay.portal.kernel.util.ParamUtil;
18  import com.liferay.portal.kernel.util.Validator;
19  import com.liferay.portal.kernel.workflow.WorkflowTask;
20  import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil;
21  import com.liferay.portal.theme.ThemeDisplay;
22  import com.liferay.portal.util.PortalUtil;
23  import com.liferay.portal.util.WebKeys;
24  
25  import javax.portlet.ActionRequest;
26  import javax.portlet.RenderRequest;
27  
28  import javax.servlet.http.HttpServletRequest;
29  
30  /**
31   * <a href="ActionUtil.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Marcellus Tavares
34   */
35  public class ActionUtil {
36  
37      public static void getWorkflowTask(ActionRequest actionRequest)
38          throws Exception {
39  
40          HttpServletRequest request = PortalUtil.getHttpServletRequest(
41              actionRequest);
42  
43          getWorkflowTask(request);
44      }
45  
46      public static void getWorkflowTask(RenderRequest renderRequest)
47          throws Exception {
48  
49          HttpServletRequest request = PortalUtil.getHttpServletRequest(
50              renderRequest);
51  
52          getWorkflowTask(request);
53      }
54  
55      public static void getWorkflowTask(HttpServletRequest request)
56          throws Exception {
57  
58          ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
59              WebKeys.THEME_DISPLAY);
60  
61          long workflowTaskId = ParamUtil.getLong(request, "workflowTaskId");
62  
63          WorkflowTask workflowTask = null;
64  
65          if (Validator.isNotNull(workflowTaskId)) {
66              workflowTask = WorkflowTaskManagerUtil.getWorkflowTask(
67                  themeDisplay.getCompanyId(), workflowTaskId);
68          }
69  
70          request.setAttribute(WebKeys.WORKFLOW_TASK, workflowTask);
71      }
72  
73  }