use of javax.portlet.PortletPreferences in project SimpleContentPortlet by Jasig.
the class ConfigureContentController method updateConfiguration.
/**
* Update the portlet's configuration according to the submitted form
* object.
*
* @param request ActionRequest
* @param response ActionResponse
* @param form configuration form
* @throws PortletModeException exception
*/
@RequestMapping(params = "action=updateConfiguration")
public void updateConfiguration(ActionRequest request, ActionResponse response, @ModelAttribute("form") ContentForm form) throws PortletModeException {
String content = form.getContent();
String locale = form.getLocale();
// if configured to do so, validate the content and strip out any
// potentially dangerous HTML
PortletPreferences preferences = request.getPreferences();
if (Boolean.valueOf(preferences.getValue("cleanContent", "true"))) {
content = cleaningService.getSafeContent(form.getContent());
}
// save the new content to the portlet preferences
this.contentDao.saveContent(request, content, locale);
// exit the portlet's configuration mode
response.setPortletMode(PortletMode.VIEW);
}
use of javax.portlet.PortletPreferences in project SimpleContentPortlet by Jasig.
the class PortletPreferencesContentDaoImpl method getContent.
/*
* (non-Javadoc)
* @see org.jasig.portlet.cms.service.dao.IContentDao#getContent(javax.portlet.PortletRequest, java.lang.String)
*/
public String getContent(PortletRequest request, String localeKey) {
PortletPreferences preferences = request.getPreferences();
String content = null;
if (StringUtils.isNotBlank(localeKey)) {
content = preferences.getValue(getLocaleSpecificKey(localeKey), null);
}
if (content == null) {
content = preferences.getValue(CONTENT_KEY, "");
}
return content;
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class PortletMarketplaceController method setUpInitialView.
private void setUpInitialView(WebRequest webRequest, PortletRequest portletRequest, Model model, final 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());
}
logger.debug("initialFilter: {}", initialFilter);
String filter = initialFilter == null ? null : categoryList.stream().parallel().map(PortletCategory::getName).filter(cat -> cat.equals(initialFilter)).findAny().orElse("");
logger.debug("filter: {}", filter);
model.addAttribute("categoryList", categoryList);
model.addAttribute("initialFilter", filter);
logger.debug("Marketplace took {}ms in setUpInitialView for user '{}'", System.currentTimeMillis() - timestamp, user.getUserName());
}
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 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;
}
Aggregations