Skip to content

Commit

Permalink
Upgrade to Jakarta EE 9
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinleturc authored and angelozerr committed Jun 15, 2024
1 parent 483bed8 commit 4fab1fd
Show file tree
Hide file tree
Showing 75 changed files with 377 additions and 357 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
ignore:
- dependency-name: org.apache.cxf:*
versions:
- "> 3, < 4"
- dependency-name: org.eclipse.jetty:*
versions:
- " < 11"
28 changes: 14 additions & 14 deletions document/fr.opensagres.xdocreport.document.tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,65 +79,65 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.9</version>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.9</version>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.1.9</version>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.1.9</version>
<version>4.0.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.2</version>
<groupId>com.fasterxml.jackson.jakarta.rs</groupId>
<artifactId>jackson-jakarta-rs-json-provider</artifactId>
<version>2.13.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.7.8</version>
<version>2.13.5</version>
</dependency>

<!-- Jetty is extremely convenient for testing REST and WS -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.53.v20231009</version>
<version>11.0.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.4.53.v20231009</version>
<version>11.0.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.53.v20231009</version>
<version>11.0.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
<version>9.4.53.v20231009</version>
<version>11.0.21</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-io</artifactId>
<version>9.4.53.v20231009</version>
<version>11.0.21</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -149,7 +149,7 @@
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.7</version>
<version>3.0.2</version>
<type>pom</type>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@
import java.io.PrintStream;
import java.io.Writer;

import javax.ws.rs.RuntimeType;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Configuration;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;

import org.apache.cxf.jaxrs.impl.ConfigurationImpl;

import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.fasterxml.jackson.jakarta.rs.json.JacksonXmlBindJsonProvider;

import fr.opensagres.xdocreport.core.io.IOUtils;
import fr.opensagres.xdocreport.core.utils.StringUtils;
Expand Down Expand Up @@ -154,7 +150,7 @@ private static void processJAXRS( String baseAddress, String user, String passwo
{
String resources = null;
Client client = ClientBuilder.newBuilder()
.register(JacksonJaxbJsonProvider.class)
.register(JacksonXmlBindJsonProvider.class)
.register(LargeBinaryDataMessageBodyReader.class)
.register(LargeBinaryDataMessageBodyWriter.class)
.build();
Expand Down Expand Up @@ -323,8 +319,9 @@ private static void processDownloadLargeFile( JAXRSResourcesService client, Stri
if ( resources.indexOf( ";" ) == -1 )
{

LargeBinaryData data = client.downloadLarge( resources );
binaryDataContentToFile( new File( out ), data );
try ( LargeBinaryData data = client.downloadLarge( resources ) ) {
binaryDataContentToFile( new File( out ), data );
}
}
else
{
Expand All @@ -345,8 +342,9 @@ private static void processUploadLargeLargeFile( JAXRSResourcesService client, S
}
if ( resources.indexOf( ";" ) == -1 )
{
LargeBinaryData data = createLargeBinaryDataFromFile( resources, new File( out ) );
client.uploadLarge( data );
try ( LargeBinaryData data = createLargeBinaryDataFromFile( resources, new File( out ) ) ) {
client.uploadLarge(data);
}

}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ public static Object wrap( Object object )
Package objectPackage = object.getClass().getPackage();
String objectPackageName = objectPackage != null ? objectPackage.getName() : "";
if ( objectPackageName.startsWith( "java." ) || objectPackageName.startsWith( "javax." )
|| object.getClass().getClassLoader() == null )
|| objectPackageName.startsWith( "jakarta." ) || object.getClass().getClassLoader() == null )
{
return object.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
package fr.opensagres.xdocreport.document.tools.remoting.resources.services.server.jaxws;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.xml.ws.Endpoint;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.xml.ws.Endpoint;

import org.apache.cxf.transport.servlet.CXFNonSpringServlet;

Expand All @@ -44,7 +44,7 @@ public void init( ServletConfig sc )
super.init( sc );
String address = "/resources";
Endpoint e =
javax.xml.ws.Endpoint.publish( address, new JAXWSResourcesServiceImpl( new MockResourcesService() ) );
jakarta.xml.ws.Endpoint.publish( address, new JAXWSResourcesServiceImpl( new MockResourcesService() ) );
System.err.println( e );
}
}
20 changes: 13 additions & 7 deletions document/fr.opensagres.xdocreport.document/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@


<dependencies>


<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-core</artifactId>
<version>2.0.0-M2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.5</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-jakarta-servlet5</artifactId>
<version>2.0.0-M2</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ public static Object wrap( Object object, IJSONNode node )
Package objectPackage = object.getClass().getPackage();
String objectPackageName = objectPackage != null ? objectPackage.getName() : "";
if ( objectPackageName.startsWith( "java." ) || objectPackageName.startsWith( "javax." )
|| object.getClass().getClassLoader() == null )
|| objectPackageName.startsWith( "jakarta." ) || object.getClass().getClassLoader() == null )
{
return object.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
import java.io.PrintWriter;
import java.io.StringWriter;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.URIResolver;

import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import fr.opensagres.xdocreport.converter.ConverterTypeTo;
import fr.opensagres.xdocreport.converter.IConverter;
import fr.opensagres.xdocreport.converter.IURIResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import fr.opensagres.xdocreport.converter.MimeMapping;
import fr.opensagres.xdocreport.core.utils.HttpHeaderUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload2.core.DiskFileItem;
import org.apache.commons.fileupload2.core.DiskFileItemFactory;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.fileupload2.core.FileUploadException;
import org.apache.commons.fileupload2.jakarta.servlet5.JakartaServletFileUpload;

import fr.opensagres.xdocreport.core.XDocReportException;
import fr.opensagres.xdocreport.document.IXDocReport;
Expand Down Expand Up @@ -70,26 +70,25 @@ protected void processRequest( HttpServletRequest request, HttpServletResponse r
protected void doUpload( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException
{
boolean isMultipart = ServletFileUpload.isMultipartContent( request );
boolean isMultipart = JakartaServletFileUpload.isMultipartContent( request );

if ( isMultipart )
{

// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
DiskFileItemFactory factory = DiskFileItemFactory.builder().get();

// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload( factory );
JakartaServletFileUpload<DiskFileItem, DiskFileItemFactory> upload = new JakartaServletFileUpload<>( factory );

// Parse the request
try
{
@SuppressWarnings( "unchecked" )
List<FileItem> items = upload.parseRequest( request );
for ( Iterator<FileItem> iterator = items.iterator(); iterator.hasNext(); )
List<DiskFileItem> items = upload.parseRequest( request );
for ( Iterator<DiskFileItem> iterator = items.iterator(); iterator.hasNext(); )
{

FileItem fileItem = (FileItem) iterator.next();
DiskFileItem fileItem = iterator.next();

if ( "uploadfile".equals( fileItem.getFieldName() ) )
{
Expand Down Expand Up @@ -126,7 +125,7 @@ protected void reportLoaded( IXDocReport report, HttpServletRequest request )
// Do Nothing
}

protected String generateReportId( FileItem fileItem, HttpServletRequest request )
protected String generateReportId( FileItem<?> fileItem, HttpServletRequest request )
{
String reportId = fileItem.getName();
// test if report id has slash (when document is uploaded with IE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package fr.opensagres.xdocreport.document.web;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import fr.opensagres.xdocreport.converter.IURIResolver;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package fr.opensagres.xdocreport.document.web.dispatcher;

import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;

import fr.opensagres.xdocreport.document.IXDocReport;
import fr.opensagres.xdocreport.document.dispatcher.IXDocReportController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;

import fr.opensagres.xdocreport.core.XDocReportException;
import fr.opensagres.xdocreport.core.utils.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-minimal</artifactId>
<version>2.5.2</version>
<version>4.0.4</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
Expand Down Expand Up @@ -235,9 +235,9 @@
</exclusions>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static Option[] configure()

mavenBundle("org.slf4j", "slf4j-simple", "1.6.1").noStart(),

wrappedBundle( mavenBundle( "javax.activation", "activation", "1.1.1" ) ),
wrappedBundle( mavenBundle( "jakarta.activation", "jakarta.activation-api", "2.0.1" ) ),
wrappedBundle( mavenBundle( "org.apache.poi", "poi", "5.2.0" ) ),
wrappedBundle( mavenBundle( "org.apache.poi", "poi-ooxml", "5.2.0" ) ).exports("org.apache.poi.ooxml","org.apache.poi.openxml4j.opc","org.apache.poi.xwpf.usermodel"),
wrappedBundle( mavenBundle( "org.apache.servicemix.bundles", "org.apache.servicemix.bundles.xmlbeans", "2.4.0_5" ) ),
Expand Down
Loading

0 comments on commit 4fab1fd

Please sign in to comment.