Search in sources :

Example 46 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)

Example 47 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project metacat by Netflix.

the class ConnectorTableServiceProxy method rename.

/**
 * Calls the connector table service rename method.
 * @param oldName old table name
 * @param newName new table name
 * @param isMView true, if the object is a view
 */
@CacheEvict(key = "'table.' + #oldName")
public void rename(final QualifiedName oldName, final QualifiedName newName, final boolean isMView) {
    final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
    final ConnectorTableService service = connectorManager.getTableService(oldName);
    try {
        log.info("Renaming {} {} to {}", isMView ? "view" : "table", oldName, newName);
        final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
        service.rename(connectorRequestContext, oldName, newName);
    } catch (UnsupportedOperationException ignored) {
    }
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorTableService(com.netflix.metacat.common.server.connectors.ConnectorTableService) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 48 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project metacat by Netflix.

the class ConnectorTableServiceProxy method delete.

/**
 * Calls the connector table service delete method.
 * @param name table name
 */
@CacheEvict(key = "'table.' + #name")
public void delete(final QualifiedName name) {
    final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
    final ConnectorTableService service = connectorManager.getTableService(name);
    log.info("Drop table {}", name);
    final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
    service.delete(connectorRequestContext, name);
}
Also used : MetacatRequestContext(com.netflix.metacat.common.MetacatRequestContext) ConnectorTableService(com.netflix.metacat.common.server.connectors.ConnectorTableService) ConnectorRequestContext(com.netflix.metacat.common.server.connectors.ConnectorRequestContext) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 49 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.

the class SocialActivityStreamManager method editActionLikeRecord.

@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamLikeRecords_id_'.concat(#id)")
public void editActionLikeRecord(int id, String username, boolean add) throws ApsSystemException {
    try {
        this.getSocialActivityStreamDAO().editActionLikeRecord(id, username, add);
        this.getActionLogManager().updateRecordDate(id);
    } catch (Throwable t) {
        _logger.error("Error editing activity stream like records", t);
        throw new ApsSystemException("Error editing activity stream like records", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 50 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.

the class GuiFragmentManager method addGuiFragment.

@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'GuiFragment_'.concat(#guiFragment.code)")
// TODO improve group handling
@CacheInfoEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, groups = "'GuiFragment_uniqueByWidgetTypeGroup,GuiFragment_codesByWidgetTypeGroup'")
public void addGuiFragment(GuiFragment guiFragment) throws ApsSystemException {
    try {
        this.getGuiFragmentDAO().insertGuiFragment(guiFragment);
        this.notifyGuiFragmentChangedEvent(guiFragment, GuiFragmentChangedEvent.INSERT_OPERATION_CODE);
    } catch (Throwable t) {
        logger.error("Error adding GuiFragment", t);
        throw new ApsSystemException("Error adding GuiFragment", t);
    }
}
Also used : ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict) CacheInfoEvict(org.entando.entando.aps.system.services.cache.CacheInfoEvict)

Aggregations

CacheEvict (org.springframework.cache.annotation.CacheEvict)64 Transactional (org.springframework.transaction.annotation.Transactional)17 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)14 Date (java.util.Date)8 ArrayList (java.util.ArrayList)6 CacheInfoEvict (org.entando.entando.aps.system.services.cache.CacheInfoEvict)5 DataValidationException (org.thingsboard.server.dao.exception.DataValidationException)5 EntityView (org.thingsboard.server.common.data.EntityView)4 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 ExecutionException (java.util.concurrent.ExecutionException)3 ConstraintViolationException (org.hibernate.exception.ConstraintViolationException)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