mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
129125 mmuller: Merged RETURN-OF-THE-API (5.2.0) to 5.2.N (5.2.1) 128122 jvonka: v1 REST API: minor bug fix(es) to update http error code mappings (to 4xx rather than 500) + sanity api tests REPO-475, REPO-512, REPO-516, REPO-473 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129319 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -136,6 +136,11 @@
|
|||||||
<property name="exceptionMappings">
|
<property name="exceptionMappings">
|
||||||
<map>
|
<map>
|
||||||
<entry key="org.alfresco.rest.framework.core.exceptions.ApiException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
<entry key="org.alfresco.rest.framework.core.exceptions.ApiException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||||
|
<entry key="java.lang.NullPointerException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||||
|
<entry key="java.lang.IndexOutOfBoundsException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||||
|
<entry key="java.lang.OutOfMemoryError" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_INTERNAL_SERVER_ERROR}" />
|
||||||
|
<entry key="java.lang.IllegalArgumentException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
||||||
|
<entry key="org.alfresco.service.cmr.repository.CyclicChildRelationshipException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
||||||
<entry key="org.alfresco.rest.framework.core.exceptions.InvalidArgumentException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
<entry key="org.alfresco.rest.framework.core.exceptions.InvalidArgumentException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_BAD_REQUEST}" />
|
||||||
<entry key="org.alfresco.rest.framework.core.exceptions.NotFoundException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_NOT_FOUND}" />
|
<entry key="org.alfresco.rest.framework.core.exceptions.NotFoundException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_NOT_FOUND}" />
|
||||||
<entry key="org.alfresco.rest.framework.core.exceptions.EntityNotFoundException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_NOT_FOUND}" />
|
<entry key="org.alfresco.rest.framework.core.exceptions.EntityNotFoundException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_NOT_FOUND}" />
|
||||||
@@ -153,6 +158,7 @@
|
|||||||
<entry key="org.alfresco.repo.node.integrity.IntegrityException" value="422" />
|
<entry key="org.alfresco.repo.node.integrity.IntegrityException" value="422" />
|
||||||
<entry key="org.alfresco.repo.site.SiteServiceException" value="422" />
|
<entry key="org.alfresco.repo.site.SiteServiceException" value="422" />
|
||||||
<entry key="org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_UNSUPPORTED_MEDIA_TYPE}" />
|
<entry key="org.alfresco.rest.framework.core.exceptions.UnsupportedMediaTypeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_UNSUPPORTED_MEDIA_TYPE}" />
|
||||||
|
<entry key="org.springframework.http.InvalidMediaTypeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_UNSUPPORTED_MEDIA_TYPE}" />
|
||||||
</map>
|
</map>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -107,7 +107,6 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.CyclicChildRelationshipException;
|
|
||||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
@@ -2162,10 +2161,6 @@ public class NodesImpl implements Nodes
|
|||||||
{
|
{
|
||||||
throw new InvalidArgumentException("Invalid type of target parent: "+targetParentId);
|
throw new InvalidArgumentException("Invalid type of target parent: "+targetParentId);
|
||||||
}
|
}
|
||||||
catch (CyclicChildRelationshipException ccre)
|
|
||||||
{
|
|
||||||
throw new InvalidArgumentException("Parent/child cycle detected: "+targetParentId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1908,6 +1908,15 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
n.setNodeType(TYPE_CM_FOLDER);
|
n.setNodeType(TYPE_CM_FOLDER);
|
||||||
n.setRelativePath("d1.txt");
|
n.setRelativePath("d1.txt");
|
||||||
post(getNodeChildrenUrl(myNodeId), user1, RestApiUtil.toJsonAsStringNonNull(n), 409);
|
post(getNodeChildrenUrl(myNodeId), user1, RestApiUtil.toJsonAsStringNonNull(n), 409);
|
||||||
|
|
||||||
|
// -ve test - minor: error code if trying to create with property with invalid format (REPO-473)
|
||||||
|
props = new HashMap<>();
|
||||||
|
props.put("exif:pixelYDimension", "my unknown property");
|
||||||
|
n = new Folder();
|
||||||
|
n.setName("fZ");
|
||||||
|
n.setNodeType(TYPE_CM_FOLDER);
|
||||||
|
n.setProperties(props);
|
||||||
|
post(getNodeChildrenUrl(myNodeId), user1, RestApiUtil.toJsonAsStringNonNull(n), 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2736,6 +2745,13 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
fUpdate = new Folder();
|
fUpdate = new Folder();
|
||||||
fUpdate.setParentId(myNodeId);
|
fUpdate.setParentId(myNodeId);
|
||||||
put(URL_NODES, user1, fId, toJsonAsStringNonNull(fUpdate), null, 200);
|
put(URL_NODES, user1, fId, toJsonAsStringNonNull(fUpdate), null, 200);
|
||||||
|
|
||||||
|
// -ve test - minor: error code if trying to update property with invalid format (REPO-473)
|
||||||
|
props = new HashMap<>();
|
||||||
|
props.put("exif:pixelYDimension", "my unknown property");
|
||||||
|
fUpdate = new Folder();
|
||||||
|
fUpdate.setProperties(props);
|
||||||
|
put(URL_NODES, user1, f2Id, toJsonAsStringNonNull(fUpdate), null, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2962,6 +2978,10 @@ public class NodeApiTest extends AbstractBaseApiTest
|
|||||||
// -ve - try to update content using multi-part form data
|
// -ve - try to update content using multi-part form data
|
||||||
payload = new BinaryPayload(txtFile, "multipart/form-data", null);
|
payload = new BinaryPayload(txtFile, "multipart/form-data", null);
|
||||||
putBinary(url, user1, payload, null, null, 415);
|
putBinary(url, user1, payload, null, null, 415);
|
||||||
|
|
||||||
|
// -ve - try to invalid media type argument (when parsing request)
|
||||||
|
payload = new BinaryPayload(txtFile, "/jpeg", null);
|
||||||
|
putBinary(url, user1, payload, null, null, 415);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1503,6 +1503,16 @@ public class NodeAssociationsApiTest extends AbstractBaseApiTest
|
|||||||
assertEquals(o2Id, nodes.get(0).getId());
|
assertEquals(o2Id, nodes.get(0).getId());
|
||||||
|
|
||||||
// TODO test model with mandatory aspect
|
// TODO test model with mandatory aspect
|
||||||
|
|
||||||
|
|
||||||
|
// -ve test - minor: error code if creating a cyclic child assoc (REPO-475)
|
||||||
|
String myNodeId = getMyNodeId(user1);
|
||||||
|
n = new Node();
|
||||||
|
n.setName("my-folder-1");
|
||||||
|
n.setNodeType(TYPE_CM_FOLDER);
|
||||||
|
AssocChild assocChild = new AssocChild(myNodeId, "cm:contains");
|
||||||
|
n.setSecondaryChildren(Collections.singletonList(assocChild));
|
||||||
|
post(getNodeChildrenUrl(myNodeId), user1, RestApiUtil.toJsonAsStringNonNull(n), 400);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@@ -29,14 +29,11 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.repo.tenant.TenantUtil;
|
import org.alfresco.repo.tenant.TenantUtil;
|
||||||
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||||
import org.alfresco.rest.api.tests.RepoService.SiteInformation;
|
|
||||||
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
||||||
import org.alfresco.rest.api.tests.RepoService.TestSite;
|
import org.alfresco.rest.api.tests.RepoService.TestSite;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
|
import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
|
||||||
@@ -50,6 +47,7 @@ import org.alfresco.rest.api.tests.client.data.SiteRole;
|
|||||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.apache.commons.httpclient.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -289,6 +287,32 @@ public class TestSites extends EnterpriseTestApi
|
|||||||
sitesProxy.createSite(site);
|
sitesProxy.createSite(site);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -ve - minor: error code if updating via nodes api (REPO-512)
|
||||||
|
{
|
||||||
|
String siteId = "zzz";
|
||||||
|
String siteTitle = "ZZZ site";
|
||||||
|
|
||||||
|
Site site = new SiteImpl(null, siteId, null, siteTitle, null, SiteVisibility.PRIVATE.toString(), null, null);
|
||||||
|
String siteNodeId = sitesProxy.createSite(site).getGuid();
|
||||||
|
|
||||||
|
// try to update to invalid site visibility
|
||||||
|
JSONObject prop = new JSONObject();
|
||||||
|
prop.put("st:siteVisibility","INVALID");
|
||||||
|
JSONObject properties = new JSONObject();
|
||||||
|
properties.put("properties", new JSONObject(prop));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sitesProxy.update("nodes", siteNodeId, null, null, properties.toJSONString(), null);
|
||||||
|
fail();
|
||||||
|
} catch (PublicApiException e)
|
||||||
|
{
|
||||||
|
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
sitesProxy.removeSite(siteId); // cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
// -ve tests - belts-and-braces for unsupported methods
|
||||||
{
|
{
|
||||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user