| Line 23... |
Line 23... |
| 23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24 |
import com.spice.profitmandi.common.services.ReporticoService;
|
24 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 25 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
25 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
26 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 27 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
27 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| - |
|
28 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 28 |
import com.spice.profitmandi.web.model.LoginDetails;
|
29 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 29 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
30 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 30 |
|
31 |
|
| 31 |
@Controller
|
32 |
@Controller
|
| 32 |
@Transactional(rollbackFor=Throwable.class)
|
33 |
@Transactional(rollbackFor=Throwable.class)
|
| Line 39... |
Line 40... |
| 39 |
private CookiesProcessor cookiesProcessor;
|
40 |
private CookiesProcessor cookiesProcessor;
|
| 40 |
|
41 |
|
| 41 |
@Autowired
|
42 |
@Autowired
|
| 42 |
private ReporticoService reporticoService;
|
43 |
private ReporticoService reporticoService;
|
| 43 |
|
44 |
|
| - |
|
45 |
@Autowired
|
| - |
|
46 |
private RoleManager roleManager;
|
| - |
|
47 |
|
| 44 |
private static final Logger log = LogManager.getLogger(OrderController.class);
|
48 |
private static final Logger log = LogManager.getLogger(OrderController.class);
|
| 45 |
|
49 |
|
| 46 |
@RequestMapping(value = "/reports/{projectName}/{fileName}", method = RequestMethod.GET)
|
50 |
@RequestMapping(value = "/reports/{projectName}/{fileName}", method = RequestMethod.GET)
|
| 47 |
public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName,
|
51 |
public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName,
|
| 48 |
@PathVariable ReporticoProject projectName)
|
52 |
@PathVariable ReporticoProject projectName)
|
| 49 |
throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
|
53 |
throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
|
| 50 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
54 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 51 |
HttpResponse response;
|
55 |
HttpResponse response;
|
| 52 |
Role role = roleRepository.selectByName(RoleType.FOFO_ADMIN.toString());
|
- |
|
| 53 |
if (loginDetails.getRoleIds().contains(role.getId())) {
|
56 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 54 |
response = reporticoService.getReportFile(projectName, fileName + ".xml");
|
57 |
response = reporticoService.getReportFile(projectName, fileName + ".xml");
|
| 55 |
} else {
|
58 |
} else {
|
| 56 |
response = reporticoService.getReportFile(loginDetails.getFofoId(), projectName, fileName + ".xml");
|
59 |
response = reporticoService.getReportFile(loginDetails.getFofoId(), projectName, fileName + ".xml");
|
| 57 |
}
|
60 |
}
|
| 58 |
HttpHeaders headers = new HttpHeaders();
|
61 |
HttpHeaders headers = new HttpHeaders();
|