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;
}
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";
}
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);
}
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);
}
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;
}
Aggregations