put("restrictObjects", objects);
put("categories", entityDao.getAll(UserCategory.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"); }
}
Long[] patternIds = SeqStrUtils.transformToLong(get("restrictObjectIds"));
List<RestrictObject> objects = Collections.emptyList();
if (null != patternIds) {
objects = entityDao.get(RestrictObject.class, patternIds);
}
resource.getObjects().clear();
resource.getObjects().addAll(objects);
String categoryIds = get("categoryIds");
List<UserCategory> categories = entityDao.get(UserCategory.class,
SeqStrUtils.transformToLong(categoryIds));
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");
}