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");
}
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");
}
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);
}
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));
}
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";
}
Aggregations