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