Subversion Repositories SmartDukaan

Rev

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

Rev 6915 Rev 7077
Line 111... Line 111...
111
            System.out.println("Unable to stream the manifest file");
111
            System.out.println("Unable to stream the manifest file");
112
        }
112
        }
113
        return "index";
113
        return "index";
114
	}
114
	}
115
    
115
    
-
 
116
	public String downloadInvoice() {
-
 
117
	    ByteBuffer buffer = null;
-
 
118
        try {
-
 
119
            if (orderId == null || orderId.isEmpty()) {
-
 
120
                logger.error("Order Id is null or empty");
-
 
121
                return "index";
-
 
122
            }
-
 
123
            TransactionClient transactionServiceClient = new TransactionClient();
-
 
124
            TransactionService.Client orderClient = transactionServiceClient.getClient();
-
 
125
            buffer = orderClient.retrieveInvoice(Long.parseLong(orderId));
-
 
126
            if(!buffer.hasArray()) {
-
 
127
                logger.error("The invoice does not found");
-
 
128
            }
-
 
129
        } catch (Exception e) {
-
 
130
            System.out.println(e.getMessage());
-
 
131
        }
-
 
132
        response.setHeader("Content-disposition", "inline; filename=invoice-" + orderId + ".pdf");
-
 
133
 
-
 
134
        ServletOutputStream sos;
-
 
135
        try {
-
 
136
            sos = response.getOutputStream();
-
 
137
            sos.write(buffer.array());
-
 
138
            sos.flush();
-
 
139
        } catch (Exception e) {
-
 
140
            System.out.println("Unable to stream the invoice file");
-
 
141
        }
-
 
142
        return "index";
-
 
143
	}
-
 
144
 
116
	public String formatPrice(double price)    {
145
	public String formatPrice(double price)    {
117
        return formattingUtils.formatPrice(price);
146
        return formattingUtils.formatPrice(price);
118
    }
147
    }
119
	
148
	
120
    public List<Order> getOrders()  {
149
    public List<Order> getOrders()  {