Search in sources :

Example 6 with CacheEvict

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

Example 7 with CacheEvict

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;
}
Also used : ArrayList(java.util.ArrayList) RoleMenuDO(io.github.tesla.ops.system.domain.RoleMenuDO) CacheEvict(org.springframework.cache.annotation.CacheEvict) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with CacheEvict

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

Example 9 with CacheEvict

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

Example 10 with CacheEvict

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);
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) 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