Package org.apache.jetspeed.om.window.impl

Examples of org.apache.jetspeed.om.window.impl.PortletWindowImpl


       
        // create base PortletURL
        PortalURL url = component.createURL(context.getRequest(), context.getCharacterEncoding());
        context.setPortalURL(url);

        PortletWindow window = new PortletWindowImpl("111");
        PortletWindow window2 = new PortletWindowImpl("222");
        PortletWindow window3 = new PortletWindowImpl("333");
        HashMap parameters = new HashMap();
        parameters.put("test",new String[]{"one","two","three"});

        String portletURL = url.createPortletURL(window,parameters,PortletMode.EDIT,WindowState.MAXIMIZED,true,false);
View Full Code Here


        if (found != null)
        {
            return found;
        }
       
        PortletWindowImpl window = new PortletWindowImpl(windowId);
        window.setPortletEntity(entity);
        windows.put(windowId, window);
        return window;       
    }
View Full Code Here

        PortletWindow found = getWindowFromCache(windowId);
        if (found != null)
        {
            return found;
        }       
        PortletWindowImpl window = new PortletWindowImpl(windowId);
        return window;               
    }
View Full Code Here

        return createPortletWindow(fragment, null);
    }
   
    private PortletWindow createPortletWindow(ContentFragment fragment, String principal) throws FailedToCreateWindowException
    {
        PortletWindow portletWindow = new PortletWindowImpl(fragment.getId());
               
        MutablePortletEntity portletEntity = entityAccessor.getPortletEntityForFragment(fragment, principal);
        if (portletEntity == null)
        {
            log.info("No portlet entity defined for fragment ID "+fragment.getId()+" attempting to auto-generate...");
View Full Code Here

    {
        PortletWindow window = null;
        PortletDefinition pd = rcc.getPortletRegistry().getPortletDefinitionByUniqueName(fragment.getName(), true);
        if (pd != null)
        {
            window = new PortletWindowImpl(this, fragment, pd);
        }
        else
        {
            // invalid window: create one anyway so that this error condition is only "recorded" once for this request
            window = new PortletWindowImpl(this, fragment);
            fragment.overrideRenderedContent("Failed to retrieve Portlet Definition for " + fragment.getName());
            log.error(fragment.getOverriddenContent());
        }
        portletWindows.put(window.getWindowId(), window);
        return window;
View Full Code Here

        if (PortletWindow.Action.ACTION != action && PortletWindow.Action.RENDER != action)
        {
            return;
        }
       
        PortletWindowImpl window = (PortletWindowImpl)requestContext.getPortletWindow();
       
        PortletApplication pa = portletDefinition.getApplication();
        pa.setLocalContextPath(portalContext.getContextPath());

        ClassLoader paClassLoader = portletFactory.getPortletApplicationClassLoader(pa);
        PortletInstance portletInstance = portletFactory.getPortletInstance(jetspeedContext, portletDefinition);
       
        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
        try
        {
            PortletResponseContext responseContext = (PortletResponseContext)portletRequest.getAttribute(PortletInvokerService.RESPONSE_CONTEXT);
            ((JetspeedRequestContext)window.getRequestContext()).setCurrentPortletWindow(window);
           
            window.setInvocationState(action, requestContext, responseContext, portletRequest, portletResponse, portletInstance);
            window.setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, window.getFragment());
            window.setAttribute(PortalReservedParameters.PORTLET_WINDOW_ATTRIBUTE, window);
            window.setAttribute(PortalReservedParameters.PORTLET_DEFINITION_ATTRIBUTE, portletDefinition);
           
            // initialize request/response for portletRequestContext
            HttpServletRequest request = requestContext.getContainerRequest();
            HttpServletResponse response = requestContext.getContainerResponse();
           
            request = (HttpServletRequest) requestResponseUnwrapper.unwrapContainerRequest(request);
            response = (HttpServletResponse) requestResponseUnwrapper.unwrapContainerResponse(response);
            requestContext.init(window.getPortletInstance().getConfig(), this.jetspeedContext, request, response);
            window.getPortletResponseContext().init(request, response);
           
            Thread.currentThread().setContextClassLoader(paClassLoader);
           
            if (PortletWindow.Action.ACTION == action)
            {
                ActionRequest actionRequest = (ActionRequest) portletRequest;
                ActionResponse actionResponse = (ActionResponse) portletResponse;

                portletInstance.processAction(actionRequest, actionResponse);
            }
            else // if (PortletWindow.Action.RENDER == action)
            {
                RenderRequest renderRequest = (RenderRequest) portletRequest;
                RenderResponse renderResponse = (RenderResponse) portletResponse;
                renderResponse.setContentType(window.getRequestContext().getMimeType());
                portletInstance.render(renderRequest, renderResponse);
            }
        }
        catch (Throwable t)
        {
            if ( t instanceof UnavailableException )
            {
                // take it out of service
                try
                {
                    portletInstance.destroy();
                }
                catch (Throwable ignore)
                {
                    // never mind, it won't be used anymore
                }
            }
            if ( t instanceof PortletException )
            {
                throw (PortletException)t;
            }
            if ( t instanceof IOException )
            {
                throw (IOException)t;
            }
            else
            {
                throw new PortletException(t);
            }
        }
        finally
        {
            ((JetspeedRequestContext)window.getRequestContext()).setCurrentPortletWindow(null);
            Thread.currentThread().setContextClassLoader(oldLoader);
        }
    }
View Full Code Here

     */
    public void invoke(PortletRequestContext requestContext, PortletRequest portletRequest, PortletResponse portletResponse,
                       PortletWindow.Action action, FilterManager filter)
        throws PortletException, IOException
    {
        PortletWindowImpl window = (PortletWindowImpl)requestContext.getPortletWindow();
        PortletDefinition portletDefinition = window.getPortletDefinition();
        PortletApplication app = portletDefinition.getApplication();

        String appContextPath = app.getContextPath();

        ServletContext appContext = jetspeedContext.getContext(appContextPath);
        if (null == appContext)
        {
            String message = "Failed to find Servlet context for Portlet Application: " + appContextPath;
            log.error(message);
            throw new PortletException(message);
        }
        PortletInstance portletInstance = portletFactory.getPortletInstance(appContext, portletDefinition);
        RequestDispatcher dispatcher = appContext.getRequestDispatcher(servletMappingName);
        if (null == dispatcher)
        {
            String message = "Failed to get Request Dispatcher for Portlet Application: "+appContextPath+", servlet: "+servletMappingName;
            log.error(message);
            throw new PortletException(message);
        }

        boolean useForward = window.getAttribute(PortalReservedParameters.PORTLET_CONTAINER_INVOKER_USE_FORWARD) != null;

        try
        {
            PortletResponseContext responseContext = (PortletResponseContext)portletRequest.getAttribute(PortletInvokerService.RESPONSE_CONTEXT);
            ((JetspeedRequestContext)window.getRequestContext()).setCurrentPortletWindow(window);
            window.setInvocationState(action, requestContext, responseContext, portletRequest, portletResponse, portletInstance);
            window.setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, window.getFragment());
            window.setAttribute(PortalReservedParameters.PORTLET_WINDOW_ATTRIBUTE, window);
            window.setAttribute(PortalReservedParameters.PORTLET_DEFINITION_ATTRIBUTE, portletDefinition);
            window.setAttribute(PortalReservedParameters.PORTLET_FILTER_MANAGER_ATTRIBUTE, filter);

            ServletRequest request = this.requestResponseUnwrapper.unwrapContainerRequest(requestContext.getContainerRequest());
            ServletResponse response = this.requestResponseUnwrapper.unwrapContainerResponse(requestContext.getContainerResponse());
           
            if (useForward)
            {
                dispatcher.forward(request, response);
            }
            else
            {
                dispatcher.include(request, response);
            }
           
        }
        catch (Exception e)
        {
            String message =
                "Failed to dispatch."+(useForward?"forward":"include")+" for Portlet Application: "+appContextPath+", servlet: "+servletMappingName;
            log.error(message, e);
            throw new PortletException(message, e);
        }
        finally
        {
            ((JetspeedRequestContext)window.getRequestContext()).setCurrentPortletWindow(null);
        }
    }
View Full Code Here

    {
        PortletWindow window = null;
        PortletDefinition pd = rcc.getPortletRegistry().getPortletDefinitionByUniqueName(fragment.getName(), true);
        if (pd != null)
        {
            window = new PortletWindowImpl(this, fragment, pd);
        }
        else
        {
            // invalid window: create one anyway so that this error condition is only "recorded" once for this request
            window = new PortletWindowImpl(this, fragment);
            fragment.overrideRenderedContent("Failed to retrieve Portlet Definition for " + fragment.getName());
            log.error(fragment.getOverriddenContent());
        }
        portletWindows.put(window.getWindowId(), window);
        return window;
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.window.impl.PortletWindowImpl

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.