| Line 4... |
Line 4... |
| 4 |
|
4 |
|
| 5 |
import javax.servlet.http.HttpServletRequest;
|
5 |
import javax.servlet.http.HttpServletRequest;
|
| 6 |
|
6 |
|
| 7 |
import org.apache.http.Header;
|
7 |
import org.apache.http.Header;
|
| 8 |
import org.apache.http.HttpResponse;
|
8 |
import org.apache.http.HttpResponse;
|
| - |
|
9 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 9 |
import org.springframework.core.io.InputStreamResource;
|
10 |
import org.springframework.core.io.InputStreamResource;
|
| 10 |
import org.springframework.http.HttpHeaders;
|
11 |
import org.springframework.http.HttpHeaders;
|
| 11 |
import org.springframework.http.HttpStatus;
|
12 |
import org.springframework.http.HttpStatus;
|
| 12 |
import org.springframework.http.ResponseEntity;
|
13 |
import org.springframework.http.ResponseEntity;
|
| 13 |
import org.springframework.stereotype.Controller;
|
14 |
import org.springframework.stereotype.Controller;
|
| - |
|
15 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
16 |
import org.springframework.ui.Model;
|
| 14 |
import org.springframework.web.bind.annotation.PathVariable;
|
17 |
import org.springframework.web.bind.annotation.PathVariable;
|
| 15 |
import org.springframework.web.bind.annotation.RequestMapping;
|
18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 16 |
import org.springframework.web.bind.annotation.RequestMethod;
|
19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 17 |
|
20 |
|
| 18 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
21 |
import com.spice.profitmandi.common.enumuration.ReporticoProject;
|
| Line 20... |
Line 23... |
| 20 |
import com.spice.profitmandi.common.services.ReporticoService;
|
23 |
import com.spice.profitmandi.common.services.ReporticoService;
|
| 21 |
import com.spice.profitmandi.web.model.LoginDetails;
|
24 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
25 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 23 |
|
26 |
|
| 24 |
@Controller
|
27 |
@Controller
|
| - |
|
28 |
@Transactional(rollbackFor=Throwable.class)
|
| 25 |
public class ReportsController {
|
29 |
public class ReportsController {
|
| 26 |
|
30 |
|
| - |
|
31 |
@Autowired
|
| 27 |
private CookiesProcessor cookiesProcessor;
|
32 |
private CookiesProcessor cookiesProcessor;
|
| 28 |
|
33 |
|
| 29 |
@RequestMapping(value = "/reports/{projectName}/{fileName}", method = RequestMethod.GET)
|
34 |
@RequestMapping(value = "/reports/{projectName}/{fileName}", method = RequestMethod.GET)
|
| 30 |
public ResponseEntity<?> updateTest(HttpServletRequest request, @PathVariable String fileName, @PathVariable ReporticoProject reporticoProject) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException{
|
35 |
public ResponseEntity<?> fetchReport(HttpServletRequest request, @PathVariable String fileName, @PathVariable ReporticoProject projectName) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException{
|
| 31 |
ReporticoService rs = new ReporticoService();
|
36 |
ReporticoService rs = new ReporticoService();
|
| 32 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
37 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 33 |
HttpResponse response;
|
38 |
HttpResponse response;
|
| 34 |
if(loginDetails.isAdmin()) {
|
39 |
if(loginDetails.isAdmin()) {
|
| 35 |
response = rs.getReportFile(reporticoProject, fileName + ".xml");
|
40 |
response = rs.getReportFile(projectName, fileName + ".xml");
|
| 36 |
} else {
|
41 |
} else {
|
| 37 |
response = rs.getReportFile(loginDetails.getFofoId(), reporticoProject, fileName + ".xml");
|
42 |
response = rs.getReportFile(loginDetails.getFofoId(), projectName, fileName + ".xml");
|
| 38 |
}
|
43 |
}
|
| 39 |
HttpHeaders headers = new HttpHeaders();
|
44 |
HttpHeaders headers = new HttpHeaders();
|
| 40 |
for (Header header : response.getAllHeaders()) {
|
45 |
for (Header header : response.getAllHeaders()) {
|
| 41 |
headers.add(header.getName(), header.getValue());
|
46 |
headers.add(header.getName(), header.getValue());
|
| 42 |
}
|
47 |
}
|
| 43 |
return new ResponseEntity<InputStreamResource>(new InputStreamResource(response.getEntity().getContent()), headers, HttpStatus.OK);
|
48 |
return new ResponseEntity<InputStreamResource>(new InputStreamResource(response.getEntity().getContent()), headers, HttpStatus.OK);
|
| 44 |
}
|
49 |
}
|
| - |
|
50 |
|
| - |
|
51 |
@RequestMapping(value = "/reports/", method = RequestMethod.GET)
|
| - |
|
52 |
public String reports(Model model) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException{
|
| - |
|
53 |
model.addAttribute("reporticoProjectMap", ReporticoProject.reporticoProjectMap);
|
| - |
|
54 |
return "reports";
|
| - |
|
55 |
}
|
| 45 |
}
|
56 |
}
|