Subversion Repositories SmartDukaan

Rev

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

Rev 32650 Rev 32654
Line 195... Line 195...
195
                if (invoiceNumbers.size() == 1) {
195
                if (invoiceNumbers.size() == 1) {
196
                    Order order = invoiceOrdersMap.get(invoiceNumbers.get(0)).get(0);
196
                    Order order = invoiceOrdersMap.get(invoiceNumbers.get(0)).get(0);
197
                    String invoicePath = this.getInvoicePath(invoiceOrdersMap.get(invoiceNumbers.get(0)).get(0));
197
                    String invoicePath = this.getInvoicePath(invoiceOrdersMap.get(invoiceNumbers.get(0)).get(0));
198
                    HttpResponse response;
198
                    HttpResponse response;
199
                    try {
199
                    try {
200
                        response = restClient.getResponse("http://45.79.106.95/" + invoicePath, null, headersMap);
200
                        response = restClient.getResponse("http://192.168.202.117/" + invoicePath, null, headersMap);
201
                    } catch (Exception e) {
201
                    } catch (Exception e) {
202
                        invoicePath = this.getInvoicePathLastMonth(order);
202
                        invoicePath = this.getInvoicePathLastMonth(order);
203
                        response = restClient.getResponse("http://45.79.106.95/" + invoicePath, null, headersMap);
203
                        response = restClient.getResponse("http://192.168.202.117/" + invoicePath, null, headersMap);
204
                    }
204
                    }
205
                    headers.setContentType(MediaType.APPLICATION_PDF);
205
                    headers.setContentType(MediaType.APPLICATION_PDF);
206
                    headers.set("Content-Type", "application/pdf");
206
                    headers.set("Content-Type", "application/pdf");
207
                    headers.set("Content-disposition", "inline; filename=" + invoiceNumber + ".pdf");
207
                    headers.set("Content-disposition", "inline; filename=" + invoiceNumber + ".pdf");
208
                    InputStreamResource is = new InputStreamResource(response.getEntity().getContent());
208
                    InputStreamResource is = new InputStreamResource(response.getEntity().getContent());
Line 216... Line 216...
216
                    for (String invoice : invoiceNumbers) {
216
                    for (String invoice : invoiceNumbers) {
217
                        Order order = invoiceOrdersMap.get(invoiceNumbers.get(0)).get(0);
217
                        Order order = invoiceOrdersMap.get(invoiceNumbers.get(0)).get(0);
218
                        String invoicePath = this.getInvoicePath(order);
218
                        String invoicePath = this.getInvoicePath(order);
219
                        HttpResponse response;
219
                        HttpResponse response;
220
                        try {
220
                        try {
221
                            response = restClient.getResponse("http://45.79.106.95/" + invoicePath, null, headersMap);
221
                            response = restClient.getResponse("http://192.168.202.117/" + invoicePath, null, headersMap);
222
                        } catch (Exception e) {
222
                        } catch (Exception e) {
223
                            invoicePath = this.getInvoicePathLastMonth(order);
223
                            invoicePath = this.getInvoicePathLastMonth(order);
224
                            response = restClient.getResponse("http://45.79.106.95/" + invoicePath, null, headersMap);
224
                            response = restClient.getResponse("http://192.168.202.117/" + invoicePath, null, headersMap);
225
                        }
225
                        }
226
                        this.addFileToZip(zipOut, response.getEntity().getContent(), invoice + ".pdf");
226
                        this.addFileToZip(zipOut, response.getEntity().getContent(), invoice + ".pdf");
227
                    }
227
                    }
228
                    zipOut.close();
228
                    zipOut.close();
229
                    byte[] byteArray = fos.toByteArray();
229
                    byte[] byteArray = fos.toByteArray();