mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126482 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 122590 jkaabimofrad: RA-841: Fixed the status code for the large file upload. Also, added a new exception with 507 status code to be thrown, when "ContentQuotaException" occurs. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126826 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -12,4 +12,5 @@ framework.exception.StaleEntity=Attempt to update a stale entity
|
||||
framework.exception.UnsupportedResourceOperation=The operation is unsupported
|
||||
framework.exception.DeletedResource=In this version of the API resource {0} has been deleted
|
||||
framework.exception.RequestEntityTooLarge=Request entity too large
|
||||
framework.exception.InsufficientStorage=Content storage quota exceeded
|
||||
|
||||
|
@@ -144,6 +144,7 @@
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.StaleEntityException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_CONFLICT}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.RequestEntityTooLargeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_REQUEST_ENTITY_TOO_LARGE}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.DisabledServiceException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_NOT_IMPLEMENTED}" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.InsufficientStorageException" value="507" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -64,6 +64,7 @@ import org.alfresco.rest.api.model.UserInfo;
|
||||
import org.alfresco.rest.framework.core.exceptions.ApiException;
|
||||
import org.alfresco.rest.framework.core.exceptions.ConstraintViolatedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InsufficientStorageException;
|
||||
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
|
||||
import org.alfresco.rest.framework.core.exceptions.PermissionDeniedException;
|
||||
import org.alfresco.rest.framework.core.exceptions.RequestEntityTooLargeException;
|
||||
@@ -1715,11 +1716,11 @@ public class NodesImpl implements Nodes
|
||||
}
|
||||
catch (ContentQuotaException cqe)
|
||||
{
|
||||
throw new RequestEntityTooLargeException(cqe.getMessage());
|
||||
throw new InsufficientStorageException();
|
||||
}
|
||||
catch (ContentLimitViolationException clv)
|
||||
{
|
||||
throw new ConstraintViolatedException(clv.getMessage());
|
||||
throw new RequestEntityTooLargeException(clv.getMessage());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2016 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.rest.framework.core.exceptions;
|
||||
|
||||
/**
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
public class InsufficientStorageException extends ApiException
|
||||
{
|
||||
private static final long serialVersionUID = 4188371184446611887L;
|
||||
|
||||
private static final String DEFAULT_MESSAGE_ID = "framework.exception.InsufficientStorage";
|
||||
|
||||
public InsufficientStorageException()
|
||||
{
|
||||
super(DEFAULT_MESSAGE_ID);
|
||||
}
|
||||
|
||||
public InsufficientStorageException(String msgId)
|
||||
{
|
||||
super(msgId);
|
||||
}
|
||||
|
||||
public InsufficientStorageException(String msgId, Object[] msgParams)
|
||||
{
|
||||
super(msgId, msgParams);
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.repo.content.ContentLimitProvider.SimpleFixedLimitProvider;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
@@ -867,6 +868,26 @@ public class NodeApiTest extends AbstractBaseApiTest
|
||||
.build();
|
||||
post(getChildrenUrl(user1Home.getId()), user1, reqBody.getBody(), null, reqBody.getContentType(), 400);
|
||||
|
||||
// Test content size limit
|
||||
final SimpleFixedLimitProvider limitProvider = applicationContext.getBean("defaultContentLimitProvider", SimpleFixedLimitProvider.class);
|
||||
final long defaultSizeLimit = limitProvider.getSizeLimit();
|
||||
limitProvider.setSizeLimitString("20000"); //20 KB
|
||||
|
||||
try
|
||||
{
|
||||
// quick.pdf size is about 23 KB
|
||||
reqBody = MultiPartBuilder.create()
|
||||
.setFileData(new FileData(fileName, file, MimetypeMap.MIMETYPE_PDF))
|
||||
.setAutoRename(true)
|
||||
.build();
|
||||
|
||||
// Try to upload a file larger than the configured size limit
|
||||
post(getChildrenUrl(Nodes.PATH_MY), user1, reqBody.getBody(), null, reqBody.getContentType(), 413);
|
||||
}
|
||||
finally
|
||||
{
|
||||
limitProvider.setSizeLimitString(Long.toString(defaultSizeLimit));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user