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

@@ -1,28 +1,28 @@
/* /*
* #%L * #%L
* Alfresco Remote API * Alfresco Remote API
* %% * %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited * Copyright (C) 2005 - 2016 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.rest.api.impl; package org.alfresco.rest.api.impl;
import java.util.ArrayList; import java.util.ArrayList;
@@ -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

@@ -350,6 +350,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
{ {