diff --git a/source/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java b/source/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java
index aff26b31ce..0367200421 100644
--- a/source/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java
+++ b/source/java/org/alfresco/rest/api/impl/SiteMembershipRequestsImpl.java
@@ -1,28 +1,28 @@
-/*
- * #%L
- * Alfresco Remote API
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * 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 .
- * #L%
- */
+/*
+ * #%L
+ * Alfresco Remote API
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * 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 .
+ * #L%
+ */
package org.alfresco.rest.api.impl;
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.Sites;
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.RelationshipResourceNotFoundException;
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))
{
// 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))
{
// return a site membership request only if this is a moderated site
diff --git a/source/test-java/org/alfresco/rest/api/tests/TestSiteMembershipRequests.java b/source/test-java/org/alfresco/rest/api/tests/TestSiteMembershipRequests.java
index 55365bc16d..3b53f8f60f 100644
--- a/source/test-java/org/alfresco/rest/api/tests/TestSiteMembershipRequests.java
+++ b/source/test-java/org/alfresco/rest/api/tests/TestSiteMembershipRequests.java
@@ -350,6 +350,21 @@ public class TestSiteMembershipRequests extends EnterpriseTestApi
{
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
{