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)
127573 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2) 126282 gjames: RA-878:All api errors should return the standard error, fix 404s git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127667 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,41 +28,28 @@ package org.alfresco.rest.api;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.alfresco.rest.api.authentications.AuthenticationTicketsEntityResource;
|
||||
import org.alfresco.rest.framework.Api;
|
||||
import org.alfresco.rest.framework.core.ResourceLocator;
|
||||
import org.alfresco.rest.framework.core.ResourceWithMetadata;
|
||||
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceBinaryAction;
|
||||
import org.alfresco.rest.framework.resource.actions.interfaces.ResourceAction;
|
||||
import org.alfresco.rest.framework.tools.ApiAssistant;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.extensions.webscripts.ArgumentTypeDescription;
|
||||
import org.springframework.extensions.webscripts.Container;
|
||||
import org.springframework.extensions.webscripts.DeclarativeRegistry;
|
||||
import org.springframework.extensions.webscripts.Description;
|
||||
import org.springframework.extensions.webscripts.*;
|
||||
import org.springframework.extensions.webscripts.Description.FormatStyle;
|
||||
import org.springframework.extensions.webscripts.Description.RequiredAuthentication;
|
||||
import org.springframework.extensions.webscripts.Description.RequiredTransaction;
|
||||
import org.springframework.extensions.webscripts.Description.TransactionCapability;
|
||||
import org.springframework.extensions.webscripts.DescriptionImpl;
|
||||
import org.springframework.extensions.webscripts.Match;
|
||||
import org.springframework.extensions.webscripts.NegotiatedFormat;
|
||||
import org.springframework.extensions.webscripts.Path;
|
||||
import org.springframework.extensions.webscripts.TransactionParameters;
|
||||
import org.springframework.extensions.webscripts.TypeDescription;
|
||||
import org.springframework.extensions.webscripts.URLModelFactory;
|
||||
import org.springframework.extensions.webscripts.WebScript;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author steveglover
|
||||
@@ -209,6 +196,10 @@ public class PublicApiDeclarativeRegistry extends DeclarativeRegistry
|
||||
match = super.findWebScript(method, uri);
|
||||
}
|
||||
|
||||
if (match == null)
|
||||
{
|
||||
throw new NotFoundException(NotFoundException.DEFAULT_MESSAGE_ID, new String[] {uri});
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
|
@@ -25,10 +25,6 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.tests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -39,6 +35,7 @@ import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
||||
import org.alfresco.rest.api.tests.RepoService.TestPerson;
|
||||
import org.alfresco.rest.api.tests.client.HttpResponse;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
|
||||
import org.alfresco.rest.api.tests.client.PublicApiClient.People;
|
||||
@@ -46,11 +43,15 @@ import org.alfresco.rest.api.tests.client.PublicApiException;
|
||||
import org.alfresco.rest.api.tests.client.RequestContext;
|
||||
import org.alfresco.rest.api.tests.client.data.Person;
|
||||
import org.alfresco.rest.api.tests.client.data.PersonNetwork;
|
||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class TestNetworks extends EnterpriseTestApi
|
||||
{
|
||||
private List<TestPerson> people = new ArrayList<TestPerson>(3);
|
||||
@@ -150,13 +151,28 @@ public class TestNetworks extends EnterpriseTestApi
|
||||
publicApiClient.setRequestContext(rc);
|
||||
|
||||
HttpResponse response = publicApiClient.delete(null, null, null, null, null);
|
||||
//url /null/alfresco/versions/1 does not map to a Web Script
|
||||
assertEquals(404, response.getStatusCode());
|
||||
PublicApiClient.ExpectedErrorResponse errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
assertNotNull(errorResponse);
|
||||
assertNotNull(errorResponse.getErrorKey());
|
||||
assertNotNull(errorResponse.getBriefSummary());
|
||||
|
||||
|
||||
response = publicApiClient.put(null, null, null, null, null, null, null);
|
||||
assertEquals(404, response.getStatusCode());
|
||||
errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
assertNotNull(errorResponse);
|
||||
assertNotNull(errorResponse.getErrorKey());
|
||||
assertNotNull(errorResponse.getBriefSummary());
|
||||
|
||||
|
||||
response = publicApiClient.post(null, null, null, null, null, null);
|
||||
assertEquals(404, response.getStatusCode());
|
||||
errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
assertNotNull(errorResponse);
|
||||
assertNotNull(errorResponse.getErrorKey());
|
||||
assertNotNull(errorResponse.getBriefSummary());
|
||||
|
||||
List<PersonNetwork> expectedNetworkMembers = person.getNetworkMemberships();
|
||||
|
||||
|
@@ -2076,13 +2076,14 @@ public class PublicApiClient
|
||||
private String stackTrace;
|
||||
private Map<String, Object> additionalState;
|
||||
private String descriptionURL;
|
||||
private String logId;
|
||||
|
||||
public ExpectedErrorResponse()
|
||||
{
|
||||
}
|
||||
|
||||
public ExpectedErrorResponse(String errorKey, int statusCode, String briefSummary, StackTraceElement[] stackTrace,
|
||||
Map<String, Object> additionalState)
|
||||
Map<String, Object> additionalState, String logId)
|
||||
{
|
||||
super();
|
||||
this.errorKey = errorKey;
|
||||
@@ -2090,6 +2091,7 @@ public class PublicApiClient
|
||||
this.briefSummary = briefSummary;
|
||||
this.stackTrace = Arrays.toString(stackTrace);
|
||||
this.additionalState = additionalState;
|
||||
this.logId = logId;
|
||||
}
|
||||
|
||||
public String getErrorKey()
|
||||
@@ -2125,6 +2127,14 @@ public class PublicApiClient
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLogId() {
|
||||
return logId;
|
||||
}
|
||||
|
||||
public void setLogId(String logId) {
|
||||
this.logId = logId;
|
||||
}
|
||||
|
||||
public String getStackTrace()
|
||||
{
|
||||
return stackTrace;
|
||||
@@ -2165,6 +2175,7 @@ public class PublicApiClient
|
||||
sb.append("ExpectedErrorResponse [errorKey='").append(errorKey)
|
||||
.append(", statusCode=").append(statusCode)
|
||||
.append(", briefSummary='").append(briefSummary)
|
||||
.append(", logId='").append(logId)
|
||||
.append(", stackTrace='").append(stackTrace)
|
||||
.append(", additionalState=").append(additionalState)
|
||||
.append(", descriptionURL='").append(descriptionURL)
|
||||
|
Reference in New Issue
Block a user