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.util.OrderByComparator;
019    import com.liferay.portal.kernel.util.ProxyFactory;
020    import com.liferay.portal.service.ServiceContext;
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 BackgroundTask fetchBackgroundTask(long backgroundTaskId) {
111                    return _backgroundTaskManager.fetchBackgroundTask(backgroundTaskId);
112            }
113    
114            public static BackgroundTask fetchFirstBackgroundTask(
115                    long groupId, String taskExecutorClassName, boolean completed,
116                    OrderByComparator<BackgroundTask> orderByComparator) {
117    
118                    return _backgroundTaskManager.fetchFirstBackgroundTask(
119                            groupId, taskExecutorClassName, completed, orderByComparator);
120            }
121    
122            public static BackgroundTask fetchFirstBackgroundTask(
123                    String taskExecutorClassName, int status) {
124    
125                    return _backgroundTaskManager.fetchFirstBackgroundTask(
126                            taskExecutorClassName, status);
127            }
128    
129            public static BackgroundTask fetchFirstBackgroundTask(
130                    String taskExecutorClassName, int status,
131                    OrderByComparator<BackgroundTask> orderByComparator) {
132    
133                    return _backgroundTaskManager.fetchFirstBackgroundTask(
134                            taskExecutorClassName, status, orderByComparator);
135            }
136    
137            public static BackgroundTask getBackgroundTask(long backgroundTaskId)
138                    throws PortalException {
139    
140                    return _backgroundTaskManager.getBackgroundTask(backgroundTaskId);
141            }
142    
143            public static List<BackgroundTask>
144                    getBackgroundTasks(long groupId, int status) {
145    
146                    return _backgroundTaskManager.getBackgroundTasks(groupId, status);
147            }
148    
149            public static List<BackgroundTask> getBackgroundTasks(
150                    long groupId, String taskExecutorClassName) {
151    
152                    return _backgroundTaskManager.getBackgroundTasks(
153                            groupId, taskExecutorClassName);
154            }
155    
156            public static List<BackgroundTask> getBackgroundTasks(
157                    long groupId, String taskExecutorClassName, int status) {
158    
159                    return _backgroundTaskManager.getBackgroundTasks(
160                            groupId, taskExecutorClassName, status);
161            }
162    
163            public static List<BackgroundTask> getBackgroundTasks(
164                    long groupId, String taskExecutorClassName, int start, int end,
165                    OrderByComparator<BackgroundTask> orderByComparator) {
166    
167                    return _backgroundTaskManager.getBackgroundTasks(
168                            groupId, taskExecutorClassName, start, end, orderByComparator);
169            }
170    
171            public static List<BackgroundTask> getBackgroundTasks(
172                    long groupId, String name, String taskExecutorClassName, int start,
173                    int end, OrderByComparator<BackgroundTask> orderByComparator) {
174    
175                    return _backgroundTaskManager.getBackgroundTasks(
176                            groupId, name, taskExecutorClassName, start, end,
177                            orderByComparator);
178            }
179    
180            public static List<BackgroundTask> getBackgroundTasks(
181                    long groupId, String[] taskExecutorClassNames) {
182    
183                    return _backgroundTaskManager.getBackgroundTasks(
184                            groupId, taskExecutorClassNames);
185            }
186    
187            public static List<BackgroundTask> getBackgroundTasks(
188                    long groupId, String[] taskExecutorClassNames, int status) {
189    
190                    return _backgroundTaskManager.getBackgroundTasks(
191                            groupId, taskExecutorClassNames, status);
192            }
193    
194            public static List<BackgroundTask> getBackgroundTasks(
195                    long groupId, String[] taskExecutorClassNames, int start, int end,
196                    OrderByComparator<BackgroundTask> orderByComparator) {
197    
198                    return _backgroundTaskManager.getBackgroundTasks(
199                            groupId, taskExecutorClassNames, start, end, orderByComparator);
200            }
201    
202            public static List<BackgroundTask> getBackgroundTasks(
203                    long[] groupIds, String name, String taskExecutorClassName, int start,
204                    int end, OrderByComparator<BackgroundTask> orderByComparator) {
205    
206                    return _backgroundTaskManager.getBackgroundTasks(
207                            groupIds, name, taskExecutorClassName, start, end,
208                            orderByComparator);
209            }
210    
211            public static List<BackgroundTask> getBackgroundTasks(
212                    String taskExecutorClassName, int status) {
213    
214                    return _backgroundTaskManager.getBackgroundTasks(
215                            taskExecutorClassName, status);
216            }
217    
218            public static List<BackgroundTask> getBackgroundTasks(
219                    String taskExecutorClassName, int status, int start, int end,
220                    OrderByComparator<BackgroundTask> orderByComparator) {
221    
222                    return _backgroundTaskManager.getBackgroundTasks(
223                            taskExecutorClassName, status, start, end, orderByComparator);
224            }
225    
226            public static List<BackgroundTask> getBackgroundTasks(
227                    String[] taskExecutorClassNames, int status) {
228    
229                    return _backgroundTaskManager.getBackgroundTasks(
230                            taskExecutorClassNames, status);
231            }
232    
233            public static List<BackgroundTask> getBackgroundTasks(
234                    String[] taskExecutorClassNames, int status, int start, int end,
235                    OrderByComparator<BackgroundTask> orderByComparator) {
236    
237                    return _backgroundTaskManager.getBackgroundTasks(
238                            taskExecutorClassNames, status, start, end, orderByComparator);
239            }
240    
241            public static int getBackgroundTasksCount(
242                    long groupId, String taskExecutorClassName) {
243    
244                    return _backgroundTaskManager.getBackgroundTasksCount(
245                            groupId, taskExecutorClassName);
246            }
247    
248            public static int getBackgroundTasksCount(
249                    long groupId, String taskExecutorClassName, boolean completed) {
250    
251                    return _backgroundTaskManager.getBackgroundTasksCount(
252                            groupId, taskExecutorClassName, completed);
253            }
254    
255            public static int getBackgroundTasksCount(
256                    long groupId, String name, String taskExecutorClassName) {
257    
258                    return _backgroundTaskManager.getBackgroundTasksCount(
259                            groupId, name, taskExecutorClassName);
260            }
261    
262            public static int getBackgroundTasksCount(
263                    long groupId, String name, String taskExecutorClassName,
264                    boolean completed) {
265    
266                    return _backgroundTaskManager.getBackgroundTasksCount(
267                            groupId, name, taskExecutorClassName, completed);
268            }
269    
270            public static int getBackgroundTasksCount(
271                    long groupId, String[] taskExecutorClassNames) {
272    
273                    return _backgroundTaskManager.getBackgroundTasksCount(
274                            groupId, taskExecutorClassNames);
275            }
276    
277            public static int getBackgroundTasksCount(
278                    long groupId, String[] taskExecutorClassNames, boolean completed) {
279    
280                    return _backgroundTaskManager.getBackgroundTasksCount(
281                            groupId, taskExecutorClassNames, completed);
282            }
283    
284            public static int getBackgroundTasksCount(
285                    long[] groupIds, String name, String taskExecutorClassName) {
286    
287                    return _backgroundTaskManager.getBackgroundTasksCount(
288                            groupIds, name, taskExecutorClassName);
289            }
290    
291            public static int getBackgroundTasksCount(
292                    long[] groupIds, String name, String taskExecutorClassName,
293                    boolean completed) {
294    
295                    return _backgroundTaskManager.getBackgroundTasksCount(
296                            groupIds, name, taskExecutorClassName, completed);
297            }
298    
299            public static String getBackgroundTaskStatusJSON(long backgroundTaskId) {
300                    return _backgroundTaskManager.getBackgroundTaskStatusJSON(
301                            backgroundTaskId);
302            }
303    
304            public static void resumeBackgroundTask(long backgroundTaskId) {
305                    _backgroundTaskManager.resumeBackgroundTask(backgroundTaskId);
306            }
307    
308            public static void triggerBackgroundTask(long backgroundTaskId) {
309                    _backgroundTaskManager.triggerBackgroundTask(backgroundTaskId);
310            }
311    
312            private static final BackgroundTaskManager
313                    _backgroundTaskManager = ProxyFactory.newServiceTrackedInstance(
314                            BackgroundTaskManager.class);
315    
316    }