|
@ -3,6 +3,8 @@ |
|
|
package com.fjordtek.bookstore.web; |
|
|
package com.fjordtek.bookstore.web; |
|
|
|
|
|
|
|
|
import java.time.Year; |
|
|
import java.time.Year; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.validation.Valid; |
|
|
import javax.validation.Valid; |
|
@ -32,6 +34,20 @@ public class BookController { |
|
|
private static final String bookDeletePageView = "bookdelete"; |
|
|
private static final String bookDeletePageView = "bookdelete"; |
|
|
private static final String bookEditPageView = "bookedit"; |
|
|
private static final String bookEditPageView = "bookedit"; |
|
|
|
|
|
|
|
|
|
|
|
private static String currency_symbol = "€"; |
|
|
|
|
|
|
|
|
|
|
|
private Map<String,String> globalModelMap = new HashMap<String,String>() { |
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
|
|
{ |
|
|
|
|
|
put("indexpage", landingPageView); |
|
|
|
|
|
put("listpage", bookListPageView); |
|
|
|
|
|
put("addpage", bookAddPageView); |
|
|
|
|
|
put("deletepage", bookDeletePageView); |
|
|
|
|
|
put("editpage", bookEditPageView); |
|
|
|
|
|
|
|
|
|
|
|
put("currency_symbol", currency_symbol); |
|
|
|
|
|
}}; |
|
|
|
|
|
|
|
|
private HttpServerLogger httpServerLogger = new HttpServerLogger(); |
|
|
private HttpServerLogger httpServerLogger = new HttpServerLogger(); |
|
|
//private HttpExceptionHandler httpExceptionHandler = new HttpExceptionHandler(); |
|
|
//private HttpExceptionHandler httpExceptionHandler = new HttpExceptionHandler(); |
|
|
|
|
|
|
|
@ -41,6 +57,13 @@ public class BookController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private CategoryRepository categoryRepository; |
|
|
private CategoryRepository categoryRepository; |
|
|
|
|
|
|
|
|
|
|
|
@ModelAttribute |
|
|
|
|
|
public void globalAttributes(Model dataModel) { |
|
|
|
|
|
|
|
|
|
|
|
// Security implications of adding these all? |
|
|
|
|
|
dataModel.addAllAttributes(globalModelMap); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
////////////////////////////// |
|
|
////////////////////////////// |
|
|
// LIST PAGE |
|
|
// LIST PAGE |
|
|
@RequestMapping( |
|
|
@RequestMapping( |
|
@ -51,10 +74,6 @@ public class BookController { |
|
|
|
|
|
|
|
|
dataModel.addAttribute("books", bookRepository.findAll()); |
|
|
dataModel.addAttribute("books", bookRepository.findAll()); |
|
|
|
|
|
|
|
|
dataModel.addAttribute("deletepage", bookDeletePageView); |
|
|
|
|
|
dataModel.addAttribute("editpage", bookEditPageView); |
|
|
|
|
|
dataModel.addAttribute("addpage", bookAddPageView); |
|
|
|
|
|
|
|
|
|
|
|
httpServerLogger.logMessageNormal( |
|
|
httpServerLogger.logMessageNormal( |
|
|
requestData, |
|
|
requestData, |
|
|
bookListPageView + ": " + "HTTPOK" |
|
|
bookListPageView + ": " + "HTTPOK" |
|
@ -80,9 +99,6 @@ public class BookController { |
|
|
dataModel.addAttribute("book", new Book()); |
|
|
dataModel.addAttribute("book", new Book()); |
|
|
dataModel.addAttribute("categories", categoryRepository.findAll()); |
|
|
dataModel.addAttribute("categories", categoryRepository.findAll()); |
|
|
|
|
|
|
|
|
dataModel.addAttribute("addpage", bookAddPageView); |
|
|
|
|
|
dataModel.addAttribute("listpage", bookListPageView); |
|
|
|
|
|
|
|
|
|
|
|
if (newBook.getYear() == 0) { |
|
|
if (newBook.getYear() == 0) { |
|
|
newBook.setYear(Year.now().getValue()); |
|
|
newBook.setYear(Year.now().getValue()); |
|
|
} |
|
|
} |
|
@ -160,8 +176,6 @@ public class BookController { |
|
|
dataModel.addAttribute("book", book); |
|
|
dataModel.addAttribute("book", book); |
|
|
dataModel.addAttribute("categories", categoryRepository.findAll()); |
|
|
dataModel.addAttribute("categories", categoryRepository.findAll()); |
|
|
|
|
|
|
|
|
dataModel.addAttribute("listpage", bookListPageView); |
|
|
|
|
|
|
|
|
|
|
|
httpServerLogger.logMessageNormal( |
|
|
httpServerLogger.logMessageNormal( |
|
|
requestData, |
|
|
requestData, |
|
|
bookEditPageView + ": " + "HTTPOK" |
|
|
bookEditPageView + ": " + "HTTPOK" |
|
|