Skip to content

Commit c6f39e3

Browse files
committed
Merge branch 'master' of https://github.com/tomersimis/rgms
2 parents a98dee1 + e6a8d78 commit c6f39e3

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

grails-app/controllers/rgms/publication/BookController.groovy

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ class BookController {
4040

4141
def show(Long id) {
4242
def bookInstance = Book.get(id)
43-
if (!bookInstance) {
44-
flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id])
45-
redirect(action: "list")
46-
return
47-
}
48-
49-
[bookInstance: bookInstance]
43+
bookInstanceRedirectIfItsNull(id, bookInstance)
5044
}
5145

5246
def edit(Long id) {
5347
def bookInstance = Book.get(id)
48+
bookInstanceRedirectIfItsNull(id, bookInstance)
49+
}
50+
51+
private def bookInstanceRedirectIfItsNull(Long id, Book bookInstance) {
5452
if (!bookInstance) {
5553
flash.message = message(code: 'default.not.found.message', args: [message(code: 'book.label', default: 'Book'), id])
5654
redirect(action: "list")
@@ -68,14 +66,12 @@ class BookController {
6866
return
6967
}
7068

71-
if (version != null) {
72-
if (bookInstance.version > version) {
69+
if (version != null && bookInstance.version > version) {
7370
bookInstance.errors.rejectValue("version", "default.optimistic.locking.failure",
7471
[message(code: 'book.label', default: 'Book')] as Object[],
7572
"Another user has updated this Book while you were editing")
7673
render(view: "edit", model: [bookInstance: bookInstance])
7774
return
78-
}
7975
}
8076

8177
bookInstance.properties = params

0 commit comments

Comments
 (0)