Search in sources :

Example 6 with PortletRequest

use of javax.portlet.PortletRequest in project uPortal by Jasig.

the class PersonLookupHelperImpl method getSelf.

/* (non-Javadoc)
     * @see org.apereo.portal.portlets.lookup.IPersonLookupHelper#getSelf(org.springframework.webflow.context.ExternalContext)
     */
public IPersonAttributes getSelf(ExternalContext externalContext) {
    final PortletRequest portletRequest = (PortletRequest) externalContext.getNativeRequest();
    final String username = portletRequest.getRemoteUser();
    return this.personAttributeDao.getPerson(username);
}
Also used : PortletRequest(javax.portlet.PortletRequest)

Example 7 with PortletRequest

use of javax.portlet.PortletRequest in project uPortal by Jasig.

the class PersonLookupHelperImpl method getQueryAttributes.

/* (non-Javadoc)
     * @see org.apereo.portal.portlets.swapper.IPersonLookupHelper#getQueryAttributes(org.springframework.webflow.context.ExternalContext)
     */
public Set<String> getQueryAttributes(ExternalContext externalContext) {
    final PortletRequest portletRequest = (PortletRequest) externalContext.getNativeRequest();
    final PortletPreferences preferences = portletRequest.getPreferences();
    final Set<String> queryAttributes;
    final String[] configuredAttributes = preferences.getValues(PERSON_LOOKUP_PERSON_LOOKUP_QUERY_ATTRIBUTES, null);
    final String[] excludedAttributes = preferences.getValues(PERSON_LOOKUP_PERSON_LOOKUP_QUERY_ATTRIBUTES_EXCLUDES, null);
    //If attributes are configured in portlet prefs just use them
    if (configuredAttributes != null) {
        queryAttributes = new LinkedHashSet<String>(Arrays.asList(configuredAttributes));
    } else //Otherwise provide all available attributes from the IPersonAttributeDao
    {
        final Set<String> availableAttributes = this.personAttributeDao.getAvailableQueryAttributes();
        queryAttributes = new TreeSet<String>(availableAttributes);
    }
    //Remove excluded attributes
    if (excludedAttributes != null) {
        for (final String excludedAttribute : excludedAttributes) {
            queryAttributes.remove(excludedAttribute);
        }
    }
    return queryAttributes;
}
Also used : PortletRequest(javax.portlet.PortletRequest) PortletPreferences(javax.portlet.PortletPreferences)

Example 8 with PortletRequest

use of javax.portlet.PortletRequest in project uPortal by Jasig.

the class PortletSessionExpirationManager method onEnd.

/* (non-Javadoc)
     * @see org.apache.pluto.spi.optional.PortletInvocationListener#onEnd(org.apache.pluto.spi.optional.PortletInvocationEvent)
     */
@SuppressWarnings("unchecked")
public void onEnd(PortletInvocationEvent event) {
    final PortletRequest portletRequest = event.getPortletRequest();
    final PortletSession portletSession = portletRequest.getPortletSession(false);
    if (portletSession == null) {
        return;
    }
    final HttpServletRequest portalRequest = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
    final HttpSession portalSession = portalRequest.getSession();
    if (portalSession != null) {
        NonSerializableMapHolder<String, PortletSession> portletSessions;
        synchronized (WebUtils.getSessionMutex(portalSession)) {
            portletSessions = (NonSerializableMapHolder<String, PortletSession>) portalSession.getAttribute(PORTLET_SESSIONS_MAP);
            if (portletSessions == null || !portletSessions.isValid()) {
                portletSessions = new NonSerializableMapHolder(new ConcurrentHashMap<String, PortletSession>());
                portalSession.setAttribute(PORTLET_SESSIONS_MAP, portletSessions);
            }
        }
        final String contextPath = portletRequest.getContextPath();
        portletSessions.put(contextPath, portletSession);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletRequest(javax.portlet.PortletRequest) PortletSession(javax.portlet.PortletSession) HttpSession(javax.servlet.http.HttpSession) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 9 with PortletRequest

use of javax.portlet.PortletRequest in project uPortal by Jasig.

the class PortalWebUtils method currentRequestContextPath.

/**
     * Get the request context path from the current request. Copes with both HttpServletRequest and
     * PortletRequest and so usable when handling Spring-processed Servlet or Portlet requests.
     * Requires that Spring have bound the request, as in the case of dispatcher servlet or portlet
     * or when the binding filter or listener is active. This should be the case for all requests in
     * the uPortal framework and framework portlets.
     *
     * @return request.getContextPath() for the relevant servlet or portlet request
     * @throws IllegalStateException if the request is not Spring-bound or is neither Servlet nor
     *     Portlet flavored
     */
public static String currentRequestContextPath() {
    final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (null == requestAttributes) {
        throw new IllegalStateException("Request attributes are not bound.  " + "Not operating in context of a Spring-processed Request?");
    }
    if (requestAttributes instanceof ServletRequestAttributes) {
        final ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
        final HttpServletRequest request = servletRequestAttributes.getRequest();
        return request.getContextPath();
    } else if (requestAttributes instanceof PortletRequestAttributes) {
        final PortletRequestAttributes portletRequestAttributes = (PortletRequestAttributes) requestAttributes;
        final PortletRequest request = portletRequestAttributes.getRequest();
        return request.getContextPath();
    } else {
        throw new IllegalStateException("Request attributes are an unrecognized implementation.");
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) PortletRequestAttributes(org.springframework.web.portlet.context.PortletRequestAttributes) PortletRequest(javax.portlet.PortletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) RequestAttributes(org.springframework.web.context.request.RequestAttributes) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) PortletRequestAttributes(org.springframework.web.portlet.context.PortletRequestAttributes)

Example 10 with PortletRequest

use of javax.portlet.PortletRequest in project uPortal by Jasig.

the class RuntimeMvcViewFactory method createMvcView.

/* (non-Javadoc)
     * @see org.springframework.webflow.mvc.view.AbstractMvcViewFactory#createMvcView(org.springframework.web.servlet.View, org.springframework.webflow.execution.RequestContext)
     */
@Override
protected AbstractMvcView createMvcView(View view, RequestContext context) {
    final ExternalContext externalContext = context.getExternalContext();
    final Object nativeRequest = externalContext.getNativeRequest();
    if (nativeRequest instanceof PortletRequest) {
        return new PortletMvcView(view, context);
    }
    return new ServletMvcView(view, context);
}
Also used : ServletMvcView(org.springframework.webflow.mvc.servlet.ServletMvcView) PortletRequest(javax.portlet.PortletRequest) PortletMvcView(org.springframework.webflow.mvc.portlet.PortletMvcView) ExternalContext(org.springframework.webflow.context.ExternalContext)

Aggregations

PortletRequest (javax.portlet.PortletRequest)12 PortletPreferences (javax.portlet.PortletPreferences)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 Principal (java.security.Principal)3 List (java.util.List)3 IPersonAttributes (org.jasig.services.persondir.IPersonAttributes)3 LinkedHashSet (java.util.LinkedHashSet)2 PortletSession (javax.portlet.PortletSession)2 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)2 IPerson (org.apereo.portal.security.IPerson)2 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PortletResponse (javax.portlet.PortletResponse)1 RenderRequest (javax.portlet.RenderRequest)1 RenderResponse (javax.portlet.RenderResponse)1 HttpSession (javax.servlet.http.HttpSession)1 DelegationRequest (org.apereo.portal.api.portlet.DelegationRequest)1