Search in sources :

Example 41 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project mica2 by obiba.

the class MicaConfigService method save.

@CacheEvict(value = "micaConfig", allEntries = true)
public void save(@NotNull @Valid MicaConfig micaConfig) {
    MicaConfig savedConfig = getOrCreateMicaConfig();
    ArrayList<String> removedRoles = Lists.newArrayList(Sets.difference(Sets.newHashSet(savedConfig.getRoles()), Sets.newHashSet(micaConfig.getRoles())));
    BeanUtils.copyProperties(micaConfig, savedConfig, "id", "version", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate", "secretKey", "micaVersion");
    if (micaConfig.getMicaVersion() != null)
        savedConfig.setMicaVersion(micaConfig.getMicaVersion());
    micaConfigRepository.save(savedConfig);
    eventBus.post(new MicaConfigUpdatedEvent(getConfig(), removedRoles));
}
Also used : MicaConfig(org.obiba.mica.micaConfig.domain.MicaConfig) MicaConfigUpdatedEvent(org.obiba.mica.micaConfig.event.MicaConfigUpdatedEvent) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 42 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 43 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 44 with CacheEvict

use of org.springframework.cache.annotation.CacheEvict in project ArachneCentralAPI by OHDSI.

the class CommentServiceImpl method addComment.

@CacheEvict(cacheNames = "comments", allEntries = true)
@Override
@PreAuthorize("hasPermission(#topicId, 'CommentTopic', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).EDIT_INSIGHT)")
public Comment addComment(Long topicId, Long parentId, Comment comment) {
    comment.setId(null);
    comment.setDate(new Date());
    final CommentTopic topic = commentTopicRepository.getOne(topicId);
    comment.setTopic(topic);
    if (parentId != null) {
        final Comment parent = commentRepository.findById(parentId).orElse(null);
        comment.setParent(parent);
    }
    return commentRepository.save(comment);
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) Date(java.util.Date) CacheEvict(org.springframework.cache.annotation.CacheEvict) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

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

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