use of org.springframework.cache.annotation.CacheEvict in project thingsboard by thingsboard.
the class DeviceServiceImpl method saveDevice.
@CacheEvict(cacheNames = DEVICE_CACHE, key = "{#device.tenantId, #device.name}")
@Override
public Device saveDevice(Device device) {
log.trace("Executing saveDevice [{}]", device);
deviceValidator.validate(device);
Device savedDevice = deviceDao.save(device);
if (device.getId() == null) {
DeviceCredentials deviceCredentials = new DeviceCredentials();
deviceCredentials.setDeviceId(new DeviceId(savedDevice.getUuidId()));
deviceCredentials.setCredentialsType(DeviceCredentialsType.ACCESS_TOKEN);
deviceCredentials.setCredentialsId(RandomStringUtils.randomAlphanumeric(20));
deviceCredentialsService.createDeviceCredentials(deviceCredentials);
}
return savedDevice;
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class UserProfileManager method updateProfile.
@AfterReturning(pointcut = "execution(* com.agiletec.aps.system.services.user.IUserManager.updateUser(..)) && args(user,..)")
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#user.username)")
public void updateProfile(Object user) {
if (user != null) {
UserDetails userDetails = (UserDetails) user;
Object profile = userDetails.getProfile();
if (null != profile) {
try {
this.updateProfile(userDetails.getUsername(), (IUserProfile) profile);
} catch (Throwable t) {
logger.error("Error updating profile to user {}", userDetails.getUsername(), t);
}
}
}
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class SocialActivityStreamManager method addActionCommentRecord.
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamCommentRecords_id_'.concat(#streamId)")
public void addActionCommentRecord(String username, String commentText, int streamId) throws ApsSystemException {
try {
Integer key = null;
ActionLogRecord record = null;
do {
key = this.getKeyGeneratorManager().getUniqueKeyCurrentValue();
record = this.getActionLogManager().getActionRecord(key);
} while (null != record);
this.getSocialActivityStreamDAO().addActionCommentRecord(key, streamId, username, commentText);
this.getActionLogManager().updateRecordDate(streamId);
} catch (Throwable t) {
_logger.error("Error adding a comment record to stream with id:{}", streamId, t);
throw new ApsSystemException("Error adding a comment record", t);
}
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class ContentManager method removeOnLineContent.
/**
* Unpublish a content, preventing it from being displayed in the portal.
* Obviously the content itself is not deleted.
*
* @param content the content to unpublish.
* @throws ApsSystemException in case of error
*/
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "T(com.agiletec.plugins.jacms.aps.system.JacmsSystemConstants).CONTENT_CACHE_PREFIX.concat(#content.id)", condition = "#content.id != null")
@CacheInfoEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, groups = "T(com.agiletec.plugins.jacms.aps.system.services.cache.CmsCacheWrapperManager).getContentCacheGroupsToEvictCsv(#content.id, #content.typeCode)")
public void removeOnLineContent(Content content) throws ApsSystemException {
try {
content.setLastModified(new Date());
content.incrementVersion(false);
if (null != content.getStatus() && content.getStatus().equals(Content.STATUS_PUBLIC)) {
content.setStatus(Content.STATUS_READY);
}
this.getContentDAO().removeOnLineContent(content);
this.notifyPublicContentChanging(content, PublicContentChangedEvent.REMOVE_OPERATION_CODE);
} catch (Throwable t) {
_logger.error("Error while removing onLine content", t);
throw new ApsSystemException("Error while removing onLine content", t);
}
}
use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class ResourceDAO method deleteResource.
/**
* Cancella una risorsa dal db.
*
* @param id L'identificativo della risorsa da cancellare.
*/
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'jacms_resource_'.concat(#id)", condition = "null != #id")
public void deleteResource(String id) {
Connection conn = null;
try {
conn = this.getConnection();
conn.setAutoCommit(false);
this.executeDeleteResource(id, conn);
conn.commit();
} catch (Throwable t) {
this.executeRollback(conn);
_logger.error("Error deleting resource {}", id, t);
throw new RuntimeException("Error deleting resource " + id, t);
} finally {
this.closeConnection(conn);
}
}
Aggregations