Package org.apache.jetspeed.request

Examples of org.apache.jetspeed.request.RequestContext


    }
   
    public void serviceNavsPipeline(RunData data, String entityId)
    {       
        RequestContextComponent contextComponent = null;
        RequestContext context = null;
        try
        {
            HttpServletRequest request = data.getRequest();
            HttpServletResponse response =  data.getResponse();
            ServletConfig config = data.getServletConfig();
            Engine engine = Jetspeed.getEngine();
            contextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
            context = (RequestContext) data.getRequest().getAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE);
            if (context == null)
            {
                context = contextComponent.create(request, response, config);
                data.getRequest().setAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE, context);               
            }
           
            context.setAttribute(PortalReservedParameters.PORTLET_ENTITY, entityId);
            context.setAttribute(PortalReservedParameters.PIPELINE, FusionResources.NAVS_PIPELINE);
            engine.service(context);         
        }
        catch (Throwable t)
        {
            t.printStackTrace();           
View Full Code Here


    public ConcreteElement service(RunData data, String entityId)
    {
        String result = "";
       
        RequestContextComponent contextComponent = null;
        RequestContext context = null;
        try
        {
            HttpServletRequest request = data.getRequest();
            HttpServletResponse response =  data.getResponse();
            ServletConfig config = data.getServletConfig();
            Engine engine = Jetspeed.getEngine();
            contextComponent = (RequestContextComponent)Jetspeed.getComponentManager().getComponent(RequestContextComponent.class);
           
            context = (RequestContext) data.getRequest().getAttribute(FUSION_NAV_STATE);
            if (context == null)
            {
                context = contextComponent.create(request, response, config);
                data.getRequest().setAttribute(JetspeedFusionPortlet.FUSION_NAV_STATE, context);                               
            }
            context.setAttribute(PortalReservedParameters.PORTLET_ENTITY, entityId);
            context.getRequest().removeAttribute(PortalReservedParameters.PIPELINE);
           
            engine.service(context);
           
        }
        catch (Throwable t)
View Full Code Here

   
    public MutableNavigationalState getNavigationalState(JetspeedRunData data)
    {
        NavigationalState ns = null;
        RequestContext context = (RequestContext) data.getRequest().getAttribute(FUSION_NAV_STATE);
        if (context != null)
        {
            PortalURL url = context.getPortalURL();
            if (url != null)
                ns = url.getNavigationalState();
        }
        return (MutableNavigationalState)ns;
    }
View Full Code Here

                                       JetspeedRunData data,
                                       int mode,
                                       PortletInstance instance)
    {
        MutableNavigationalState nav = getNavigationalState(data);
        RequestContext context = (RequestContext) data.getRequest().getAttribute(FUSION_NAV_STATE);       
        if (null == nav)
        {
            return;
        }
           
View Full Code Here

     * Render the specified Page fragment. Result is returned in the
     * PortletResponse.
     */
    public void renderNow( ContentFragment fragment, HttpServletRequest request, HttpServletResponse response )
    {
        RequestContext requestContext = (RequestContext) request
                .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
        renderNow(fragment, requestContext);
    }
View Full Code Here

     * Helper for admin portlets to generate portal urls
     */
    public String getPortalURL(PortletRequest request, PortletResponse response, String path)
    {
        // get internal request context
        RequestContext context = (RequestContext)
            request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
        String baseUrl = context.getPortalURL().getBaseURL();
        String basePath = context.getPortalURL().getBasePath();
        if (basePath != null && basePath.endsWith("/action"))
        {
            basePath = basePath.replace("/action", "/desktop");
        }
        String jetspeedPath = AdminUtil.concatenatePaths(baseUrl, basePath);
View Full Code Here

     */
    private PortalSiteRequestContext getMockPortalSiteRequestContext(User user, Locale locale, String serverName) throws Exception
    {
        // setup profiler and portal site to determine template
        // folders paths generate mock request for new user to profile
        RequestContext request = new MockRequestContext("/");
        request.setSubject(userManager.getSubject(user));
        request.setLocale((locale != null) ? locale : Locale.getDefault());
        MockHttpServletRequest servletRequest = new MockHttpServletRequest();
        if (serverName != null)
        {
            servletRequest.setServerName(serverName);
        }
        request.setRequest(servletRequest);

        // get profile locators map for new user request, (taken from
        // ProfilerValveImpl)
        Map locators = profiler.getProfileLocators(request , user);
        if (locators.size() == 0)
View Full Code Here

        {
            if (windowId == null || portletUniqueName == null)
            {
                throw new IllegalArgumentException("Parameter windowId and portletUniqueName are both required");
            }
            RequestContext context = getRequestContext();
            PortletWindow window = context.getPortletWindow(windowId);
            if (window == null)
            {
                window = context.getInstantlyCreatedPortletWindow(windowId, portletUniqueName);
            }
            if (window.isValid())
            {
                PortletWindow currentPortletWindow = context.getCurrentPortletWindow();
                try
                {
                    context.setCurrentPortletWindow(window);
                    renderer.renderNow(window.getFragment(), context);
                    return window.getFragment().getRenderedContent();
                }
                finally
                {
                    context.setCurrentPortletWindow(currentPortletWindow);
                }
            }
            else
            {
                return "";
View Full Code Here

        return this.ajaxCustomization;
    }

    public Map<String,String> getUserAttributes()
    {
        RequestContext rc = getRequestContext();
        Map<String,String> map = null;
        Principal principal = rc.getRequest().getUserPrincipal();
        if (principal instanceof UserSubjectPrincipal)
        {
            UserSubjectPrincipal jp = (UserSubjectPrincipal)principal;
            map = jp.getUser().getInfoMap();
        }
View Full Code Here

     * @param ctx  VelocityContext to fill
     * @return Velocity Template object or null
     */
    protected Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context ctx) throws Exception
    {
        RequestContext requestContext = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
        if(requestContext == null)
        {
            throw new IllegalStateException("JetspeedVelocityViewServlet unable to handle request because there is no RequestContext in "+
                   "the HttpServletRequest.");
        }
       
        // hook up eventHandlers to the context, specifically our own IgnoringNullSetEventHandling
        eventCartridge.attachToContext(ctx);
       
        JetspeedDesktopContext desktopContext = (JetspeedDesktopContext)request.getAttribute(JetspeedDesktopContext.DESKTOP_CONTEXT_ATTRIBUTE);
        if (desktopContext != null)
        {
            // standard render request and response also available in context
            ctx.put(JetspeedDesktopContext.DESKTOP_CONTEXT_ATTRIBUTE, desktopContext);
            ctx.put("JS2RequestContext", requestContext);
           
            // setup TLS for Context propagation
            handlingRequestContext.set(ctx);           
            return super.handleRequest(request, response, ctx);           
        }
        // configure velocity context
        PortletRequest renderRequest = (PortletRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
        RenderResponse renderResponse = (RenderResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
        PortletConfig portletConfig = (PortletConfig) request.getAttribute(ContainerConstants.PORTLET_CONFIG);
        if (renderRequest != null)
        {
            renderRequest.setAttribute(VELOCITY_CONTEXT_ATTR, ctx);
        }
               
        JetspeedVelocityPowerTool jpt = (JetspeedVelocityPowerTool) renderRequest.getAttribute(PortalReservedParameters.JETSPEED_POWER_TOOL_REQ_ATTRIBUTE);
        if(jpt == null)
        {
            throw new IllegalStateException("JetspeedVelocityViewServlet unable to handle request because there is no JetspeedPowerTool in "+
                   "the HttpServletRequest.");
        }
       
        jpt.setVelocityContext(ctx);
        ctx.put("jetspeed", jpt)
        ctx.put("JS2RequestContext", requestContext);
        ctx.put("renderRequest", renderRequest);
        ctx.put("renderResponse", renderResponse);
        ctx.put("portletConfig", portletConfig);
        ctx.put("portletModeView", PortletMode.VIEW);
        ctx.put("portletModeEdit", PortletMode.EDIT);
        ctx.put("portletModeHelp", PortletMode.HELP);
        ctx.put("windowStateNormal", WindowState.NORMAL);
        ctx.put("windowStateMinimized", WindowState.MINIMIZED);
        ctx.put("windowStateMaximized", WindowState.MAXIMIZED);
        ctx.put("rco", requestContext.getObjects());
        StringBuffer appRoot = new StringBuffer();
        if (!requestContext.getPortalURL().isRelativeOnly())
        {
            appRoot.append(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getServerPort());
        }
        appRoot.append(renderRequest.getContextPath());
        ctx.put("appRoot", appRoot.toString());       
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.request.RequestContext

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.