Merged 5.2.N (5.2.1) to HEAD (5.2)

130868 jvonka: REPO-1027: V1 REST API - fix error handling (get site membership request)
   - fix error code (should be 404 not 500) & add -ve api test
   - ACE-2049 / ACE-5442


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132194 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:28:07 +00:00
parent f72f83051f
commit 5e3d908af7
2 changed files with 53 additions and 25 deletions

View File

@@ -43,6 +43,7 @@ import org.alfresco.rest.api.People;
import org.alfresco.rest.api.SiteMembershipRequests; import org.alfresco.rest.api.SiteMembershipRequests;
import org.alfresco.rest.api.Sites; import org.alfresco.rest.api.Sites;
import org.alfresco.rest.api.model.SiteMembershipRequest; import org.alfresco.rest.api.model.SiteMembershipRequest;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException; import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException; import org.alfresco.rest.framework.core.exceptions.RelationshipResourceNotFoundException;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo; import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
@@ -349,6 +350,12 @@ public class SiteMembershipRequestsImpl implements SiteMembershipRequests
} }
}); });
if(siteInfo == null)
{
// site does not exist
throw new RelationshipResourceNotFoundException(inviteeId, siteId);
}
if(siteInfo.getVisibility().equals(SiteVisibility.MODERATED)) if(siteInfo.getVisibility().equals(SiteVisibility.MODERATED))
{ {
// set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url) // set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url)
@@ -397,6 +404,12 @@ public class SiteMembershipRequestsImpl implements SiteMembershipRequests
} }
}); });
if(siteInfo == null)
{
// site does not exist
throw new EntityNotFoundException(siteId);
}
if(siteInfo.getVisibility().equals(SiteVisibility.MODERATED)) if(siteInfo.getVisibility().equals(SiteVisibility.MODERATED))
{ {
// return a site membership request only if this is a moderated site // return a site membership request only if this is a moderated site

View File

@@ -351,6 +351,21 @@ public class TestSiteMembershipRequests extends EnterpriseTestApi
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode()); assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
} }
// ACE-2409 / ACE-5442
// get site membership request for unknown site
try
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person11Id));
siteMembershipRequestsProxy.getSiteMembershipRequest(person11Id, GUID.generate());
fail("");
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
// DELETEs // DELETEs
{ {
{ {