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.service.ServiceContext;
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, int status);
104    
105            public List<BackgroundTask> getBackgroundTasks(
106                    long groupId, String taskExecutorClassName, int start, int end,
107                    OrderByComparator<BackgroundTask> orderByComparator);
108    
109            public List<BackgroundTask> getBackgroundTasks(
110                    long groupId, String name, String taskExecutorClassName, int start,
111                    int end, OrderByComparator<BackgroundTask> orderByComparator);
112    
113            public List<BackgroundTask> getBackgroundTasks(
114                    long groupId, String[] taskExecutorClassNames);
115    
116            public List<BackgroundTask> getBackgroundTasks(
117                    long groupId, String[] taskExecutorClassNames, int status);
118    
119            public List<BackgroundTask> getBackgroundTasks(
120                    long groupId, String[] taskExecutorClassNames, int start, int end,
121                    OrderByComparator<BackgroundTask> orderByComparator);
122    
123            public List<BackgroundTask> getBackgroundTasks(
124                    long[] groupIds, String name, String taskExecutorClassName, int start,
125                    int end, OrderByComparator<BackgroundTask> orderByComparator);
126    
127            public List<BackgroundTask> getBackgroundTasks(
128                    String taskExecutorClassName, int status);
129    
130            public List<BackgroundTask> getBackgroundTasks(
131                    String taskExecutorClassName, int status, int start, int end,
132                    OrderByComparator<BackgroundTask> orderByComparator);
133    
134            public List<BackgroundTask> getBackgroundTasks(
135                    String[] taskExecutorClassNames, int status);
136    
137            public List<BackgroundTask> getBackgroundTasks(
138                    String[] taskExecutorClassNames, int status, int start, int end,
139                    OrderByComparator<BackgroundTask> orderByComparator);
140    
141            public int getBackgroundTasksCount(
142                    long groupId, String taskExecutorClassName);
143    
144            public int getBackgroundTasksCount(
145                    long groupId, String taskExecutorClassName, boolean completed);
146    
147            public int getBackgroundTasksCount(
148                    long groupId, String name, String taskExecutorClassName);
149    
150            public int getBackgroundTasksCount(
151                    long groupId, String name, String taskExecutorClassName,
152                    boolean completed);
153    
154            public int getBackgroundTasksCount(
155                    long groupId, String[] taskExecutorClassNames);
156    
157            public int getBackgroundTasksCount(
158                    long groupId, String[] taskExecutorClassNames, boolean completed);
159    
160            public int getBackgroundTasksCount(
161                    long[] groupIds, String name, String taskExecutorClassName);
162    
163            public int getBackgroundTasksCount(
164                    long[] groupIds, String name, String taskExecutorClassName,
165                    boolean completed);
166    
167            public String getBackgroundTaskStatusJSON(long backgroundTaskId);
168    
169            public void resumeBackgroundTask(long backgroundTaskId);
170    
171            public void triggerBackgroundTask(long backgroundTaskId);
172    
173    }