use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class ResourceDAO method updateResource.
/**
* Aggiorna una risorsa nel database.
*
* @param resource La risorsa da aggiornare nel db.
*/
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'jacms_resource_'.concat(#resource.id)", condition = "null != #resource")
public void updateResource(ResourceInterface resource) {
Connection conn = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
this.executeUpdateResource(resource, conn);
conn.commit();
} catch (Throwable t) {
this.executeRollback(conn);
_logger.error("Error updating resource", t);
throw new RuntimeException("Error updating resource", t);
} finally {
closeConnection(conn);
}
}
use of org.springframework.cache.annotation.CacheEvict in project tesla by linking12.
the class RoleServiceImpl method save.
@CacheEvict(value = CACHE_NAME, key = ROLE_ALL_KEY)
@Transactional
@Override
public int save(RoleDO role) {
int count = roleMapper.save(role);
List<Long> menuIds = role.getMenuIds();
Long roleId = role.getRoleId();
List<RoleMenuDO> rms = new ArrayList<>();
for (Long menuId : menuIds) {
RoleMenuDO rmDo = new RoleMenuDO();
rmDo.setRoleId(roleId);
rmDo.setMenuId(menuId);
rms.add(rmDo);
}
roleMenuMapper.removeByRoleId(roleId);
if (rms.size() > 0) {
roleMenuMapper.batchSave(rms);
}
return count;
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class UserProfileManager method updateProfile.
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
public void updateProfile(String username, IUserProfile profile) throws ApsSystemException {
try {
profile.setId(username);
this.getProfileDAO().updateEntity(profile);
this.notifyProfileChanging(profile, ProfileChangedEvent.UPDATE_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error updating profile {}", username, t);
throw new ApsSystemException("Error updating profile", t);
}
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class UserProfileManager method addProfile.
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
public void addProfile(String username, IUserProfile profile) throws ApsSystemException {
try {
profile.setId(username);
this.getProfileDAO().addEntity(profile);
this.notifyProfileChanging(profile, ProfileChangedEvent.INSERT_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error saving profile - user: {}", username, t);
throw new ApsSystemException("Error saving profile", t);
}
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class UserProfileManager method deleteProfile.
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
public void deleteProfile(String username) throws ApsSystemException {
try {
IUserProfile profileToDelete = this.getProfile(username);
if (null == profileToDelete) {
return;
}
this.getProfileDAO().deleteEntity(username);
this.notifyProfileChanging(profileToDelete, ProfileChangedEvent.REMOVE_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error deleting user profile {}", username, t);
throw new ApsSystemException("Error deleting user profile", t);
}
}
Aggregations