Search in sources :

Example 6 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper 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 7 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper 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)

Aggregations

ActionSequenceJCRHelper (org.pentaho.platform.engine.services.ActionSequenceJCRHelper)7 IActionSequence (org.pentaho.platform.api.engine.IActionSequence)6 List (java.util.List)4 Document (org.dom4j.Document)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)3 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ServletException (javax.servlet.ServletException)2 Element (org.dom4j.Element)2 Node (org.dom4j.Node)2 XMLWriter (org.dom4j.io.XMLWriter)2 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)2 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)2 HttpOutputHandler (org.pentaho.platform.web.http.HttpOutputHandler)2