use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class ViewBackgroundPreferenceController method getView.
/**
* Display the main user-facing view of the portlet.
*
* @param request
* @return
*/
@RenderMapping
public String getView(RenderRequest req, Model model) {
final String[] images = imageSetSelectionStrategy.getImageSet(req);
model.addAttribute("images", images);
final String[] thumbnailImages = imageSetSelectionStrategy.getImageThumbnailSet(req);
model.addAttribute("thumbnailImages", thumbnailImages);
final String[] imageCaptions = imageSetSelectionStrategy.getImageCaptions(req);
model.addAttribute("imageCaptions", imageCaptions);
final String preferredBackgroundImage = imageSetSelectionStrategy.getSelectedImage(req);
model.addAttribute("backgroundImage", preferredBackgroundImage);
final String backgroundContainerSelector = imageSetSelectionStrategy.getBackgroundContainerSelector(req);
model.addAttribute("backgroundContainerSelector", backgroundContainerSelector);
final PortletPreferences prefs = req.getPreferences();
model.addAttribute("applyOpacityTo", prefs.getValue("applyOpacityTo", null));
model.addAttribute("opacityCssValue", prefs.getValue("opacityCssValue", "1.0"));
return "/jsp/BackgroundPreference/viewBackgroundPreference";
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class SqlQueryConfigurationController method getConfigurationForm.
public SqlQueryConfigForm getConfigurationForm(PortletRequest request) {
PortletPreferences prefs = request.getPreferences();
SqlQueryConfigForm form = new SqlQueryConfigForm();
form.setDataSource(prefs.getValue(SqlQueryPortletController.DATASOURCE_BEAN_NAME_PARAM_NAME, defaultDataSource));
form.setViewName(prefs.getValue(SqlQueryPortletController.VIEW_PARAM_NAME, defaultView));
form.setSqlQuery(prefs.getValue(SqlQueryPortletController.SQL_QUERY_PARAM_NAME, ""));
form.setCacheName(prefs.getValue(SqlQueryPortletController.PREF_CACHE_NAME, SqlQueryPortletController.DEFAULT_CACHE_NAME));
return form;
}
use of javax.portlet.PortletPreferences 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);
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class JspInvokerPortletController method addSecurityRoleChecksToModel.
/**
* Run through the list of configured security roles and add an "is"+Rolename to the model. The
* security roles must also be defined with a <code><security-role-ref></code> element in
* the portlet.xml.
*
* @param req Portlet request
* @param model Model object to add security indicators to
*/
private void addSecurityRoleChecksToModel(PortletRequest req, Map<String, Object> model) {
PortletPreferences prefs = req.getPreferences();
String[] securityRoles = prefs.getValues(PREF_SECURITY_ROLE_NAMES, new String[] {});
for (int i = 0; i < securityRoles.length; i++) {
model.put("is" + securityRoles[i].replace(" ", "_"), req.isUserInRole(securityRoles[i]));
}
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class PortletMarketplaceController method setUpInitialView.
private void setUpInitialView(WebRequest webRequest, PortletRequest portletRequest, Model model, String initialFilter) {
// We'll track and potentially log the time it takes to perform this initialization
final long timestamp = System.currentTimeMillis();
final HttpServletRequest servletRequest = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
final PortletPreferences preferences = portletRequest.getPreferences();
final boolean isLogLevelDebug = logger.isDebugEnabled();
final IPerson user = personManager.getPerson(servletRequest);
final Map<String, Set<?>> registry = getRegistry(user, portletRequest);
@SuppressWarnings("unchecked") final Set<MarketplaceEntry> marketplaceEntries = (Set<MarketplaceEntry>) registry.get("portlets");
model.addAttribute("marketplaceEntries", marketplaceEntries);
@SuppressWarnings("unchecked") Set<PortletCategory> categoryList = (Set<PortletCategory>) registry.get("categories");
@SuppressWarnings("unchecked") final Set<MarketplaceEntry> featuredPortlets = (Set<MarketplaceEntry>) registry.get("featured");
model.addAttribute("featuredEntries", featuredPortlets);
//Determine if the marketplace is going to show the root category
String showRootCategoryPreferenceValue = preferences.getValue(SHOW_ROOT_CATEGORY_PREFERENCE, "false");
boolean showRootCategory = Boolean.parseBoolean(showRootCategoryPreferenceValue);
if (isLogLevelDebug) {
logger.debug("Going to show Root Category?: {}", Boolean.toString(showRootCategory));
}
if (showRootCategory == false) {
categoryList.remove(this.portletCategoryRegistry.getTopLevelPortletCategory());
}
model.addAttribute("categoryList", categoryList);
model.addAttribute("initialFilter", initialFilter);
logger.debug("Marketplace took {}ms in setUpInitialView for user '{}'", System.currentTimeMillis() - timestamp, user.getUserName());
}
Aggregations