try {
acHostOption = acHostRepository.findByKey(clientKey);
} catch (Throwable throwable) {
return Promise.throwing(throwable);
}
final AcHost acHost = acHostOption.orElse(new Supplier<Option<AcHost>>() {
@Override
public Option<AcHost> get() {
try {
return acHostRepository.findByUrl(baseUrl);
} catch (Throwable e) {
return none(AcHost.class);
}
}
}).getOrElse(new AcHost());
acHost.setKey(clientKey);
acHost.setBaseUrl(baseUrl);
acHost.setPublicKey(publicKey);
acHost.setSharedSecret(sharedSecret);
acHost.setName(name);
try {
acHostRepository.save(acHost);
} catch (Throwable throwable) {
return Promise.throwing(throwable);