use of javax.portlet.PortletPreferences 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 javax.portlet.PortletPreferences in project uPortal by Jasig.
the class SqlQueryConfigurationController method saveConfiguration.
@RequestMapping(params = "action=updateConfiguration")
public void saveConfiguration(ActionRequest request, ActionResponse response, @ModelAttribute("form") SqlQueryConfigForm form, BindingResult errors, @RequestParam(value = "Save", required = false) String save) throws PortletModeException, IOException, ValidatorException, ReadOnlyException {
if (StringUtils.isNotBlank(save)) {
PortletPreferences prefs = request.getPreferences();
prefs.setValue(SqlQueryPortletController.DATASOURCE_BEAN_NAME_PARAM_NAME, form.getDataSource());
prefs.setValue(SqlQueryPortletController.SQL_QUERY_PARAM_NAME, form.getSqlQuery());
prefs.setValue(SqlQueryPortletController.VIEW_PARAM_NAME, form.getViewName());
prefs.setValue(SqlQueryPortletController.PREF_CACHE_NAME, form.getCacheName());
prefs.store();
}
response.setPortletMode(PortletMode.VIEW);
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class DirectoryPortletController method submitSearch.
@ActionMapping
public void submitSearch(ActionRequest request, ActionResponse response, @RequestParam(value = "query", required = false) String query) {
// Should we request to maximize?
PortletPreferences prefs = request.getPreferences();
boolean maximize = Boolean.parseBoolean(// default is true
prefs.getValue(MAXIMIZE_ON_SEARCH_PREFERENCE, "true"));
if (maximize) {
try {
response.setWindowState(WindowState.MAXIMIZED);
} catch (WindowStateException e) {
log.warn("Failed to set the window state to MAXIMIZED", e);
}
}
// Forward the query parameter...
if (query != null) {
response.setRenderParameter("query", query);
}
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class RoleBasedBackgroundSetSelectionStrategy method getImageThumbnailSet.
@Override
public String[] getImageThumbnailSet(PortletRequest req) {
PreferenceNames names = PreferenceNames.getInstance(req);
PortletPreferences prefs = req.getPreferences();
final String[] images = prefs.getValues(names.getImageThumbnailSetPreferenceName(), null);
for (int i = 0; i < images.length; i++) {
images[i] = evaluateImagePath(images[i]);
}
return images;
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class RoleBasedBackgroundSetSelectionStrategy method setSelectedImage.
@Override
public void setSelectedImage(ActionRequest req, String backgroundImage) {
PreferenceNames names = PreferenceNames.getInstance(req);
PortletPreferences prefs = req.getPreferences();
if (StringUtils.isNotBlank(backgroundImage)) {
// We are trying to choose a background; first verify the requested image is actually in the set...
String[] images = prefs.getValues(names.getImageSetPreferenceName(), EMPTY_STRING_ARRAY);
for (int i = 0; i < images.length; i++) {
images[i] = evaluateImagePath(images[i]);
}
if (Arrays.asList(images).contains(backgroundImage)) {
try {
prefs.setValue(names.getSelectedBackgroundImagePreferenceName(), backgroundImage);
prefs.store();
} catch (Exception e) {
throw new RuntimeException("Failed to store the user's choice of background image", e);
}
}
} else {
// We are trying to clear a previous selection
try {
prefs.reset(names.getSelectedBackgroundImagePreferenceName());
prefs.store();
} catch (Exception e) {
throw new RuntimeException("Failed to reset the user's choice of background image", e);
}
}
}
Aggregations