use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.
the class PortletEntityTranslationController method getPortletDefinition.
@ResourceMapping
@RequestMapping(params = "action=getEntity")
public ModelAndView getPortletDefinition(@RequestParam("id") String portletId, @RequestParam("locale") String locale) throws Exception {
final IPortletDefinition definition = portletDefinitionDao.getPortletDefinition(portletId);
final PortletDefinitionTranslation translation = new PortletDefinitionTranslation();
translation.setId(portletId);
translation.setLocale(locale);
translation.setLocalized(new LocalizedPortletDefinition(definition, locale));
translation.setOriginal(new LocalizedPortletDefinition(definition, null));
return new ModelAndView("json", "portlet", translation);
}
use of org.springframework.web.portlet.ModelAndView 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);
}
use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.
the class DynamicRespondrSkinViewController method displaySkinCssHeader.
/**
* Display Skin CSS include based on skin's configuration values from portlet preferences.<br>
* dynamic=false: load the pre-built css file from the skins directory and default skin name;
* e.g. RELATIVE_ROOT/{defaultSkin}.css dynamic=true: Process the default skin less file if
* needed at RELATIVE_ROOT/{defaultSkin}.less to create a customized skin css file
* (RELATIVE_ROOT/skin-ID#.css to load.
*/
@RenderMapping
public ModelAndView displaySkinCssHeader(RenderRequest request, RenderResponse response, Model model) throws IOException {
if (PortletRequest.RENDER_HEADERS.equals(request.getAttribute(PortletRequest.RENDER_PART))) {
PortletPreferences prefs = request.getPreferences();
Boolean enabled = Boolean.valueOf(prefs.getValue(DynamicRespondrSkinConstants.PREF_DYNAMIC, "false"));
String skinName = prefs.getValue(DynamicRespondrSkinConstants.PREF_SKIN_NAME, DynamicRespondrSkinConstants.DEFAULT_SKIN_NAME);
String cssUrl = enabled ? calculateDynamicSkinUrlPathToUse(request, skinName) : calculateDefaultSkinCssLocationInWebapp(skinName);
model.addAttribute(DynamicRespondrSkinConstants.SKIN_CSS_URL_MODEL_ATTRIBUTE_NAME, cssUrl);
return new ModelAndView("jsp/DynamicRespondrSkin/skinHeader");
} else {
// We need to know if this user can CONFIG this skin
// Default
boolean canAccessSkinConfig = false;
final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
final IPerson user = personManager.getPerson(httpr);
final IAuthorizationPrincipal principal = AuthorizationPrincipalHelper.principalFromUser(user);
final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, request.getWindowID());
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
final IPortletEntity portletEntity = portletWindow.getPortletEntity();
if (principal.canConfigure(portletEntity.getPortletDefinitionId().toString())) {
canAccessSkinConfig = true;
}
// RENDER_MARKUP
return new ModelAndView("jsp/DynamicRespondrSkin/skinBody", DynamicRespondrSkinConstants.CAN_ACCESS_SKIN_CONFIG_MODEL_NAME, canAccessSkinConfig);
}
}
use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.
the class SitemapPortletController method displaySitemap.
/**
* Display the user sitemap.
*
* @param request
* @return "sitemapView" and a supporting model
* @throws XMLStreamException
* @throws IllegalStateException if components required for the SiteMap portlet fail to
* auto-wire
*/
@RequestMapping
public ModelAndView displaySitemap(PortletRequest request) throws XMLStreamException {
Map<String, Object> model = new HashMap<String, Object>();
if (this.xsltPortalUrlProvider == null) {
throw new IllegalStateException("Sitemap portlet requires a XsltPortalUrlProvider but it failed to " + "auto-wire");
}
if (this.attributeIncorporationComponent == null) {
throw new IllegalStateException("Sitemap portlet requires a StAXPipelineComponent with qualifier structureAttributeIncorporationComponent but it failed to auto-wire");
}
if (this.portalRequestUtils == null) {
throw new IllegalStateException("Sitemap portlet requires an IPortalRequestUtils but it failed to " + "auto-wire");
}
// retrieve the user layout with structure attributes applied (required in order to display tab groups)
final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
final HttpServletResponse httpServletResponse = this.portalRequestUtils.getOriginalPortalResponse(request);
final PipelineEventReader<XMLEventReader, XMLEvent> reader = attributeIncorporationComponent.getEventReader(httpServletRequest, httpServletResponse);
// create a Source from the user's layout document
StAXSource source = new StAXSource(reader.getEventReader());
model.put("source", source);
model.put(XsltPortalUrlProvider.CURRENT_REQUEST, httpServletRequest);
model.put(XsltPortalUrlProvider.XSLT_PORTAL_URL_PROVIDER, this.xsltPortalUrlProvider);
model.put(USE_TAB_GROUPS, useTabGroups);
model.put(USER_LANG, ObjectUtils.toString(request.getLocale()));
return new ModelAndView("sitemapView", model);
}
use of org.springframework.web.portlet.ModelAndView in project uPortal by Jasig.
the class SearchPortletController method showJSONSearchResults.
/** Display AJAX autocomplete search results for the last query */
@ResourceMapping(value = "retrieveSearchJSONResults")
public ModelAndView showJSONSearchResults(PortletRequest request) {
PortletPreferences prefs = request.getPreferences();
int maxTextLength = Integer.parseInt(prefs.getValue(AUTOCOMPLETE_MAX_TEXT_LENGTH_PREF_NAME, "180"));
final Map<String, Object> model = new HashMap<>();
List<AutocompleteResultsModel> results = new ArrayList<>();
final PortletSession session = request.getPortletSession();
String queryId = (String) session.getAttribute(SEARCH_LAST_QUERY_ID);
if (queryId != null) {
final PortalSearchResults portalSearchResults = this.getPortalSearchResults(request, queryId);
if (portalSearchResults != null) {
final ConcurrentMap<String, List<Tuple<SearchResult, String>>> resultsMap = portalSearchResults.getResults();
results = collateResultsForAutoCompleteResponse(resultsMap, maxTextLength);
}
}
model.put("results", results);
model.put("count", results.size());
return new ModelAndView("json", model);
}
Aggregations