similarity index 66%rename from dg1cloud-core/src/main/java/it/digione/dg1cloud/controller/DownloadPageController.javarename to dg1cloud-core/src/main/java/it/digione/dg1cloud/controller/DownloadController.java| .. | .. |
|---|
| 14 | 14 | import it.digione.dg1cloud.recaptcha.DownloadFileCaptchaForm; |
|---|
| 15 | 15 | |
|---|
| 16 | 16 | @Controller |
|---|
| 17 | | -public class DownloadPageController { |
|---|
| 17 | +public class DownloadController { |
|---|
| 18 | 18 | |
|---|
| 19 | | - private static final Logger logger = LoggerFactory.getLogger(DownloadPageController.class); |
|---|
| 19 | + private static final Logger logger = LoggerFactory.getLogger(DownloadController.class); |
|---|
| 20 | 20 | |
|---|
| 21 | | - @RequestMapping("/downloadPage") |
|---|
| 22 | | - public ModelAndView downloadPage(@RequestParam String fileName, @RequestParam long id, |
|---|
| 21 | + @Autowired CaptchaSettings captchaSettings; |
|---|
| 22 | + |
|---|
| 23 | + @RequestMapping("/download") |
|---|
| 24 | + public ModelAndView download(@RequestParam String fileName, @RequestParam long id, |
|---|
| 23 | 25 | @RequestParam(value = "secretKey", required = false) String secretKey) throws IOException { |
|---|
| 24 | 26 | |
|---|
| 25 | | - logger.debug("Preparazione pagina download file {} con id {}", fileName, id); |
|---|
| 27 | + logger.debug("Preparazione download file {} con id {}", fileName, id); |
|---|
| 26 | 28 | |
|---|
| 27 | 29 | DownloadFileCaptchaForm downloadParams = new DownloadFileCaptchaForm(); |
|---|
| 28 | 30 | |
|---|
| .. | .. |
|---|
| 30 | 32 | downloadParams.setId(id); |
|---|
| 31 | 33 | downloadParams.setSecretKey(secretKey); |
|---|
| 32 | 34 | |
|---|
| 33 | | - ModelAndView modelAndView = new ModelAndView("downloadFileCaptcha"); |
|---|
| 35 | + ModelAndView modelAndView; |
|---|
| 36 | + |
|---|
| 37 | + if ( captchaSettings.isEnabled() == true ) { |
|---|
| 38 | + modelAndView = new ModelAndView("downloadFileCaptcha"); |
|---|
| 39 | + } else { |
|---|
| 40 | + modelAndView = new ModelAndView("forward:/downloadFile"); |
|---|
| 41 | + } |
|---|
| 42 | + |
|---|
| 34 | 43 | modelAndView.addObject("downloadFileCaptchaForm", downloadParams); |
|---|
| 35 | 44 | |
|---|
| 36 | 45 | return modelAndView; |
|---|