forked from piranhacloud/piranha
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes piranhacloud#4185 - Update Apache Commons File Upload to latest…
… version (piranhacloud#4201)
- Loading branch information
Showing
19 changed files
with
52 additions
and
99 deletions.
There are no files selected for viewing
43 changes: 0 additions & 43 deletions
43
...ache-fileupload/src/main/java/cloud/piranha/extension/apache/fileupload/package-info.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.extension.apache.fileupload; | ||
package cloud.piranha.extension.fileupload; | ||
|
||
import cloud.piranha.core.api.WebApplication; | ||
import cloud.piranha.core.api.WebApplicationExtension; | ||
|
@@ -37,23 +37,22 @@ | |
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public class ApacheMultiPartExtension implements WebApplicationExtension { | ||
public class FileUploadExtension implements WebApplicationExtension { | ||
|
||
/** | ||
* Stores the logger. | ||
*/ | ||
private static final System.Logger LOGGER = System.getLogger( | ||
ApacheMultiPartExtension.class.getName()); | ||
private static final System.Logger LOGGER = System.getLogger(FileUploadExtension.class.getName()); | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public ApacheMultiPartExtension() { | ||
public FileUploadExtension() { | ||
} | ||
|
||
@Override | ||
public void configure(WebApplication webApplication) { | ||
LOGGER.log(TRACE, "Configuring Apache Commons FileUpload extension"); | ||
webApplication.addInitializer(ApacheMultiPartInitializer.class.getName()); | ||
webApplication.addInitializer(FileUploadMultiPartInitializer.class.getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.extension.apache.fileupload; | ||
package cloud.piranha.extension.fileupload; | ||
|
||
import jakarta.servlet.http.Part; | ||
import java.io.File; | ||
|
@@ -45,7 +45,7 @@ | |
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public class ApacheMultiPart implements Part { | ||
public class FileUploadMultiPart implements Part { | ||
|
||
/** | ||
* Stores the item. | ||
|
@@ -57,7 +57,7 @@ public class ApacheMultiPart implements Part { | |
* | ||
* @param item the file item. | ||
*/ | ||
public ApacheMultiPart(FileItem item) { | ||
public FileUploadMultiPart(FileItem item) { | ||
this.item = item; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.extension.apache.fileupload; | ||
package cloud.piranha.extension.fileupload; | ||
|
||
import cloud.piranha.core.api.WebApplication; | ||
import jakarta.servlet.ServletContainerInitializer; | ||
|
@@ -43,24 +43,24 @@ | |
* </p> | ||
* | ||
* <ol> | ||
* <li>Sets the MultiPartManager to an instance of ApacheMultiPartManager.</li> | ||
* <li>Sets the MultiPartManager to an instance of FileUploadMultiPartManager.</li> | ||
* <li>Adds the JakartaFileCleaner listener that cleans up the temporary files.</li> | ||
* </ol> | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public class ApacheMultiPartInitializer implements ServletContainerInitializer { | ||
public class FileUploadMultiPartInitializer implements ServletContainerInitializer { | ||
|
||
/** | ||
* Stores the logger. | ||
*/ | ||
private static final Logger LOGGER = System.getLogger(ApacheMultiPartInitializer.class.getName()); | ||
private static final Logger LOGGER = System.getLogger(FileUploadMultiPartInitializer.class.getName()); | ||
|
||
@Override | ||
public void onStartup(Set<Class<?>> classes, ServletContext servletContext) throws ServletException { | ||
LOGGER.log(TRACE, "Setting ApacheMultiPartManager"); | ||
WebApplication webApplication = (WebApplication) servletContext; | ||
webApplication.getManager().setMultiPartManager(new ApacheMultiPartManager()); | ||
webApplication.getManager().setMultiPartManager(new FileUploadMultiPartManager()); | ||
webApplication.addListener("org.apache.commons.fileupload2.jakarta.servlet6.JakartaFileCleaner"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.extension.apache.fileupload; | ||
package cloud.piranha.extension.fileupload; | ||
|
||
import cloud.piranha.core.api.MultiPartManager; | ||
import cloud.piranha.core.api.WebApplication; | ||
|
@@ -50,24 +50,24 @@ | |
* The ApacheMultiPartManager. | ||
* | ||
* <p> | ||
* The ApacheMultiPartManager implements the MultiPartManager API that delivers | ||
* file upload functionality to a web application by delegating to Apache | ||
* Commons File Upload. | ||
* </p> | ||
The FileUploadMultiPartManager implements the MultiPartManager API that delivers | ||
file upload functionality to a web application by delegating to Apache | ||
Commons File Upload. | ||
</p> | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
public class ApacheMultiPartManager implements MultiPartManager { | ||
public class FileUploadMultiPartManager implements MultiPartManager { | ||
|
||
/** | ||
* Stores the logger. | ||
*/ | ||
private static final Logger LOGGER = System.getLogger(ApacheMultiPartManager.class.getName()); | ||
private static final Logger LOGGER = System.getLogger(FileUploadMultiPartManager.class.getName()); | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public ApacheMultiPartManager() { | ||
public FileUploadMultiPartManager() { | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
|
@@ -85,7 +85,7 @@ public Collection<Part> getParts(WebApplication webApplication, WebApplicationRe | |
try { | ||
setupFileUpload(webApplication, request.getMultipartConfig()) | ||
.parseRequest((HttpServletRequest) request) | ||
.forEach(item -> newParts.add(new ApacheMultiPart((FileItem) item))); | ||
.forEach(item -> newParts.add(new FileUploadMultiPart((FileItem) item))); | ||
} catch (FileUploadException fue) { | ||
LOGGER.log(WARNING, "Error getting part", fue); | ||
} | ||
|
@@ -118,7 +118,7 @@ public Part getPart(WebApplication webApplication, WebApplicationRequest request | |
* @return the JakartServletFileUpload instance. | ||
*/ | ||
private synchronized JakartaServletFileUpload setupFileUpload(WebApplication webApplication, MultipartConfigElement multipartConfig) { | ||
JakartaServletFileUpload upload = (JakartaServletFileUpload) webApplication.getAttribute(ApacheMultiPartManager.class.getName()); | ||
JakartaServletFileUpload upload = (JakartaServletFileUpload) webApplication.getAttribute(FileUploadMultiPartManager.class.getName()); | ||
if (upload == null) { | ||
File outputDirectory; | ||
if (multipartConfig.getLocation() == null || multipartConfig.getLocation().isEmpty()) { | ||
|
@@ -140,7 +140,7 @@ private synchronized JakartaServletFileUpload setupFileUpload(WebApplication web | |
.setFile(outputDirectory) | ||
.get(); | ||
upload = new JakartaServletFileUpload(factory); | ||
webApplication.setAttribute(ApacheMultiPartManager.class.getName(), upload); | ||
webApplication.setAttribute(FileUploadMultiPartManager.class.getName(), upload); | ||
} | ||
return upload; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,19 +27,16 @@ | |
*/ | ||
|
||
/** | ||
* This module delivers the file upload extension using Apache Commons FileUpload. | ||
* | ||
* <p> | ||
* See https://github.com/apache/commons-fileupload for more information about | ||
* its project. | ||
* </p> | ||
* This module delivers the file upload functionality using Apache Commons | ||
* FileUpload. See https://github.com/apache/commons-fileupload for more | ||
* information. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
module cloud.piranha.extension.apache.fileupload { | ||
module cloud.piranha.extension.fileupload { | ||
|
||
exports cloud.piranha.extension.apache.fileupload; | ||
opens cloud.piranha.extension.apache.fileupload; | ||
exports cloud.piranha.extension.fileupload; | ||
opens cloud.piranha.extension.fileupload; | ||
requires cloud.piranha.core.api; | ||
requires org.apache.commons.fileupload2.core; | ||
requires org.apache.commons.fileupload2.jakarta.servlet6; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package cloud.piranha.extension.apache.fileupload; | ||
package cloud.piranha.extension.fileupload; | ||
|
||
import cloud.piranha.core.impl.DefaultWebApplication; | ||
import cloud.piranha.core.impl.DefaultWebApplicationRequest; | ||
|
@@ -35,11 +35,11 @@ | |
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* The JUnit tests for the ApacheMultiPartManager class. | ||
* The JUnit tests for the FileUploadMultiPartManager class. | ||
* | ||
* @author Manfred Riem ([email protected]) | ||
*/ | ||
class ApacheMultiPartManagerTest { | ||
class FileUploadMultiPartManagerTest { | ||
|
||
/** | ||
* Test getPart method. | ||
|
@@ -53,7 +53,7 @@ void testGetPart() throws Exception { | |
request.setMultipartConfig(new MultipartConfigElement(new File("target").getAbsolutePath())); | ||
request.setContentType("multipart/form-data"); | ||
request.setMethod("POST"); | ||
ApacheMultiPartManager manager = new ApacheMultiPartManager(); | ||
FileUploadMultiPartManager manager = new FileUploadMultiPartManager(); | ||
assertNull(manager.getPart(application, request, "part_test")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.