mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57701: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 57648: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1) 57594: MNT-9770 : Merged from DEV to V4.1-BUG-FIX 57002: MNT-9770 : WebDAV uploads over 2gb in size fails. Change int type to long, as content length from http request more than Integer.MAX_VALUE . git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61869 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -65,6 +65,9 @@
|
|||||||
<property name="tenantService">
|
<property name="tenantService">
|
||||||
<ref bean="tenantService" />
|
<ref bean="tenantService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeLimitString">
|
||||||
|
<value>${system.content.maximumFileSizeLimit}</value>
|
||||||
|
</property>
|
||||||
<property name="policyBehaviourFilter">
|
<property name="policyBehaviourFilter">
|
||||||
<ref bean="policyBehaviourFilter" />
|
<ref bean="policyBehaviourFilter" />
|
||||||
</property>
|
</property>
|
||||||
|
@@ -115,6 +115,29 @@ public class WebDAVHelper
|
|||||||
|
|
||||||
private String m_urlPathPrefix;
|
private String m_urlPathPrefix;
|
||||||
|
|
||||||
|
private long sizeLimit = -1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets a value for the limit. If the string does not {@link Long#parseLong(String) parse} to a
|
||||||
|
* java long.
|
||||||
|
*
|
||||||
|
* @param limit a String representing a valid Java long.
|
||||||
|
*/
|
||||||
|
public void setSizeLimitString(String limit)
|
||||||
|
{
|
||||||
|
// A string parameter is used here in order to not to require end users to provide a value for the limit in a property
|
||||||
|
// file. This results in the empty string being injected to this method.
|
||||||
|
long longLimit = -1L;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
longLimit = Long.parseLong(limit);
|
||||||
|
} catch (NumberFormatException ignored)
|
||||||
|
{
|
||||||
|
// Intentionally empty
|
||||||
|
}
|
||||||
|
this.sizeLimit = longLimit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the regular expression that will be applied to filenames during renames
|
* Set the regular expression that will be applied to filenames during renames
|
||||||
* to detect whether clients are performing a renaming shuffle - common during
|
* to detect whether clients are performing a renaming shuffle - common during
|
||||||
@@ -129,6 +152,14 @@ public class WebDAVHelper
|
|||||||
this.m_renameShufflePattern = renameShufflePattern;
|
this.m_renameShufflePattern = renameShufflePattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Return the limit size
|
||||||
|
*/
|
||||||
|
public long getSizeLimit()
|
||||||
|
{
|
||||||
|
return sizeLimit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Return the authentication service
|
* @return Return the authentication service
|
||||||
*/
|
*/
|
||||||
|
@@ -25,7 +25,6 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -46,8 +45,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
import org.alfresco.repo.content.LimitedStreamCopier;
|
||||||
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
@@ -68,15 +66,12 @@ import org.alfresco.service.cmr.security.AuthenticationService;
|
|||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.FileFilterMode;
|
|
||||||
import org.alfresco.util.FileFilterMode.Client;
|
|
||||||
import org.alfresco.util.TempFileProvider;
|
import org.alfresco.util.TempFileProvider;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.dom4j.DocumentHelper;
|
import org.dom4j.DocumentHelper;
|
||||||
import org.dom4j.io.OutputFormat;
|
import org.dom4j.io.OutputFormat;
|
||||||
import org.dom4j.io.XMLWriter;
|
import org.dom4j.io.XMLWriter;
|
||||||
import org.springframework.util.FileCopyUtils;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
@@ -289,12 +284,15 @@ public abstract class WebDAVMethod
|
|||||||
if (this.m_requestBody == null)
|
if (this.m_requestBody == null)
|
||||||
{
|
{
|
||||||
this.m_requestBody = TempFileProvider.createTempFile("webdav_" + req.getMethod() + "_", ".bin");
|
this.m_requestBody = TempFileProvider.createTempFile("webdav_" + req.getMethod() + "_", ".bin");
|
||||||
OutputStream out = new FileOutputStream(this.m_requestBody);
|
// copy the streams
|
||||||
int bytesRead = FileCopyUtils.copy(req.getInputStream(), out);
|
LimitedStreamCopier streamCopier = new LimitedStreamCopier();
|
||||||
|
long bytes = streamCopier.copyStreamsLong(req.getInputStream(), new FileOutputStream(this.m_requestBody), m_davHelper.getSizeLimit());
|
||||||
|
|
||||||
|
// get content length
|
||||||
|
long contentLength = Long.valueOf(req.getHeader(WebDAV.HEADER_CONTENT_LENGTH));
|
||||||
|
|
||||||
// ALF-7377: check for corrupt request
|
// ALF-7377: check for corrupt request
|
||||||
int contentLength = req.getIntHeader(WebDAV.HEADER_CONTENT_LENGTH);
|
if (contentLength >= 0 && contentLength != bytes)
|
||||||
if (contentLength >= 0 && contentLength != bytesRead)
|
|
||||||
{
|
{
|
||||||
throw new IOException("Request body does not have specified Content Length");
|
throw new IOException("Request body does not have specified Content Length");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user