Search in sources :

Example 6 with ResourceMapping

use of org.springframework.web.portlet.bind.annotation.ResourceMapping in project uPortal by Jasig.

the class PortletMarketplaceController method getLayoutInfo.

@ResourceMapping("layoutInfo")
public String getLayoutInfo(ResourceRequest request, @RequestParam String portletFName, Model model) throws TransformerException {
    Validate.notNull(portletFName, "Please supply a portlet fname");
    final HttpServletRequest servletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
    IUserInstance ui = userInstanceManager.getUserInstance(servletRequest);
    UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
    IUserLayoutManager ulm = upm.getUserLayoutManager();
    IPerson person = ui.getPerson();
    DistributedUserLayout userLayout = userLayoutStore.getUserLayout(person, upm.getUserProfile());
    List<PortletTab> tabs = getPortletTabInfo(userLayout, portletFName);
    boolean isFavorite = isPortletFavorited(ulm.getUserLayout(), portletFName);
    model.addAttribute("favorite", isFavorite);
    model.addAttribute("tabs", tabs);
    return "json";
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IUserInstance(org.apereo.portal.user.IUserInstance) IPerson(org.apereo.portal.security.IPerson) DistributedUserLayout(org.apereo.portal.layout.dlm.DistributedUserLayout) IUserLayoutManager(org.apereo.portal.layout.IUserLayoutManager) UserPreferencesManager(org.apereo.portal.UserPreferencesManager) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping)

Example 7 with ResourceMapping

use of org.springframework.web.portlet.bind.annotation.ResourceMapping in project uPortal by Jasig.

the class GoogleAnalyticsConfigController method storeData.

@ResourceMapping("storeData")
public String storeData(ResourceRequest request, @RequestParam JsonNode config) throws ValidatorException, IOException, ReadOnlyException {
    final PortletPreferences preferences = request.getPreferences();
    this.portletPreferencesJsonDao.storeJson(preferences, CONFIG_PREF_NAME, config);
    return "jsonView";
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping)

Example 8 with ResourceMapping

use of org.springframework.web.portlet.bind.annotation.ResourceMapping in project uPortal by Jasig.

the class MessageEntityTranslationController method getEntity.

@ResourceMapping
@RequestMapping(params = "action=getEntity")
public ModelAndView getEntity(@RequestParam("id") String code, @RequestParam("locale") String localeStr) {
    final Locale locale = LocaleManager.parseLocale(localeStr);
    final Message message = messageDao.getMessage(code, locale);
    return new ModelAndView("json", "message", message);
}
Also used : Locale(java.util.Locale) Message(org.apereo.portal.i18n.Message) ModelAndView(org.springframework.web.portlet.ModelAndView) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with ResourceMapping

use of org.springframework.web.portlet.bind.annotation.ResourceMapping in project uPortal by Jasig.

the class PortletEntityTranslationController method getPortletDefinition.

@ResourceMapping
@RequestMapping(params = "action=getEntity")
public ModelAndView getPortletDefinition(@RequestParam("id") String portletId, @RequestParam("locale") String locale) throws Exception {
    final IPortletDefinition definition = portletDefinitionDao.getPortletDefinition(portletId);
    final PortletDefinitionTranslation translation = new PortletDefinitionTranslation();
    translation.setId(portletId);
    translation.setLocale(locale);
    translation.setLocalized(new LocalizedPortletDefinition(definition, locale));
    translation.setOriginal(new LocalizedPortletDefinition(definition, null));
    return new ModelAndView("json", "portlet", translation);
}
Also used : ModelAndView(org.springframework.web.portlet.ModelAndView) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with ResourceMapping

use of org.springframework.web.portlet.bind.annotation.ResourceMapping 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)

Aggregations

ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)11 ModelAndView (org.springframework.web.portlet.ModelAndView)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 PortletPreferences (javax.portlet.PortletPreferences)4 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 Message (org.apereo.portal.i18n.Message)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PortletSession (javax.portlet.PortletSession)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 UserPreferencesManager (org.apereo.portal.UserPreferencesManager)1 IUserLayoutManager (org.apereo.portal.layout.IUserLayoutManager)1 DistributedUserLayout (org.apereo.portal.layout.dlm.DistributedUserLayout)1 IMarketplaceRating (org.apereo.portal.portlet.marketplace.IMarketplaceRating)1 SearchResult (org.apereo.portal.search.SearchResult)1