Search in sources :

Example 1 with MicaConfigUpdatedEvent

use of org.obiba.mica.micaConfig.event.MicaConfigUpdatedEvent 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)

Aggregations

MicaConfig (org.obiba.mica.micaConfig.domain.MicaConfig)1 MicaConfigUpdatedEvent (org.obiba.mica.micaConfig.event.MicaConfigUpdatedEvent)1 CacheEvict (org.springframework.cache.annotation.CacheEvict)1