| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.io.ByteArrayInputStream;
|
| 3 |
import java.io.IOException;
|
4 |
import java.io.IOException;
|
| - |
|
5 |
import java.io.InputStream;
|
| 4 |
|
6 |
|
| 5 |
import javax.servlet.http.HttpServletRequest;
|
7 |
import javax.servlet.http.HttpServletRequest;
|
| 6 |
|
8 |
|
| 7 |
import org.apache.http.Header;
|
9 |
import org.apache.http.Header;
|
| 8 |
import org.apache.http.HttpResponse;
|
10 |
import org.apache.http.HttpResponse;
|
| Line 11... |
Line 13... |
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 12 |
import org.springframework.core.io.InputStreamResource;
|
14 |
import org.springframework.core.io.InputStreamResource;
|
| 13 |
import org.springframework.core.io.InputStreamSource;
|
15 |
import org.springframework.core.io.InputStreamSource;
|
| 14 |
import org.springframework.http.HttpHeaders;
|
16 |
import org.springframework.http.HttpHeaders;
|
| 15 |
import org.springframework.http.HttpStatus;
|
17 |
import org.springframework.http.HttpStatus;
|
| - |
|
18 |
import org.springframework.http.MediaType;
|
| 16 |
import org.springframework.http.ResponseEntity;
|
19 |
import org.springframework.http.ResponseEntity;
|
| 17 |
import org.springframework.stereotype.Controller;
|
20 |
import org.springframework.stereotype.Controller;
|
| 18 |
import org.springframework.transaction.annotation.Transactional;
|
21 |
import org.springframework.transaction.annotation.Transactional;
|
| 19 |
import org.springframework.ui.Model;
|
22 |
import org.springframework.ui.Model;
|
| 20 |
import org.springframework.web.bind.annotation.PathVariable;
|
23 |
import org.springframework.web.bind.annotation.PathVariable;
|
| Line 50... |
Line 53... |
| 50 |
} else {
|
53 |
} else {
|
| 51 |
response = reporticoService.getReportFile(loginDetails.getFofoId(), projectName, fileName + ".xml");
|
54 |
response = reporticoService.getReportFile(loginDetails.getFofoId(), projectName, fileName + ".xml");
|
| 52 |
}
|
55 |
}
|
| 53 |
HttpHeaders headers = new HttpHeaders();
|
56 |
HttpHeaders headers = new HttpHeaders();
|
| 54 |
InputStreamResource is = new InputStreamResource(response.getEntity().getContent());
|
57 |
InputStreamResource is = new InputStreamResource(response.getEntity().getContent());
|
| - |
|
58 |
headers.set("Content-Type", "application/vnd.ms-excel");
|
| 55 |
for (Header header : response.getAllHeaders()) {
|
59 |
headers.set("Content-disposition",
|
| 56 |
log.info("Header name - {}, value - {}", header.getName(), header.getValue());
|
60 |
"inline; filename=report-" + is.getFilename() + ".csv");
|
| 57 |
headers.add(header.getName(), header.getValue());
|
61 |
headers.setContentLength(is.contentLength());
|
| 58 |
}
|
- |
|
| 59 |
return new ResponseEntity<InputStreamResource>(is, headers, HttpStatus.OK);
|
62 |
return new ResponseEntity<InputStreamResource>(is, headers, HttpStatus.OK);
|
| 60 |
}
|
63 |
}
|
| 61 |
|
64 |
|
| 62 |
@RequestMapping(value = "/reports/", method = RequestMethod.GET)
|
65 |
@RequestMapping(value = "/reports/", method = RequestMethod.GET)
|
| 63 |
public String reports(Model model) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
|
66 |
public String reports(Model model) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
|