|
@ -118,13 +118,16 @@ public class BookController { |
|
|
HttpServletRequest requestData |
|
|
HttpServletRequest requestData |
|
|
) { |
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
// TODO consider better solution. Add custom Hibernate annotation for Book class? |
|
|
|
|
|
if (bookRepository.existsByIsbn(book.getIsbn())) { |
|
|
|
|
|
bindingResult.rejectValue("isbn", "error.user", "ISBN code already exists"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (bindingResult.hasErrors()) { |
|
|
if (bindingResult.hasErrors()) { |
|
|
httpServerLogger.commonError("Book add: error " + book.toString(), requestData); |
|
|
httpServerLogger.commonError("Book add: error " + book.toString(), requestData); |
|
|
return bookAddPageView; |
|
|
return bookAddPageView; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bookRepository.save(book); |
|
|
|
|
|
|
|
|
|
|
|
httpServerLogger.logMessageNormal( |
|
|
httpServerLogger.logMessageNormal( |
|
|
requestData, |
|
|
requestData, |
|
|
bookAddPageView + ": " + "HTTPOK" |
|
|
bookAddPageView + ": " + "HTTPOK" |
|
|