Package org.apache.jetspeed.container

Examples of org.apache.jetspeed.container.PortletWindow


    throws PortletAccessDeniedException
    {
        RenderingJob job = null;
        try
        {
            PortletWindow portletWindow = requestContext.getPortletWindow(fragment);
            if (!portletWindow.isValid())
            {
                return null;
            }
            PortletDefinition portletDefinition = portletWindow.getPortletDefinition();    

            long timeoutMetadata = this.getTimeoutOnJob(portletDefinition);
            portletTracking.setExpiration(portletWindow, timeoutMetadata);           
           
            if (checkSecurityConstraints && !checkSecurityConstraint(portletDefinition, fragment))
            {
                throw new PortletAccessDeniedException("Access Denied.");
            }
            if (portletTracking.isOutOfService(portletWindow))
            {
                log.info("Taking portlet out of service: " + portletDefinition.getUniqueName() + " for window " + portletWindow.getId());
                fragment.overrideRenderedContent(OUT_OF_SERVICE_MESSAGE);
                return null;
            }
            int expirationCache = getExpirationCache(portletDefinition);
            if (expirationCache != 0)
View Full Code Here


        WorkerMonitor monitor = new WorkerMonitorImpl(1, 2, 1, 1);
       
        List jobs = new ArrayList(JOB_COUNT);
        for (int ix = 0; ix < JOB_COUNT; ix++)
        {
            PortletWindow window = new MockPortletWindow("w" + String.valueOf(ix));      
            jobs.add(new MockRenderJob("Job-" + (ix + 1), 4000, window));
        }
        assertNotNull("monitor is null", monitor);
        monitor.start();
        for (int ix = 0; ix < JOB_COUNT; ix++)
View Full Code Here

        portalURL.setCharacterEncoding("UTF-8");
        MockRequestContext requestContext = new MockRequestContext();
        requestContext.setRequest(request);
        portalURL.getNavigationalState().sync(requestContext);

        PortletWindow window = new MockPortletWindow("111");

        HashMap<String,String[]> parameters = new HashMap<String, String[]>();
        parameters.put("test",new String[]{"one","two","three"});

        Map<String, String[]> privateRenderParameters = Collections.emptyMap();
View Full Code Here

    protected void doTestUrl(PortalURL portalURL, HttpServletRequest request)
    {
        portalURL.setRequest(request);
        portalURL.setCharacterEncoding("UTF-8");
       
        PortletWindow window = new MockPortletWindow("111");
        NavigationalState nav = portalURL.getNavigationalState();
        MockRequestContext requestContext = new MockRequestContext();
        requestContext.addPortletWindow(window);
        requestContext.setRequest(request);
        nav.sync(requestContext);
       
        // Check that they come out correctly
        assertTrue("window mode is not set", nav.getMode(window).equals(PortletMode.EDIT));
        assertTrue("window state is not set", nav.getState(window).equals(WindowState.MAXIMIZED));
        PortletWindow target = nav.getPortletWindowOfAction();
        assertNotNull("target window is null", target);
        assertEquals("target window should equal window 111", target.getId().getStringId(), "111");
       
        PortletWindow maximizedWindow = nav.getMaximizedWindow();
        assertNotNull("maximized window is null", maximizedWindow);
        assertEquals("maximized window should equal window 111", maximizedWindow.getId().getStringId(), "111");
       
        Map<String,String[]> parameters = nav.getParameterMap(target);
        assertTrue("There should be one parameter",parameters.size()==1);
        String[] values = parameters.get("test");
        assertNotNull("parameter name has no values", values);
View Full Code Here

        this.requestDispatcherService = requestDispatcherService;
    }
   
    public ServletContext getServletContext(GenericPortlet portlet)
    {
        PortletWindow window = Jetspeed.getCurrentRequestContext().getCurrentPortletWindow();
       
        ServletContext servletContext = (ServletContext)window.getAttribute(SERVLET_CONTEXT);
        if (servletContext == null)
        {
            servletContext = ServletContextProxy.createProxy(((JetspeedPortletContext)portlet.getPortletContext()).getServletContext(), portlet.getPortletContext());
            window.setAttribute(SERVLET_CONTEXT, servletContext);
        }
        return servletContext;
    }
View Full Code Here

        return servletContext;
    }

    public HttpServletRequest getHttpServletRequest(GenericPortlet portlet, PortletRequest request)
    {       
        PortletWindow window = Jetspeed.getCurrentRequestContext().getCurrentPortletWindow();
        HttpServletRequest req = (HttpServletRequest)window.getAttribute(SERVLET_REQUEST);
        if (req == null)
        {
            PortletRequestContext rc = window.getPortletRequestContext();
            req = requestDispatcherService.getRequestWrapper(rc.getServletContext(),
                                                             rc.getServletRequest(),
                                                             request,
                                                             null,
                                                             true,
                                                             false);
            req.setAttribute(ContainerConstants.PORTLET_CONFIG, rc.getPortletConfig());
            req.setAttribute(ContainerConstants.PORTLET_REQUEST, window.getPortletRequest());
            req.setAttribute(ContainerConstants.PORTLET_RESPONSE, window.getPortletResponse());
            window.setAttribute(SERVLET_REQUEST, req);
        }
        return req;
    }
View Full Code Here

        return req;
    }

    public HttpServletResponse getHttpServletResponse(GenericPortlet portlet, PortletResponse response)
    {
        PortletWindow window = Jetspeed.getCurrentRequestContext().getCurrentPortletWindow();
        HttpServletResponse res = (HttpServletResponse)window.getAttribute(SERVLET_RESPONSE);
        if (res == null)
        {
            boolean included = window.getAttribute(PortalReservedParameters.PORTLET_CONTAINER_INVOKER_USE_FORWARD) == null;
            PortletRequestContext rc = window.getPortletRequestContext();
            res = requestDispatcherService.getResponseWraper(rc.getServletContext(),
                                                             rc.getServletResponse(),
                                                             window.getPortletRequest(),
                                                             response,
                                                             included);
            if (PortletWindow.Action.RENDER == window.getAction() && !included)
            {
                res = new HttpServletPortletResourceResponseWrapper(res);
            }
            window.setAttribute(SERVLET_RESPONSE, res);
        }
        return res;
    }
View Full Code Here

              if ( pageActionAccess == null )
              {
                throw new Exception( "cannot change action for root layout fragment due to null PageActionAccess object" );
              }
              //pageActionAccess.
              PortletWindow window = requestContext.getPortletWindow(fragment);
              if (!window.isValid())
              {
                  throw new Exception("Failed to retrieve Portlet Definition for: "+ fragment.getId() + ", " + fragment.getName());
              }
              PortletMode currentMode = requestContext.getPortalURL().getNavigationalState().getMode( window );
              WindowState currentState = requestContext.getPortalURL().getNavigationalState().getState( window );
             
              boolean requestedModeAlreadySet = false;
              if ( requestedMode == null )
              {
                requestedModeAlreadySet = true;
              }
              else
              {
                if ( requestedMode.equals( PortletMode.EDIT.toString() ) )
                {
                  if( pageActionAccess.isEditing() )
                    requestedModeAlreadySet = true;
                  else
                  {
                    if ( pageActionAccess.isEditAllowed())
                    {
                      pageActionAccess.setEditing( true );
                      resultMap.put(STATUS, status);
                      resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
                      resultMap.put(PORTLET_MODE, requestedMode);
                    }
                    else
                    {
                      throw new Exception( "permissions do no allow page edit" );
                    }
                  }
                }
                else if ( requestedMode.equals( PortletMode.VIEW.toString() ) )
                {
                  pageActionAccess.setEditing( false );
                  //if ( currentMode.equals( PortletMode.HELP ) )
                  resultMap.put(STATUS, status);
                  resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
                  resultMap.put(PORTLET_MODE, requestedMode);
                }
                else
                {
                  requestedModeAlreadySet = true;
                }
              }
              if ( requestedModeAlreadySet )
              {
                 resultMap.put(STATUS, status);
                 resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
                 resultMap.put(PORTLET_MODE, currentMode.toString());
               }
            }
            else
            {
              if (requestedState == null && requestedMode == null)
              {
                  throw new Exception("portlet window state or mode not provided");
              }          
              if (requestedState != null && !isValidWindowState(requestedState))
              {
                  throw new Exception("portlet window state " + requestedState + " is not supported");
              }
              if (requestedMode != null && !isValidPortletMode(requestedMode))
              {
                  throw new Exception("portlet mode " + requestedMode + " is not supported");
              }
 
             
              String oldState = fragment.getState();
              String oldMode = fragment.getMode();
             
              // Now Change the transient navigational state
              MutableNavigationalState navState = (MutableNavigationalState)requestContext.getPortalURL().getNavigationalState();
              PortletWindow portletWindow = requestContext.getPortletWindow(fragment);
              if (portletWindow != null)
              {
                  oldState = navState.getState(portletWindow).toString();
                  oldMode =  navState.getMode(portletWindow).toString();
                  if (requestedState != null)
View Full Code Here

    {    
        boolean responseCommitted = false;
        boolean failure = false;
        try
        {           
            PortletWindow actionWindow = request.getActionWindow();
            if (actionWindow != null)
            {
                HttpServletRequest servletRequest = request.getRequest();
                HttpServletResponse serlvetResponse = request.getResponse();
               
                actionWindow.setAttribute("JETSPEED_ACTION", request);
                container.doAction(actionWindow,servletRequest,serlvetResponse);
                // The container redirects the client after PortletAction processing
                // so there is no need to continue the pipeline
               
                // clear the cache for all portlets on the current page
View Full Code Here

           
            try
            {
                if (log.isWarnEnabled())
                {
                    PortletWindow window = job.getWindow();
                    log.warn("Portlet Rendering job to be interrupted by timeout (" + job.getTimeout() + "ms)" + (window != null ? ": "+window.getId().getStringId() : ""));
                }

                PortletContent content = job.getPortletContent();
                Thread worker = (Thread) job.getWorkerAttribute(WORKER_THREAD_ATTR);
               
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.container.PortletWindow

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.