use of org.apereo.portal.i18n.Message 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.apereo.portal.i18n.Message in project uPortal by Jasig.
the class JpaMessageDao method deleteMessage.
@Override
@PortalTransactional
public void deleteMessage(Message message) {
Validate.notNull(message, "message can not be null");
final Message msg;
final EntityManager entityManager = this.getEntityManager();
if (entityManager.contains(message)) {
msg = message;
} else {
msg = entityManager.merge(message);
}
entityManager.remove(msg);
}
use of org.apereo.portal.i18n.Message in project uPortal by Jasig.
the class JpaMessageDao method createMessage.
@Override
@PortalTransactional
public Message createMessage(String code, Locale locale, String value) {
Validate.notNull(code, "code can not be null");
final Message msg = new MessageImpl(code, locale, value);
this.getEntityManager().persist(msg);
return msg;
}
use of org.apereo.portal.i18n.Message 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);
}
Aggregations