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:
Alan Davis
2014-02-11 21:25:14 +00:00
parent 42c7df23b3
commit 2d53704b85
3 changed files with 42 additions and 10 deletions

View File

@@ -25,7 +25,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.SocketException;
import java.util.Date;
import java.util.HashMap;
@@ -46,8 +45,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.filefolder.HiddenAspect;
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
import org.alfresco.repo.content.LimitedStreamCopier;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
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.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.FileFilterMode;
import org.alfresco.util.FileFilterMode.Client;
import org.alfresco.util.TempFileProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import org.springframework.util.FileCopyUtils;
import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
@@ -289,12 +284,15 @@ public abstract class WebDAVMethod
if (this.m_requestBody == null)
{
this.m_requestBody = TempFileProvider.createTempFile("webdav_" + req.getMethod() + "_", ".bin");
OutputStream out = new FileOutputStream(this.m_requestBody);
int bytesRead = FileCopyUtils.copy(req.getInputStream(), out);
// copy the streams
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
int contentLength = req.getIntHeader(WebDAV.HEADER_CONTENT_LENGTH);
if (contentLength >= 0 && contentLength != bytesRead)
if (contentLength >= 0 && contentLength != bytes)
{
throw new IOException("Request body does not have specified Content Length");
}