Add Resource Permission in Liferay 5. X

What will you do if you want to set permission directly from code (instead of GUI). This post will summarize how you can define permission for role from your code itself.
Lets start with one example of document library . Basically we are adding documents in DL using Lifeay API and what if you want to provide permission against role once the document is added .

 Below example will help you on this . Lets start first by adding document in DL. (This example is for Liferay 5.2.7 for later version API might have changed.) After adding document into document library next thing is to set resource permission . Both of things are well explained in below code snippet.


Above code will add permission for Regular Role User to add discussion , delete , update , view etc. (As defined in ActionId).

Next PostNewer Post Previous PostOlder Post Home