/*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* Copyright 2007 - 2008 Pentaho Corporation. All rights reserved.
*/
package org.pentaho.platform.api.engine;
import java.util.List;
import org.pentaho.platform.api.repository.IContentItem;
import org.pentaho.platform.api.scheduler.BackgroundExecutionException;
import org.pentaho.platform.api.scheduler.IJobDetail;
public interface IBackgroundExecution {
public static final String BACKGROUND_ACTION_NAME_STR = "background_action_name"; //$NON-NLS-1$
public static final String BACKGROUND_SUBMITTED = "background_submit_time"; //$NON-NLS-1$
public static final String DEFAULT_USER_NAME = "SYSTEM"; //$NON-NLS-1$
/**
* Queues the action specified in the request parameters for execution in the background
* @param userSession IPentahoSession of the session executing in background
* @param parameterProvider Provides the parameters containing the action to execute in the background
* @return String response that will be used for user feedback.
*/
public String backgroundExecuteAction(IPentahoSession userSession, IParameterProvider parameterProvider) throws BackgroundExecutionException;
/**
* Gets the list of items scheduled for background execution, and those currently executing
* @param userSession The usersession
* @return List of scheduled/executing jobs
*/
public List<IJobDetail> getScheduledAndExecutingBackgroundJobs(IPentahoSession userSession) throws BackgroundExecutionException;
/**
* Removes the content generated by background execution
* @param contentGUID The GUID of the content generated
* @param userSession The user session
*/
public void removeBackgroundExecutedContentForID(String contentGUID, IPentahoSession userSession);
/**
* Gets the content generated by background execution
* @param contentGUID The GUID for the content
* @param userSession The user session
* @return IContentItem pointing to the generated content
*/
public IContentItem getBackgroundContent(String contentGUID, IPentahoSession userSession);
/**
* Gets a list of content GUIDs of background executed jobs
* @param userSession User session
* @return List of executed content ids
*/
public List<IContentItem> getBackgroundExecutedContentList(IPentahoSession userSession);
/**
* When the job runs in background, gets the effective user session for the user executing the job
* @param user The user name
* @return IPentahoSession for the user as if the user was clicking to run the job in realtime.
*/
public IPentahoSession getEffectiveUserSession(String user);
/**
* This provides an entry point for tracking the created background execution task
* @param userSession
* @param GUID
*/
public void trackBackgroundExecution(IPentahoSession userSession, String GUID);
/**
* Returns the output handler for content, specific to the implementation of the background execution helper.
* @param location Location for the content
* @param fileName File name for the content
* @param solutionName Solution name
* @param userSession IPentahoSession of the caller
* @param parameterProvider parameter provider containing request parameters
* @return IOutputHandler implementation for storing the content.
*/
public IOutputHandler getContentOutputHandler(String location, String fileName, String solutionName,
IPentahoSession userSession, IParameterProvider parameterProvider);
}