use of org.alfresco.rest.api.tests.client.data.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class TestFavourites method testPUBLICAPI156.
@Test
public void testPUBLICAPI156() throws Exception {
// person1's public site
final TestSite publicSite = person1PublicSites.get(0);
// person1's public site
final TestSite publicSite1 = person1PublicSites.get(1);
// person1's folder
final NodeRef folderNodeRef = person1PublicFolders.get(0);
// a file in the folder
final NodeRef nodeRef = person1PublicDocs.get(1);
final List<Favourite> expectedFavourites = new ArrayList<Favourite>();
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person14Id));
// invite to another user's public site
SiteMembershipRequest siteMembershipRequest = new SiteMembershipRequest();
siteMembershipRequest.setId(publicSite.getSiteId());
siteMembershipRequest.setMessage("Please can I join your site?");
siteMembershipRequestsProxy.createSiteMembershipRequest(person14Id, siteMembershipRequest);
// favourite other users site, folder and file
Favourite folderFavourite = makeFolderFavourite(folderNodeRef.getId());
favouritesProxy.createFavourite(person14Id, folderFavourite);
expectedFavourites.add(folderFavourite);
Favourite fileFavourite = makeFileFavourite(nodeRef.getId());
favouritesProxy.createFavourite(person14Id, fileFavourite);
expectedFavourites.add(fileFavourite);
final Favourite siteFavourite = makeSiteFavourite(publicSite);
favouritesProxy.createFavourite(person14Id, siteFavourite);
expectedFavourites.add(siteFavourite);
final Favourite siteFavourite1 = makeSiteFavourite(publicSite1);
favouritesProxy.createFavourite(person14Id, siteFavourite1);
expectedFavourites.add(siteFavourite1);
sort(expectedFavourites, FavouritesService.DEFAULT_SORT_PROPS);
// remove the folder and file
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
repoService.deleteNode(nodeRef);
repoService.deleteNode(folderNodeRef);
return null;
}
}, person11Id, network1.getId());
expectedFavourites.remove(folderFavourite);
expectedFavourites.remove(fileFavourite);
sort(expectedFavourites, FavouritesService.DEFAULT_SORT_PROPS);
// GETs should not return the favourites nor error
{
try {
favouritesProxy.getFavourite(person14Id, folderFavourite.getTargetGuid());
} catch (PublicApiException e) {
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
try {
favouritesProxy.getFavourite(person14Id, fileFavourite.getTargetGuid());
} catch (PublicApiException e) {
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
int skipCount = 0;
int maxItems = Integer.MAX_VALUE;
Paging paging = getPaging(skipCount, maxItems, expectedFavourites.size(), expectedFavourites.size());
ListResponse<Favourite> resp = favouritesProxy.getFavourites(person14Id, createParams(paging, null));
checkList(sublist(expectedFavourites, skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
}
}
}
use of org.alfresco.rest.api.tests.client.data.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class TestFavourites method testPUBLICAPI141.
@Test
public void testPUBLICAPI141() throws Exception {
// person1's public site
final TestSite publicSite = person1PublicSites.get(0);
// person1's public site
final TestSite publicSite1 = person1PublicSites.get(1);
// person1's private site
final TestSite privateSite = person1PrivateSites.get(0);
// person1's folder
final NodeRef folderNodeRef = person1PublicFolders.get(0);
// a file in the folder
final NodeRef nodeRef = person1PublicDocs.get(1);
final List<Favourite> expectedFavourites = new ArrayList<Favourite>();
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person12Id));
// invite to another user's public site
SiteMembershipRequest siteMembershipRequest = new SiteMembershipRequest();
siteMembershipRequest.setId(publicSite.getSiteId());
siteMembershipRequest.setMessage("Please can I join your site?");
siteMembershipRequestsProxy.createSiteMembershipRequest(person12Id, siteMembershipRequest);
// favourite other users site, folder and file
Favourite folderFavourite = makeFolderFavourite(folderNodeRef.getId());
favouritesProxy.createFavourite(person12Id, folderFavourite);
Favourite fileFavourite = makeFileFavourite(nodeRef.getId());
favouritesProxy.createFavourite(person12Id, fileFavourite);
final Favourite siteFavourite = makeSiteFavourite(publicSite);
favouritesProxy.createFavourite(person12Id, siteFavourite);
expectedFavourites.add(siteFavourite);
final Favourite siteFavourite1 = makeSiteFavourite(publicSite1);
favouritesProxy.createFavourite(person12Id, siteFavourite1);
expectedFavourites.add(siteFavourite1);
sort(expectedFavourites, FavouritesService.DEFAULT_SORT_PROPS);
// move the folder and file to person1's private site
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
NodeRef documentLibraryNodeRef = privateSite.getContainerNodeRef("documentLibrary");
repoService.moveNode(folderNodeRef, documentLibraryNodeRef);
return null;
}
}, person11Id, network1.getId());
try {
favouritesProxy.getFavourite(person12Id, folderFavourite.getTargetGuid());
} catch (PublicApiException e) {
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
try {
favouritesProxy.getFavourite(person12Id, fileFavourite.getTargetGuid());
} catch (PublicApiException e) {
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
{
int skipCount = 0;
int maxItems = Integer.MAX_VALUE;
Paging paging = getPaging(skipCount, maxItems, expectedFavourites.size(), expectedFavourites.size());
ListResponse<Favourite> resp = favouritesProxy.getFavourites(person12Id, createParams(paging, null));
checkList(sublist(expectedFavourites, skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
}
// make the public sites private
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
publicSite.setSiteVisibility(SiteVisibility.PRIVATE);
publicSite1.setSiteVisibility(SiteVisibility.PRIVATE);
return null;
}
}, person11Id, network1.getId());
expectedFavourites.remove(siteFavourite1);
// Given that person2Id is still a member of 'publicSite', they should still have access and therefore
// it should show up in their favourites. But person2Id is not a member of 'publicSite1', they should
// not have access and therefore it should not show up in their favourites.
{
Favourite actual = favouritesProxy.getFavourite(person12Id, siteFavourite.getTargetGuid());
siteFavourite.expected(actual);
try {
favouritesProxy.getFavourite(person12Id, siteFavourite1.getTargetGuid());
} catch (PublicApiException e) {
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
int skipCount = 0;
int maxItems = Integer.MAX_VALUE;
Paging paging = getPaging(skipCount, maxItems, expectedFavourites.size(), expectedFavourites.size());
ListResponse<Favourite> resp = favouritesProxy.getFavourites(person12Id, createParams(paging, null));
checkList(sublist(expectedFavourites, skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
}
}
}
use of org.alfresco.rest.api.tests.client.data.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class TestSiteMembershipRequests method getSiteMembershipRequest.
private SiteMembershipRequest getSiteMembershipRequest(String networkId, String runAsUserId, String personId) throws PublicApiException, ParseException {
publicApiClient.setRequestContext(new RequestContext(networkId, runAsUserId));
int skipCount = 0;
int maxItems = Integer.MAX_VALUE;
Paging paging = getPaging(skipCount, maxItems);
ListResponse<SiteMembershipRequest> resp = siteMembershipRequestsProxy.getSiteMembershipRequests(personId, createParams(paging, null));
List<SiteMembershipRequest> list = resp.getList();
int size = list.size();
assertTrue(size > 0);
int idx = random.nextInt(size);
SiteMembershipRequest request = list.get(idx);
return request;
}
use of org.alfresco.rest.api.tests.client.data.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class TestSiteMembershipRequests method createSiteMembershipRequest.
private SiteMembershipRequest createSiteMembershipRequest(String siteId, String personId) throws ParseException, PublicApiException {
SiteMembershipRequest siteMembershipRequest = new SiteMembershipRequest();
siteMembershipRequest.setId(siteId);
siteMembershipRequest.setMessage("Please can I join your site?");
return siteMembershipRequestsProxy.createSiteMembershipRequest(personId, siteMembershipRequest);
}
use of org.alfresco.rest.api.tests.client.data.SiteMembershipRequest in project alfresco-remote-api by Alfresco.
the class TestSiteMembershipRequests method testALF19332.
@Test
public void testALF19332() throws Exception {
String networkId = network1.getId();
final TestNetwork systemNetwork = getRepoService().getSystemNetwork();
long time = System.currentTimeMillis();
// note: username for site creator is of the form user@network
PersonInfo personInfo = new PersonInfo("test", "test", "test" + time, "password", null, "test", "test", "test", "test", "test", "test");
TestPerson person = network1.createUser(personInfo);
personInfo = new PersonInfo("test", "test", "test1" + time, "password", null, "test", "test", "test", "test", "test", "test");
TestPerson person1 = network1.createUser(personInfo);
TestSite site = TenantUtil.runAsUserTenant(new TenantRunAsWork<TestSite>() {
@Override
public TestSite doWork() throws Exception {
TestSite site = systemNetwork.createSite(SiteVisibility.PUBLIC);
return site;
}
}, person.getId(), networkId);
publicApiClient.setRequestContext(new RequestContext("-default-", person1.getId()));
SiteMembershipRequest siteMembershipRequest = new SiteMembershipRequest();
siteMembershipRequest.setId(site.getSiteId());
siteMembershipRequest.setMessage("Please can I join your site?");
SiteMembershipRequest ret = siteMembershipRequestsProxy.createSiteMembershipRequest(person1.getId(), siteMembershipRequest);
}
Aggregations