001    /**
002     * Copyright (c) 2000-present 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.backgroundtask;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.service.ServiceContext;
019    import com.liferay.portal.kernel.util.OrderByComparator;
020    import com.liferay.portal.kernel.util.ProxyFactory;
021    
022    import java.io.File;
023    import java.io.Serializable;
024    
025    import java.util.List;
026    import java.util.Map;
027    
028    /**
029     * @author Michael C. Han
030     */
031    public class BackgroundTaskManagerUtil {
032    
033            public static BackgroundTask addBackgroundTask(
034                            long userId, long groupId, String name,
035                            String taskExecutorClassName,
036                            Map<String, Serializable> taskContextMap,
037                            ServiceContext serviceContext)
038                    throws PortalException {
039    
040                    return _backgroundTaskManager.addBackgroundTask(
041                            userId, groupId, name, taskExecutorClassName, taskContextMap,
042                            serviceContext);
043            }
044    
045            public static BackgroundTask addBackgroundTask(
046                            long userId, long groupId, String name,
047                            String[] servletContextNames, Class<?> taskExecutorClass,
048                            Map<String, Serializable> taskContextMap,
049                            ServiceContext serviceContext)
050                    throws PortalException {
051    
052                    return _backgroundTaskManager.addBackgroundTask(
053                            userId, groupId, name, servletContextNames, taskExecutorClass,
054                            taskContextMap, serviceContext);
055            }
056    
057            public static void addBackgroundTaskAttachment(
058                            long userId, long backgroundTaskId, String fileName, File file)
059                    throws PortalException {
060    
061                    _backgroundTaskManager.addBackgroundTaskAttachment(
062                            userId, backgroundTaskId, fileName, file);
063            }
064    
065            public static BackgroundTask amendBackgroundTask(
066                    long backgroundTaskId, Map<String, Serializable> taskContextMap,
067                    int status, ServiceContext serviceContext) {
068    
069                    return _backgroundTaskManager.amendBackgroundTask(
070                            backgroundTaskId, taskContextMap, status, serviceContext);
071            }
072    
073            public static BackgroundTask amendBackgroundTask(
074                    long backgroundTaskId, Map<String, Serializable> taskContextMap,
075                    int status, String statusMessage, ServiceContext serviceContext) {
076    
077                    return _backgroundTaskManager.amendBackgroundTask(
078                            backgroundTaskId, taskContextMap, status, statusMessage,
079                            serviceContext);
080            }
081    
082            public static void cleanUpBackgroundTask(
083                    BackgroundTask backgroundTask, int status) {
084    
085                    _backgroundTaskManager.cleanUpBackgroundTask(backgroundTask, status);
086            }
087    
088            public static void cleanUpBackgroundTasks() {
089                    _backgroundTaskManager.cleanUpBackgroundTasks();
090            }
091    
092            public static BackgroundTask deleteBackgroundTask(long backgroundTaskId)
093                    throws PortalException {
094    
095                    return _backgroundTaskManager.deleteBackgroundTask(backgroundTaskId);
096            }
097    
098            public static void deleteCompanyBackgroundTasks(long companyId)
099                    throws PortalException {
100    
101                    _backgroundTaskManager.deleteCompanyBackgroundTasks(companyId);
102            }
103    
104            public static void deleteGroupBackgroundTasks(long groupId)
105                    throws PortalException {
106    
107                    _backgroundTaskManager.deleteGroupBackgroundTasks(groupId);
108            }
109    
110            public static void deleteGroupBackgroundTasks(
111                            long groupId, String name, String taskExecutorClassName)
112                    throws PortalException {
113    
114                    _backgroundTaskManager.deleteGroupBackgroundTasks(
115                            groupId, name, taskExecutorClassName);
116            }
117    
118            public static BackgroundTask fetchBackgroundTask(long backgroundTaskId) {
119                    return _backgroundTaskManager.fetchBackgroundTask(backgroundTaskId);
120            }
121    
122            public static BackgroundTask fetchFirstBackgroundTask(
123                    long groupId, String taskExecutorClassName, boolean completed,
124                    OrderByComparator<BackgroundTask> orderByComparator) {
125    
126                    return _backgroundTaskManager.fetchFirstBackgroundTask(
127                            groupId, taskExecutorClassName, completed, orderByComparator);
128            }
129    
130            public static BackgroundTask fetchFirstBackgroundTask(
131                    String taskExecutorClassName, int status) {
132    
133                    return _backgroundTaskManager.fetchFirstBackgroundTask(
134                            taskExecutorClassName, status);
135            }
136    
137            public static BackgroundTask fetchFirstBackgroundTask(
138                    String taskExecutorClassName, int status,
139                    OrderByComparator<BackgroundTask> orderByComparator) {
140    
141                    return _backgroundTaskManager.fetchFirstBackgroundTask(
142                            taskExecutorClassName, status, orderByComparator);
143            }
144    
145            public static BackgroundTask getBackgroundTask(long backgroundTaskId)
146                    throws PortalException {
147    
148                    return _backgroundTaskManager.getBackgroundTask(backgroundTaskId);
149            }
150    
151            public static List<BackgroundTask>
152                    getBackgroundTasks(long groupId, int status) {
153    
154                    return _backgroundTaskManager.getBackgroundTasks(groupId, status);
155            }
156    
157            public static List<BackgroundTask> getBackgroundTasks(
158                    long groupId, String taskExecutorClassName) {
159    
160                    return _backgroundTaskManager.getBackgroundTasks(
161                            groupId, taskExecutorClassName);
162            }
163    
164            public static List<BackgroundTask> getBackgroundTasks(
165                    long groupId, String taskExecutorClassName, boolean completed,
166                    int start, int end,
167                    OrderByComparator<BackgroundTask> orderByComparator) {
168    
169                    return _backgroundTaskManager.getBackgroundTasks(
170                            groupId, taskExecutorClassName, completed, start, end,
171                            orderByComparator);
172            }
173    
174            public static List<BackgroundTask> getBackgroundTasks(
175                    long groupId, String taskExecutorClassName, int status) {
176    
177                    return _backgroundTaskManager.getBackgroundTasks(
178                            groupId, taskExecutorClassName, status);
179            }
180    
181            public static List<BackgroundTask> getBackgroundTasks(
182                    long groupId, String taskExecutorClassName, int start, int end,
183                    OrderByComparator<BackgroundTask> orderByComparator) {
184    
185                    return _backgroundTaskManager.getBackgroundTasks(
186                            groupId, taskExecutorClassName, start, end, orderByComparator);
187            }
188    
189            public static List<BackgroundTask> getBackgroundTasks(
190                    long groupId, String name, String taskExecutorClassName, int start,
191                    int end, OrderByComparator<BackgroundTask> orderByComparator) {
192    
193                    return _backgroundTaskManager.getBackgroundTasks(
194                            groupId, name, taskExecutorClassName, start, end,
195                            orderByComparator);
196            }
197    
198            public static List<BackgroundTask> getBackgroundTasks(
199                    long groupId, String[] taskExecutorClassNames) {
200    
201                    return _backgroundTaskManager.getBackgroundTasks(
202                            groupId, taskExecutorClassNames);
203            }
204    
205            public static List<BackgroundTask> getBackgroundTasks(
206                    long groupId, String[] taskExecutorClassNames, int status) {
207    
208                    return _backgroundTaskManager.getBackgroundTasks(
209                            groupId, taskExecutorClassNames, status);
210            }
211    
212            public static List<BackgroundTask> getBackgroundTasks(
213                    long groupId, String[] taskExecutorClassNames, int start, int end,
214                    OrderByComparator<BackgroundTask> orderByComparator) {
215    
216                    return _backgroundTaskManager.getBackgroundTasks(
217                            groupId, taskExecutorClassNames, start, end, orderByComparator);
218            }
219    
220            public static List<BackgroundTask> getBackgroundTasks(
221                    long[] groupIds, String taskExecutorClassName, boolean completed,
222                    int start, int end,
223                    OrderByComparator<BackgroundTask> orderByComparator) {
224    
225                    return _backgroundTaskManager.getBackgroundTasks(
226                            groupIds, taskExecutorClassName, completed, start, end,
227                            orderByComparator);
228            }
229    
230            public static List<BackgroundTask> getBackgroundTasks(
231                    long[] groupIds, String taskExecutorClassName, int start, int end,
232                    OrderByComparator<BackgroundTask> orderByComparator) {
233    
234                    return _backgroundTaskManager.getBackgroundTasks(
235                            groupIds, taskExecutorClassName, start, end, orderByComparator);
236            }
237    
238            public static List<BackgroundTask> getBackgroundTasks(
239                    long[] groupIds, String name, String taskExecutorClassName, int start,
240                    int end, OrderByComparator<BackgroundTask> orderByComparator) {
241    
242                    return _backgroundTaskManager.getBackgroundTasks(
243                            groupIds, name, taskExecutorClassName, start, end,
244                            orderByComparator);
245            }
246    
247            public static List<BackgroundTask> getBackgroundTasks(
248                    String taskExecutorClassName, int status) {
249    
250                    return _backgroundTaskManager.getBackgroundTasks(
251                            taskExecutorClassName, status);
252            }
253    
254            public static List<BackgroundTask> getBackgroundTasks(
255                    String taskExecutorClassName, int status, int start, int end,
256                    OrderByComparator<BackgroundTask> orderByComparator) {
257    
258                    return _backgroundTaskManager.getBackgroundTasks(
259                            taskExecutorClassName, status, start, end, orderByComparator);
260            }
261    
262            public static List<BackgroundTask> getBackgroundTasks(
263                    String[] taskExecutorClassNames, int status) {
264    
265                    return _backgroundTaskManager.getBackgroundTasks(
266                            taskExecutorClassNames, status);
267            }
268    
269            public static List<BackgroundTask> getBackgroundTasks(
270                    String[] taskExecutorClassNames, int status, int start, int end,
271                    OrderByComparator<BackgroundTask> orderByComparator) {
272    
273                    return _backgroundTaskManager.getBackgroundTasks(
274                            taskExecutorClassNames, status, start, end, orderByComparator);
275            }
276    
277            public static int getBackgroundTasksCount(
278                    long groupId, String taskExecutorClassName) {
279    
280                    return _backgroundTaskManager.getBackgroundTasksCount(
281                            groupId, taskExecutorClassName);
282            }
283    
284            public static int getBackgroundTasksCount(
285                    long groupId, String taskExecutorClassName, boolean completed) {
286    
287                    return _backgroundTaskManager.getBackgroundTasksCount(
288                            groupId, taskExecutorClassName, completed);
289            }
290    
291            public static int getBackgroundTasksCount(
292                    long groupId, String name, String taskExecutorClassName) {
293    
294                    return _backgroundTaskManager.getBackgroundTasksCount(
295                            groupId, name, taskExecutorClassName);
296            }
297    
298            public static int getBackgroundTasksCount(
299                    long groupId, String name, String taskExecutorClassName,
300                    boolean completed) {
301    
302                    return _backgroundTaskManager.getBackgroundTasksCount(
303                            groupId, name, taskExecutorClassName, completed);
304            }
305    
306            public static int getBackgroundTasksCount(
307                    long groupId, String[] taskExecutorClassNames) {
308    
309                    return _backgroundTaskManager.getBackgroundTasksCount(
310                            groupId, taskExecutorClassNames);
311            }
312    
313            public static int getBackgroundTasksCount(
314                    long groupId, String[] taskExecutorClassNames, boolean completed) {
315    
316                    return _backgroundTaskManager.getBackgroundTasksCount(
317                            groupId, taskExecutorClassNames, completed);
318            }
319    
320            public static int getBackgroundTasksCount(
321                    long[] groupIds, String taskExecutorClassName) {
322    
323                    return _backgroundTaskManager.getBackgroundTasksCount(
324                            groupIds, taskExecutorClassName);
325            }
326    
327            public static int getBackgroundTasksCount(
328                    long[] groupIds, String taskExecutorClassName, boolean completed) {
329    
330                    return _backgroundTaskManager.getBackgroundTasksCount(
331                            groupIds, taskExecutorClassName, completed);
332            }
333    
334            public static int getBackgroundTasksCount(
335                    long[] groupIds, String name, String taskExecutorClassName) {
336    
337                    return _backgroundTaskManager.getBackgroundTasksCount(
338                            groupIds, name, taskExecutorClassName);
339            }
340    
341            public static int getBackgroundTasksCount(
342                    long[] groupIds, String name, String taskExecutorClassName,
343                    boolean completed) {
344    
345                    return _backgroundTaskManager.getBackgroundTasksCount(
346                            groupIds, name, taskExecutorClassName, completed);
347            }
348    
349            public static String getBackgroundTaskStatusJSON(long backgroundTaskId) {
350                    return _backgroundTaskManager.getBackgroundTaskStatusJSON(
351                            backgroundTaskId);
352            }
353    
354            public static void resumeBackgroundTask(long backgroundTaskId) {
355                    _backgroundTaskManager.resumeBackgroundTask(backgroundTaskId);
356            }
357    
358            public static void triggerBackgroundTask(long backgroundTaskId) {
359                    _backgroundTaskManager.triggerBackgroundTask(backgroundTaskId);
360            }
361    
362            private static final BackgroundTaskManager _backgroundTaskManager =
363                    ProxyFactory.newServiceTrackedInstance(BackgroundTaskManager.class);
364    
365    }