Package javax.portlet

Examples of javax.portlet.PortletSession


    @Override
    protected boolean isValid(String value, UIFormInput uiInput) {
        PortletRequestContext ctx = PortletRequestContext.getCurrentInstance();
        PortletRequest req = ctx.getRequest();
        PortletSession session = req.getPortletSession();

        Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);

        return ((captcha != null) && (captcha.isCorrect(value)));
    }
View Full Code Here


    }

    private void endApplication(PortletRequest request,
            PortletResponse response, Application application)
            throws IOException {
        final PortletSession session = request.getPortletSession();
        if (session != null) {
            PortletApplicationContext2.getApplicationContext(session)
                    .removeApplication(application);
        }
        // Do not send any redirects when running inside a portlet.
View Full Code Here

    private Application getExistingApplication(PortletRequest request,
            boolean allowSessionCreation) throws MalformedURLException,
            SessionExpiredException {

        final PortletSession session = request
                .getPortletSession(allowSessionCreation);

        if (session == null) {
            throw new SessionExpiredException();
        }
View Full Code Here

    protected void writeAjaxWindow(RenderRequest request,
            RenderResponse response) throws IOException {

        response.setContentType("text/html");
        if (app != null) {
            PortletSession sess = request.getPortletSession();
            PortletApplicationContext ctx = PortletApplicationContext
                    .getApplicationContext(sess);

            PortletRequestDispatcher dispatcher = sess.getPortletContext()
                    .getRequestDispatcher("/" + app);

            try {
                // portal-wide settings
                PortalContext portalCtx = request.getPortalContext();
View Full Code Here

   * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
   */
  public int doEndTag() throws JspException {
    // get the ContentRenderer
    RenderRequest renderRequest = getRenderRequest();
    PortletSession session = renderRequest.getPortletSession();

    ContentRenderer renderer = (ContentRenderer) renderRequest.getAttribute(RENDERER_PARAM);
    PLinkReplacer pLinkReplacer = (PLinkReplacer) renderRequest.getAttribute(PLINK_PARAM);
    CRConfigUtil crConf = (CRConfigUtil) renderRequest.getAttribute(CRCONF_PARAM);

    try {
      if (object != null) {
        try {
          String content = renderer.renderContent(object, contentAttribute, true, pLinkReplacer, false, null);

          /* Get the ContentPostProcessor-Config from the PortletSession or instance it from the Config */
          @SuppressWarnings("unchecked")
          ConcurrentHashMap<String, ContentPostProcesser> confs = (ConcurrentHashMap<String, ContentPostProcesser>) session
              .getAttribute(SESSION_KEY_CONTENTPOSTPROCESSOR_CONF, PortletSession.APPLICATION_SCOPE);
          if (confs == null) {
            confs = ContentPostProcesser.getProcessorTable(crConf);
            if (confs != null) {
              session.setAttribute(
                SESSION_KEY_CONTENTPOSTPROCESSOR_CONF,
                confs,
                PortletSession.APPLICATION_SCOPE);
              logger.debug("Put ContentPostProcessor config into session of " + crConf.getName() + "!");
            }
View Full Code Here

     * Restore attributes from the PortletSession.
     * @param request The portletRequest
     */
    public void restoreAttributes(PortletRequest request)
    {
        PortletSession portletSession = request.getPortletSession();
        ArrayList attributes = (ArrayList)portletSession.getAttribute(name);
        if ( attributes != null )
        {
            for ( int size = attributes.size(), i = size - 1 ; i > -1; i-- )
            {
                AttributeValue attributeValue = (AttributeValue)attributes.get(i);
                if ( attributeValue == null )
                {
                    if ( i == 0 )
                    {
                        portletSession.removeAttribute(name);
                    }
                    else
                    {
                        // remove this and previously retrieved attributeValues as being temporarily
                        while (size > i )
View Full Code Here

        boolean actionRequest = ACTION_REQUEST.equals(requestType);
       
        // save requestType early so getStrutsPageURL and getStrutsOrigURL can determine the type
        req.setAttribute(StrutsPortlet.REQUEST_TYPE, requestType);
       
        PortletSession portletSession = request.getPortletSession();
       
        try
        {
            StrutsPortletErrorContext errorContext = (StrutsPortletErrorContext) portletSession.getAttribute(StrutsPortlet.ERROR_CONTEXT);
            if (errorContext != null)
            {
                if (!actionRequest)
                {
                    portletSession.removeAttribute(StrutsPortlet.ERROR_CONTEXT);
                    renderError(res, errorContext);
                }
                return;
            }

            String keepRenderAttributes = null;
           
            if ( !actionRequest )
            {
                keepRenderAttributes = getKeepRenderAttributes(request);
            }
            if ( keepRenderAttributes == null )
            {
                strutsPortletConfig.getRenderContextAttributes().clearAttributes(portletSession);
            }
            else
            {
                strutsPortletConfig.getRenderContextAttributes().restoreAttributes(request);
            }
                               
            String path = null;
            String pageURL = getStrutsPageURL(request);
           
            if (pageURL == null)
            {
                path = defaultPage;
            }
            else
            {
                path = pageURL;
            }
            if ( !actionRequest )
            {
                // restore possible render context from the session and store it as request attribute for the StrutsServlet to be able to find it
                StrutsPortletRenderContext renderContext = (StrutsPortletRenderContext)portletSession.getAttribute(RENDER_CONTEXT);
                if ( renderContext != null )
                {                       
                    portletSession.removeAttribute(RENDER_CONTEXT);
                    req.setAttribute(RENDER_CONTEXT, renderContext);
                }
            }

            if (log.isDebugEnabled())
                log.debug("process path: " + path + ", requestType: " + requestType);

            RequestDispatcher rd = servletContext.getRequestDispatcher(path);
            if (rd != null)
            {
                if (actionRequest)
                {
                    res = new EmptyHttpServletResponseWrapper(res);
                   
                    // http://issues.apache.org/jira/browse/PB-2:
                    // provide servlet access to the Portlet components even from
                    // an actionRequest in extension to the JSR-168 requirement
                    // PLT.16.3.2 which (currently) only covers renderRequest
                    // servlet inclusion.
                    if ( req.getAttribute("javax.portlet.config") == null )
                    {
                        req.setAttribute("javax.portlet.config", getPortletConfig());
                    }
                    if ( req.getAttribute("javax.portlet.request") == null )
                    {
                        req.setAttribute("javax.portlet.request", request);
                    }
                    if ( req.getAttribute("javax.portlet.response") == null )
                    {
                        req.setAttribute("javax.portlet.response", response);
                    }
                    String origin = getStrutsOriginURL(request);
                    if ( origin == null )
                    {
                        origin = defaultPage;
                    }
                    request.setAttribute(StrutsPortlet.ORIGIN_URL, origin);                   
                }
                if (path != null)
                {
                    req.setAttribute(StrutsPortlet.PAGE_URL, path);
                }
               
                HttpSession proxiedSession = null;
                if ( portletScopeStrutsSession )
                {
                    proxiedSession = (HttpSession)portletSession.getAttribute(SERVLET_PORTLET_SESSION_PROXY);
                    if (proxiedSession == null)
                    {
                        proxiedSession = ServletPortletSessionProxy.createProxy(req);
                        portletSession.setAttribute(SERVLET_PORTLET_SESSION_PROXY, proxiedSession);
                    }
                }
                req.setAttribute(SERVLET_PORTLET_APPLICATION_SESSION, req.getSession());
                try
                {
                    rd.include(new PortletServletRequestWrapper(servletContext, req, proxiedSession), res);
                }
                catch (ServletException e)
                {
                    if (log.isErrorEnabled())
                        log.error("Include exception", e);
                    errorContext = new StrutsPortletErrorContext();
                    errorContext.setError(e);
                    req.setAttribute(StrutsPortlet.ERROR_CONTEXT, errorContext);
                    if (!actionRequest)
                        renderError(res, errorContext);
                }
                if (actionRequest)
                {
                    String renderURL;
                    if (req.getAttribute(StrutsPortlet.ERROR_CONTEXT) != null)
                    {
                        pageURL = StrutsPortletURL.getOriginURL(req);
                        if ( pageURL != null )
                        {   
                          ((ActionResponse) response).setRenderParameter(StrutsPortletURL.PAGE+request.getPortletMode().toString(), pageURL);
                        }
                        if (log.isDebugEnabled())
                            log.debug("action render error context");
                        try
                        {
                            portletSession.setAttribute(StrutsPortlet.ERROR_CONTEXT,req.getAttribute(StrutsPortlet.ERROR_CONTEXT));
                        }
                        catch (IllegalStateException ise)
                        {
                            // catch Session already invalidated exception
                            // There isn't much we can do here other than
                            // redirecting the user to the start page
                        }
                    }
                    else
                    {
                        if ((renderURL = (String) req
                                .getAttribute(StrutsPortlet.REDIRECT_URL)) != null)
                        {
                            if (log.isDebugEnabled())
                                log.debug("action send redirect: " + renderURL);
                            ((ActionResponse) response).sendRedirect(renderURL);
                        }
                        else
                        {
                            try
                            {
                                strutsPortletConfig.getRenderContextAttributes().saveAttributes(request);
                            }
                            catch (IllegalStateException ise)
                            {
                                // catch Session already invalidated exception
                                // There isn't much we can do here other than
                                // redirecting the user to the start page
                                return;
                            }
                            StrutsPortletRenderContext renderContext = (StrutsPortletRenderContext)req.getAttribute(RENDER_CONTEXT);
                            if ( renderContext != null )
                            {
                                portletSession.setAttribute(RENDER_CONTEXT, renderContext);
                            }
                            ((ActionResponse) response).setRenderParameter(
                                    StrutsPortletURL.KEEP_RENDER_ATTRIBUTES+request.getPortletMode().toString(), "1");

                            if ((renderURL = (String) req
View Full Code Here

     * @throws PortletException
     */
    protected String determineLogicalView(PortletRequest request) throws PortletException
    {       
        String view = null;
        PortletSession session = request.getPortletSession();
        if (request.getPortletMode().equals(PortletMode.VIEW))
        {
            view  = request.getParameter(FrameworkConstants.VIEW_VIEW_MODE);
            if (view == null)
            {
                view = (String)session.getAttribute(FrameworkConstants.VIEW_VIEW_MODE);
                //view = request.getParameter(FrameworkConstants.VIEW_VIEW_MODE);
                if (view == null)
                {
                    view = this.getDefaultViewPage();
                }
            }
        }
        else if (request.getPortletMode().equals(PortletMode.EDIT))
        {
            view  = request.getParameter(FrameworkConstants.VIEW_EDIT_MODE);
            if (view == null)
            {           
                view = (String)session.getAttribute(FrameworkConstants.VIEW_EDIT_MODE);
                //view = request.getParameter(FrameworkConstants.VIEW_EDIT_MODE);
                if (view == null)
                {
                    view = this.getDefaultEditPage();
                }
            }
        }
        else if (request.getPortletMode().equals(PortletMode.HELP))
        {
            view  = request.getParameter(FrameworkConstants.VIEW_HELP_MODE);
            if (view == null)
            {           
                view = (String)session.getAttribute(FrameworkConstants.VIEW_HELP_MODE);
                //view = request.getParameter(FrameworkConstants.VIEW_HELP_MODE);
                if (view == null)
                {
                    view = this.getDefaultHelpPage();
                }
View Full Code Here

        return view;
    }
   
    protected void setLogicalView(PortletRequest request, PortletResponse response, String view, PortletMode newMode)
    {
        PortletSession session = request.getPortletSession();
        if (request.getPortletMode().equals(PortletMode.VIEW))
        {
            session.setAttribute(FrameworkConstants.VIEW_VIEW_MODE, view);               
        }
        else if (request.getPortletMode().equals(PortletMode.EDIT))
        {
            session.setAttribute(FrameworkConstants.VIEW_EDIT_MODE, view);               
        }
        else if (request.getPortletMode().equals(PortletMode.HELP))
        {
            session.setAttribute(FrameworkConstants.VIEW_HELP_MODE, view);               
        }
    }
View Full Code Here

    {
        HttpSession servletSession = request.getSession();
        PortletRequest portletRequest = (PortletRequest) request.getAttribute("javax.portlet.request");
        if (portletRequest != null)
        {
            PortletSession portletSession = portletRequest.getPortletSession();
            servletSession = (HttpSession)createProxy(request, "javax.portlet.p."+PortletWindowUtils.getPortletWindowId(portletSession));
        }
        return servletSession;
    }
View Full Code Here

TOP

Related Classes of javax.portlet.PortletSession

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.