Search in sources :

Example 36 with CacheEvict

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;
}
Also used : DeviceId(org.thingsboard.server.common.data.id.DeviceId) DeviceCredentials(org.thingsboard.server.common.data.security.DeviceCredentials) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 37 with CacheEvict

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);
            }
        }
    }
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) CacheEvict(org.springframework.cache.annotation.CacheEvict) AfterReturning(org.aspectj.lang.annotation.AfterReturning)

Example 38 with CacheEvict

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);
    }
}
Also used : ActionLogRecord(org.entando.entando.aps.system.services.actionlog.model.ActionLogRecord) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 39 with CacheEvict

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);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Date(java.util.Date) CacheEvict(org.springframework.cache.annotation.CacheEvict) CacheInfoEvict(org.entando.entando.aps.system.services.cache.CacheInfoEvict)

Example 40 with CacheEvict

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);
    }
}
Also used : Connection(java.sql.Connection) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Aggregations

CacheEvict (org.springframework.cache.annotation.CacheEvict)53 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)14 Transactional (org.springframework.transaction.annotation.Transactional)13 Date (java.util.Date)8 ArrayList (java.util.ArrayList)6 CacheInfoEvict (org.entando.entando.aps.system.services.cache.CacheInfoEvict)5 QUser (com.github.liuweijw.business.admin.domain.QUser)3 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)3 ConnectorRequestContext (com.netflix.metacat.common.server.connectors.ConnectorRequestContext)3 ConnectorTableService (com.netflix.metacat.common.server.connectors.ConnectorTableService)3 QMenu (com.github.liuweijw.business.admin.domain.QMenu)2 QRole (com.github.liuweijw.business.admin.domain.QRole)2 QUserRole (com.github.liuweijw.business.admin.domain.QUserRole)2 Role (com.github.liuweijw.business.admin.domain.Role)2 User (com.github.liuweijw.business.admin.domain.User)2 UserRole (com.github.liuweijw.business.admin.domain.UserRole)2 AuthUser (com.github.liuweijw.system.api.model.AuthUser)2 RoleMenuDO (io.github.tesla.ops.system.domain.RoleMenuDO)2 Connection (java.sql.Connection)2 HashMap (java.util.HashMap)2