mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-01 14:41:46 +00:00
[ACS-5424] replace usage of apache fileupload dependency
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>binary-transformed-to-jakarta</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload-jakarta</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.5</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.transformer</groupId>
|
||||
<artifactId>transformer-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>transform-jar</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifact>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</artifact>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@@ -32,6 +32,5 @@
|
||||
|
||||
<modules>
|
||||
<module>apache-chemistry</module>
|
||||
<module>commons-fileupload-jakarta</module>
|
||||
</modules>
|
||||
</project>
|
@@ -20,7 +20,7 @@ function clone_and_install {
|
||||
mvn -f $project_path -B clean install -DskipTests -Dmaven.javadoc.skip=true
|
||||
}
|
||||
|
||||
clone_and_install surf-webscripts
|
||||
clone_and_install surf-webscripts "feature/acs-5424_apache_fileupload_replace"
|
||||
clone_and_install alfresco-greenmail
|
||||
clone_and_install alfresco-tas-utility
|
||||
clone_and_install alfresco-tas-email
|
||||
|
5
pom.xml
5
pom.xml
@@ -423,11 +423,6 @@
|
||||
<artifactId>commons-digester</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload-jakarta</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
|
@@ -32,7 +32,6 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferReceiver;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.transfer;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
public class CommandProcessorUtils
|
||||
{
|
||||
public static boolean isMultipartContent(HttpServletRequest servletRequest)
|
||||
{
|
||||
if(!servletRequest.getMethod().equalsIgnoreCase("post"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String contentType = servletRequest.getContentType();
|
||||
return contentType != null && contentType.toLowerCase().startsWith(MediaType.MULTIPART_FORM_DATA_VALUE);
|
||||
}
|
||||
}
|
@@ -30,17 +30,19 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferReceiver;
|
||||
import org.apache.commons.fileupload.FileItemIterator;
|
||||
import org.apache.commons.fileupload.FileItemStream;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.extensions.webscripts.WrappingWebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData.FormField;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.alfresco.repo.web.scripts.transfer.CommandProcessorUtils.isMultipartContent;
|
||||
|
||||
/**
|
||||
* This command processor is used to receive one or more content files for a given transfer.
|
||||
@@ -105,7 +107,7 @@ public class PostContentCommandProcessor implements CommandProcessor
|
||||
//Read the transfer id from the request
|
||||
String transferId = servletRequest.getParameter("transferId");
|
||||
|
||||
if ((transferId == null) || !ServletFileUpload.isMultipartContent(servletRequest))
|
||||
if ((transferId == null) || !isMultipartContent(servletRequest))
|
||||
{
|
||||
resp.setStatus(Status.STATUS_BAD_REQUEST);
|
||||
return Status.STATUS_BAD_REQUEST;
|
||||
@@ -113,17 +115,16 @@ public class PostContentCommandProcessor implements CommandProcessor
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
ServletFileUpload upload = new ServletFileUpload();
|
||||
FileItemIterator iter = upload.getItemIterator(servletRequest);
|
||||
|
||||
FormData formData = new FormData(servletRequest);
|
||||
Iterator<FormData.FormField> iter = Arrays.stream(formData.getFields()).iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
FileItemStream item = iter.next();
|
||||
String name = item.getFieldName();
|
||||
if (!item.isFormField())
|
||||
FormData.FormField formField = iter.next();
|
||||
if (formField.getIsFile())
|
||||
{
|
||||
logger.debug("got content Mime Part : " + name);
|
||||
receiver.saveContent(transferId, item.getName(), item.openStream());
|
||||
logger.debug("got content Mime Part : " + formField.getName());
|
||||
receiver.saveContent(transferId, formField.getFilename(), formField.getInputStream());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,24 +27,26 @@
|
||||
package org.alfresco.repo.web.scripts.transfer;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.repo.transfer.TransferCommons;
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferReceiver;
|
||||
import org.apache.commons.fileupload.FileItemIterator;
|
||||
import org.apache.commons.fileupload.FileItemStream;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.extensions.webscripts.WrappingWebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData;
|
||||
import org.springframework.extensions.webscripts.servlet.WebScriptServletRequest;
|
||||
import org.springframework.extensions.webscripts.servlet.FormData.FormField;
|
||||
|
||||
import static org.alfresco.repo.web.scripts.transfer.CommandProcessorUtils.isMultipartContent;
|
||||
|
||||
/**
|
||||
* This command processor is used to receive the snapshot for a given transfer.
|
||||
*
|
||||
@@ -100,7 +102,7 @@ public class PostSnapshotCommandProcessor implements CommandProcessor
|
||||
//Read the transfer id from the request
|
||||
String transferId = servletRequest.getParameter("transferId");
|
||||
|
||||
if ((transferId == null) || !ServletFileUpload.isMultipartContent(servletRequest))
|
||||
if ((transferId == null) || !isMultipartContent(servletRequest))
|
||||
{
|
||||
logger.debug("bad request, not multipart");
|
||||
resp.setStatus(Status.STATUS_BAD_REQUEST);
|
||||
@@ -111,15 +113,15 @@ public class PostSnapshotCommandProcessor implements CommandProcessor
|
||||
{
|
||||
logger.debug("about to upload manifest file");
|
||||
|
||||
ServletFileUpload upload = new ServletFileUpload();
|
||||
FileItemIterator iter = upload.getItemIterator(servletRequest);
|
||||
while (iter.hasNext())
|
||||
FormData formData = new FormData(servletRequest);
|
||||
Iterator<FormField> iter = Arrays.stream(formData.getFields()).iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
FileItemStream item = iter.next();
|
||||
if (!item.isFormField() && TransferCommons.PART_NAME_MANIFEST.equals(item.getFieldName()))
|
||||
FormField formField = iter.next();
|
||||
if (formField.getIsFile() && TransferCommons.PART_NAME_MANIFEST.equals(formField.getName()))
|
||||
{
|
||||
logger.debug("got manifest file");
|
||||
receiver.saveSnapshot(transferId, item.openStream());
|
||||
receiver.saveSnapshot(transferId, formField.getInputStream());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -30,10 +30,8 @@ import java.io.StringWriter;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.repo.transfer.TransferServiceImpl;
|
||||
import org.alfresco.service.cmr.transfer.TransferException;
|
||||
import org.alfresco.service.cmr.transfer.TransferReceiver;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
|
@@ -83,10 +83,6 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload-jakarta</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
|
Reference in New Issue
Block a user