* to set the current logged user.
*/
@Transactional
@Override public void create(DomainEntity entity, boolean flush) {
if (entity instanceof AbstractOwnedDomainEntity) {
AbstractOwnedDomainEntity owned = (AbstractOwnedDomainEntity) entity;
if (CollectionUtils.isEmpty(owned.getOwners())) {
User user = getCurrentUser();
if (user instanceof UserImpl) {
if (logger.isDebugEnabled()) logger.debug("Adding default owner [" + user + "] to entity [" + entity + "]");
owned.addOwner((UserImpl) user);
}
}
}
super.create(entity, flush);
}