put("restrictEntities", entities);
put("categories", entityDao.getAll(Category.class));
}
protected String saveAndForward(Entity<?> entity) {
Resource resource = (Resource) entity;
if (null != resource) {
if (entityDao.duplicate(Resource.class, resource.getId(), "name", resource.getName())) { return redirect(
"edit", "error.notUnique"); }
}
List<RestrictEntity> entities = entityDao.get(RestrictEntity.class,
getAll("restrictEntityId", Long.class));
resource.getEntities().clear();
resource.getEntities().addAll(entities);
List<Category> categories = entityDao.get(Category.class, getAll("categoryId",Long.class));
resource.getCategories().clear();
resource.getCategories().addAll(categories);
entityDao.saveOrUpdate(resource);
authorityManager.refreshCache();
logger.info("save resource success {}", resource.getTitle());
return redirect("search", "info.save.success");
}