Package org.apache.turbine.util

Examples of org.apache.turbine.util.RunData


    public void testGroupPage2() throws Exception
    {
        JetspeedLink jetspeedLink = null;
       
        // Create the RunData object to be used during testing.
        RunData rundata = RunDataFactory.getRunData( request, response, config );
        assertNotNull( "Got rundata", rundata);
        TurbineTestUtilities.setupRunData(rundata);
       
        // Get and populate the context
        Context context = TurbineVelocity.getContext(rundata);
View Full Code Here


    public void testGetLink() throws Exception
    {
        JetspeedLink jetspeedLink = null;
       
        // Create the RunData object to be used during testing.
        RunData rundata = RunDataFactory.getRunData( request, response, config );
        assertNotNull( "Got rundata", rundata);
        TurbineTestUtilities.setupRunData(rundata);
       
        // Get and populate the context
        Context context = TurbineVelocity.getContext(rundata);
View Full Code Here

        catch (PortletException pe)
        {
            logger.error("XSLViewProcessor - error: " + pe.getMessage(), pe);
        }

        RunData data = (RunData) context.get("data");
        CapabilityMap map = ((JetspeedRunData) data).getCapability();
        String type = map.getPreferredType().toString();
        ConcreteElement content = new JetspeedClearElement(INVALID_TYPE);
        String stylesheet = (String) stylesheets.get(type);
View Full Code Here

    public Object processView(GenericMVCContext context)
    {
      String result = "";
     
        Portlet portlet = (Portlet) context.get("portlet");
        RunData data = (RunData) context.get("data");
        HttpServletRequest request = data.getRequest();
        String template = (String) context.get("template");
        logger.info("JSPViewProcessor - processing template " + template);

        try
        {

            // Allow access to portlet from .jsp template
            request.setAttribute("portlet", portlet);

            // put context in attribute so you can get to it from .jsp template
            request.setAttribute("context", context);

            // Add js_peid out of convenience
            request.setAttribute("js_peid", portlet.getID());

            // Add rundata out of convenience (JspService.RUNDATA differs from GenericMVCPortlet.RUNDATA)
            request.setAttribute(JspService.RUNDATA, data);

            // Retrieve the URL. For backward compatibility, use the URL first
            // and then fallback to "template" parameter
            PortletEntry pe = (PortletEntry) Registry.getEntry(Registry.PORTLET, portlet.getName());

            // Files referenced from default templates folder will be processed
            // using JspService. Otherwise, they will be loaded using EcsServletElement
            // from where ever they came from.
            if (pe.getURL() == null || pe.getURL().trim().length() == 0)
            {

                if (template != null && -1 == template.indexOf(".jsp"))
                {
                    template = template + ".jsp";
                }

                logger.info("JSPViewProcessor - locating template - " + data.toString()
                         + " - " + template);

                //we use the template locator to translate the template
                String locatedTemplate = TemplateLocator.locatePortletTemplate(data, template);
                logger.info("JSPViewProcessor - located template: " + locatedTemplate);

                /*if (locatedTemplate == null)
                {
                    locatedTemplate = TemplateLocator.locateScreenTemplate(data, template);
                    if (locatedTemplate != null)
                    {
                        locatedTemplate = "/screens" + locatedTemplate;
                    }
                    logger.debug("JSPViewProcessor - located screen template: " + locatedTemplate);
                } */

                JetspeedJspService service = (JetspeedJspService) ServiceUtil.getServiceByName(JspService.SERVICE_NAME);

                // this is only necessary if we don't run in a JSP page environment
                // but better be safe than sorry...
                service.addDefaultObjects(data);

                // handle request
                result = service.handleBufferedRequest(data, locatedTemplate, false);

            }
            else
            {
                // Build parameter list to be passed with the jsp
                Iterator names = portlet.getPortletConfig().getInitParameterNames();
                while (names.hasNext())
                {
                    String name = (String) names.next();
                    String value = (String) portlet.getPortletConfig().getInitParameter(name);
                    data.getParameters().setString(name, value);
                }

                template = pe.getURL();

                if (logger.isDebugEnabled())
                {
                    logger.debug("JSPViewProcessor - serving jsp directly using: " + template);
                }

                // get the RequestDispatcher for the JSP
                StringWriter writer = new StringWriter();
              HttpBufferedResponse response = new HttpBufferedResponse(data.getResponse(), new PrintWriter(writer));
             
                RequestDispatcher dispatcher = data.getServletContext().getRequestDispatcher(template);
                data.getOut().flush();
                dispatcher.include(data.getRequest(), response);
               
                result = writer.toString();
            }

        }
View Full Code Here

                                          (RunData) context.get("data"),
                                          template);

            // need to add cache support
            Portlet portlet = (Portlet) context.get("portlet");
            RunData rundata = (RunData) context.get("data");
            long cachePeriod = -1;
            AbstractPortlet abstractPortlet = null;
            // STW: Safety net ;)
            if(portlet instanceof AbstractPortlet)
            {
View Full Code Here

                                          (RunData) context.get("data"),
                                          template);

            // need to add cache support
            Portlet portlet = (Portlet) context.get("portlet");
            RunData rundata = (RunData) context.get("data");
            long cachePeriod = -1;
            AbstractPortlet abstractPortlet = null;
            // STW: Safety net ;)
            if(portlet instanceof AbstractPortlet)
            {
              abstractPortlet =(AbstractPortlet) portlet;
              if(abstractPortlet.getExpirationMillis() != null)
              {
                cachePeriod = abstractPortlet.getExpirationMillis().longValue();
              }
            }
          
      if (cachePeriod > 0 && abstractPortlet != null)
      {
        String s = TurbineVelocity.handleRequest(context, templatePath);
        abstractPortlet.setExpirationMillis(
          cachePeriod + System.currentTimeMillis());
        element = new JetspeedClearElement(s);

      }
      else
      {
              rundata.getOut().flush();
        TurbineVelocity.handleRequest(
          context, templatePath, rundata.getOut());
      }
           
           
          }
        catch (Exception e)
View Full Code Here

    public Object processView(GenericMVCContext context)
    {

        Portlet portlet = (Portlet) context.get("portlet");
        RunData data = (RunData) context.get("data");
        HttpServletRequest request = data.getRequest();
        String template = (String) context.get("template");
        logger.info("JSPViewProcessor - processing template " + template);

        try
        {

            // Allow access to portlet from .jsp template
            request.setAttribute("portlet", portlet);

            // put context in attribute so you can get to it from .jsp template
            request.setAttribute("context", context);

            // Add js_peid out of convenience
            request.setAttribute("js_peid", portlet.getID());

            // Add rundata out of convenience (JspService.RUNDATA differs from GenericMVCPortlet.RUNDATA)
            request.setAttribute(JspService.RUNDATA, data);

            // Retrieve the URL. For backward compatibility, use the URL first
            // and then fallback to "template" parameter
            PortletEntry pe = (PortletEntry) Registry.getEntry(Registry.PORTLET, portlet.getName());

            // Files referenced from default templates folder will be processed
            // using JspService. Otherwise, they will be loaded using EcsServletElement
            // from where ever they came from.
            if (pe.getURL() == null || pe.getURL().trim().length() == 0)
            {

                if (template != null && -1 == template.indexOf(".jsp"))
                {
                    template = template + ".jsp";
                }

                logger.info("JSPViewProcessor - locating template - " + data.toString()
                         + " - " + template);

                //we use the template locator to translate the template
                String locatedTemplate = TemplateLocator.locatePortletTemplate(data, template);
                logger.info("JSPViewProcessor - located template: " + locatedTemplate);

                /*if (locatedTemplate == null)
                {
                    locatedTemplate = TemplateLocator.locateScreenTemplate(data, template);
                    if (locatedTemplate != null)
                    {
                        locatedTemplate = "/screens" + locatedTemplate;
                    }
                    logger.debug("JSPViewProcessor - located screen template: " + locatedTemplate);
                } */

                JspService service = (JspService) ServiceUtil.getServiceByName(JspService.SERVICE_NAME);

                // this is only necessary if we don't run in a JSP page environment
                // but better be safe than sorry...
                service.addDefaultObjects(data);

                // handle request
                service.handleRequest(data, locatedTemplate);

            }
            else
            {
                // Build parameter list to be passed with the jsp
                Iterator names = portlet.getPortletConfig().getInitParameterNames();
                while (names.hasNext())
                {
                    String name = (String) names.next();
                    String value = (String) portlet.getPortletConfig().getInitParameter(name);
                    data.getParameters().setString(name, value);
                }

                template = pe.getURL();

                if (logger.isDebugEnabled())
                {
                    logger.debug("JSPViewProcessor - serving jsp directly using: " + template);
                }

                // get the RequestDispatcher for the JSP
                RequestDispatcher dispatcher = data.getServletContext().getRequestDispatcher(template);
                data.getOut().flush();
                dispatcher.include(data.getRequest(), data.getResponse());
            }

        }
        catch (Exception e)
        {
View Full Code Here

    public int doStartTag() throws JspException
    {
        String template = defaultTemplate;
        String module   = null;

        RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
        try
       
            /* LOGGED_IN */
            if ( (data != null) && (data.getUser() != null) && data.getUser().hasLoggedIn() && (loggedInTemplate != null) )
              template = loggedInTemplate;

            data.getTemplateInfo().setNavigationTemplate(
                        TemplateLocator.locateNavigationTemplate(data,template));

            pageContext.getOut().flush();
            module = ((TemplateService)TurbineServices.getInstance().getService(
            TemplateService.SERVICE_NAME)).getNavigationName(template);
            NavigationLoader.getInstance().exec(data, module);
        }
        catch (Exception e)
        {
            String message = "Error processing navigation template:" + template + " using module: " + module;
            logger.error(message, e);
            try
            {
                data.getOut().print("Error processing navigation template: " + template + " using module: " + module);
            }
            catch(java.io.IOException ioe) {}   
        }
        return SKIP_BODY;
    }
View Full Code Here

        this.action = action;
    }

    public int doStartTag() throws JspException
    {
        RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);   
       
        TemplateLink uri = new TemplateLink( data );
        if ( template != null ) uri.setPage( template );
        if ( screen != null ) uri.setScreen( screen );
        if ( action != null ) uri.setAction( action );

        try
        {
            if (uri != null) {
                pageContext.getOut().print(uri.toString());
            }
        }
        catch (Exception e)
        {
            String message = "Error processing DynamicUriTag, parameter: screen='"+ screen + "', action='" +action +"'";
            logger.error(message, e);
            try
            {
                data.getOut().print( message );
            }
            catch(java.io.IOException ioe) {}   
        }
      
        return EVAL_BODY_INCLUDE;
View Full Code Here

        this.type = type;
    }

    public int doStartTag() throws JspException
    {
        RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);   

        try
        {          
            String result = null;

            /* HOME */
            if (type.equalsIgnoreCase( "Home" )) {
              result = URILookup.getURI(URILookup.TYPE_HOME, URILookup.SUBTYPE_NONE, data);
           

            /* LOGIN */
            if (type.equalsIgnoreCase( "Login" )) {
              result = URILookup.getURI(URILookup.TYPE_LOGIN, URILookup.SUBTYPE_NONE, data);
           

            /* ENROLLMENT */
            if (type.equalsIgnoreCase( "Enrollment" )) {
              result = URILookup.getURI(URILookup.TYPE_ENROLLMENT, URILookup.SUBTYPE_NONE, data);
           

            /* LOGOUT */
            if (type.equalsIgnoreCase( "Logout" )) {
              result = URILookup.getURI(URILookup.TYPE_HOME, URILookup.SUBTYPE_LOGOUT, data);
           

            /* CUSTOMIZE */
            if (type.equalsIgnoreCase( "Customize") ) {
              result = URILookup.getURI(URILookup.TYPE_CUSTOMIZE, URILookup.SUBTYPE_NONE, data);
           

            /* EDIT ACCOUNT */
            if (type.equalsIgnoreCase( "EditAccount" )) {
              result = URILookup.getURI(URILookup.TYPE_EDIT_ACCOUNT, URILookup.SUBTYPE_NONE, data);
           

            /* APPLICATIONS */
            if (type.equalsIgnoreCase( "Applications" )) {
              PortletEntry entry = null;
              entry = (PortletEntry)Registry.getEntry( Registry.PORTLET, "Applications" );
              result = PortletURIManager.getPortletMaxURI( entry, data ).toString();
           

            /* BASE URL */
            if (type.equalsIgnoreCase( "BaseURL" )) {
              result = URILookup.getWebAppBaseDirURI( data );
            }  

            if (result != null) {
              pageContext.getOut().print(result);
            } else {
              throw new Exception( "jetspeed-URILookup tag: Unknown parameter!");
            }
        }
        catch (Exception e)
        {
            String message = "Error processing uriLookup-tag, parameter: "+ type;
            logger.error(message, e);
            try
            {
                data.getOut().print( "Error processing uriLookup-tag, parameter: "+ type);
            }
            catch(java.io.IOException ioe) {}   
        }
        return EVAL_BODY_INCLUDE;
    }
View Full Code Here

TOP

Related Classes of org.apache.turbine.util.RunData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.