use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method sendHPDRequest.
public void sendHPDRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
Beans.get(EbicsService.class).sendHPDRequest(ebicsUser, null, null, null);
downloadFile(response, ebicsUser);
} catch (Exception e) {
response.setFlash(stripClass(e.getLocalizedMessage()));
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method printCertificates.
public void printCertificates(ActionRequest request, ActionResponse response) throws AxelorException {
EbicsUser ebicsUser = request.getContext().asType(EbicsUser.class);
ArrayList<Long> certIds = new ArrayList<Long>();
if (ebicsUser.getA005Certificate() != null) {
certIds.add(ebicsUser.getA005Certificate().getId());
}
if (ebicsUser.getE002Certificate() != null) {
certIds.add(ebicsUser.getE002Certificate().getId());
}
if (ebicsUser.getX002Certificate() != null) {
certIds.add(ebicsUser.getX002Certificate().getId());
}
if (certIds.isEmpty()) {
throw new AxelorException(ebicsUser, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EBICS_MISSING_CERTIFICATES));
}
String title = I18n.get("EbicsCertificate");
ReportSettings report = ReportFactory.createReport(IReport.EBICS_CERTIFICATE, title + "-${date}${time}");
report.addParam("CertificateId", Joiner.on(",").join(certIds));
report.addParam("EbicsUserId", ebicsUser.getId());
report.addParam("Timezone", ebicsUser.getAssociatedUser() != null ? ebicsUser.getAssociatedUser().getActiveCompany() : null);
report.toAttach(ebicsUser);
report.generate();
response.setView(ActionView.define(title).add("html", report.getFileLink()).map());
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method sendPTKRequest.
public void sendPTKRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
Beans.get(EbicsService.class).sendPTKRequest(ebicsUser, null, null, null);
downloadFile(response, ebicsUser);
} catch (Exception e) {
response.setFlash(stripClass(e.getLocalizedMessage()));
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method generateCertificate.
@Transactional
public void generateCertificate(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
if (ebicsUser.getStatusSelect() != EbicsUserRepository.STATUS_WAITING_CERTIFICATE_CONFIG && ebicsUser.getStatusSelect() != EbicsUserRepository.STATUS_CERTIFICATES_SHOULD_BE_RENEWED) {
return;
}
CertificateManager cm = new CertificateManager(ebicsUser);
try {
cm.create();
ebicsUser.setStatusSelect(EbicsUserRepository.STATUS_WAITING_SENDING_SIGNATURE_CERTIFICATE);
Beans.get(EbicsUserRepository.class).save(ebicsUser);
} catch (GeneralSecurityException | IOException e) {
e.printStackTrace();
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.EbicsUser in project axelor-open-suite by axelor.
the class EbicsController method sendFULRequest.
public void sendFULRequest(ActionRequest request, ActionResponse response) {
EbicsUser ebicsUser = Beans.get(EbicsUserRepository.class).find(request.getContext().asType(EbicsUser.class).getId());
try {
MetaFile testDataMetaFile = ebicsUser.getTestDataFile();
MetaFile testSignatureMetaFile = ebicsUser.getTestSignatureFile();
BankOrderFileFormat bankOrderFileFormat = ebicsUser.getTestBankOrderFileFormat();
if (testDataMetaFile != null && bankOrderFileFormat != null) {
File testSignatureFile = null;
if (ebicsUser.getEbicsPartner().getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS && testSignatureMetaFile != null) {
testSignatureFile = MetaFiles.getPath(testSignatureMetaFile).toFile();
}
Beans.get(EbicsService.class).sendFULRequest(ebicsUser, ebicsUser.getTestSignatoryEbicsUser(), null, MetaFiles.getPath(testDataMetaFile).toFile(), bankOrderFileFormat, testSignatureFile);
} else {
response.setFlash(I18n.get(IExceptionMessage.EBICS_TEST_MODE_NOT_ENABLED));
}
} catch (Exception e) {
response.setFlash(stripClass(e.getLocalizedMessage()));
}
response.setReload(true);
}
Aggregations