Search in sources :

Example 1 with RenderMapping

use of org.springframework.web.portlet.bind.annotation.RenderMapping in project SimpleContentPortlet by Jasig.

the class AttachmentsController method main.

@RenderMapping
public ModelAndView main(final PortletRequest request) {
    request.getPortletSession().setAttribute(REMOTE_USER_ATTR, request.getRemoteUser(), PortletSession.APPLICATION_SCOPE);
    ModelAndView view = createModelAndView(request, VIEW_MAIN);
    return view;
}
Also used : ModelAndView(org.springframework.web.portlet.ModelAndView) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 2 with RenderMapping

use of org.springframework.web.portlet.bind.annotation.RenderMapping in project uPortal by Jasig.

the class GoogleAnalyticsConfigController method renderAnalyticsHeader.

@RenderMapping
public String renderAnalyticsHeader(PortletRequest request, ModelMap model) throws IOException {
    final PortletPreferences preferences = request.getPreferences();
    final JsonNode config = this.portletPreferencesJsonDao.getJsonNode(preferences, CONFIG_PREF_NAME);
    model.put("data", config);
    return "jsp/GoogleAnalytics/config";
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) JsonNode(com.fasterxml.jackson.databind.JsonNode) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 3 with RenderMapping

use of org.springframework.web.portlet.bind.annotation.RenderMapping in project uPortal by Jasig.

the class IFramePortletController method display.

@RenderMapping
protected ModelAndView display(RenderRequest req, RenderResponse res) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();
    // get the IFrame target URL and the configured height of the IFrame
    // window from the portlet preferences
    PortletPreferences prefs = req.getPreferences();
    for (final Map.Entry<String, String> attrEntry : IFRAME_ATTRS.entrySet()) {
        final String attr = attrEntry.getKey();
        final String defaultValue = attrEntry.getValue();
        model.put(attr, prefs.getValue(attr, defaultValue));
    }
    // Legacy support for url attribute
    if (model.get("src") == null) {
        model.put("src", prefs.getValue("url", IFRAME_ATTRS.get("src")));
    }
    // Fix for double scrollbars in specialized window states that control the whole window
    if (req.getWindowState().equals(IPortletRenderer.DETACHED) || req.getWindowState().equals(IPortletRenderer.EXCLUSIVE)) {
        model.put("onload", SCROLL_HEIGHT_ONLOAD_FIX);
    }
    return new ModelAndView("/jsp/IFrame/iframePortlet", "attrs", model);
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.portlet.ModelAndView) PortletPreferences(javax.portlet.PortletPreferences) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 4 with RenderMapping

use of org.springframework.web.portlet.bind.annotation.RenderMapping in project uPortal by Jasig.

the class JspInvokerPortletController method render.

@RenderMapping
protected ModelAndView render(RenderRequest req, RenderResponse res) {
    final Map<String, Object> model = new HashMap<String, Object>();
    @SuppressWarnings("unchecked") final Map<String, String> userInfo = (Map<String, String>) req.getAttribute(PortletRequest.USER_INFO);
    model.put("userInfo", userInfo);
    logger.debug("Invoking with userInfo={}", userInfo);
    // Can access property values in JSP using ${properties.getProperty('propertyName')}
    model.put("properties", properties.getPropertyResolver());
    // Determine if guest user.
    IPerson person = personManager.getPerson(portalRequestUtils.getPortletHttpRequest(req));
    model.put("authenticated", !person.isGuest());
    model.putAll(getBeans(req));
    model.putAll(getPreferences(req));
    addSecurityRoleChecksToModel(req, model);
    final String viewLocation = getViewLocation(req);
    return new ModelAndView(viewLocation, model);
}
Also used : IPerson(org.apereo.portal.security.IPerson) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.portlet.ModelAndView) HashMap(java.util.HashMap) Map(java.util.Map) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 5 with RenderMapping

use of org.springframework.web.portlet.bind.annotation.RenderMapping in project uPortal by Jasig.

the class FavoritesController method initializeView.

/**
 * Handles all Favorites portlet VIEW mode renders. Populates model with user's favorites and
 * selects a view to display those favorites.
 *
 * <p>View selection:
 *
 * <p>Returns "jsp/Favorites/view" in the normal case where the user has at least one favorited
 * portlet or favorited collection.
 *
 * <p>Returns "jsp/Favorites/view_zero" in the edge case where the user has zero favorited
 * portlets AND zero favorited collections.
 *
 * <p>Model: marketPlaceFname --> String functional name of Marketplace portlet, or null if not
 * available. collections --> List of favorited collections (IUserLayoutNodeDescription s)
 * favorites --> List of favorited individual portlets (IUserLayoutNodeDescription s)
 *
 * @param model . Spring model. This method adds three model attributes.
 * @return jsp/Favorites/view[_zero]
 */
@RenderMapping
public String initializeView(PortletRequest req, Model model) {
    final IUserInstance ui = userInstanceManager.getUserInstance(portalRequestUtils.getCurrentPortalRequest());
    final UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
    final IUserLayoutManager ulm = upm.getUserLayoutManager();
    final IUserLayout userLayout = ulm.getUserLayout();
    // TODO: the portlet could predicate including a non-null marketplace portlet fname
    // on the accessing user having permission to render the portlet referenced by that fname
    // so that portlet would gracefully degrade when configured with bad marketplace portlet
    // fname
    // and also gracefully degrade when the accessing user doesn't have permission to access an
    // otherwise
    // viable configured marketplace.  This complexity may not be worth it.  Anyway it is not
    // yet implemented.
    model.addAttribute("marketplaceFname", this.marketplaceFName);
    final List<IUserLayoutNodeDescription> collections = favoritesUtils.getFavoriteCollections(userLayout);
    model.addAttribute("collections", collections);
    final List<IUserLayoutNodeDescription> rawFavorites = favoritesUtils.getFavoritePortletLayoutNodes(userLayout);
    /*
         * Filter the collection by SUBSCRIBE permission.
         *
         * NOTE:  In the "regular" (non-Favorites) layout, this permissions check is handled by
         * the rendering engine.  It will refuse to spawn a worker for a portlet to which you
         * cannot SUBSCRIBE.
         */
    final String username = req.getRemoteUser() != null ? req.getRemoteUser() : // First item is the default
    PersonFactory.getGuestUsernames().get(0);
    final IAuthorizationPrincipal principal = authorizationService.newPrincipal(username, IPerson.class);
    // final List<IUserLayoutNodeDescription> favorites = new ArrayList<>();
    final List<IUserLayoutChannelDescription> favoriteChannelDescriptions = new ArrayList<>();
    for (IUserLayoutNodeDescription nodeDescription : rawFavorites) {
        if (nodeDescription instanceof IUserLayoutChannelDescription) {
            final IUserLayoutChannelDescription channelDescription = (IUserLayoutChannelDescription) nodeDescription;
            if (principal.canRender(channelDescription.getChannelPublishId())) {
                // favorites.add(nodeDescription);
                favoriteChannelDescriptions.add(channelDescription);
            }
        }
    }
    // Filter list of IUserLayoutChannelDescription by FunctionalName
    final List<IUserLayoutChannelDescription> uniqueFavoritesChannel = FavoritesUtils.filterChannelFavoritesToUnique(favoriteChannelDescriptions);
    // Cast List of IUserLayoutChannelDescription to List of IUserLayoutNodeDescription
    final List<IUserLayoutNodeDescription> uniqueFavorites = FavoritesUtils.castListChannelDescriptionToListNodeDescription(uniqueFavoritesChannel);
    model.addAttribute("favorites", uniqueFavorites);
    // default to the regular old view
    String viewName = "jsp/Favorites/view";
    if (collections.isEmpty() && uniqueFavorites.isEmpty()) {
        // special edge case of zero favorites, switch to special view
        viewName = "jsp/Favorites/view_zero";
    }
    logger.debug("Favorites Portlet VIEW mode render populated model [{}] for render by view {}.", model, viewName);
    return viewName;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) ArrayList(java.util.ArrayList) IUserLayout(org.apereo.portal.layout.IUserLayout) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) IUserLayoutChannelDescription(org.apereo.portal.layout.node.IUserLayoutChannelDescription) UserPreferencesManager(org.apereo.portal.UserPreferencesManager) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Aggregations

RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)18 PortletPreferences (javax.portlet.PortletPreferences)9 HashMap (java.util.HashMap)8 ModelAndView (org.springframework.web.portlet.ModelAndView)6 IPerson (org.apereo.portal.security.IPerson)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)3 IUserLayout (org.apereo.portal.layout.IUserLayout)3 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)3 IUserLayoutNodeDescription (org.apereo.portal.layout.node.IUserLayoutNodeDescription)3 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)3 IUserInstance (org.apereo.portal.user.IUserInstance)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Map (java.util.Map)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 PortletSession (javax.portlet.PortletSession)1 Header (org.apache.http.Header)1