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.documentlibrary.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.portlet.documentlibrary.model.DLFileEntry;
24  import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
25  
26  import java.io.Serializable;
27  
28  import java.util.Map;
29  
30  /**
31   * <a href="DLFileEntryWorkflowHandler.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Bruno Farache
34   * @author Jorge Ferrer
35   */
36  public class DLFileEntryWorkflowHandler extends BaseWorkflowHandler {
37  
38      public static final String CLASS_NAME = DLFileEntry.class.getName();
39  
40      public String getClassName() {
41          return CLASS_NAME;
42      }
43  
44      public String getType() {
45          return TYPE_DOCUMENT;
46      }
47  
48      public DLFileEntry updateStatus(
49              int status, Map<String, Serializable> workflowContext)
50          throws PortalException, SystemException {
51  
52          long userId = GetterUtil.getLong(
53              (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
54          long classPK = GetterUtil.getLong(
55              (String)workflowContext.get(
56                  WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
57  
58          ServiceContext serviceContext = (ServiceContext)workflowContext.get(
59              "serviceContext");
60  
61          return DLFileEntryLocalServiceUtil.updateStatus(
62              userId, classPK, status, serviceContext);
63      }
64  
65  }