Search in sources :

Example 41 with PortletPreferences

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

Example 42 with PortletPreferences

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

Example 43 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, 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());
}
Also used : Arrays(java.util.Arrays) IUserLayoutStore(org.apereo.portal.layout.IUserLayoutStore) RequestParam(org.springframework.web.bind.annotation.RequestParam) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) WebRequest(org.springframework.web.context.request.WebRequest) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) IMarketplaceRatingDao(org.apereo.portal.portlet.dao.IMarketplaceRatingDao) ResourceResponse(javax.portlet.ResourceResponse) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) Model(org.springframework.ui.Model) MarketplaceEntry(org.apereo.portal.rest.layout.MarketplaceEntry) Document(org.w3c.dom.Document) Map(java.util.Map) PermissionHelper(org.apereo.portal.security.PermissionHelper) RenderResponse(javax.portlet.RenderResponse) IMarketplaceRating(org.apereo.portal.portlet.marketplace.IMarketplaceRating) IPortletCategoryRegistry(org.apereo.portal.portlet.registry.IPortletCategoryRegistry) UserLayoutChannelDescription(org.apereo.portal.layout.node.UserLayoutChannelDescription) IPortletDefinitionRegistry(org.apereo.portal.portlet.registry.IPortletDefinitionRegistry) FavoritesUtils(org.apereo.portal.portlets.favorites.FavoritesUtils) Set(java.util.Set) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) String.format(java.lang.String.format) List(java.util.List) IUserInstance(org.apereo.portal.user.IUserInstance) IUserLayoutNodeDescription(org.apereo.portal.layout.node.IUserLayoutNodeDescription) IPortalRequestUtils(org.apereo.portal.url.IPortalRequestUtils) Cache(net.sf.ehcache.Cache) Validate(org.apache.commons.lang.Validate) UserPreferencesManager(org.apereo.portal.UserPreferencesManager) IUserInstanceManager(org.apereo.portal.user.IUserInstanceManager) RenderRequest(javax.portlet.RenderRequest) TransformerException(javax.xml.transform.TransformerException) XPath(javax.xml.xpath.XPath) XPathConstants(javax.xml.xpath.XPathConstants) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) XPathExpression(javax.xml.xpath.XPathExpression) Controller(org.springframework.stereotype.Controller) IPortletDefinitionDao(org.apereo.portal.portlet.dao.IPortletDefinitionDao) AuthorizationPrincipalHelper(org.apereo.portal.security.AuthorizationPrincipalHelper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ResourceRequest(javax.portlet.ResourceRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPersonManager(org.apereo.portal.security.IPersonManager) GroupService(org.apereo.portal.services.GroupService) Node(org.w3c.dom.Node) DistributedUserLayout(org.apereo.portal.layout.dlm.DistributedUserLayout) Qualifier(org.springframework.beans.factory.annotation.Qualifier) PortletRequest(javax.portlet.PortletRequest) IPerson(org.apereo.portal.security.IPerson) IPermission(org.apereo.portal.security.IPermission) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) IGroupConstants(org.apereo.portal.groups.IGroupConstants) MarketplacePortletDefinition(org.apereo.portal.portlet.marketplace.MarketplacePortletDefinition) PortletPreferences(javax.portlet.PortletPreferences) IPersonalizer(org.apereo.portal.utils.personalize.IPersonalizer) XPathFactory(javax.xml.xpath.XPathFactory) PortletCategory(org.apereo.portal.portlet.om.PortletCategory) Element(org.w3c.dom.Element) TreeMap(java.util.TreeMap) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) EntityIdentifier(org.apereo.portal.EntityIdentifier) IUserLayout(org.apereo.portal.layout.IUserLayout) IMarketplaceService(org.apereo.portal.portlet.marketplace.IMarketplaceService) Collections(java.util.Collections) 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)

Example 44 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 45 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)

Aggregations

PortletPreferences (javax.portlet.PortletPreferences)59 HashMap (java.util.HashMap)12 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)10 ModelAndView (org.springframework.web.portlet.ModelAndView)9 List (java.util.List)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 PortletRequest (javax.portlet.PortletRequest)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPerson (org.apereo.portal.security.IPerson)5 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)5 KBArticle (com.liferay.knowledgebase.model.KBArticle)4 Map (java.util.Map)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 AdminSubscriptionSender (com.liferay.knowledgebase.admin.util.AdminSubscriptionSender)2 KBFolder (com.liferay.knowledgebase.model.KBFolder)2 BaseUpgradePortletPreferences (com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences)2 Portlet (com.liferay.portal.model.Portlet)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2