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                    String taskExecutorClassName, int status);
121    
122            public List<BackgroundTask> getBackgroundTasks(
123                    String taskExecutorClassName, int status, int start, int end,
124                    OrderByComparator<BackgroundTask> orderByComparator);
125    
126            public List<BackgroundTask> getBackgroundTasks(
127                    String[] taskExecutorClassNames, int status);
128    
129            public List<BackgroundTask> getBackgroundTasks(
130                    String[] taskExecutorClassNames, int status, int start, int end,
131                    OrderByComparator<BackgroundTask> orderByComparator);
132    
133            public int getBackgroundTasksCount(
134                    long groupId, String taskExecutorClassName);
135    
136            public int getBackgroundTasksCount(
137                    long groupId, String taskExecutorClassName, boolean completed);
138    
139            public int getBackgroundTasksCount(
140                    long groupId, String name, String taskExecutorClassName);
141    
142            public int getBackgroundTasksCount(
143                    long groupId, String name, String taskExecutorClassName,
144                    boolean completed);
145    
146            public int getBackgroundTasksCount(
147                    long groupId, String[] taskExecutorClassNames);
148    
149            public int getBackgroundTasksCount(
150                    long groupId, String[] taskExecutorClassNames, boolean completed);
151    
152            public String getBackgroundTaskStatusJSON(long backgroundTaskId);
153    
154            public void resumeBackgroundTask(long backgroundTaskId);
155    
156            public void triggerBackgroundTask(long backgroundTaskId);
157    
158    }