Nicolas Raoul
Nicolas Raoul

Reputation: 60203

Get Alfresco sites I am a member of

Is there a way to get the list of Alfresco Share sites I am a member of? (from a remote application)

By "member" I mean: listed at https://example.com/share/page/site/thesite/site-members

Ideally a CMIS call would be the best, but I guess it is impossible, so another REST API is OK too.
It needs to be fast even when there are thousands of sites, so checking for each site one-by-one would not work.
An official API that will not disappear soon is preferred.
It should work on Alfresco 4.2 and later.

Upvotes: 1

Views: 360

Answers (2)

Nicolas Raoul
Nicolas Raoul

Reputation: 60203

Reverse-engineering the Alfresco Share dashboard led me to discover this JSON REST call:

https://example.com/share/proxy/alfresco/api/people/nicolas/sites?roles=user&size=100

You get something like this:

[
{
    "url": "\/alfresco\/s\/api\/sites\/superproject",
    "sitePreset": "site-dashboard",
    "shortName": "superproject",
    "title": "Super Project",
    "description": "A fabulous project",
    "node": "\/alfresco\/s\/api\/node\/workspace\/SpacesStore\/9dfb2426-bc2e-471e-8452-d4f6ea4b1cfa",
    "tagScope": "\/alfresco\/s\/api\/tagscopes\/workspace\/SpacesStore\/9dfb2426-bc2e-471e-8452-d4f6ea4b1cfa",
    "siteRole": "SiteCollaborator",
    "isPublic": true,
    "visibility": "PUBLIC"
}
        ,
{
    "url": "\/alfresco\/s\/api\/sites\/another",
    "sitePreset": "site-dashboard",
    "shortName": "another",
    "title": "Another Project",
    "description": "A less wonderful project",
    "node": "\/alfresco\/s\/api\/node\/workspace\/SpacesStore\/3859750c-8b3a-4736-b3e5-1ca1c2ff1cac",
    "tagScope": "\/alfresco\/s\/api\/tagscopes\/workspace\/SpacesStore\/3859750c-8b3a-4736-b3e5-1ca1c2ff1cac",
    "siteRole": "SiteManager",
    "isPublic": true,
    "visibility": "PUBLIC"
}
]

So it works for my Alfresco 4.2 test server, but the problem is I am not really sure how "official" it is. If not official it might disappear in the next Alfresco release.

I have also found http://sharextras.org/jsdoc/share/enterprise-4.0.0/symbols/Alfresco.SiteFinder.html#memberOfSites which seems to be exactly what I need, but it is part of the Alfresco Share JavaScript API whose documentation seems to end at 4.0 so I am not sure it still exists in Alfresco 5.

Upvotes: 1

Yagami Light
Yagami Light

Reputation: 1796

You can to use this to get the membership details for a user.

GET /alfresco/service/api/sites/{shortname}/memberships/{username}

it worked for me, you can even test it with Postman but do not forget the authentification.

you can find more in https://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference

Upvotes: 0

Related Questions