Subversion Repositories SmartDukaan

Rev

Rev 30387 | Rev 30389 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30387 Rev 30388
Line 29... Line 29...
29
import org.springframework.web.bind.annotation.RequestParam;
29
import org.springframework.web.bind.annotation.RequestParam;
30
 
30
 
31
import javax.servlet.http.HttpServletRequest;
31
import javax.servlet.http.HttpServletRequest;
32
import java.io.ByteArrayOutputStream;
32
import java.io.ByteArrayOutputStream;
33
import java.io.File;
33
import java.io.File;
34
import java.io.InputStream;
-
 
35
import java.time.LocalDateTime;
34
import java.time.LocalDateTime;
36
import java.util.*;
35
import java.util.*;
37
import java.util.stream.Collectors;
36
import java.util.stream.Collectors;
38
import java.util.zip.ZipEntry;
37
import java.util.zip.ZipEntry;
39
import java.util.zip.ZipOutputStream;
38
import java.util.zip.ZipOutputStream;
Line 136... Line 135...
136
							List<Order> orders = invoiceOrdersMap.get(invoice);
135
							List<Order> orders = invoiceOrdersMap.get(invoice);
137
							String invoicePath = this.getInvoicePath(orders.get(0));
136
							String invoicePath = this.getInvoicePath(orders.get(0));
138
							HttpResponse response = restClient.getResponse("http://50.116.3.101/" + invoicePath, null, headersMap);
137
							HttpResponse response = restClient.getResponse("http://50.116.3.101/" + invoicePath, null, headersMap);
139
							ZipEntry zipEntry = new ZipEntry(invoice + ".pdf");
138
							ZipEntry zipEntry = new ZipEntry(invoice + ".pdf");
140
							zipOut.putNextEntry(zipEntry);
139
							zipOut.putNextEntry(zipEntry);
141
							byte[] bytes = new byte[1024];
-
 
142
							int length;
-
 
143
							InputStream is = response.getEntity().getContent();
140
							byte[] bytes = new byte[(int) response.getEntity().getContentLength()];
144
							while ((length = is.read(bytes)) >= 0) {
141
							response.getEntity().getContent().read(bytes);
145
								zipOut.write(bytes, 0, length);
142
							zipOut.write(bytes, 0, (int) response.getEntity().getContentLength());
146
							}
-
 
147
							is.close();
-
 
148
						}
143
						}
149
						byte[] byteArray = fos.toByteArray();
144
						byte[] byteArray = fos.toByteArray();
150
						headers.set("Content-Type", "application/octet-stream");
145
						headers.set("Content-Type", "application/octet-stream");
151
						headers.set("Content-disposition", "inline; filename=invoices.zip");
146
						headers.set("Content-disposition", "inline; filename=invoices.zip");
152
						headers.setContentLength(byteArray.length);
147
						headers.setContentLength(byteArray.length);