Package javax.portlet

Examples of javax.portlet.PortletSession


   
    protected void createSessionObject(PortletRequest request, Object applObj)
    {
        try {
            // createSessionObject
            PortletSession portletSession = request.getPortletSession(false);
            if (portletSession==null ||  portletSession.getAttribute( WebSession.SESSION_NAME)==null)
            {
                Object session = createObject(sessionClassName);
                portletSession = request.getPortletSession(true);
                // Call init() if Session Object implements IWebSession
                if (session instanceof WebSession)
                {
                    ((WebSession)session).init( new PortletSessionWrapper(portletSession), applObj );
                }
                else
                    log.warn("Session object does not implement IWebSession!");
                // Save Session
                portletSession.setAttribute( WebSession.SESSION_NAME , session);
            }
        } catch(Exception e) {
            // Error 
            log.error("Failed to create session [" + sessionClassName + "] msg= " + e.getMessage());
        }   
View Full Code Here


        super(service);
    }

    public PortletSession getPortletSession() {
        WrappedSession wrappedSession = getSession();
        PortletSession session = ((WrappedPortletSession) wrappedSession)
                .getPortletSession();
        return session;
    }
View Full Code Here

                String contentType = portletRequest.getProperty("Content-Type");

                String characterEncoding = lookupCharacterEncoding(contentType);

                if (characterEncoding == null) {
                    PortletSession session = portletRequest.getPortletSession(false);

                    if (session != null) {
                        characterEncoding = (String) session.getAttribute(ViewHandler.CHARACTER_ENCODING_KEY,
                                                                          PortletSession.PORTLET_SCOPE);
                    }

                    if (characterEncoding != null) {
                        actionRequest.setCharacterEncoding(characterEncoding);
View Full Code Here

        _portletRequest = portletRequest;
    }

    protected Object getAttribute(String key)
    {
        PortletSession portletSession = getSession();
        return (portletSession == null)
            ? null : portletSession.getAttribute(key.toString(), PortletSession.PORTLET_SCOPE);
    }
View Full Code Here

        _portletRequest.getPortletSession(true).setAttribute(key, value, PortletSession.PORTLET_SCOPE);
    }

    protected void removeAttribute(String key)
    {
        PortletSession portletSession = getSession();
        if (portletSession != null)
        {
            portletSession.removeAttribute(key, PortletSession.PORTLET_SCOPE);
        }
    }
View Full Code Here


    /** {@inheritDoc} */
    @SuppressWarnings("unchecked")
    public boolean equals(Object o) {
        PortletSession otherSession = ((PortletSessionScopeMap) o).session;
        boolean retValue = true;
        synchronized (session) {
            for (Enumeration<String> attribs = session.getAttributeNames(); attribs
                    .hasMoreElements()
                    && retValue;) {
                String attributeName = attribs.nextElement();
                retValue = session.getAttribute(attributeName).equals(
                        otherSession.getAttribute(attributeName));
            }
        }

        return retValue;
    }
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

            LOG.debug("Max inactive interval is set to portlet session: "
                + "portlet session should have expired "
                + "(current time millis: "
                + System.currentTimeMillis() + ")...");
          }
            PortletSession session = request.getPortletSession(false);
            if (session == null) {
              result.setReturnCode(TestResult.PASSED);
            } else {
              result.setReturnCode(TestResult.FAILED);
              result.setResultMessage("PortletSession should have expired "
                  + "and have been invalidated, but is still available. "
                  + "Make sure that other portlets did not create a new "
                  + "portlet session.");
            }
        }
       
        // If the max inactive interval is not set to portlet session, set its
        //   value to 5 (seconds). In this way, next time the test portlet is
        //   rendered, the portlet session should have been invalidated.
        else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Max inactive interval is not set to portlet session: "
                + "setting to 5 seconds (current time millis: "
                + System.currentTimeMillis() + ")...");
          }
            PortletSession session = request.getPortletSession(true);
            session.setMaxInactiveInterval(5);
            result.setReturnCode(TestResult.WARNING);
            result.setResultMessage("Click the provided link to validate test.");
        }
       
        // Return the test result:
View Full Code Here

        if (test != null && test instanceof ActionTest) {
            TestResults results = test.doTest(getPortletConfig(),
                                              getPortletContext(),
                                              request,
                                              response);
            PortletSession session = request.getPortletSession();
            session.setAttribute(test.getClass().getName(), results);
        }
       
        Map renderParameters = null;
        if (test != null) {
            renderParameters = test.getRenderParameters(request);
View Full Code Here

                                              response);
            request.setAttribute("results", results);
        }
        // For ActionTest, retrieve results from session and save in request.
        else if (test != null) {
            PortletSession session = request.getPortletSession();
            TestResults results = (TestResults) session.getAttribute(
                test.getClass().getName());
            request.setAttribute("results", results);
        }
       
       
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.