Example #1
0
 private List<String> validate(SeoUrlEntity entity) {
   List<String> errors = new ArrayList<String>();
   SeoUrlEntity found = getDao().getSeoUrlDao().getByFrom(entity.getFromLink());
   if (found != null && !found.getId().equals(entity.getId())) {
     errors.add(Messages.get("seo_urls.already_exists"));
   }
   return errors;
 }
Example #2
0
 @Override
 public ServiceResponse save(Map<String, String> vo) {
   SeoUrlEntity seoUrl = null;
   if (!StringUtils.isEmpty(vo.get("id"))) {
     seoUrl = getDao().getSeoUrlDao().getById(Long.valueOf(vo.get("id")));
   }
   if (seoUrl == null) {
     seoUrl = new SeoUrlEntity();
   }
   seoUrl.setFromLink(vo.get("fromLink"));
   seoUrl.setToLink(vo.get("toLink"));
   List<String> errors = validate(seoUrl);
   if (errors.isEmpty()) {
     getDao().getSeoUrlDao().save(seoUrl);
     return ServiceResponse.createSuccessResponse(Messages.get("seo_urls.success_save"));
   } else {
     return ServiceResponse.createErrorResponse(Messages.get("errors_occured"), errors);
   }
 }