List of usage examples for org.springframework.beans BeanUtils copyProperties
public static void copyProperties(Object source, Object target) throws BeansException
From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java
/** * AuthCapture or immediate sale operation will be be used if payment gateway does not support normal flow authorize - delivery - capture. * * @param order to authorize payments.//from w ww.j av a2s . c o m * @param params for payment gateway to create template from. Also if this map contains key * forceSinglePayment, only one payment will be created (hack to support pay pal express). * @return status of operation. */ protected String authorizeCapture(final CustomerOrder order, final Map params) { final List<Payment> paymentsToAuthorize = createPaymentsToAuthorize(order, params.containsKey("forceSinglePayment"), params, PaymentGateway.AUTH_CAPTURE); String paymentResult = null; boolean atLeastOneProcessing = false; boolean atLeastOneOk = false; boolean atLeastOneError = false; for (Payment payment : paymentsToAuthorize) { try { payment = getPaymentGateway().authorizeCapture(payment); paymentResult = payment.getPaymentProcessorResult(); } catch (Throwable th) { paymentResult = Payment.PAYMENT_STATUS_FAILED; payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED); payment.setPaymentProcessorBatchSettlement(false); payment.setTransactionOperationResultMessage(th.getMessage()); } finally { final CustomerOrderPayment authCaptureOrderPayment = new CustomerOrderPaymentEntity(); //customerOrderPaymentService.getGenericDao().getEntityFactory().getByIface(CustomerOrderPayment.class); BeanUtils.copyProperties(payment, authCaptureOrderPayment); //from PG object to persisted authCaptureOrderPayment.setPaymentProcessorResult(paymentResult); authCaptureOrderPayment.setShopCode(order.getShop().getCode()); customerOrderPaymentService.create(authCaptureOrderPayment); if (Payment.PAYMENT_STATUS_PROCESSING.equals(paymentResult)) { atLeastOneProcessing = true; } else if (!Payment.PAYMENT_STATUS_OK.equals(paymentResult)) { // all other statuses - we fail atLeastOneError = true; } else { atLeastOneOk = true; } } } if (atLeastOneError) { if (atLeastOneOk) { // we need to put this in processing since this will move order to waiting payment // from there we have cancellation flow (with manual refund) return Payment.PAYMENT_STATUS_PROCESSING; } return Payment.PAYMENT_STATUS_FAILED; } return atLeastOneProcessing ? Payment.PAYMENT_STATUS_PROCESSING : Payment.PAYMENT_STATUS_OK; }
From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java
/** * {@inheritDoc}/*from w w w . j av a 2s. c o m*/ */ public String authorize(final CustomerOrder order, final Map params) { if (getPaymentGateway().getPaymentGatewayFeatures().isSupportAuthorize()) { final List<Payment> paymentsToAuthorize = createPaymentsToAuthorize(order, params.containsKey("forceSinglePayment"), params, PaymentGateway.AUTH); boolean atLeastOneProcessing = false; boolean atLeastOneError = false; for (Payment payment : paymentsToAuthorize) { String paymentResult = null; try { if (atLeastOneError) { // no point in order auths as we reverse all in case of at least one failure paymentResult = Payment.PAYMENT_STATUS_FAILED; payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED); payment.setPaymentProcessorBatchSettlement(false); payment.setTransactionOperationResultMessage("skipped due to previous errors"); } else { payment = getPaymentGateway().authorize(payment); paymentResult = payment.getPaymentProcessorResult(); } } catch (Throwable th) { paymentResult = Payment.PAYMENT_STATUS_FAILED; payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED); payment.setPaymentProcessorBatchSettlement(false); payment.setTransactionOperationResultMessage(th.getMessage()); } finally { final CustomerOrderPayment authOrderPayment = new CustomerOrderPaymentEntity(); //customerOrderPaymentService.getGenericDao().getEntityFactory().getByIface(CustomerOrderPayment.class); BeanUtils.copyProperties(payment, authOrderPayment); //from PG object to persisted authOrderPayment.setPaymentProcessorResult(paymentResult); authOrderPayment.setShopCode(order.getShop().getCode()); customerOrderPaymentService.create(authOrderPayment); if (Payment.PAYMENT_STATUS_PROCESSING.equals(paymentResult)) { atLeastOneProcessing = true; } else if (!Payment.PAYMENT_STATUS_OK.equals(paymentResult)) { // all other statuses - we fail atLeastOneError = true; } } } if (atLeastOneError) { reverseAuthorizations(order.getOrdernum()); return Payment.PAYMENT_STATUS_FAILED; } return atLeastOneProcessing ? Payment.PAYMENT_STATUS_PROCESSING : Payment.PAYMENT_STATUS_OK; } else if (getPaymentGateway().getPaymentGatewayFeatures().isSupportAuthorizeCapture()) { return authorizeCapture(order, params); } throw new RuntimeException(MessageFormat.format( "Payment gateway {0} must supports 'authorize' or 'authorize-capture' operations", getPaymentGateway().getLabel())); }
From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java
/** * Reverse authorized payments. This can be when one of the payments from whole set is failed. * Reverse authorization will be applied to authorized payments only * * @param orderNum order with some authorized payments *//*from ww w . j av a 2 s . c o m*/ protected void reverseAuthorizations(final String orderNum) { if (getPaymentGateway().getPaymentGatewayFeatures().isSupportReverseAuthorization()) { final List<CustomerOrderPayment> paymentsToRevAuth = determineOpenAuthorisations(orderNum, null); for (CustomerOrderPayment customerOrderPayment : paymentsToRevAuth) { Payment payment = new PaymentImpl(); BeanUtils.copyProperties(customerOrderPayment, payment); //from persisted to PG object String paymentResult = null; try { payment = getPaymentGateway().reverseAuthorization(payment); //pass "original" to perform reverse authorization. paymentResult = payment.getPaymentProcessorResult(); } catch (Throwable th) { paymentResult = Payment.PAYMENT_STATUS_FAILED; payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED); payment.setPaymentProcessorBatchSettlement(false); payment.setTransactionOperationResultMessage(th.getMessage()); } finally { final CustomerOrderPayment authReversedOrderPayment = new CustomerOrderPaymentEntity(); //customerOrderPaymentService.getGenericDao().getEntityFactory().getByIface(CustomerOrderPayment.class); BeanUtils.copyProperties(payment, authReversedOrderPayment); //from PG object to persisted authReversedOrderPayment.setPaymentProcessorResult(paymentResult); authReversedOrderPayment.setShopCode(customerOrderPayment.getShopCode()); customerOrderPaymentService.create(authReversedOrderPayment); } } } }
From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java
/** * {@inheritDoc}//from w ww . j a va2 s . c o m */ public String shipmentComplete(final CustomerOrder order, final String orderShipmentNumber, final Map params) { if (getPaymentGateway().getPaymentGatewayFeatures().isSupportAuthorize()) { final boolean isMultiplePaymentsSupports = getPaymentGateway().getPaymentGatewayFeatures() .isSupportAuthorizePerShipment(); final List<CustomerOrderPayment> paymentsToCapture = determineOpenAuthorisations(order.getOrdernum(), isMultiplePaymentsSupports ? orderShipmentNumber : order.getOrdernum()); final Logger log = ShopCodeContext.getLog(this); log.debug("Attempting to capture funds for Order num {} Shipment num {}", order.getOrdernum(), orderShipmentNumber); if (paymentsToCapture.size() > 1) { log.warn( //must be only one record MessageFormat.format( "Payment gateway {0} with features {1}. Found {2} records to capture, but expected 1 only. Order num {3} Shipment num {4}", getPaymentGateway().getLabel(), getPaymentGateway().getPaymentGatewayFeatures(), paymentsToCapture.size(), order.getOrdernum(), orderShipmentNumber)); } else if (paymentsToCapture.isEmpty()) { log.debug( //this could be a single payment PG and it was already captured MessageFormat.format( "Payment gateway {0} with features {1}. Found 0 records to capture, possibly already captured all payments. Order num {2} Shipment num {3}", getPaymentGateway().getLabel(), getPaymentGateway().getPaymentGatewayFeatures(), order.getOrdernum(), orderShipmentNumber)); } final boolean forceManualProcessing = Boolean.TRUE.equals(params.get("forceManualProcessing")); final String forceManualProcessingMessage = (String) params.get("forceManualProcessingMessage"); boolean wasError = false; String paymentResult = null; // We always attempt to Capture funds at this stage. // Funds are captured either: // 1. for delivery for authorise per shipment PG; or // 2. captured as soon as first delivery is shipped (thereafter there will be no AUTHs to CAPTURE, // so all subsequent deliveries will not have any paymentsToCapture) for (CustomerOrderPayment paymentToCapture : paymentsToCapture) { Payment payment = new PaymentImpl(); BeanUtils.copyProperties(paymentToCapture, payment); //from persisted to PG object payment.setTransactionOperation(PaymentGateway.CAPTURE); try { if (forceManualProcessing) { payment.setTransactionReferenceId(UUID.randomUUID().toString()); payment.setTransactionAuthorizationCode(UUID.randomUUID().toString()); payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_OK); payment.setPaymentProcessorBatchSettlement(true); payment.setTransactionGatewayLabel("forceManualProcessing"); payment.setTransactionOperationResultCode("forceManualProcessing"); payment.setTransactionOperationResultMessage(forceManualProcessingMessage); } else { payment = getPaymentGateway().capture(payment); //pass "original" to perform fund capture. } paymentResult = payment.getPaymentProcessorResult(); } catch (Throwable th) { paymentResult = Payment.PAYMENT_STATUS_FAILED; payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_FAILED); payment.setPaymentProcessorBatchSettlement(false); payment.setTransactionOperationResultMessage(th.getMessage()); ShopCodeContext.getLog(this).error("Cannot capture " + payment, th); } finally { final CustomerOrderPayment captureOrderPayment = new CustomerOrderPaymentEntity(); //customerOrderPaymentService.getGenericDao().getEntityFactory().getByIface(CustomerOrderPayment.class); BeanUtils.copyProperties(payment, captureOrderPayment); //from PG object to persisted captureOrderPayment.setPaymentProcessorResult(paymentResult); captureOrderPayment.setShopCode(paymentToCapture.getShopCode()); customerOrderPaymentService.create(captureOrderPayment); } if (!Payment.PAYMENT_STATUS_OK.equals(paymentResult)) { wasError = true; } } return wasError ? Payment.PAYMENT_STATUS_FAILED : Payment.PAYMENT_STATUS_OK; } return Payment.PAYMENT_STATUS_OK; }
From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java
/** * {@inheritDoc}/*from w w w . j ava 2 s . c o m*/ */ public String cancelOrder(final CustomerOrder order, final Map params) { if (!CustomerOrder.ORDER_STATUS_CANCELLED.equals(order.getOrderStatus()) && !CustomerOrder.ORDER_STATUS_RETURNED.equals(order.getOrderStatus())) { reverseAuthorizations(order.getOrdernum()); final boolean forceManualProcessing = Boolean.TRUE.equals(params.get("forceManualProcessing")); final String forceManualProcessingMessage = (String) params.get("forceManualProcessingMessage"); boolean wasError = false; final List<CustomerOrderPayment> paymentsToRollBack = determineOpenCaptures(order.getOrdernum(), null); /* We do NOT need to check for features (isSupportRefund(), isSupportVoid()). PG must create payments with Payment.PAYMENT_STATUS_MANUAL_PROCESSING_REQUIRED for audit purposes and manual flow support. */ for (CustomerOrderPayment customerOrderPayment : paymentsToRollBack) { Payment payment = null; String paymentResult = null; try { payment = new PaymentImpl(); BeanUtils.copyProperties(customerOrderPayment, payment); //from persisted to PG object if (forceManualProcessing) { payment.setTransactionOperation(PaymentGateway.REFUND); payment.setTransactionReferenceId(UUID.randomUUID().toString()); payment.setTransactionAuthorizationCode(UUID.randomUUID().toString()); payment.setPaymentProcessorResult(Payment.PAYMENT_STATUS_OK); payment.setPaymentProcessorBatchSettlement(false); payment.setTransactionGatewayLabel("forceManualProcessing"); payment.setTransactionOperationResultCode("forceManualProcessing"); payment.setTransactionOperationResultMessage(forceManualProcessingMessage); } else { if (customerOrderPayment.isPaymentProcessorBatchSettlement()) { // refund payment.setTransactionOperation(PaymentGateway.REFUND); payment = getPaymentGateway().refund(payment); } else { //void payment.setTransactionOperation(PaymentGateway.VOID_CAPTURE); payment = getPaymentGateway().voidCapture(payment); } } paymentResult = payment.getPaymentProcessorResult(); } catch (Throwable th) { ShopCodeContext.getLog(this) .error(MessageFormat.format( "Can not perform roll back operation on payment record {0} payment {1}", customerOrderPayment.getCustomerOrderPaymentId(), payment), th); paymentResult = Payment.PAYMENT_STATUS_FAILED; wasError = true; } finally { final CustomerOrderPayment captureReversedOrderPayment = new CustomerOrderPaymentEntity(); //customerOrderPaymentService.getGenericDao().getEntityFactory().getByIface(CustomerOrderPayment.class); BeanUtils.copyProperties(payment, captureReversedOrderPayment); //from PG object to persisted captureReversedOrderPayment.setPaymentProcessorResult(paymentResult); captureReversedOrderPayment.setShopCode(customerOrderPayment.getShopCode()); customerOrderPaymentService.create(captureReversedOrderPayment); } if (!Payment.PAYMENT_STATUS_OK.equals(paymentResult)) { wasError = true; } } return wasError ? Payment.PAYMENT_STATUS_FAILED : Payment.PAYMENT_STATUS_OK; } ShopCodeContext.getLog(this).warn("Can refund canceled order {}", order.getOrdernum()); return Payment.PAYMENT_STATUS_FAILED; }
From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java
/** * Add information to template payment object. * * @param templatePayment template payment. * @param order order/*from w ww . jav a2 s. c o m*/ * @param transactionOperation operation in term of payment processor * @param transactionGatewayLabel label of payment gateway * @return payment prototype; */ private Payment fillPaymentPrototype(final CustomerOrder order, final Payment templatePayment, final String transactionOperation, final String transactionGatewayLabel) { final Customer customer = order.getCustomer(); if (customer != null) { Address shippingAddr = customer.getDefaultAddress(Address.ADDR_TYPE_SHIPPING); Address billingAddr = customer.getDefaultAddress(Address.ADDR_TYPE_BILLING); if (billingAddr == null) { billingAddr = shippingAddr; } if (billingAddr != null) { PaymentAddress addr = new PaymentAddressImpl(); BeanUtils.copyProperties(billingAddr, addr); templatePayment.setBillingAddress(addr); } if (shippingAddr != null) { PaymentAddress addr = new PaymentAddressImpl(); BeanUtils.copyProperties(shippingAddr, addr); templatePayment.setShippingAddress(addr); } templatePayment.setBillingAddressString(order.getBillingAddress()); templatePayment.setShippingAddressString(order.getShippingAddress()); templatePayment.setBillingEmail(customer.getEmail()); } templatePayment.setOrderDate(order.getOrderTimestamp()); templatePayment.setOrderCurrency(order.getCurrency()); templatePayment.setOrderLocale(order.getLocale()); templatePayment.setOrderNumber(order.getOrdernum()); templatePayment.setTransactionOperation(transactionOperation); templatePayment.setTransactionGatewayLabel(transactionGatewayLabel); return templatePayment; }
From source file:org.yes.cart.web.support.entity.decorator.impl.CategoryDecoratorImpl.java
/** * Construct entity decorator.//from w ww.j a va 2 s .c o m * * @param imageService image service to get the image seo info * @param categoryImageService category image service to get the image. * @param categoryService category service to get the images width and height * @param categoryEntity entity to decorate. * @param httpServletContextPath servlet context path * @param i18NWebSupport i18n support */ public CategoryDecoratorImpl(final ImageService imageService, final AttributableImageService categoryImageService, final CategoryService categoryService, final Category categoryEntity, final String httpServletContextPath, final I18NWebSupport i18NWebSupport) { this.categoryService = categoryService; this.categoryImageService = categoryImageService; this.httpServletContextPath = httpServletContextPath; this.imageService = imageService; this.i18NWebSupport = i18NWebSupport; if (categoryEntity != null) { BeanUtils.copyProperties(categoryEntity, this); } }
From source file:org.yes.cart.web.support.entity.decorator.impl.ProductDecoratorImpl.java
/** * Construct entity decorator.//ww w.ja v a2 s . c om * * @param imageService image service to get the image seo info * @param productImageService category image service to get the image. * @param productEntity original product to decorate. * @param httpServletContextPath servlet context path * @param productService product service * @param i18NWebSupport i18n support */ public ProductDecoratorImpl(final ImageService imageService, final AttributableImageService productImageService, final ProductService productService, final I18NWebSupport i18NWebSupport, final Product productEntity, final String httpServletContextPath, final boolean withAttributes, final String defaultImageAttributeValue) { this.i18NWebSupport = i18NWebSupport; if (productEntity != null) { BeanUtils.copyProperties(productEntity, this); } this.httpServletContextPath = httpServletContextPath; this.defaultImageAttributeValue = defaultImageAttributeValue; if (withAttributes) { this.attrValueMap = getAllAttributesAsMap(); } else { this.attrValueMap = Collections.emptyMap(); } this.productImageService = productImageService; this.productService = productService; this.imageService = imageService; }
From source file:org.yes.cart.web.support.entity.decorator.impl.ProductSkuDecoratorImpl.java
/** * Construct product sku decorator.//from w w w . j av a2 s . c om * * @param imageService image service to get the image seo info * @param productSkuImageService category image service to get the image. * @param productSkuEntity sku to decorate * @param httpServletContextPath servlet context path * @param productService product service * @param i18NWebSupport i18n */ public ProductSkuDecoratorImpl(final ImageService imageService, final AttributableImageService productSkuImageService, final ProductSku productSkuEntity, final String httpServletContextPath, final ProductService productService, final I18NWebSupport i18NWebSupport) { this.productService = productService; this.i18NWebSupport = i18NWebSupport; if (productSkuEntity != null) { BeanUtils.copyProperties(productSkuEntity, this); } this.httpServletContextPath = httpServletContextPath; this.productSkuImageService = productSkuImageService; this.imageService = imageService; }
From source file:tw.edu.chit.struts.action.deptassist.ReportPrintAction.java
/** * ???/*from w ww .j a va 2 s . c o m*/ * * @param mapping org.apache.struts.action.ActionMapping object * @param form org.apache.struts.action.ActionForm object * @param request request javax.servlet.http.HttpServletRequest object * @param response response javax.servlet.http.HttpServletResponse object * @param sterm */ @SuppressWarnings("unchecked") private void printDeptStdSkillList2(ActionMapping mapping, DynaActionForm form, HttpServletRequest request, HttpServletResponse response, String sterm) throws Exception { HttpSession session = request.getSession(false); AdminManager am = (AdminManager) getBean(IConstants.ADMIN_MANAGER_BEAN_NAME); MemberManager mm = (MemberManager) getBean(MEMBER_MANAGER_BEAN_NAME); Member member = (Member) getUserCredential(session).getMember(); Empl empl = mm.findEmplByOid(member.getOid()); ServletContext context = request.getSession().getServletContext(); CodeEmpl codeEmpl = new CodeEmpl(); codeEmpl.setIdno(empl.getUnit()); Example example4CodeEmpl = Example.create(codeEmpl).ignoreCase().enableLike(MatchMode.START); List<CodeEmpl> codeEmpls = (List<CodeEmpl>) am.findSQLWithCriteria(CodeEmpl.class, example4CodeEmpl, null, null); DateFormat df = new SimpleDateFormat("yyyy/MM/dd"); Calendar cal = Calendar.getInstance(); Calendar cal1 = (Calendar) cal.clone(); Calendar cal2 = (Calendar) cal.clone(); if (StringUtils.isNotBlank(form.getString("licenseValidDateStart")) || StringUtils.isNotBlank(form.getString("licenseValidDateEnd"))) { Date from = StringUtils.isBlank(form.getString("licenseValidDateStart")) ? null : Toolket.parseNativeDate(form.getString("licenseValidDateStart")); // ??? Date to = StringUtils.isBlank(form.getString("licenseValidDateEnd")) ? Calendar.getInstance().getTime() : Toolket.parseNativeDate(form.getString("licenseValidDateEnd")); cal1.setTime(from); cal1.set(Calendar.HOUR_OF_DAY, 0); cal1.set(Calendar.MINUTE, 0); cal1.set(Calendar.SECOND, 0); cal1.set(Calendar.MILLISECOND, 0); cal2.setTime(to); cal2.set(Calendar.HOUR_OF_DAY, 23); cal2.set(Calendar.MINUTE, 59); cal2.set(Calendar.SECOND, 59); cal2.set(Calendar.MILLISECOND, 999); } // Y boolean flag = form.getString("amountDateType").equalsIgnoreCase("y"); String hql = ""; if (flag) hql = "FROM StdSkill s WHERE s.amountDate IS NOT NULL AND s.deptNo = ? " + "AND s.licenseValidDate BETWEEN ? AND ? ORDER BY s.studentNo"; else // ? hql = "FROM StdSkill s WHERE s.amountDate IS NULL AND s.deptNo = ? " + "AND s.licenseValidDate BETWEEN ? AND ? ORDER BY s.studentNo"; /* List<StdSkill> skills = (List<StdSkill>) am.find(hql, new Object[] { codeEmpls.get(0).getIdno2().trim(), cal1.getTime(), cal2.getTime() }); */ codeEmpl.setIdno(empl.getUnit()); List<StdSkill> skills = (List<StdSkill>) am.find(hql, new Object[] { codeEmpl.getIdno().trim(), cal1.getTime(), cal2.getTime() }); File templateXLS = new File(context.getRealPath("/WEB-INF/reports/DeptStdSkillList2.xls")); HSSFWorkbook workbook = Toolket.getHSSFWorkbook(templateXLS); HSSFSheet sheet = workbook.getSheetAt(0); // Header Toolket.setCellValue(sheet, 0, 0, "?" + Toolket.getEmpUnit(empl.getUnit()) + "??? (" + df.format(cal1.getTime()) + "~" + df.format(cal2.getTime()) + ") - " + (flag ? "" : "")); int index = 2; Student student = null; Graduate graduate = null; List<LicenseCode> codes = null; List<LicenseCode961> code961s = null; LicenseCode code = null; LicenseCode961 code961 = null; String checkStr1 = "???\n?\n???"; String checkStr2 = "?\n?"; for (StdSkill skill : skills) { student = mm.findStudentByNo(skill.getStudentNo()); if (student == null) { graduate = mm.findGraduateByStudentNo(skill.getStudentNo()); if (graduate != null) { Toolket.setCellValue(sheet, index, 13, Toolket.getStatus(graduate.getOccurStatus(), true)); Toolket.setCellValue(sheet, index, 14, df.format(graduate.getOccurDate())); student = new Student(); BeanUtils.copyProperties(graduate, student); } } if (student != null || graduate != null) { Toolket.setCellValue(sheet, index, 0, String.valueOf(index - 1)); Toolket.setCellValue(sheet, index, 1, StringUtils.isBlank(student.getDepartClass()) ? "" : Toolket.getSchoolName(student.getDepartClass())); Toolket.setCellValue(sheet, index, 2, Toolket.getClassFullName(student.getDepartClass())); Toolket.setCellValue(sheet, index, 3, student.getStudentNo()); Toolket.setCellValue(sheet, index, 4, student.getStudentName()); Toolket.setCellValue(sheet, index, 5, student.getIdno()); Toolket.setCellValue(sheet, index, 9, String.valueOf(skill.getAmount())); Toolket.setCellValue(sheet, index, 10, ""); Toolket.setCellValue(sheet, index, 11, checkStr1); Toolket.setCellValue(sheet, index, 12, checkStr2); codes = (List<LicenseCode>) am .findLicenseCodesBy(new LicenseCode(String.valueOf(skill.getLicenseCode()))); if (!codes.isEmpty()) { code = codes.get(0); Toolket.setCellValue(sheet, index, 6, code.getName()); Toolket.setCellValue(sheet, index, 7, code.getDeptName()); Toolket.setCellValue(sheet, index, 8, code.getLevel()); } else { code961s = (List<LicenseCode961>) am .findLicenseCode961sBy(new LicenseCode961(String.valueOf(skill.getLicenseCode()))); if (!code961s.isEmpty()) { code961 = code961s.get(0); Toolket.setCellValue(sheet, index, 6, code961.getName()); Toolket.setCellValue(sheet, index, 7, code961.getDeptName()); Toolket.setCellValue(sheet, index, 8, code961.getLevel()); } } index++; } } File tempDir = new File( context.getRealPath("/WEB-INF/reports/temp/" + getUserCredential(session).getMember().getIdno() + (new SimpleDateFormat("yyyyMMdd").format(new Date())))); if (!tempDir.exists()) tempDir.mkdirs(); File output = new File(tempDir, "DeptStdSkillList2.xls"); FileOutputStream fos = new FileOutputStream(output); workbook.write(fos); fos.close(); JasperReportUtils.printXlsToFrontEnd(response, output); output.delete(); tempDir.delete(); }