return getDao().getTemplateDao().getById(id);
}
@Override
public ServiceResponse saveTemplate(Map<String, String> vo) {
TemplateEntity template = null;
if (!StringUtils.isEmpty(vo.get("id"))) {
template = getDao().getTemplateDao().getById(Long.valueOf(
vo.get("id")));
}
if (template == null) {
template = new TemplateEntity();
}
template.setTitle(vo.get("title"));
template.setUrl(vo.get("url"));
template.setContent(vo.get("content"));
List<String> errors = getBusiness().getTemplateBusiness()
.validateBeforeUpdate(template);
if (errors.isEmpty()) {
getBusiness().getTemplateBusiness().save(template);
return ServiceResponse.createSuccessResponse(template.getId()
.toString());
}
else {
return ServiceResponse.createErrorResponse(
Messages.get("errors_occured"), errors);