Subversion Repositories SmartDukaan

Rev

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

Rev 28084 Rev 28088
Line 562... Line 562...
562
			Model model) throws Exception {
562
			Model model) throws Exception {
563
		byte[] bytes = null;
563
		byte[] bytes = null;
564
		List<Attachment> attachments= new ArrayList<>();
564
		List<Attachment> attachments= new ArrayList<>();
565
		for(String serialNumber : serialNumbers) {
565
		for(String serialNumber : serialNumbers) {
566
			if (!imeis.contains(serialNumber)) {
566
			if (!imeis.contains(serialNumber)) {
-
 
567
				PdfModel pdfModel = null;
567
				
568
				try {
568
				PdfModel pdfModel = orderService.getDummyPdfModel(serialNumber);
569
					pdfModel = orderService.getDummyPdfModel(serialNumber);
-
 
570
				} catch(Exception e) {
-
 
571
					continue;
-
 
572
				}
569
				ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
573
				ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
570
				PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
574
				PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
571
				bytes = byteArrayOutputStream.toByteArray();
575
				bytes = byteArrayOutputStream.toByteArray();
572
			} else {
576
			} else {
573
				ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
577
				ClassPathResource resource = new ClassPathResource("/META-INF/" + serialNumber + ".pdf");
574
				try {
578
				try {
575
					bytes = FileUtils.readFileToByteArray(resource.getFile());
579
					bytes = FileUtils.readFileToByteArray(resource.getFile());
576
				} catch (Exception e) {
580
				} catch (Exception e) {
577
					
581
					continue;
578
				}
582
				}
579
			}
583
			}
580
			attachments.add(new Attachment("invoice-" + serialNumber + ".pdf", new ByteArrayResource(bytes)));
584
			attachments.add(new Attachment("invoice-" + serialNumber + ".pdf", new ByteArrayResource(bytes)));
581
		}
585
		}
582
		
586