diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9fb536f..a85b212 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,4 +11,4 @@ updates: interval: "daily" target-branch: "SERVLET60" labels: - - "servlet60" \ No newline at end of file + - "servlet60" diff --git a/README.md b/README.md index bd44eaf..cbf8dbc 100644 --- a/README.md +++ b/README.md @@ -5,47 +5,66 @@ Servlet for Oracle APEX to run PDF Reports based on Apache FOP Fahrdienst-Anwendung / Kostenblatt * Uses Apache FOP for rendering -https://xmlgraphics.apache.org/fop/ + * Uses JavaMelody for monitoring -https://github.com/javamelody/javamelody/wiki + * Use Java 17 LTS (also tested with Java 21 LTS) * Use Tomcat 10.1.x+ (Jakarta EE / Servlet 6.0) or Jetty 12 + ## Run tests + `mvn test` ## Build + `mvn package verify` ## Upgrade + * set new version in pom.xml * check dependent libraries for updates * run tests and build ## Release + * create a tag with version number * create a github release ## Installation + * rename target/fop4apex*.war to fop4apex.war * copy fop4apex.war to tomcat webapps folder * Oracle APEX - Sample Settings * PrintServer External (Apache FOP) - * Protocol HTTP / HTTPS - * Host 127.0.0.1 - * Port 8080 + * Protocol HTTP / HTTPS + * Host 127.0.0.1 + * Port 8080 * Script: /fop4apex/pdf * Timeout 300 + ### Debugging + Add to Tomcat logging.properties: ``` org.apache.tomcat.util.http.Parameters.level = ALL de.pdv.apex.level = ALL ``` -### Deploy to tomcat 10.1.x+ or Jetty 12 (IntelliJ / Netbeans) +### Deploy to tomcat 9.x (IntelliJ / Netbeans) / Jetty 10.x + Run http://localhost:port/ Example: * http://localhost:8080/fop4apex_war_exploded/ * http://localhost:8080/fop4apex_war_exploded/monitoring +## Conversion using Apache fop (windows powershell) + +``` +$env:PATH="c:\Users\oliver1\Downloads\_tools\fop-2.9\fop;$env:PATH" +cd src\test\ressources\samples +fop.cmd -xsl kostenblatt_2014.xsl -xml kostenblatt_2014.xml -pdf Result2014.pdf +fop.cmd -xsl kostenblatt_2023_vh.xsl -xml kostenblatt_2023_vh.xml -pdf Result2023_vh.pdf +fop.cmd -xsl kostenblatt_2023_e.xsl -xml kostenblatt_2023_e.xml -pdf Result2023_e.pdf +start Result.pdf +``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index 76dd818..a2db3b4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ de.pdv.apex fop4apex - 2.0.0-SNAPSHOT + 2.0.1-SNAPSHOT fop4apex war https://www.pdv.de @@ -24,12 +24,28 @@ + + jakarta.servlet jakarta.servlet-api 6.1.0 provided + + + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + 3.0.1 + + + + org.glassfish.web + jakarta.servlet.jsp.jstl + 3.0.1 + + + org.junit.jupiter junit-jupiter-api @@ -96,6 +112,16 @@ compile + + + + @@ -143,6 +169,17 @@ bom + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + @@ -209,6 +246,7 @@ dependency-check-maven 10.0.3 + nvd html json diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 39b755f..c6e1015 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,8 +1,10 @@ - + + javamelody net.bull.javamelody.MonitoringFilter @@ -22,4 +24,4 @@ net.bull.javamelody.SessionListener - \ No newline at end of file + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 3de476f..8ea1a82 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,10 +1,16 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.LinkedHashMap" %> +<%@ taglib prefix="c" uri="jakarta.tags.core" %> + - - - + + + + Apache FOP for Oracle APEX @@ -42,11 +48,11 @@ Port - 8080 + Script - ${pageContext.request.contextPath}/pdf + /pdf Timeout @@ -61,24 +67,42 @@
org.apache.tomcat.util.http.Parameters.level = ALL
 de.pdv.apex.level = ALL
-

Server Info / Environment

<%--@elvariable id="System" type=""--%> -
-Server Version:   <%= application.getServerInfo() %>
-Servlet Version:  <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>
-JSP Version:      <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>
-Context Path:     ${pageContext.request.contextPath}
+<%
+    Map systemProperties = new LinkedHashMap<>();
+    systemProperties.put("Server Version",application.getServerInfo());
+    systemProperties.put("Servlet Version",String.format("%d.%d",application.getMajorVersion(),application.getMinorVersion()));
+    systemProperties.put("JSP Version",JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion());
+    systemProperties.put("Context Path", request.getContextPath() );
+    systemProperties.put("","");
+    systemProperties.put("java.version",System.getProperty("java.version"));
+    systemProperties.put("java.vm.vendor",System.getProperty("java.vm.vendor"));
+    systemProperties.put("user.country",System.getProperty("user.country"));
+    systemProperties.put("user.language",System.getProperty("user.language"));
+    systemProperties.put("user.name",System.getProperty("user.name"));
+    systemProperties.put("user.timezone",System.getProperty("user.timezone"));
+    systemProperties.put("os.name",System.getProperty("os.name"));
+    systemProperties.put("os.version",System.getProperty("os.version"));
+    systemProperties.put("file.encoding",System.getProperty("file.encoding"));
+    systemProperties.put("sun.jnu.encoding",System.getProperty("sun.jnu.encoding"));
+    request.setAttribute("systemProperties",systemProperties);
+%>
 
-java.version:     ${System.getProperty("java.version")}
-java.vm.vendor:   ${System.getProperty("java.vm.vendor")}
-user.country:     ${System.getProperty("user.country")}
-user.language:    ${System.getProperty("user.language")}
-user.name:        ${System.getProperty("user.name")}
-user.timezone:    ${System.getProperty("user.timezone")}
-os.name:          ${System.getProperty("os.name")}
-os.version:       ${System.getProperty("os.version")}
-file.encoding:    ${System.getProperty("file.encoding")}
-sun.jnu.encoding: ${System.getProperty("sun.jnu.encoding")}
+

Server Info / Environment

+ + + + + + + + + + + + + +
ParameterValue

page built with Pico.css, fop conversion with Apache FOP

diff --git a/src/test/java/de/pdv/apex/ExampleFO2PDFTest.java b/src/test/java/de/pdv/apex/ExampleFO2PDFTest.java index e108e02..2ddde49 100644 --- a/src/test/java/de/pdv/apex/ExampleFO2PDFTest.java +++ b/src/test/java/de/pdv/apex/ExampleFO2PDFTest.java @@ -109,8 +109,7 @@ class ExampleFO2PDFTest { app.convertFO2PDFHelper(inputStream, pdfFile); - if (!pdfFile.exists()) - throw new Exception("result file missing"); + Assertions.assertTrue(pdfFile.exists(), "Error: result file missing"); try (PDDocument document = Loader.loadPDF(new RandomAccessReadBufferedFile(pdfFile))) { diff --git a/src/test/java/de/pdv/apex/ExampleXML2PDFTest.java b/src/test/java/de/pdv/apex/ExampleXML2PDFTest.java index 0f719dc..206dc7d 100644 --- a/src/test/java/de/pdv/apex/ExampleXML2PDFTest.java +++ b/src/test/java/de/pdv/apex/ExampleXML2PDFTest.java @@ -84,8 +84,7 @@ class ExampleXML2PDFTest { //close out.close(); - if (!pdfFile.exists()) - throw new Exception("result file missing"); + Assertions.assertTrue(pdfFile.exists(), "Error: result file missing"); try (PDDocument document = Loader.loadPDF(new RandomAccessReadBufferedFile(pdfFile))) { System.out.println("Pages: " + document.getNumberOfPages()); System.out.println("Filesize (Bytes): " + Files.size(pdfFile.toPath()));