use of org.obiba.mica.micaConfig.domain.MicaConfig in project mica2 by obiba.
the class CustomTranslationsResource method save.
@PUT
@Path("/{locale}.json")
@Consumes("application/json")
public Response save(String translations, @PathParam("locale") String locale, @QueryParam("merge") @DefaultValue("false") boolean merge) throws IOException {
MicaConfig config = micaConfigService.getConfig();
if (merge) {
micaConfigService.mergeJson(getTranslations(locale), objectMapper.readTree(translations));
} else {
config.getTranslations().put(locale, translations);
}
micaConfigService.save(config);
return Response.ok().build();
}
use of org.obiba.mica.micaConfig.domain.MicaConfig in project mica2 by obiba.
the class MicaVersionModifier method setVersion.
@Override
public void setVersion(Version version) {
MicaConfig config = micaConfigService.getConfig();
config.setMicaVersion(version);
micaConfigService.save(config);
}
use of org.obiba.mica.micaConfig.domain.MicaConfig 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.obiba.mica.micaConfig.domain.MicaConfig in project mica2 by obiba.
the class MicaConfigService method getPublicUrl.
/**
* Get the public url, statically defined if not part of the {@link org.obiba.mica.micaConfig.domain.MicaConfig}.
*
* @return
*/
public String getPublicUrl() {
MicaConfig config = getConfig();
if (config.hasPublicUrl()) {
return config.getPublicUrl();
} else {
String host = env.getProperty("server.address");
String port = env.getProperty("https.port");
return "https://" + host + ":" + port;
}
}
use of org.obiba.mica.micaConfig.domain.MicaConfig in project mica2 by obiba.
the class MicaConfigService method getOrCreateMicaConfig.
private MicaConfig getOrCreateMicaConfig() {
if (micaConfigRepository.count() == 0) {
MicaConfig micaConfig = new MicaConfig();
micaConfig.getLocales().add(MicaConfig.DEFAULT_LOCALE);
micaConfig.setSecretKey(generateSecretKey());
micaConfigRepository.save(micaConfig);
return getConfig();
}
return micaConfigRepository.findAll().get(0);
}
Aggregations