Search in sources :

Example 31 with PortletPreferences

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

Example 32 with PortletPreferences

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

Example 33 with PortletPreferences

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);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.portlet.ModelAndView) SearchResult(org.apereo.portal.search.SearchResult) PortletSession(javax.portlet.PortletSession) PortletPreferences(javax.portlet.PortletPreferences) List(java.util.List) ArrayList(java.util.ArrayList) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping)

Example 34 with PortletPreferences

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>&lt;security-role-ref&gt;</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]));
    }
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 35 with PortletPreferences

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());
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPerson(org.apereo.portal.security.IPerson) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) PortletPreferences(javax.portlet.PortletPreferences) PortletCategory(org.apereo.portal.portlet.om.PortletCategory)

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