use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.
the class XQueryBaseComponent method executeAction.
@Override
protected boolean executeAction() {
boolean result = false;
IActionDefinition actionDefinition = getActionDefinition();
// int queryTimeout = -1;
if (actionDefinition instanceof XQueryAction) {
XQueryAction xQueryAction = (XQueryAction) actionDefinition;
// Not implemented yet
// IActionInput queryTimeoutInput = xQueryAction.getQueryTimeout();
IActionInput maxRowsInput = xQueryAction.getMaxRows();
if (maxRowsInput != ActionInputConstant.NULL_INPUT) {
this.setMaxRows(maxRowsInput.getIntValue());
}
IPreparedComponent sharedConnection = (IPreparedComponent) xQueryAction.getSharedConnection().getValue();
if (sharedConnection != null) {
connectionOwner = false;
connection = sharedConnection.shareConnection();
} else {
connection = getConnection();
}
if (connection == null) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0002_CONNECTION_NOT_AVAILABLE", // $NON-NLS-1$
getActionName()));
} else if (connection.getDatasourceType() != IPentahoConnection.XML_DATASOURCE) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", // $NON-NLS-1$
getActionName()));
} else {
result = runQuery(connection, xQueryAction.getQuery().getStringValue());
}
} else if (actionDefinition instanceof XQueryConnectionAction) {
XQueryConnectionAction xQueryConnectionAction = (XQueryConnectionAction) getActionDefinition();
connection = getConnection();
if (connection == null) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0002_CONNECTION_NOT_AVAILABLE", // $NON-NLS-1$
getActionName()));
} else if (connection.getDatasourceType() != IPentahoConnection.XML_DATASOURCE) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", // $NON-NLS-1$
getActionName()));
} else {
xQueryConnectionAction.getOutputConnection().setValue(this);
result = true;
}
}
return result;
}
use of org.pentaho.actionsequence.dom.IActionDefinition 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.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.
the class XactionUtil method createOutputFileName.
@SuppressWarnings("rawtypes")
public static void createOutputFileName(RepositoryFile file, IOutputHandler outputHandler) {
IPentahoSession userSession = PentahoSessionHolder.getSession();
ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(userSession);
IActionSequence actionSequence = actionHelper.getActionSequence(file.getPath(), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
// $NON-NLS-1$
String fileName = "content";
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;
}
}
}
}
}
IMimeTypeListener mimeTypeListener = outputHandler.getMimeTypeListener();
if (mimeTypeListener != null) {
mimeTypeListener.setName(fileName);
}
}
use of org.pentaho.actionsequence.dom.IActionDefinition 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();
}
}
use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.
the class ActionSequenceException method _printStack.
/*
* We are not i18n-ing these stack trace messages. This can be thought of as Throwable.printStackTrace()
*/
@SuppressWarnings("nls")
protected void _printStack(IActionSequenceExecutableStatement statement, PrintWriter s, String prefix) {
if (statement instanceof IActionIfStatement) {
s.println(prefix + "IF STATEMENT: " + ((IActionIfStatement) statement).getCondition());
} else if (statement instanceof IActionLoop) {
s.println(prefix + "LOOP ON: " + ((IActionLoop) statement).getLoopOn());
} else if (statement instanceof IActionDefinition) {
String actionDesc = StringUtils.defaultString(((IActionDefinition) statement).getDescription(), "");
s.println(prefix + "EXECUTING ACTION: " + actionDesc + " (" + ((IActionDefinition) statement).getComponentName() + ")");
} else if (statement instanceof IActionControlStatement) {
s.println(prefix + "UNKNOWN CONTROL STATEMENT");
} else {
s.println(prefix + "UNKNOWN EXECUTABLE STATEMENT");
}
IActionSequenceExecutableStatement parent = statement.getParent();
if (parent != null) {
_printStack(statement.getParent(), s, "\tin ");
}
}
Aggregations