@@ -0,0 +1,2211 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0A package cz.muni.fi.pa165.controller;%0A%0A%0A%0A%0Aimport cz.muni.fi.pa165.dto.BookDTO;%0Aimport cz.muni.fi.pa165.dto.CreateBookDTO;%0Aimport cz.muni.fi.pa165.enums.BookState;%0Aimport cz.muni.fi.pa165.facade.BookFacade;%0Aimport java.util.Collections;%0A%0A%0Aimport java.util.List;%0Aimport javax.inject.Inject;%0A%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.web.bind.annotation.PathVariable;%0Aimport org.springframework.web.bind.annotation.RequestBody;%0A%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod;%0Aimport org.springframework.web.bind.annotation.RestController;%0A%0A%0A@RestController%0A@RequestMapping(%22/rest/books%22)%0Apublic class BookRestController %7B%0A    final static Logger logger = LoggerFactory.getLogger(BookController.class);%0A%0A    @Inject%0A    private BookFacade bookFacade;%0A%0A    %0A    @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)%0A    public List%3CBookDTO%3E getAll()%7B%0A        return bookFacade.findAll();%0A    %7D%0A    %0A    %0A    %0A    @RequestMapping(value = %22/%7Bid%7D%22)%0A    public BookDTO getBook(@PathVariable long id) throws Exception %7B%0A       %0A        logger.debug(%22rest getBook(%7B%7D)%22, id);%0A%0A        BookDTO book = bookFacade.findById(id);%0A        if (book == null) %7B%0A            throw new IllegalArgumentException(%22Book not found!%22);%0A        %7D%0A        return book;%0A    %7D%0A    %0A  %0A    @RequestMapping(value = %22/create%22, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE,%0A            produces = MediaType.APPLICATION_JSON_VALUE)%0A    public Long createBook(@RequestBody CreateBookDTO bookDTO)%7B%0A       Long id = bookFacade.createBook(bookDTO);%0A       return id;%0A    %7D%0A%0A     @RequestMapping(value = %22/update/%7Bid%7D%22, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE,%0A            produces = MediaType.APPLICATION_JSON_VALUE)%0A    public void changeBookState(@PathVariable long id, String state)%7B%0A       System.out.println(%22%22+state);%0A       bookFacade.setState(id,BookState.valueOf(state)); %0A    %7D%0A%0A%7D%0A

add BookRestController