Search in sources :

Example 11 with IActionSequence

use of org.pentaho.platform.api.engine.IActionSequence 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);
    }
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) List(java.util.List) ArrayList(java.util.ArrayList) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper)

Example 12 with IActionSequence

use of org.pentaho.platform.api.engine.IActionSequence 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();
    }
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) HttpOutputHandler(org.pentaho.platform.web.http.HttpOutputHandler) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpRequestParameterProvider(org.pentaho.platform.web.http.request.HttpRequestParameterProvider) List(java.util.List) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory)

Example 13 with IActionSequence

use of org.pentaho.platform.api.engine.IActionSequence in project pentaho-platform by pentaho.

the class ActionSequenceJCRHelper method getActionSequence.

public IActionSequence getActionSequence(String actionPath, int loggingLevel, RepositoryFilePermission actionOperation) {
    Document actionSequenceDocument = getSolutionDocument(actionPath, actionOperation);
    if (actionSequenceDocument == null) {
        return null;
    }
    IActionSequence actionSequence = SequenceDefinition.ActionSequenceFactory(actionSequenceDocument, actionPath, pentahoSession, PentahoSystem.getApplicationContext(), loggingLevel);
    if (actionSequence == null) {
        return null;
    }
    return actionSequence;
}
Also used : IActionSequence(org.pentaho.platform.api.engine.IActionSequence) Document(org.dom4j.Document)

Aggregations

IActionSequence (org.pentaho.platform.api.engine.IActionSequence)13 List (java.util.List)7 Document (org.dom4j.Document)6 ActionSequenceJCRHelper (org.pentaho.platform.engine.services.ActionSequenceJCRHelper)6 ArrayList (java.util.ArrayList)5 ISolutionActionDefinition (org.pentaho.platform.api.engine.ISolutionActionDefinition)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3 IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)3 ActionSequenceException (org.pentaho.platform.api.engine.ActionSequenceException)3 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)3 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)3 ServletException (javax.servlet.ServletException)2 Element (org.dom4j.Element)2 Node (org.dom4j.Node)2