Search in sources :

Example 6 with RenderMapping

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

the class GoogleAnalyticsController method renderAnalyticsHeader.

@RenderMapping
public String renderAnalyticsHeader(RenderRequest request, ModelMap model) throws IOException {
    // For which user account are we logging portal activity?
    final HttpServletRequest req = portalRequestUtils.getCurrentPortalRequest();
    final IPerson person = personManager.getPerson(req);
    final String username = person.getUserName();
    final IGroupMember groupMember = GroupService.getGroupMember(username, IPerson.class);
    final Map<String, Boolean> isMemberCache = new HashMap<>();
    final PortletPreferences preferences = request.getPreferences();
    final JsonNode config = this.portletPreferencesJsonDao.getJsonNode(preferences, GoogleAnalyticsConfigController.CONFIG_PREF_NAME);
    final JsonNode propertyConfig = config.get("defaultConfig");
    this.filterAnalyticsGroups(groupMember, propertyConfig, isMemberCache);
    final JsonNode hosts = config.get("hosts");
    if (hosts != null) {
        for (final Iterator<JsonNode> hostsItr = hosts.elements(); hostsItr.hasNext(); ) {
            final JsonNode institution = hostsItr.next();
            this.filterAnalyticsGroups(groupMember, institution, isMemberCache);
        }
    }
    model.put("data", config);
    if (propertyConfig == null || propertyConfig.get("propertyId") == null) {
        return "jsp/GoogleAnalytics/noop";
    } else {
        return "jsp/GoogleAnalytics/init";
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) IGroupMember(org.apereo.portal.groups.IGroupMember) HashMap(java.util.HashMap) PortletPreferences(javax.portlet.PortletPreferences) JsonNode(com.fasterxml.jackson.databind.JsonNode) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 7 with RenderMapping

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

the class PortletMarketplaceController method entryView.

@RenderMapping(params = "action=view")
public String entryView(RenderRequest renderRequest, RenderResponse renderResponse, WebRequest webRequest, PortletRequest portletRequest, Model model) {
    IPortletDefinition result = this.portletDefinitionRegistry.getPortletDefinitionByFname(portletRequest.getParameter("fName"));
    if (result == null) {
        this.setUpInitialView(webRequest, portletRequest, model, null);
        return "jsp/Marketplace/portlet/view";
    }
    final HttpServletRequest servletRequest = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
    final IPerson user = personManager.getPerson(servletRequest);
    final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
    if (!this.marketplaceService.mayBrowsePortlet(principal, result)) {
        // TODO: provide an error experience
        // currently at least blocks rendering the entry for the portlet the user is not
        // authorized to see.
        this.setUpInitialView(webRequest, portletRequest, model, null);
        return "jsp/Marketplace/portlet/view";
    }
    MarketplacePortletDefinition mpDefinition = marketplaceService.getOrCreateMarketplacePortletDefinition(result);
    IMarketplaceRating tempRatingImpl = marketplaceRatingDAO.getRating(portletRequest.getRemoteUser(), portletDefinitionDao.getPortletDefinitionByFname(result.getFName()));
    final MarketplaceEntry marketplaceEntry = new MarketplaceEntry(mpDefinition, user);
    marketplaceEntry.setPersonalizer(personalizer);
    model.addAttribute("marketplaceRating", tempRatingImpl);
    model.addAttribute("reviewMaxLength", IMarketplaceRating.REVIEW_MAX_LENGTH);
    model.addAttribute("marketplaceEntry", marketplaceEntry);
    model.addAttribute("shortURL", mpDefinition.getShortURL());
    // User allowed to favorite this portlet?
    final String targetString = PermissionHelper.permissionTargetIdForPortletDefinition(mpDefinition);
    final boolean canFavorite = principal.hasPermission(IPermission.PORTAL_SYSTEM, IPermission.PORTLET_FAVORITE_ACTIVITY, targetString);
    model.addAttribute("canFavorite", canFavorite);
    // Reviews feature enabled?
    final PortletPreferences prefs = renderRequest.getPreferences();
    final String enableReviewsPreferenceValue = prefs.getValue(ENABLE_REVIEWS_PREFERENCE, ENABLE_REVIEWS_DEFAULT);
    model.addAttribute("enableReviews", Boolean.valueOf(enableReviewsPreferenceValue));
    return "jsp/Marketplace/portlet/entry";
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) IMarketplaceRating(org.apereo.portal.portlet.marketplace.IMarketplaceRating) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) PortletPreferences(javax.portlet.PortletPreferences) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 8 with RenderMapping

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

the class SessionTimeoutViewController method writeJsContent.

@RenderMapping
public String writeJsContent(RenderRequest req, RenderResponse resp, Model model) throws IOException {
    if (PortletRequest.RENDER_HEADERS.equals(req.getAttribute(PortletRequest.RENDER_PART))) {
        PortletPreferences prefs = req.getPreferences();
        boolean enabled = getEnabled(prefs);
        int timeout = req.getPortletSession().getMaxInactiveInterval();
        String logoutURL = prefs.getValue(PREF_LOGOUT_URL_FRAGMENT, DEFAULT_LOGOUT_URL_FRAGMENT);
        String resetURL = prefs.getValue(PREF_RESET_SESSION_URL_FRAGMENT, DEFAULT_RESET_SESSION_FRAGMENT);
        int dialogDisplayTime = getDialogDisplayTime(prefs, timeout);
        model.addAttribute(ATTR_ENABLED, enabled);
        model.addAttribute(ATTR_SESSION_TIMEOUT_MS, timeout * 1000);
        model.addAttribute(ATTR_DIALOG_DISPLAY_MS, dialogDisplayTime * 1000);
        model.addAttribute(ATTR_LOGOUT_URL_FRAGMENT, logoutURL);
        model.addAttribute(ATTR_RESET_SESSION_URL_FRAGMENT, resetURL);
        return HEADER_JSP;
    } else {
        return BODY_JSP;
    }
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 9 with RenderMapping

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

the class TenantManagerController method showTenantDetails.

/**
 * @since 4.3
 */
@RenderMapping(params = "action=showTenantDetails")
public ModelAndView showTenantDetails(final RenderRequest req, final PortletSession session) {
    // Should the user chose to perform an action on the details screen, we
    // will need to know which tenant upon which to invoke it.  Not crazy
    // about storing this object in the PortletSession, but taking it as a
    // @RequestParameter could increase the challenges of URL-hacking
    // diligence down the road.  Every pass through this method will re-set
    // the tenancy under the microscope.
    ITenant tenant = null;
    // There are two possibilities that work...
    final String fnameParameter = req.getParameter("fname");
    if (!StringUtils.isBlank(fnameParameter)) {
        // An fname came in the request;  this possibility trumps others
        tenant = tenantService.getTenantByFName(fnameParameter);
        session.setAttribute(CURRENT_TENANT_SESSION_ATTRIBUTE, tenant);
    } else if (session.getAttributeMap().containsKey(CURRENT_TENANT_SESSION_ATTRIBUTE)) {
        // A tenant was previously identified;  we are most likely
        // re-playing the tenant details after failed validation
        tenant = (ITenant) session.getAttribute(CURRENT_TENANT_SESSION_ATTRIBUTE);
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("tenant", tenant);
    model.put("tenantManagerAttributes", Collections.unmodifiableMap(tenantManagerAttributes));
    model.put(OPERATIONS_LINTENER_AVAILABLE_ACTIONS, tenantService.getAllAvaialableActions());
    /*
         * The following 2 items are empty the first time you visit the screen,
         * but may contain data if you attempted to create a tenant but your
         * inputs failed validation.
         */
    // default
    Map<String, String> previousResponses = Collections.emptyMap();
    if (session.getAttributeMap().containsKey(PREVIOUS_RESPONSES)) {
        previousResponses = (Map<String, String>) session.getAttribute(PREVIOUS_RESPONSES);
    }
    model.put(PREVIOUS_RESPONSES, previousResponses);
    // default
    Map<String, Object> invalidFields = Collections.emptyMap();
    if (session.getAttributeMap().containsKey(INVALID_FIELDS)) {
        invalidFields = (Map<String, Object>) session.getAttribute(INVALID_FIELDS);
    }
    model.put(INVALID_FIELDS, invalidFields);
    return new ModelAndView(TENANT_DETAILS_VIEW_NAME, model);
}
Also used : ITenant(org.apereo.portal.tenants.ITenant) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 10 with RenderMapping

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

the class TenantManagerController method showReport.

/**
 * @since 4.3
 */
@RenderMapping(params = "action=showReport")
public ModelAndView showReport(final RenderRequest req) {
    Map<String, Object> model = new HashMap<String, Object>();
    PortletSession session = req.getPortletSession();
    model.put(OPERATION_NAME_CODE, session.getAttribute(OPERATION_NAME_CODE));
    model.put(OPERATIONS_LISTENER_RESPONSES, session.getAttribute(OPERATIONS_LISTENER_RESPONSES));
    return new ModelAndView(REPORT_VIEW_NAME, model);
}
Also used : PortletSession(javax.portlet.PortletSession) HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) 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