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 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, int status) {
166    
167                    return _backgroundTaskManager.getBackgroundTasks(
168                            groupId, taskExecutorClassName, status);
169            }
170    
171            public static List<BackgroundTask> getBackgroundTasks(
172                    long groupId, String taskExecutorClassName, int start, int end,
173                    OrderByComparator<BackgroundTask> orderByComparator) {
174    
175                    return _backgroundTaskManager.getBackgroundTasks(
176                            groupId, taskExecutorClassName, start, end, orderByComparator);
177            }
178    
179            public static List<BackgroundTask> getBackgroundTasks(
180                    long groupId, String name, String taskExecutorClassName, int start,
181                    int end, OrderByComparator<BackgroundTask> orderByComparator) {
182    
183                    return _backgroundTaskManager.getBackgroundTasks(
184                            groupId, name, taskExecutorClassName, start, end,
185                            orderByComparator);
186            }
187    
188            public static List<BackgroundTask> getBackgroundTasks(
189                    long groupId, String[] taskExecutorClassNames) {
190    
191                    return _backgroundTaskManager.getBackgroundTasks(
192                            groupId, taskExecutorClassNames);
193            }
194    
195            public static List<BackgroundTask> getBackgroundTasks(
196                    long groupId, String[] taskExecutorClassNames, int status) {
197    
198                    return _backgroundTaskManager.getBackgroundTasks(
199                            groupId, taskExecutorClassNames, status);
200            }
201    
202            public static List<BackgroundTask> getBackgroundTasks(
203                    long groupId, String[] taskExecutorClassNames, int start, int end,
204                    OrderByComparator<BackgroundTask> orderByComparator) {
205    
206                    return _backgroundTaskManager.getBackgroundTasks(
207                            groupId, taskExecutorClassNames, start, end, orderByComparator);
208            }
209    
210            public static List<BackgroundTask> getBackgroundTasks(
211                    long[] groupIds, String name, String taskExecutorClassName, int start,
212                    int end, OrderByComparator<BackgroundTask> orderByComparator) {
213    
214                    return _backgroundTaskManager.getBackgroundTasks(
215                            groupIds, name, taskExecutorClassName, start, end,
216                            orderByComparator);
217            }
218    
219            public static List<BackgroundTask> getBackgroundTasks(
220                    String taskExecutorClassName, int status) {
221    
222                    return _backgroundTaskManager.getBackgroundTasks(
223                            taskExecutorClassName, status);
224            }
225    
226            public static List<BackgroundTask> getBackgroundTasks(
227                    String taskExecutorClassName, int status, int start, int end,
228                    OrderByComparator<BackgroundTask> orderByComparator) {
229    
230                    return _backgroundTaskManager.getBackgroundTasks(
231                            taskExecutorClassName, status, start, end, orderByComparator);
232            }
233    
234            public static List<BackgroundTask> getBackgroundTasks(
235                    String[] taskExecutorClassNames, int status) {
236    
237                    return _backgroundTaskManager.getBackgroundTasks(
238                            taskExecutorClassNames, status);
239            }
240    
241            public static List<BackgroundTask> getBackgroundTasks(
242                    String[] taskExecutorClassNames, int status, int start, int end,
243                    OrderByComparator<BackgroundTask> orderByComparator) {
244    
245                    return _backgroundTaskManager.getBackgroundTasks(
246                            taskExecutorClassNames, status, start, end, orderByComparator);
247            }
248    
249            public static int getBackgroundTasksCount(
250                    long groupId, String taskExecutorClassName) {
251    
252                    return _backgroundTaskManager.getBackgroundTasksCount(
253                            groupId, taskExecutorClassName);
254            }
255    
256            public static int getBackgroundTasksCount(
257                    long groupId, String taskExecutorClassName, boolean completed) {
258    
259                    return _backgroundTaskManager.getBackgroundTasksCount(
260                            groupId, taskExecutorClassName, completed);
261            }
262    
263            public static int getBackgroundTasksCount(
264                    long groupId, String name, String taskExecutorClassName) {
265    
266                    return _backgroundTaskManager.getBackgroundTasksCount(
267                            groupId, name, taskExecutorClassName);
268            }
269    
270            public static int getBackgroundTasksCount(
271                    long groupId, String name, String taskExecutorClassName,
272                    boolean completed) {
273    
274                    return _backgroundTaskManager.getBackgroundTasksCount(
275                            groupId, name, taskExecutorClassName, completed);
276            }
277    
278            public static int getBackgroundTasksCount(
279                    long groupId, String[] taskExecutorClassNames) {
280    
281                    return _backgroundTaskManager.getBackgroundTasksCount(
282                            groupId, taskExecutorClassNames);
283            }
284    
285            public static int getBackgroundTasksCount(
286                    long groupId, String[] taskExecutorClassNames, boolean completed) {
287    
288                    return _backgroundTaskManager.getBackgroundTasksCount(
289                            groupId, taskExecutorClassNames, completed);
290            }
291    
292            public static int getBackgroundTasksCount(
293                    long[] groupIds, String name, String taskExecutorClassName) {
294    
295                    return _backgroundTaskManager.getBackgroundTasksCount(
296                            groupIds, name, taskExecutorClassName);
297            }
298    
299            public static int getBackgroundTasksCount(
300                    long[] groupIds, String name, String taskExecutorClassName,
301                    boolean completed) {
302    
303                    return _backgroundTaskManager.getBackgroundTasksCount(
304                            groupIds, name, taskExecutorClassName, completed);
305            }
306    
307            public static String getBackgroundTaskStatusJSON(long backgroundTaskId) {
308                    return _backgroundTaskManager.getBackgroundTaskStatusJSON(
309                            backgroundTaskId);
310            }
311    
312            public static void resumeBackgroundTask(long backgroundTaskId) {
313                    _backgroundTaskManager.resumeBackgroundTask(backgroundTaskId);
314            }
315    
316            public static void triggerBackgroundTask(long backgroundTaskId) {
317                    _backgroundTaskManager.triggerBackgroundTask(backgroundTaskId);
318            }
319    
320            private static final BackgroundTaskManager
321                    _backgroundTaskManager = ProxyFactory.newServiceTrackedInstance(
322                            BackgroundTaskManager.class);
323    
324    }