use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class SolutionEngine method init.
public void init(final IPentahoSession pSession) {
parameterProviders = new HashMap<String, IParameterProvider>();
this.session = pSession;
this.setParameterProvider(SolutionEngine.JVM_PARAMETER_PROVIDER, new JVMParameterProvider());
setForcePrompt(false);
// Provide the security parameter provider to the parameter provider map in the super class
SecurityParameterProvider provider = new SecurityParameterProvider(pSession);
this.setParameterProvider(SecurityParameterProvider.SCOPE_SECURITY, provider);
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class SolutionEngineAgent method execute.
public int execute() {
PentahoSystem.systemEntryPoint();
try {
// create a generic session object
StandaloneSession session = new StandaloneSession(userId);
solutionEngine = PentahoSystem.get(SolutionEngine.class, session);
solutionEngine.init(session);
SimpleParameterProvider parameterProvider = new SimpleParameterProvider(parameters);
HashMap<String, IParameterProvider> parameterProviderMap = new HashMap<String, IParameterProvider>();
parameterProviderMap.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
// $NON-NLS-1$
IPentahoUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath());
String processName = description;
boolean persisted = false;
List messages = new ArrayList();
outputStream = new ByteArrayOutputStream(0);
SimpleOutputHandler outputHandler = null;
if (outputStream != null) {
outputHandler = new SimpleOutputHandler(outputStream, false);
outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
}
solutionEngine.execute(actionSequence, processName, false, true, null, persisted, parameterProviderMap, outputHandler, null, urlFactory, messages);
} finally {
PentahoSystem.systemExitPoint();
}
return solutionEngine.getStatus();
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class SolutionHelper method execute.
/**
* Runs an action sequence. This method uses the base URL set by the Application Context
*
* @param description
* An identifier for this process. This is used for auditing and logging purposes only.
* @param session
* The user session that is requesting this execution. This is used for auditing and logging and also
* can be used in action sequences (for example to filter data)
* @param actionSequence
* Path to the action sequence file
* @param parameters
* Parameters to be passed to the action sequence
* @param outputStream
* The output stream for content generated by the action sequence. Can be null.
* @param execListener
* An execution listener for feedback during execution. Can be null.
* @return
*/
public static ISolutionEngine execute(final String description, final IPentahoSession session, final String actionSequence, final Map parameters, OutputStream outputStream, final IExecutionListener execListener, final boolean collateMessages, final boolean manageHibernate) {
if (manageHibernate) {
PentahoSystem.systemEntryPoint();
}
ISolutionEngine solutionEngine = null;
try {
solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
solutionEngine.init(session);
solutionEngine.setlistener(execListener);
SimpleParameterProvider parameterProvider = new SimpleParameterProvider(parameters);
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
String url = requestContext.getContextPath();
// Modifications by Ezequiel Cuellar
// Old code.
// String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
// New code. Since the SubActionComponent is being instantiated below to return feedback
// it is necesary to configure the baseUrl to include the ViewAction.
Object actionUrlComponent = parameters.get(StandardSettings.ACTION_URL_COMPONENT);
if ((actionUrlComponent != null) && (actionUrlComponent.toString().length() > 0)) {
url += actionUrlComponent.toString();
} else {
// $NON-NLS-1$
url += "ViewAction?";
}
HashMap<String, IParameterProvider> parameterProviderMap = new HashMap<String, IParameterProvider>();
parameterProviderMap.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);
IPentahoUrlFactory urlFactory = new SimpleUrlFactory(url);
String processName = description;
boolean persisted = false;
// for now, the messages list needs to be untyped since we may put exceptions as well as strings in it
List<?> messages = null;
if (collateMessages) {
messages = new ArrayList();
}
if (outputStream == null) {
outputStream = new ByteArrayOutputStream(0);
}
SimpleOutputHandler outputHandler = null;
if (outputStream != null) {
// Modifications by Ezequiel Cuellar
// Old code.
// outputHandler = new SimpleOutputHandler(outputStream, false);
// New code. Without setting the allowFeedback parameter to true it is assumed that SubActionComponent
// instances
// are never capable of returning feedback which may not always be the case.
outputHandler = new SimpleOutputHandler(outputStream, true);
outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
}
solutionEngine.execute(actionSequence, processName, false, true, null, persisted, parameterProviderMap, outputHandler, null, urlFactory, messages);
} finally {
if (manageHibernate) {
PentahoSystem.systemExitPoint();
}
}
return solutionEngine;
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class SolutionEngineInteractivityService method doGet.
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
PentahoSystem.systemEntryPoint();
try {
IPentahoSession userSession = getPentahoSession(request);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// $NON-NLS-1$
String solutionName = request.getParameter("solution");
// $NON-NLS-1$
String actionPath = request.getParameter("path");
// $NON-NLS-1$
String actionName = request.getParameter("action");
IActionSequence actionSequence = new ActionSequenceJCRHelper().getActionSequence(ActionInfo.buildSolutionPath(solutionName, actionPath, actionName), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
String fileName = null;
if (actionSequence != null) {
String title = actionSequence.getTitle();
if ((title != null) && (title.length() > 0)) {
fileName = title;
} else {
String sequenceName = actionSequence.getSequenceName();
if ((sequenceName != null) && (sequenceName.length() > 0)) {
fileName = sequenceName;
} else {
List actionDefinitionsList = actionSequence.getActionDefinitionsAndSequences();
int i = 0;
boolean done = false;
while ((actionDefinitionsList.size() > i) && !done) {
IActionDefinition actionDefinition = (IActionDefinition) actionDefinitionsList.get(i);
String componentName = actionDefinition.getComponentName();
if ((componentName != null) && (componentName.length() > 0)) {
fileName = componentName;
done = true;
} else {
i++;
}
}
}
}
}
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
HttpOutputHandler outputHandler = createOutputHandler(response, outputStream);
outputHandler.setSession(userSession);
IMimeTypeListener listener = new HttpMimeTypeListener(request, response);
listener.setName(fileName);
outputHandler.setMimeTypeListener(listener);
SimpleUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath() + // $NON-NLS-1$
"SolutionEngineInteractivityService?");
IParameterProvider requestParameters = new HttpRequestParameterProvider(request);
setupOutputHandler(outputHandler, requestParameters);
HttpServletRequestHandler requestHandler = getRequestHandler(request, response, userSession, requestParameters, outputStream, outputHandler, urlFactory);
handleActionRequest(request, response, outputHandler, requestHandler, requestParameters, outputStream, null);
} finally {
PentahoSystem.systemExitPoint();
}
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class ViewAction method doGet.
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
PentahoSystem.systemEntryPoint();
try {
IPentahoSession userSession = getPentahoSession(request);
if (!doBackgroundExecution(request, response, userSession)) {
OutputStream outputStream = getOutputStream(response, doMessages(request));
ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(userSession);
// $NON-NLS-1$
String actionPath = request.getParameter("path");
IActionSequence actionSequence = actionHelper.getActionSequence(actionPath, PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
String fileName = null;
if (actionSequence != null) {
String title = actionSequence.getTitle();
if ((title != null) && (title.length() > 0)) {
fileName = title;
} else {
String sequenceName = actionSequence.getSequenceName();
if ((sequenceName != null) && (sequenceName.length() > 0)) {
fileName = sequenceName;
} else {
List actionDefinitionsList = actionSequence.getActionDefinitionsAndSequences();
int i = 0;
boolean done = false;
while ((actionDefinitionsList.size() > i) && !done) {
IActionDefinition actionDefinition = (IActionDefinition) actionDefinitionsList.get(i);
String componentName = actionDefinition.getComponentName();
if ((componentName != null) && (componentName.length() > 0)) {
fileName = componentName;
done = true;
} else {
i++;
}
}
}
}
}
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
HttpOutputHandler outputHandler = createOutputHandler(response, outputStream);
outputHandler.setSession(userSession);
IMimeTypeListener listener = new HttpMimeTypeListener(request, response, fileName);
outputHandler.setMimeTypeListener(listener);
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath() + "ViewAction?");
IParameterProvider requestParameters = new HttpRequestParameterProvider(request);
HttpServletRequestHandler requestHandler = getRequestHandler(request, response, userSession, requestParameters, outputStream, outputHandler, urlFactory);
handleActionRequest(request, response, outputHandler, requestHandler, outputStream, null);
}
} finally {
PentahoSystem.systemExitPoint();
}
}
Aggregations