Search in sources :

Example 16 with RenderMapping

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

the class FavoritesEditController method initializeView.

/**
 * Handles all Favorites portlet EDIT mode renders. Populates model with user's favorites and
 * selects a view to display those favorites.
 *
 * <p>View selection:
 *
 * <p>Returns "jsp/Favorites/edit" in the normal case where the user has at least one favorited
 * portlet or favorited collection.
 *
 * <p>Returns "jsp/Favorites/edit_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)
 * successMessageCode --> String success message bundle key, or null if none errorMessageCode
 * --> String error message bundle key, or null if none nameOfFavoriteActedUpon --> Name of
 * favorite acted upon, intended as parameter to success or error message
 *
 * @param model . Spring model. This method adds five model attributes.
 * @return jsp/Favorites/edit[_zero]
 */
@RenderMapping
public String initializeView(Model model, RenderRequest renderRequest) {
    IUserInstance ui = userInstanceManager.getUserInstance(portalRequestUtils.getCurrentPortalRequest());
    UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
    IUserLayoutManager ulm = upm.getUserLayoutManager();
    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);
    List<IUserLayoutNodeDescription> collections = favoritesUtils.getFavoriteCollections(userLayout);
    model.addAttribute("collections", collections);
    List<IUserLayoutNodeDescription> favorites = favoritesUtils.getFavoritePortletLayoutNodes(userLayout);
    model.addAttribute("favorites", favorites);
    model.addAttribute("successMessageCode", renderRequest.getParameter("successMessageCode"));
    model.addAttribute("errorMessageCode", renderRequest.getParameter("errorMessageCode"));
    model.addAttribute("nameOfFavoriteActedUpon", renderRequest.getParameter("nameOfFavoriteActedUpon"));
    // default to the regular old edit view
    String viewName = "jsp/Favorites/edit";
    if (collections.isEmpty() && favorites.isEmpty()) {
        // use the special case view
        viewName = "jsp/Favorites/edit_zero";
    }
    logger.trace("Favorites Portlet EDIT mode built model [{}] and selected view {}.", model, viewName);
    return viewName;
}
Also used : IUserInstance(org.apereo.portal.user.IUserInstance) IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) IUserLayout(org.apereo.portal.layout.IUserLayout) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) UserPreferencesManager(org.apereo.portal.UserPreferencesManager) IUserPreferencesManager(org.apereo.portal.IUserPreferencesManager) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 17 with RenderMapping

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

the class DirectoryPortletController method findPersonByUsername.

@RenderMapping(params = "action=findByUsername")
public ModelAndView findPersonByUsername(RenderRequest request, @RequestParam String username) {
    // get an authorization principal for the current requesting user
    HttpServletRequest servletRequest = portalRequestUtils.getPortletHttpRequest(request);
    IPerson currentUser = personManager.getPerson(servletRequest);
    // get the set of people matching the search query
    final IPersonAttributes person = this.lookupHelper.findPerson(currentUser, username);
    final boolean isMobile = isMobile(request);
    String viewName = isMobile ? "/jsp/Directory/mobileDirectory" : "/jsp/Directory/directory";
    final Map<String, Object> model = new HashMap<String, Object>();
    model.put("query", username);
    model.put("people", Collections.singletonList(person));
    model.put("attributeNames", this.displayAttributes);
    return new ModelAndView(viewName, model);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IPersonAttributes(org.apereo.services.persondir.IPersonAttributes) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.portlet.ModelAndView) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 18 with RenderMapping

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

the class ActivityController method summary.

@RenderMapping
public ModelAndView summary(PortletRequest request) throws TypeMismatchException {
    final Map<String, Object> model = new HashMap<String, Object>();
    final PortalActivity now = buildPortalActivity(request, NOW);
    final PortalActivity today = buildPortalActivity(request, TODAY);
    final PortalActivity yesterday = buildPortalActivity(request, YESTERDAY);
    model.put("usageNow", now);
    model.put("usageToday", today);
    model.put("usageYesterday", yesterday);
    // Searches
    // default
    List<SearchInfo> popularSearchTerms = Collections.emptyList();
    final PortletPreferences prefs = request.getPreferences();
    final Boolean showSearches = Boolean.valueOf(prefs.getValue(PREFERENCE_SHOW_SEACHES, DEFAULT_PREFERENCE_SHOW_SEARCHES));
    if (showSearches) {
        popularSearchTerms = getPopularSearchTerms();
    }
    model.put("showSearches", showSearches);
    model.put("popularSearchTerms", popularSearchTerms);
    return new ModelAndView("jsp/Activity/activity", model);
}
Also used : HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) PortletPreferences(javax.portlet.PortletPreferences) 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