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 BackgroundTask fetchBackgroundTask(long backgroundTaskId);
078    
079            public BackgroundTask fetchFirstBackgroundTask(
080                    long groupId, String taskExecutorClassName, boolean completed,
081                    OrderByComparator<BackgroundTask> orderByComparator);
082    
083            public BackgroundTask fetchFirstBackgroundTask(
084                    String taskExecutorClassName, int status);
085    
086            public BackgroundTask fetchFirstBackgroundTask(
087                    String taskExecutorClassName, int status,
088                    OrderByComparator<BackgroundTask> orderByComparator);
089    
090            public BackgroundTask getBackgroundTask(long backgroundTaskId)
091                    throws PortalException;
092    
093            public List<BackgroundTask> getBackgroundTasks(long groupId, int status);
094    
095            public List<BackgroundTask> getBackgroundTasks(
096                    long groupId, String taskExecutorClassName);
097    
098            public List<BackgroundTask> getBackgroundTasks(
099                    long groupId, String taskExecutorClassName, int status);
100    
101            public List<BackgroundTask> getBackgroundTasks(
102                    long groupId, String taskExecutorClassName, int start, int end,
103                    OrderByComparator<BackgroundTask> orderByComparator);
104    
105            public List<BackgroundTask> getBackgroundTasks(
106                    long groupId, String name, String taskExecutorClassName, int start,
107                    int end, OrderByComparator<BackgroundTask> orderByComparator);
108    
109            public List<BackgroundTask> getBackgroundTasks(
110                    long groupId, String[] taskExecutorClassNames);
111    
112            public List<BackgroundTask> getBackgroundTasks(
113                    long groupId, String[] taskExecutorClassNames, int status);
114    
115            public List<BackgroundTask> getBackgroundTasks(
116                    long groupId, String[] taskExecutorClassNames, int start, int end,
117                    OrderByComparator<BackgroundTask> orderByComparator);
118    
119            public List<BackgroundTask> getBackgroundTasks(
120                    long[] groupIds, String name, String taskExecutorClassName, int start,
121                    int end, OrderByComparator<BackgroundTask> orderByComparator);
122    
123            public List<BackgroundTask> getBackgroundTasks(
124                    String taskExecutorClassName, int status);
125    
126            public List<BackgroundTask> getBackgroundTasks(
127                    String taskExecutorClassName, int status, int start, int end,
128                    OrderByComparator<BackgroundTask> orderByComparator);
129    
130            public List<BackgroundTask> getBackgroundTasks(
131                    String[] taskExecutorClassNames, int status);
132    
133            public List<BackgroundTask> getBackgroundTasks(
134                    String[] taskExecutorClassNames, int status, int start, int end,
135                    OrderByComparator<BackgroundTask> orderByComparator);
136    
137            public int getBackgroundTasksCount(
138                    long groupId, String taskExecutorClassName);
139    
140            public int getBackgroundTasksCount(
141                    long groupId, String taskExecutorClassName, boolean completed);
142    
143            public int getBackgroundTasksCount(
144                    long groupId, String name, String taskExecutorClassName);
145    
146            public int getBackgroundTasksCount(
147                    long groupId, String name, String taskExecutorClassName,
148                    boolean completed);
149    
150            public int getBackgroundTasksCount(
151                    long groupId, String[] taskExecutorClassNames);
152    
153            public int getBackgroundTasksCount(
154                    long groupId, String[] taskExecutorClassNames, boolean completed);
155    
156            public int getBackgroundTasksCount(
157                    long[] groupIds, String name, String taskExecutorClassName);
158    
159            public int getBackgroundTasksCount(
160                    long[] groupIds, String name, String taskExecutorClassName,
161                    boolean completed);
162    
163            public String getBackgroundTaskStatusJSON(long backgroundTaskId);
164    
165            public void resumeBackgroundTask(long backgroundTaskId);
166    
167            public void triggerBackgroundTask(long backgroundTaskId);
168    
169    }