Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Luca Lupo
Check if user has permission for viewing journalArticle
15 de Outubro de 2012 03:34
Resposta

Luca Lupo

Ranking: Regular Member

Mensagens: 106

Data de entrada: 1 de Outubro de 2012

Mensagens recentes

Hi Guys,

Do you know how can i check (programmatically) whereas a user has permission for viewing journalArticle?

Thanks,

Luca
Bart Simpson
RE: Check if user has permission for viewing journalArticle
10 de Outubro de 2012 23:00
Resposta

Bart Simpson

Ranking: Liferay Master

Mensagens: 524

Data de entrada: 29 de Agosto de 2011

Mensagens recentes

User
1 void com.liferay.portlet.journal.service.permission.JournalArticlePermission.check(PermissionChecker permissionChecker, JournalArticle article, String actionId) throws PortalException


pass the current permission checker from jsp or in velocity and actionId as
1ActionKeys.VIEW


Hope it helps
Luca Lupo
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 00:09
Resposta

Luca Lupo

Ranking: Regular Member

Mensagens: 106

Data de entrada: 1 de Outubro de 2012

Mensagens recentes

Hi Bart....my version of life ray (6.1.1) doesn't have this class

com.liferay.portlet.journal.service.permission

emoticon
Harish Kumar
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 00:17
Resposta

Harish Kumar

Ranking: Expert

Mensagens: 347

Data de entrada: 31 de Julho de 2010

Mensagens recentes

com.liferay.portlet.journal.service.permission.JournalArticlePermission class is there in LR 6.1.10 GA1
Luca Lupo
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 00:52
Resposta

Luca Lupo

Ranking: Regular Member

Mensagens: 106

Data de entrada: 1 de Outubro de 2012

Mensagens recentes

Thanks Harish,

I have this version liferay-portal-6.1.1-ce-ga2 and I cannot find the class emoticon
Oliver Bayer
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 01:20
Resposta

Oliver Bayer

Ranking: Liferay Master

Mensagens: 880

Data de entrada: 18 de Fevereiro de 2009

Mensagens recentes

Hi Luca,

the class is definetely there emoticon. It's located in the portal-impl.jar file. If you need the sources e.g. for debugging you should download and extract the sources zip file available in the downloads section.

HTH Oli
Bart Simpson
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 01:44
Resposta

Bart Simpson

Ranking: Liferay Master

Mensagens: 524

Data de entrada: 29 de Agosto de 2011

Mensagens recentes

https://github.com/liferay/liferay-portal/blob/6.1.1-ga2/portal-impl/src/com/liferay/portlet/journal/service/permission/JournalArticlePermission.java
Luca Lupo
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 05:19
Resposta

Luca Lupo

Ranking: Regular Member

Mensagens: 106

Data de entrada: 1 de Outubro de 2012

Mensagens recentes

Hi Bart...I finally managed to find the class by importing the .jar.

However, I have some troubles understanding "pass the current permission checker from jsp". Where should I take the permissionchecker?

Thanks
Luca Lupo
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 05:29
Resposta

Luca Lupo

Ranking: Regular Member

Mensagens: 106

Data de entrada: 1 de Outubro de 2012

Mensagens recentes

Okay, I found out that I can take that from themeDisplay.

However, the function returns void, so how can i understand if the user has permission or not?

I found out that there is also this function I can use:

PermissionLocalServiceUtil.hasUserPermissions(user.getUserId(), groupId, actionId, resourceIds, bag)

But I don't understand what bag is.

Helppp
Vitaliy Koshelenko
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 09:46
Resposta

Vitaliy Koshelenko

Ranking: Regular Member

Mensagens: 237

Data de entrada: 25 de Março de 2011

Mensagens recentes

Hi, Luca.

Although function JournalArticlePermission#check(PermissionChecker permissionChecker, JournalArticle article, String actionId) returns void, it also throws PrincipalException if user has no permissions to perform specified action on article (for example to view the article if actionId=ActionKeys.VIEW). So, you can just handle this exception:

1try {
2     JournalArticlePermission.check(permissionChecker, article, String ActionKeys.VIEW)
3} catch(PrincipalException e) {
4//user has no permissions - handle exception in this case
5}


Vitaliy
Bart Simpson
RE: Check if user has permission for viewing journalArticle
11 de Outubro de 2012 21:21
Resposta

Bart Simpson

Ranking: Liferay Master

Mensagens: 524

Data de entrada: 29 de Agosto de 2011

Mensagens recentes

Thanks Vitaliy, for this very good insight.
Luca Lupo
RE: Check if user has permission for viewing journalArticle
12 de Outubro de 2012 01:39
Resposta

Luca Lupo

Ranking: Regular Member

Mensagens: 106

Data de entrada: 1 de Outubro de 2012

Mensagens recentes

Thanks Guys...it worked perfectly....I have to say the community is really great here emoticon