From 5eabad6b223d04532bc9025077add3a1772ea0de Mon Sep 17 00:00:00 2001 From: e550448 Date: Fri, 27 Dec 2024 21:07:36 +0100 Subject: [PATCH] feat: Simplified module Refs: DEV-12343 --- .../pdf_exporter/PdfExporterInternModule.java | 25 +++++++------------ .../converter/HtmlToPdfConverter.java | 2 ++ .../converter/PdfConverterJobsService.java | 2 ++ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/PdfExporterInternModule.java b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/PdfExporterInternModule.java index 9192a77b..924d0304 100644 --- a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/PdfExporterInternModule.java +++ b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/PdfExporterInternModule.java @@ -1,12 +1,5 @@ package ch.sbb.polarion.extension.pdf_exporter; -import ch.sbb.polarion.extension.generic.service.PolarionService; -import ch.sbb.polarion.extension.pdf_exporter.converter.HtmlToPdfConverter; -import ch.sbb.polarion.extension.pdf_exporter.converter.PdfConverter; -import ch.sbb.polarion.extension.pdf_exporter.converter.PdfConverterJobsService; -import ch.sbb.polarion.extension.pdf_exporter.converter.PropertiesUtility; -import ch.sbb.polarion.extension.pdf_exporter.service.PdfExporterPolarionService; -import ch.sbb.polarion.extension.pdf_exporter.util.PdfValidationService; import com.google.inject.AbstractModule; import com.polarion.platform.core.PlatformContext; import com.polarion.platform.security.ISecurityService; @@ -15,16 +8,16 @@ public class PdfExporterInternModule extends AbstractModule { @Override protected void configure() { - PdfExporterPolarionService pdfExporterPolarionService = new PdfExporterPolarionService(); - PdfConverter pdfConverter = new PdfConverter(); +// PdfExporterPolarionService pdfExporterPolarionService = new PdfExporterPolarionService(); +// PdfConverter pdfConverter = new PdfConverter(); ISecurityService securityService = PlatformContext.getPlatform().lookupService(ISecurityService.class); - - bind(PolarionService.class).toInstance(pdfExporterPolarionService); - bind(PdfConverter.class).toInstance(pdfConverter); bind(ISecurityService.class).toInstance(securityService); - bind(PdfValidationService.class).toInstance(new PdfValidationService(pdfConverter)); - bind(PdfConverterJobsService.class).toInstance(new PdfConverterJobsService(pdfConverter, securityService)); - bind(PropertiesUtility.class).toInstance(new PropertiesUtility()); - bind(HtmlToPdfConverter.class).toInstance(new HtmlToPdfConverter()); + +// bind(PolarionService.class).toInstance(pdfExporterPolarionService); +// bind(PdfConverter.class).toInstance(pdfConverter); +// bind(PdfValidationService.class).toInstance(new PdfValidationService(pdfConverter)); +// bind(PdfConverterJobsService.class).toInstance(new PdfConverterJobsService(pdfConverter, securityService)); +// bind(PropertiesUtility.class).toInstance(new PropertiesUtility()); +// bind(HtmlToPdfConverter.class).toInstance(new HtmlToPdfConverter()); } } diff --git a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/HtmlToPdfConverter.java b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/HtmlToPdfConverter.java index 352a1bde..4f9bc867 100644 --- a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/HtmlToPdfConverter.java +++ b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/HtmlToPdfConverter.java @@ -12,6 +12,7 @@ import ch.sbb.polarion.extension.pdf_exporter.util.html.HtmlLinksHelper; import ch.sbb.polarion.extension.pdf_exporter.weasyprint.WeasyPrintOptions; import ch.sbb.polarion.extension.pdf_exporter.weasyprint.service.WeasyPrintServiceConnector; +import com.google.inject.Inject; import lombok.Getter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.VisibleForTesting; @@ -22,6 +23,7 @@ public class HtmlToPdfConverter { @Getter private final WeasyPrintServiceConnector weasyPrintServiceConnector; + @Inject public HtmlToPdfConverter() { this.pdfTemplateProcessor = new PdfTemplateProcessor(); PdfExporterFileResourceProvider fileResourceProvider = new PdfExporterFileResourceProvider(); diff --git a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/PdfConverterJobsService.java b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/PdfConverterJobsService.java index 2b5c5913..23f99b86 100644 --- a/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/PdfConverterJobsService.java +++ b/src/main/java/ch/sbb/polarion/extension/pdf_exporter/converter/PdfConverterJobsService.java @@ -2,6 +2,7 @@ import ch.sbb.polarion.extension.generic.rest.filter.LogoutFilter; import ch.sbb.polarion.extension.pdf_exporter.rest.model.conversion.ExportParams; +import com.google.inject.Inject; import com.polarion.core.util.logging.Logger; import com.polarion.platform.security.ISecurityService; import lombok.Builder; @@ -36,6 +37,7 @@ public class PdfConverterJobsService { private final PdfConverter pdfConverter; private final ISecurityService securityService; + @Inject public PdfConverterJobsService(PdfConverter pdfConverter, ISecurityService securityService) { this.pdfConverter = pdfConverter; this.securityService = securityService;