001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.workflow;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.kernel.util.OrderByComparator;
019    
020    import java.io.InputStream;
021    
022    import java.util.List;
023    
024    /**
025     * @author Micha Kiener
026     * @author Shuyang Zhou
027     * @author Brian Wing Shun Chan
028     * @author Marcellus Tavares
029     * @author Eduardo Lundgren
030     * @author Raymond Augé
031     */
032    public class WorkflowDefinitionManagerUtil {
033    
034            public static WorkflowDefinition deployWorkflowDefinition(
035                            long companyId, long userId, String title, InputStream inputStream)
036                    throws WorkflowException {
037    
038                    return getWorkflowDefinitionManager().deployWorkflowDefinition(
039                            companyId, userId, title, inputStream);
040            }
041    
042            public static int getActiveWorkflowDefinitionCount(long companyId)
043                    throws WorkflowException {
044    
045                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitionCount(
046                            companyId);
047            }
048    
049            public static int getActiveWorkflowDefinitionCount(
050                            long companyId, String name)
051                    throws WorkflowException {
052    
053                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitionCount(
054                            companyId, name);
055            }
056    
057            public static List<WorkflowDefinition> getActiveWorkflowDefinitions(
058                            long companyId, int start, int end,
059                            OrderByComparator orderByComparator)
060                    throws WorkflowException {
061    
062                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitions(
063                            companyId, start, end, orderByComparator);
064            }
065    
066            public static List<WorkflowDefinition> getActiveWorkflowDefinitions(
067                            long companyId, String name, int start, int end,
068                            OrderByComparator orderByComparator)
069                    throws WorkflowException {
070    
071                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitions(
072                            companyId, name, start, end, orderByComparator);
073            }
074    
075            public static WorkflowDefinition getLatestKaleoDefinition(
076                            long companyId, String name)
077                    throws WorkflowException {
078    
079                    return getWorkflowDefinitionManager().getLatestKaleoDefinition(
080                            companyId, name);
081            }
082    
083            public static WorkflowDefinition getWorkflowDefinition(
084                            long companyId, String name, int version)
085                    throws WorkflowException {
086    
087                    return getWorkflowDefinitionManager().getWorkflowDefinition(
088                            companyId, name, version);
089            }
090    
091            public static int getWorkflowDefinitionCount(long companyId)
092                    throws WorkflowException {
093    
094                    return getWorkflowDefinitionManager().getWorkflowDefinitionCount(
095                            companyId);
096            }
097    
098            public static int getWorkflowDefinitionCount(long companyId, String name)
099                    throws WorkflowException {
100    
101                    return getWorkflowDefinitionManager().getWorkflowDefinitionCount(
102                            companyId, name);
103            }
104    
105            public static WorkflowDefinitionManager getWorkflowDefinitionManager() {
106                    PortalRuntimePermission.checkGetBeanProperty(
107                            WorkflowDefinitionManagerUtil.class);
108    
109                    return _workflowDefinitionManager;
110            }
111    
112            public static List<WorkflowDefinition> getWorkflowDefinitions(
113                            long companyId, int start, int end,
114                            OrderByComparator orderByComparator)
115                    throws WorkflowException {
116    
117                    return getWorkflowDefinitionManager().getWorkflowDefinitions(
118                            companyId, start, end, orderByComparator);
119            }
120    
121            public static List<WorkflowDefinition> getWorkflowDefinitions(
122                            long companyId, String name, int start, int end,
123                            OrderByComparator orderByComparator)
124                    throws WorkflowException {
125    
126                    return getWorkflowDefinitionManager().getWorkflowDefinitions(
127                            companyId, name, start, end, orderByComparator);
128            }
129    
130            public static void undeployWorkflowDefinition(
131                            long companyId, long userId, String name, int version)
132                    throws WorkflowException {
133    
134                    getWorkflowDefinitionManager().undeployWorkflowDefinition(
135                            companyId, userId, name, version);
136            }
137    
138            public static WorkflowDefinition updateActive(
139                            long companyId, long userId, String name, int version,
140                            boolean active)
141                    throws WorkflowException {
142    
143                    return getWorkflowDefinitionManager().updateActive(
144                            companyId, userId, name, version, active);
145            }
146    
147            public static WorkflowDefinition updateTitle(
148                            long companyId, long userId, String name, int version, String title)
149                    throws WorkflowException {
150    
151                    return getWorkflowDefinitionManager().updateTitle(
152                            companyId, userId, name, version, title);
153            }
154    
155            public static void validateWorkflowDefinition(InputStream inputStream)
156                    throws WorkflowException {
157    
158                    getWorkflowDefinitionManager().validateWorkflowDefinition(inputStream);
159            }
160    
161            public void setWorkflowDefinitionManager(
162                    WorkflowDefinitionManager workflowDefinitionManager) {
163    
164                    PortalRuntimePermission.checkSetBeanProperty(getClass());
165    
166                    _workflowDefinitionManager = workflowDefinitionManager;
167            }
168    
169            private static WorkflowDefinitionManager _workflowDefinitionManager;
170    
171    }