Site Membership Request API joins the Alfresco Public API

cancel
Showing results for 
Search instead for 
Did you mean: 

Site Membership Request API joins the Alfresco Public API

gmelahn
Active Member
0 0 4,183
Request to join



Yesterday, I posted about the new Alfresco Favorites API.   As I mentioned, that was the first of a set of API improvements we've introduced.   Another new API is one that makes it possible to request membership in an Alfresco Site.  Let me tell more about it.



The Site Membership Request API



Using Alfresco Share, it's possible to join a public Site or request membership in a moderated Site.     The new Site Membership Request API now makes it possible to do that from a custom app.   



Requesting to Join a Site



Like with all RESTful API's, an HTTP POST request is made to create a new instance, in this case a new instance of a Site Membership Request.   The only thing you need to provide in the POST is a JSON object that contains the id of the site.   For example, suppose there was a moderated site you wanted to join with an id of 'the-secret-site' (nothing gets people more interested in joining than saying it's secret).    To request membership in the site, just POST a JSON object to your site-membership-requests collection, like this... 

  HTTP POST /people/-me-/site-membership-requests

     {

         'id' : 'the-secret-site'

      }


You get back an HTTP status code of 201 (Created) telling that the request worked, and you also get back a JSON object telling you more about the Site Membership Request.   At this point, because this is a moderated site, the request awaits approval from the Site Manager who can approve it using the Share UI (In other words this API is just a new way of creating the request and does not bypass the existing Alfresco request approval workflow). 

 

{                                           

'entry' : {                                

  'id' : 'the-secret-site',

  'createdAt' : '2012-07-20T21:46:09.659+0000',

  'modifiedAt' : '2012-07-20T21:46:09.659+0000',

   'site' : {

    'id' : 'the-secret-site',

    'guid' : '8ac18731-601b-4bb4-be1a-cd5d252cce3f',

    'title' : 'The Company’s Secret Site',

    'visibility' : 'MODERATED',

    'description' : 'The Company’s Secret Site'              

   }

}

}


Suppose that site was public instead of moderated. In that case, the request would be implicitly approved and, as soon as the request completes, you would be a member of that public site.



Getting a list of Site Membership Requests



Suppose you have a number of Site Membership Requests outstanding and you wanted to get that list so you can follow up directly with the Site Manager. Getting a list of pending Site Membership Requests is just a matter of issuing an HTTP GET request on your site-membership-requests collection. Here is an example. 

 

HTTP GET /people/-me-/site-membership-requests


and the result s an HTTP Status Code of 200 (OK) and an Alfresco list that looks like this ... 

 

   'list' : {

     'pagination' : {

       'count' : 2,

       'hasMoreItems' : false,

       'totalItems' : 2,

       'skipCount' : 0,

       'maxItems' : 100

     },

     'entries' : [ {

       'entry' : {

         'site' : {

           'guid' : '8ac18731-601b-4bb4-be1a-cd5d252cce3f',

           'id' : 'the-secret-site',

           'title' : 'The Company’s Secret Site',

           'visibility' : 'MODERATED',

           'description' : 'The Company’s Secret Site'

         },

         'id' : 'the-secret-site',

         'createdAt' : '2012-07-20T21:46:09.659+0000'

       }

     }, {

       'entry' : {

         'site' : {

           'guid' : 'f1833491-24ee-439f-ac4c-e3358e5e4c99',

           'id' : 'Marketing',

           'title' : 'The Marketing Site Site',

           'visibility' : 'MODERATED'

         },

         'id' : 'Marketing',

         'createdAt' : '2013-04-10T18:51:28.000+0000'

       }

     } ]

   }

}


The format of the list object that comes back from this request should look familiar if you've already using the Alfresco API. We've standardized the list format to provide a consistent structure that can be easily processed in JavaScript.



Deleting a Site Membership Request

Suppose you just want to cancel a pending request. That can be done using a HTTP DELETE request, as in this example.

  HTTP DELETE /people/-me-/site-membership-requests/the-secret-site


And the response is an HTTP Status Code of 204 (No Content).



Summary

This was just a brief introduction to this new API.



I hope you're interested in becoming an Alfresco API user. Just register for a free developer key and download the Reference Guide to get started.
About the Author
I'm a software engineer and have been active in that role since the early 80's. I've led the development of a wide variety of products for Team Collaboration, Document Management, WCM, Source Code Control, Distributed Build Systems, File Transfer systems and even Tax Collection Systems. Having experienced the evolution of software development based on machine language to the modern programmable web, I have a particular interest in making systems accessible to through open, standard and simple API’s.