Search in sources :

Example 6 with PortletPreferences

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;
    }
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 7 with PortletPreferences

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);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with PortletPreferences

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);
    }
}
Also used : WindowStateException(javax.portlet.WindowStateException) PortletPreferences(javax.portlet.PortletPreferences) ActionMapping(org.springframework.web.portlet.bind.annotation.ActionMapping)

Example 9 with PortletPreferences

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;
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 10 with PortletPreferences

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);
        }
    }
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Aggregations

PortletPreferences (javax.portlet.PortletPreferences)38 HashMap (java.util.HashMap)10 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)9 ModelAndView (org.springframework.web.portlet.ModelAndView)6 List (java.util.List)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPerson (org.apereo.portal.security.IPerson)5 PortletRequest (javax.portlet.PortletRequest)4 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 Principal (java.security.Principal)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Header (org.apache.http.Header)2 PortletCategory (org.apereo.portal.portlet.om.PortletCategory)2 MarketplaceEntry (org.apereo.portal.rest.layout.MarketplaceEntry)2 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)2