use of com.axelor.apps.bankpayment.ebics.client.EbicsSession in project axelor-open-suite by axelor.
the class EbicsService method fetchFile.
private File fetchFile(OrderType orderType, EbicsUser user, EbicsProduct product, Date start, Date end, String fileFormat) throws AxelorException {
EbicsSession session = new EbicsSession(user);
File file = null;
try {
boolean test = isTest(user);
if (test) {
session.addSessionParam("TEST", "true");
}
if (fileFormat != null) {
session.addSessionParam("FORMAT", fileFormat);
}
if (product == null) {
product = defaultProduct;
}
session.setProduct(product);
FileTransfer transferManager = new FileTransfer(session);
file = File.createTempFile(user.getName(), "." + orderType.getOrderType());
transferManager.fetchFile(orderType, start, end, new FileOutputStream(file));
addResponseFile(user, file);
userService.getNextOrderId(user);
} catch (AxelorException e) {
TraceBackService.trace(e);
throw e;
} catch (IOException e) {
TraceBackService.trace(e);
throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
}
return file;
}
Aggregations