mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
69695: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 68570: Merged DEV to V4.2-BUG-FIX (4.2.3) 68084 : MNT-11237 : CMIS uploading file larger the 4mb fails - Ensure that temp directory exists before buffering request input stream. - Test webscript was added (simply buffers request input stream) - TempFileProvider now has method to get or create temp folder inside system temp directory - Unit test was added git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@70435 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -93,7 +93,7 @@ public class RepositoryContainer extends AbstractRuntimeContainer
|
||||
*/
|
||||
public void setup()
|
||||
{
|
||||
File tempDirectory = new File(TempFileProvider.getTempDir(), tempDirectoryName);
|
||||
File tempDirectory = TempFileProvider.getTempDir(tempDirectoryName);
|
||||
this.streamFactory = ThresholdOutputStreamFactory.newInstance(tempDirectory, memoryThreshold, maxContentSize, encryptTempFiles);
|
||||
}
|
||||
|
||||
|
@@ -86,7 +86,7 @@ public abstract class ApiWebScript extends AbstractWebScript
|
||||
|
||||
public void init()
|
||||
{
|
||||
File tempDirectory = new File(TempFileProvider.getTempDir(), tempDirectoryName);
|
||||
File tempDirectory = TempFileProvider.getTempDir(tempDirectoryName);
|
||||
this.streamFactory = ThresholdOutputStreamFactory.newInstance(tempDirectory, memoryThreshold, maxContentSize, encryptTempFiles);
|
||||
}
|
||||
|
||||
|
@@ -18,13 +18,16 @@
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.util.CronTriggerBean;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||
import org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest;
|
||||
import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
||||
import static org.springframework.extensions.webscripts.Status.*;
|
||||
|
||||
@@ -41,6 +44,7 @@ public class RepositoryContainerTest extends BaseWebScriptTest
|
||||
|
||||
private static final String USER_ONE = "RunAsOne";
|
||||
private static final String USER_TWO = "RunAsTwo";
|
||||
private static final String SUCCESS = "success";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
@@ -109,4 +113,34 @@ public class RepositoryContainerTest extends BaseWebScriptTest
|
||||
RepositoryContainer repoContainer = (RepositoryContainer) getServer().getApplicationContext().getBean("webscripts.container");
|
||||
repoContainer.reset();
|
||||
}
|
||||
|
||||
/*
|
||||
* Test for MNT-11237 : CMIS uploading file larger the 4mb fails
|
||||
*
|
||||
* Tests that requests with content larger than 4mb (default memoryThreshold value) can be successfully handled by repository container
|
||||
*/
|
||||
public void testLargeContentRequest() throws Exception
|
||||
{
|
||||
authenticationComponent.setCurrentUser(USER_ONE);
|
||||
|
||||
// create the 5 mb size buffer of zero bytes
|
||||
byte[] content = new byte[5 * 1024 * 1024];
|
||||
Arrays.fill(content, (byte)0);
|
||||
|
||||
// chek that we can upload file larger than 4 mb
|
||||
Response response = sendRequest(new PutRequest("/test/largecontenttest", content, "text/plain"), STATUS_OK);
|
||||
assertEquals(SUCCESS, response.getContentAsString());
|
||||
|
||||
// trigger the webscript temp folder cleaner job
|
||||
CronTriggerBean webscriptsTempFileCleanerJobTrigger = (CronTriggerBean) getServer().getApplicationContext().getBean("webscripts.tempFileCleanerTrigger");
|
||||
|
||||
webscriptsTempFileCleanerJobTrigger.getScheduler().triggerJobWithVolatileTrigger(
|
||||
webscriptsTempFileCleanerJobTrigger.getJobDetail().getName(),
|
||||
webscriptsTempFileCleanerJobTrigger.getJobDetail().getGroup(),
|
||||
webscriptsTempFileCleanerJobTrigger.getJobDetail().getJobDataMap());
|
||||
|
||||
// check that we still can upload file larger than 4 mb, i.e. ensure that cleaner has not deleted temp folder
|
||||
response = sendRequest(new PutRequest("/test/largecontenttest", content, "text/plain"), STATUS_OK);
|
||||
assertEquals(SUCCESS, response.getContentAsString());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Test webscript class that simply read request content. Used in unit test for MNT-11237 issue.
|
||||
*
|
||||
* @author pavel.yurkevich
|
||||
*/
|
||||
public class LargeContentTestPut extends DeclarativeWebScript
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
|
||||
try
|
||||
{
|
||||
req.getContent().getInputStream().close();
|
||||
model.put("result", "success");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR, "Fail to read request content.");
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Large Request Test</shortname>
|
||||
<description>Large Request Test </description>
|
||||
<url>/test/largecontenttest</url>
|
||||
<format default="html">argument</format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1 @@
|
||||
${result}
|
@@ -23,4 +23,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="webscript.org.alfresco.runas.largecontent.put" class="org.alfresco.repo.web.scripts.test.LargeContentTestPut" parent="webscript">
|
||||
</bean>
|
||||
|
||||
</beans>
|
Reference in New Issue
Block a user