try {
this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForUpdate(command.json());
final Holiday holiday = this.holidayRepository.findOneWithNotFoundDetection(command.entityId());
Map<String, Object> changes = holiday.update(command);
validateInputDates(holiday.getFromDateLocalDate(), holiday.getToDateLocalDate(), holiday.getRepaymentsRescheduledToLocalDate());
if (changes.containsKey(officesParamName)) {
final Set<Office> offices = getSelectedOffices(command);
final boolean updated = holiday.update(offices);
if (!updated) {
changes.remove(officesParamName);
}
}
this.holidayRepository.saveAndFlush(holiday);
return new CommandProcessingResultBuilder().withEntityId(holiday.getId()).with(changes).build();
} catch (final DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve);
return CommandProcessingResult.empty();
}
}