final Throwable realCause = dve.getMostSpecificCause();
if (realCause.getMessage().contains("external_id")) {
final String externalId = command.stringValueOfParameterNamed("externalId");
throw new PlatformDataIntegrityException("error.msg.staff.duplicate.externalId", "Staff with externalId `" + externalId
+ "` already exists", "externalId", externalId);
} else if (realCause.getMessage().contains("display_name")) {
final String lastname = command.stringValueOfParameterNamed("lastname");
String displayName = lastname;
if (!StringUtils.isBlank(displayName)) {
final String firstname = command.stringValueOfParameterNamed("firstname");
displayName = lastname + ", " + firstname;
}
throw new PlatformDataIntegrityException("error.msg.staff.duplicate.displayName", "A staff with the given display name '"
+ displayName + "' already exists", "displayName", displayName);
}
logger.error(dve.getMessage(), dve);
throw new PlatformDataIntegrityException("error.msg.staff.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " + realCause.getMessage());
}