try {
this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForUpdate(command.json());
final Fund fund = this.fundRepository.findOne(fundId);
if (fund == null) { throw new FundNotFoundException(fundId); }
final Map<String, Object> changes = fund.update(command);
if (!changes.isEmpty()) {
this.fundRepository.saveAndFlush(fund);
}
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(fund.getId()).with(changes).build();
} catch (final DataIntegrityViolationException dve) {
handleFundDataIntegrityIssues(command, dve);
return CommandProcessingResult.empty();
}
}