Search in sources :

Example 1 with SiteRole

use of org.alfresco.rest.api.tests.client.data.SiteRole in project alfresco-remote-api by Alfresco.

the class RepoService method getSiteMemberships.

public List<MemberOfSite> getSiteMemberships(String personId) {
    List<SiteInfo> sites = siteService.listSites(personId);
    List<MemberOfSite> memberships = new ArrayList<MemberOfSite>();
    for (SiteInfo siteInfo : sites) {
        String roleStr = siteService.getMembersRole(siteInfo.getShortName(), personId);
        SiteRole role = SiteRole.valueOf(roleStr);
        SiteImpl site = new SiteImpl(siteInfo, role, true);
        memberships.add(new MemberOfSite(site, role));
    }
    return memberships;
}
Also used : SiteInfo(org.alfresco.service.cmr.site.SiteInfo) SiteImpl(org.alfresco.rest.api.tests.client.data.SiteImpl) SiteRole(org.alfresco.rest.api.tests.client.data.SiteRole) ArrayList(java.util.ArrayList) MemberOfSite(org.alfresco.rest.api.tests.client.data.MemberOfSite)

Example 2 with SiteRole

use of org.alfresco.rest.api.tests.client.data.SiteRole in project alfresco-remote-api by Alfresco.

the class TestPersonSites method testSitesWithSameTitles.

// ACE-4823
@Test
public void testSitesWithSameTitles() throws Exception {
    // Creates 3 sites
    initializeSites();
    final String site4_name = "d_" + GUID.generate();
    // Same title as site3
    final String site4_title = site3_title;
    final SiteRole site4_role = SiteRole.SiteCollaborator;
    TestSite site4 = TenantUtil.runAsUserTenant(new TenantRunAsWork<TestSite>() {

        @Override
        public TestSite doWork() throws Exception {
            SiteInformation siteInfo = new SiteInformation(site4_name, site4_title, site4_title, SiteVisibility.PRIVATE);
            TestSite site = network1.createSite(siteInfo);
            site.inviteToSite(person32.getId(), site4_role);
            return site;
        }
    }, person31.getId(), network1.getId());
    assertNotNull(site4);
    // paging
    int totalResults = 4;
    Paging paging = getPaging(null, null, totalResults, totalResults);
    // get memberships
    ListResponse<MemberOfSite> resp = getSiteMembershipsForPerson32(null, null, false);
    // check results
    List<MemberOfSite> expectedList = new LinkedList<>();
    expectedList.add(new MemberOfSite(site2, site2_role));
    expectedList.add(new MemberOfSite(site3, site3_role));
    expectedList.add(new MemberOfSite(site4, site4_role));
    expectedList.add(new MemberOfSite(site1, site1_role));
    try {
        checkList(expectedList, paging.getExpectedPaging(), resp);
    } catch (AssertionError error) {
        // Site3 and Site4 have a same title, and as we are sorting on titles (default sorting),
        // we can't guarantee the order in which the sites will
        // return, hence swap the sites and compare again.
        Collections.swap(expectedList, 1, 2);
        checkList(expectedList, paging.getExpectedPaging(), resp);
    }
}
Also used : SiteRole(org.alfresco.rest.api.tests.client.data.SiteRole) TestSite(org.alfresco.rest.api.tests.RepoService.TestSite) Paging(org.alfresco.rest.api.tests.client.PublicApiClient.Paging) MemberOfSite(org.alfresco.rest.api.tests.client.data.MemberOfSite) PublicApiException(org.alfresco.rest.api.tests.client.PublicApiException) LinkedList(java.util.LinkedList) SiteInformation(org.alfresco.rest.api.tests.RepoService.SiteInformation) Test(org.junit.Test)

Aggregations

MemberOfSite (org.alfresco.rest.api.tests.client.data.MemberOfSite)2 SiteRole (org.alfresco.rest.api.tests.client.data.SiteRole)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 SiteInformation (org.alfresco.rest.api.tests.RepoService.SiteInformation)1 TestSite (org.alfresco.rest.api.tests.RepoService.TestSite)1 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)1 PublicApiException (org.alfresco.rest.api.tests.client.PublicApiException)1 SiteImpl (org.alfresco.rest.api.tests.client.data.SiteImpl)1 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)1 Test (org.junit.Test)1