use of org.springframework.cache.annotation.CacheEvict in project entando-core by entando.
the class GuiFragmentManager method updateGuiFragment.
@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 updateGuiFragment(GuiFragment guiFragment) throws ApsSystemException {
try {
this.getGuiFragmentDAO().updateGuiFragment(guiFragment);
this.notifyGuiFragmentChangedEvent(guiFragment, GuiFragmentChangedEvent.UPDATE_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error updating GuiFragment", t);
throw new ApsSystemException("Error updating GuiFragment " + guiFragment, t);
}
}
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));
}
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);
}
use of org.springframework.cache.annotation.CacheEvict in project codekvast by crispab.
the class CustomerServiceImpl method deleteCustomerByExternalId.
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CUSTOMERS_CACHE, allEntries = true)
public void deleteCustomerByExternalId(@NonNull String source, String externalId) {
CustomerData customerData = getCustomerDataByExternalId(source, externalId);
long customerId = customerData.getCustomerId();
deleteFromTable("invocations", customerId);
deleteFromTable("method_locations", customerId);
deleteFromTable("methods", customerId);
deleteFromTable("jvms", customerId);
deleteFromTable("environments", customerId);
deleteFromTable("applications", customerId);
deleteFromTable("users", customerId);
deleteFromTable("agent_state", customerId);
deleteFromTable("price_plan_overrides", customerId);
deleteFromTable("heroku_details", customerId);
deleteFromTable("facts", customerId);
deleteFromTable("customers", customerId);
eventService.send(CustomerDeletedEvent.builder().customerId(customerId).name(customerData.getCustomerName()).displayName(customerData.getDisplayName()).source(customerData.getSource()).plan(customerData.getPricePlan().getName()).build());
slackService.sendNotification("Deleted `" + customerData + "`", SlackService.Channel.BUSINESS_EVENTS);
logger.info("Deleted customer {}", customerData);
}
use of org.springframework.cache.annotation.CacheEvict in project codekvast by crispab.
the class CustomerServiceImpl method changePlanForExternalId.
@Override
@Transactional(rollbackFor = Exception.class)
@CacheEvict(value = CUSTOMERS_CACHE, allEntries = true)
public void changePlanForExternalId(String source, @NonNull String externalId, @NonNull String newPlanName) {
CustomerData customerData = getCustomerDataByExternalId(source, externalId);
PricePlan oldEffectivePricePlan = customerData.getPricePlan();
String oldPlanName = oldEffectivePricePlan.getName();
if (newPlanName.equals(oldPlanName)) {
logger.info("{} is already on plan '{}'", customerData, newPlanName);
return;
}
int count = jdbcTemplate.update("UPDATE customers SET plan = ? WHERE source = ? AND externalId = ? ORDER BY id ", newPlanName, source, externalId);
if (count == 0) {
logger.error("Failed to change plan for customer {} from '{}' to '{}'", customerData.getDisplayName(), oldPlanName, newPlanName);
return;
}
String logMessage = String.format("Changed plan for customer %s from '%s' to '%s'", customerData.getDisplayName(), oldPlanName, newPlanName);
logger.info(logMessage);
slackService.sendNotification(logMessage, SlackService.Channel.BUSINESS_EVENTS);
eventService.send(PlanChangedEvent.builder().customerId(customerData.getCustomerId()).oldPlan(oldPlanName).newPlan(newPlanName).build());
count = jdbcTemplate.update("DELETE FROM price_plan_overrides WHERE customerId = ?", customerData.getCustomerId());
if (count > 0) {
PricePlan newEffectivePricePlan = PricePlan.of(PricePlanDefaults.ofDatabaseName(newPlanName));
eventService.send(PlanOverridesDeletedEvent.builder().customerId(customerData.getCustomerId()).oldEffectivePlan(oldEffectivePricePlan).newEffectivePlan(newEffectivePricePlan).build());
String pricePlanOverridesMessage = String.format("Removed price plan overrides for customer %s, effective price plan changed from `%s` to `%s`", customerData.getDisplayName(), oldEffectivePricePlan, newEffectivePricePlan);
slackService.sendNotification(pricePlanOverridesMessage, SlackService.Channel.BUSINESS_EVENTS);
logger.warn(pricePlanOverridesMessage);
}
}
Aggregations