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    
021    import java.io.File;
022    import java.io.InputStream;
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 interface BackgroundTaskManager {
032    
033            public 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            public BackgroundTask addBackgroundTask(
041                            long userId, long groupId, String name,
042                            String[] servletContextNames, Class<?> taskExecutorClass,
043                            Map<String, Serializable> taskContextMap,
044                            ServiceContext serviceContext)
045                    throws PortalException;
046    
047            public void addBackgroundTaskAttachment(
048                            long userId, long backgroundTaskId, String fileName, File file)
049                    throws PortalException;
050    
051            public void addBackgroundTaskAttachment(
052                            long userId, long backgroundTaskId, String fileName,
053                            InputStream inputStream)
054                    throws PortalException;
055    
056            public BackgroundTask amendBackgroundTask(
057                    long backgroundTaskId, Map<String, Serializable> taskContextMap,
058                    int status, ServiceContext serviceContext);
059    
060            public BackgroundTask amendBackgroundTask(
061                    long backgroundTaskId, Map<String, Serializable> taskContextMap,
062                    int status, String statusMessage, ServiceContext serviceContext);
063    
064            public void cleanUpBackgroundTask(
065                    BackgroundTask backgroundTask, int status);
066    
067            public void cleanUpBackgroundTasks();
068    
069            public BackgroundTask deleteBackgroundTask(long backgroundTaskId)
070                    throws PortalException;
071    
072            public void deleteCompanyBackgroundTasks(long companyId)
073                    throws PortalException;
074    
075            public void deleteGroupBackgroundTasks(long groupId) throws PortalException;
076    
077            public void deleteGroupBackgroundTasks(
078                            long groupId, String name, String taskExecutorClassName)
079                    throws PortalException;
080    
081            public BackgroundTask fetchBackgroundTask(long backgroundTaskId);
082    
083            public BackgroundTask fetchFirstBackgroundTask(
084                    long groupId, String taskExecutorClassName, boolean completed,
085                    OrderByComparator<BackgroundTask> orderByComparator);
086    
087            public BackgroundTask fetchFirstBackgroundTask(
088                    String taskExecutorClassName, int status);
089    
090            public BackgroundTask fetchFirstBackgroundTask(
091                    String taskExecutorClassName, int status,
092                    OrderByComparator<BackgroundTask> orderByComparator);
093    
094            public BackgroundTask getBackgroundTask(long backgroundTaskId)
095                    throws PortalException;
096    
097            public List<BackgroundTask> getBackgroundTasks(long groupId, int status);
098    
099            public List<BackgroundTask> getBackgroundTasks(
100                    long groupId, String taskExecutorClassName);
101    
102            public List<BackgroundTask> getBackgroundTasks(
103                    long groupId, String taskExecutorClassName, boolean completed,
104                    int start, int end,
105                    OrderByComparator<BackgroundTask> orderByComparator);
106    
107            public List<BackgroundTask> getBackgroundTasks(
108                    long groupId, String taskExecutorClassName, int status);
109    
110            public List<BackgroundTask> getBackgroundTasks(
111                    long groupId, String taskExecutorClassName, int start, int end,
112                    OrderByComparator<BackgroundTask> orderByComparator);
113    
114            public List<BackgroundTask> getBackgroundTasks(
115                    long groupId, String name, String taskExecutorClassName, int start,
116                    int end, OrderByComparator<BackgroundTask> orderByComparator);
117    
118            public List<BackgroundTask> getBackgroundTasks(
119                    long groupId, String[] taskExecutorClassNames);
120    
121            public List<BackgroundTask> getBackgroundTasks(
122                    long groupId, String[] taskExecutorClassNames, int status);
123    
124            public List<BackgroundTask> getBackgroundTasks(
125                    long groupId, String[] taskExecutorClassNames, int start, int end,
126                    OrderByComparator<BackgroundTask> orderByComparator);
127    
128            public List<BackgroundTask> getBackgroundTasks(
129                    long[] groupIds, String taskExecutorClassName, boolean completed,
130                    int start, int end,
131                    OrderByComparator<BackgroundTask> orderByComparator);
132    
133            public List<BackgroundTask> getBackgroundTasks(
134                    long[] groupIds, String taskExecutorClassName, int start, int end,
135                    OrderByComparator<BackgroundTask> orderByComparator);
136    
137            public List<BackgroundTask> getBackgroundTasks(
138                    long[] groupIds, String name, String taskExecutorClassName, int start,
139                    int end, OrderByComparator<BackgroundTask> orderByComparator);
140    
141            public List<BackgroundTask> getBackgroundTasks(
142                    String taskExecutorClassName, int status);
143    
144            public List<BackgroundTask> getBackgroundTasks(
145                    String taskExecutorClassName, int status, int start, int end,
146                    OrderByComparator<BackgroundTask> orderByComparator);
147    
148            public List<BackgroundTask> getBackgroundTasks(
149                    String[] taskExecutorClassNames, int status);
150    
151            public List<BackgroundTask> getBackgroundTasks(
152                    String[] taskExecutorClassNames, int status, int start, int end,
153                    OrderByComparator<BackgroundTask> orderByComparator);
154    
155            public int getBackgroundTasksCount(
156                    long groupId, String taskExecutorClassName);
157    
158            public int getBackgroundTasksCount(
159                    long groupId, String taskExecutorClassName, boolean completed);
160    
161            public int getBackgroundTasksCount(
162                    long groupId, String name, String taskExecutorClassName);
163    
164            public int getBackgroundTasksCount(
165                    long groupId, String name, String taskExecutorClassName,
166                    boolean completed);
167    
168            public int getBackgroundTasksCount(
169                    long groupId, String[] taskExecutorClassNames);
170    
171            public int getBackgroundTasksCount(
172                    long groupId, String[] taskExecutorClassNames, boolean completed);
173    
174            public int getBackgroundTasksCount(
175                    long[] groupIds, String taskExecutorClassName);
176    
177            public int getBackgroundTasksCount(
178                    long[] groupIds, String taskExecutorClassName, boolean completed);
179    
180            public int getBackgroundTasksCount(
181                    long[] groupIds, String name, String taskExecutorClassName);
182    
183            public int getBackgroundTasksCount(
184                    long[] groupIds, String name, String taskExecutorClassName,
185                    boolean completed);
186    
187            public String getBackgroundTaskStatusJSON(long backgroundTaskId);
188    
189            public void resumeBackgroundTask(long backgroundTaskId);
190    
191            public void triggerBackgroundTask(long backgroundTaskId);
192    
193    }