Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Jakarta servlet support #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions directjngine-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.sonatype.directjngine</groupId>
<artifactId>directjngine-parent</artifactId>
<version>2.2.11-SNAPSHOT</version>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -30,8 +30,8 @@
</licenses>

<properties>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
Expand All @@ -49,9 +49,9 @@
-->

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.io.IOException;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.IOUtils;

import com.softwarementors.extjs.djn.StringBuilderUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;

import com.softwarementors.extjs.djn.config.annotations.DirectFormPostMethod;
import com.softwarementors.extjs.djn.config.annotations.DirectMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;

import com.softwarementors.extjs.djn.config.annotations.DirectFormPostMethod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.io.IOException;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.IOUtils;

import com.softwarementors.extjs.djn.config.annotations.DirectFormPostMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.lang.reflect.Method;
import java.util.Map;

import javax.servlet.ServletConfig;
import jakarta.servlet.ServletConfig;

import com.softwarementors.extjs.djn.StringUtils;
import com.softwarementors.extjs.djn.api.RegisteredAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

package com.softwarementors.extjs.djn.test.servlet.ssm;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpSession;

import com.softwarementors.extjs.djn.config.annotations.DirectMethod;
import com.softwarementors.extjs.djn.servlet.ssm.WebContext;
Expand Down
42 changes: 24 additions & 18 deletions directjngine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.sonatype.directjngine</groupId>
<artifactId>directjngine-parent</artifactId>
<version>2.2.11-SNAPSHOT</version>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -32,51 +32,57 @@
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>2.0.1</version>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.8.3</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.11.0</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.15.1</version>
</dependency>

<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-jakarta</artifactId>
<version>2.0.0-M1</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<version>2.10.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<version>2.0.12</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>1.7.36</version>
<version>2.0.9</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -126,9 +132,9 @@
-->

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

import javax.annotation.Nullable;

import org.apache.commons.lang.StringEscapeUtils;
import static org.apache.commons.text.StringEscapeUtils.escapeHtml4;


public final class EncodingUtils {
private EncodingUtils() {
Expand All @@ -41,7 +42,6 @@ public static String htmlEncode(@Nullable String value) {
if (value == null) {
return value;
}

return StringEscapeUtils.escapeHtml(value);
return escapeHtml4(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import java.io.Writer;
import java.util.List;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.fileupload2.core.FileUploadException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;

import com.softwarementors.extjs.djn.router.processor.standard.StandardRequestData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@

package com.softwarementors.extjs.djn.router.processor.standard.form;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -135,7 +136,11 @@ private ResponseData processRequest( FormPostRequestData request ) {
}
finally {
for (FileItem fileItem : request.getFileFields().values()) {
fileItem.delete();
try {
fileItem.delete();
} catch (IOException e) {
//ignore ...
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected FileUploadException(String message, Throwable cause) {
super(message, cause);
}

public static FileUploadException forFileUploadException( org.apache.commons.fileupload.FileUploadException cause ) {
public static FileUploadException forFileUploadException( org.apache.commons.fileupload2.core.FileUploadException cause ) {
assert cause != null;

// The FileUploadException raised by commons-fileupload usually hides an inner exception that is the real cause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,23 @@

package com.softwarementors.extjs.djn.router.processor.standard.form.upload;

import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.softwarementors.extjs.djn.api.Registry;
import com.softwarementors.extjs.djn.config.GlobalConfiguration;
import com.softwarementors.extjs.djn.router.dispatcher.Dispatcher;
import com.softwarementors.extjs.djn.router.processor.standard.form.FormPostRequestProcessorBase;

import edu.umd.cs.findbugs.annotations.NonNull;
import org.apache.commons.fileupload2.core.DiskFileItemFactory;
import org.apache.commons.fileupload2.core.FileItem;
import org.apache.commons.fileupload2.jakarta.JakartaServletDiskFileUpload;
import org.apache.commons.fileupload2.jakarta.JakartaServletFileUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.softwarementors.extjs.djn.EncodingUtils.htmlEncode;

Expand Down Expand Up @@ -112,19 +110,20 @@ private static String getFileParametersLogString(Map<String, FileItem> fileField
return result.toString();
}

public static ServletFileUpload createFileUploader(final long maxUploadSize) {
public static JakartaServletFileUpload createFileUploader(final long maxUploadSize) {
// Create a factory for disk-based file items
DiskFileItemFactory factory = new DiskFileItemFactory();
JakartaServletDiskFileUpload fileUpload = new JakartaServletDiskFileUpload();
DiskFileItemFactory factory = fileUpload.getFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
JakartaServletFileUpload upload = new JakartaServletFileUpload(factory);

// Set upload handler limits
upload.setSizeMax(maxUploadSize);
upload.setFileSizeMax(maxUploadSize);
return upload;
}

public void handleFileUploadException(FileUploadException e) {
public void handleFileUploadException(org.apache.commons.fileupload2.core.FileUploadException e) {
assert e != null;

com.softwarementors.extjs.djn.router.processor.standard.form.upload.FileUploadException ex = com.softwarementors.extjs.djn.router.processor.standard.form.upload.FileUploadException.forFileUploadException(e);
Expand Down
Loading