Search in sources :

Example 26 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class DeckController method listAll.

@RequestMapping(value = "{id}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView listAll(@PathVariable Long id) {
    ModelAndView model = new ModelAndView("deck");
    model.addObject("cards", cardService.findAllByTheme(id));
    session.setAttribute("theme", id);
    return model;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 27 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class ThemeController method register.

@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView register(@RequestParam("photo") MultipartFile photoFile, @RequestParam("name") String name, @RequestParam("price") BigDecimal price) {
    String boardSrc = photosFile.createFile(photoFile);
    ThemeRequest themeDTO = new ThemeRequest(name, price, boardSrc);
    themeService.register(themeDTO);
    return listAll();
}
Also used : ThemeRequest(br.fatecsp.engsoft.domain.ThemeRequest) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 28 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class ThemeController method listAll.

@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView listAll() {
    ModelAndView model = new ModelAndView("themes");
    List<Theme> themes = themeService.findAll();
    model.addObject("themes", themes);
    return model;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Theme(br.fatecsp.engsoft.entities.Theme) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 29 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class ThemeController method edit.

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView edit(@PathVariable("id") Long id) {
    ModelAndView model = new ModelAndView("editTheme");
    model.addObject("theme", themeService.find(id));
    return model;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 30 with PreAuthorize

use of org.springframework.security.access.prepost.PreAuthorize in project Projeto_Detetive_ES3 by VitorAndrioli.

the class ThemeController method update.

@PostMapping(value = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasAuthority('ADMIN')")
public ModelAndView update(@PathVariable("id") Long id, @RequestParam("photo") MultipartFile photoFile, @RequestParam("name") String name, @RequestParam("price") BigDecimal price) {
    String boardSrc = "";
    try {
        if (photoFile.getBytes().length != 0) {
            boardSrc = photosFile.createFile(photoFile);
        } else {
            boardSrc = themeService.find(id).getImageSrc();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    ThemeRequest themeDTO = new ThemeRequest(name, price, boardSrc);
    themeService.update(id, themeDTO);
    return listAll();
}
Also used : ThemeRequest(br.fatecsp.engsoft.domain.ThemeRequest) IOException(java.io.IOException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)188 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)174 ModelAndView (org.springframework.web.servlet.ModelAndView)51 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)39 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)36 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)34 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)32 IOException (java.io.IOException)29 InputStream (java.io.InputStream)23 ArrayList (java.util.ArrayList)23 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)23 ConfigurationServiceException (org.nhindirect.config.service.ConfigurationServiceException)21 Date (java.util.Date)15 Grid (org.hisp.dhis.common.Grid)14 SearchDomainForm (org.nhindirect.config.ui.form.SearchDomainForm)14 ApiOperation (io.swagger.annotations.ApiOperation)13 ApiResponses (io.swagger.annotations.ApiResponses)13 Configuration (org.hisp.dhis.configuration.Configuration)13 HttpHeaders (org.springframework.http.HttpHeaders)13 List (java.util.List)12