Search in sources :

Example 1 with ResourceMapping

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

the class MessageEntityTranslationController method postTranslation.

@ResourceMapping
@RequestMapping(params = "action=postTranslation")
public ModelAndView postTranslation(@RequestParam("id") String code, @RequestParam("locale") String localeStr, @RequestParam("value") String value) {
    final Locale locale = LocaleManager.parseLocale(localeStr);
    if (locale != null && StringUtils.hasText(code) && StringUtils.hasText(value)) {
        final Message message = messageDao.getMessage(code, locale);
        if (message != null) {
            message.setValue(value);
            messageDao.updateMessage(message);
        } else {
            // if message is not found in the backend storage, a new one must be created
            messageDao.createMessage(code, locale, value);
        }
    }
    return new ModelAndView("json");
}
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 2 with ResourceMapping

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

the class PortletEntityTranslationController method postPortletTranslation.

@ResourceMapping
@RequestMapping(params = "action=postTranslation")
public ModelAndView postPortletTranslation(@RequestParam("id") String portletId, @RequestParam("locale") String locale, ResourceRequest request) throws Exception {
    final IPortletDefinition definition = portletDefinitionDao.getPortletDefinition(portletId);
    if (definition != null) {
        definition.addLocalizedTitle(locale, request.getParameter("title"));
        definition.addLocalizedName(locale, request.getParameter("name"));
        definition.addLocalizedDescription(locale, request.getParameter("description"));
        portletDefinitionDao.savePortletDefinition(definition);
    }
    return new ModelAndView("json");
}
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 3 with ResourceMapping

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

the class PortletEntityTranslationController method getEntityList.

@ResourceMapping
@RequestMapping(params = "action=getEntityList")
public ModelAndView getEntityList() throws Exception {
    final List<IPortletDefinition> portletDefs = portletDefinitionDao.getPortletDefinitions();
    final List<TranslatableEntity> entities = new ArrayList<TranslatableEntity>();
    for (IPortletDefinition portletDef : portletDefs) {
        TranslatableEntity entity = new TranslatableEntity();
        entity.setId(portletDef.getPortletDefinitionId().getStringId());
        entity.setTitle(portletDef.getTitle());
        entities.add(entity);
    }
    return new ModelAndView("json", "entities", entities);
}
Also used : ArrayList(java.util.ArrayList) 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 4 with ResourceMapping

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

the class PortletMarketplaceController method saveRating.

/**
     * Use to save the rating of portlet
     *
     * @param request
     * @param response
     * @param portletFName fname of the portlet to rate
     * @param rating will be parsed to int
     * @param review optional review to be saved along with rating
     * @throws NumberFormatException if rating cannot be parsed to an int
     */
@ResourceMapping("saveRating")
public void saveRating(ResourceRequest request, ResourceResponse response, PortletRequest portletRequest, @RequestParam String portletFName, @RequestParam String rating, @RequestParam(required = false) String review) {
    Validate.notNull(rating, "Please supply a rating - should not be null");
    Validate.notNull(portletFName, "Please supply a portlet to rate - should not be null");
    // Make certain reviews are permitted before trying to save one
    final PortletPreferences prefs = request.getPreferences();
    final String enableReviewsPreferenceValue = prefs.getValue(ENABLE_REVIEWS_PREFERENCE, ENABLE_REVIEWS_DEFAULT);
    if (!Boolean.valueOf(enableReviewsPreferenceValue)) {
        // Clear the parameter if sent...
        review = null;
    }
    marketplaceRatingDAO.createOrUpdateRating(Integer.parseInt(rating), portletRequest.getRemoteUser(), review, portletDefinitionDao.getPortletDefinitionByFname(portletFName));
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping)

Example 5 with ResourceMapping

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

the class PortletMarketplaceController method getRating.

/**
     * @param request
     * @param response
     * @param portletRequest
     * @return 'rating' as a JSON object. Can be null if rating doesn't exist.
     */
@ResourceMapping("getRating")
public String getRating(ResourceRequest request, ResourceResponse response, @RequestParam String portletFName, PortletRequest portletRequest, Model model) {
    Validate.notNull(portletFName, "Please supply a portlet to get rating for - should not be null");
    IMarketplaceRating tempRating = marketplaceRatingDAO.getRating(portletRequest.getRemoteUser(), portletDefinitionDao.getPortletDefinitionByFname(portletFName));
    model.addAttribute("rating", tempRating == null ? null : tempRating.getRating());
    return "json";
}
Also used : IMarketplaceRating(org.apereo.portal.portlet.marketplace.IMarketplaceRating) 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