@ 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 ( ) : PersonFactory . getGuestUsernames ( ) . get ( 0 ) ; // First item is the default final IAuthorizationPrincipal principal = authorizationService . newPrincipal ( username , IPerson . class ) ; final List < IUserLayoutNodeDescription > favorites = new ArrayList <> ( ) ; for ( IUserLayoutNodeDescription nodeDescription : rawFavorites ) { if ( nodeDescription instanceof IUserLayoutChannelDescription ) { final IUserLayoutChannelDescription channelDescription = ( IUserLayoutChannelDescription ) nodeDescription ; if ( principal . canRender ( channelDescription . getChannelPublishId ( ) ) ) { favorites . add ( nodeDescription ) ; } } } model . addAttribute ( "favorites" , favorites ) ; // default to the regular old view String viewName = "jsp/Favorites/view" ; if ( collections . isEmpty ( ) && favorites . 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 ; }
Handles all Favorites portlet VIEW mode renders . Populates model with user s favorites and selects a view to display those favorites .