Foros de discusión

asset publisher - display assets without view permission

Marc Piparo, modificado hace 12 años.

asset publisher - display assets without view permission

Junior Member Mensajes: 43 Fecha de incorporación: 14/03/11 Mensajes recientes
hi all.
I have a requirement to display assets abstracts to users without view permission to the asset. The goal is to "tease" users without view permission by displaying the abstract only in asset publisher and also search results. I cannot find though in assetentryservice or anywhere else where the search results are filtered by view permission. What is the best approach for this mod?
Thanks!
thumbnail
Shagul Khajamohideen, modificado hace 12 años.

RE: asset publisher - display assets without view permission

Liferay Master Mensajes: 758 Fecha de incorporación: 27/09/07 Mensajes recientes
Marc Piparo:
hi all.
I have a requirement to display assets abstracts to users without view permission to the asset. The goal is to "tease" users without view permission by displaying the abstract only in asset publisher and also search results. I cannot find though in assetentryservice or anywhere else where the search results are filtered by view permission. What is the best approach for this mod?
Thanks!


You may want to look at the below two elements in the liferay-portlet.xml.


<open-search-class>com.liferay.portlet.journal.util.JournalOpenSearchImpl</open-search-class>
<asset-renderer-factory>com.liferay.portlet.journal.asset.JournalArticleAssetRendererFactory</asset-renderer-factory>


As long as a userId is passed along to the OpenSearch Implementation, the search filters the result by permissions. The asset-renderer-factory is responsible to checking permission on the assets in asset publisher.
Marc Piparo, modificado hace 12 años.

RE: asset publisher - display assets without view permission

Junior Member Mensajes: 43 Fecha de incorporación: 14/03/11 Mensajes recientes
Thanks!
That definitely points me in the right direction. Follow up question though..
My plan is to extend the JournalArticleAssetRenderer's hasViewPermission method to include assets with both ActionKey.VIEW and my new action-key (VIEW_ABSTRACT) that I defined in journal.xml as follows:

<model-resource>
<model-name>com.liferay.portlet.journal.model.JournalArticle</model-name>
<portlet-ref>
<portlet-name>15</portlet-name>
</portlet-ref>
<permissions>
<supports>
....
<action-key>UPDATE_DISCUSSION</action-key>
<action-key>VIEW</action-key>
<action-key>VIEW_ABSTRACT</action-key>
</supports>
....

I am able to successfully set the new permission on Journal assets, however how do I reference my new action-key in my hasViewPermission() code. I would like to do as follows, but there is obviously no VIEW_ABSTRACT ActionKeys constant??

public boolean hasViewPermission(PermissionChecker permissionChecker) {
return JournalArticlePermission.contains(
permissionChecker,_article, ActionKeys.VIEW_ABSTRACT) || super(permissionChecker);
}

...unless i'm completely on the wrong track here about going about this... :-)
thanks!
Marc Piparo, modificado hace 12 años.

RE: asset publisher - display assets without view permission

Junior Member Mensajes: 43 Fecha de incorporación: 14/03/11 Mensajes recientes
Hi all. Please help. After much debugging of my first Ext plugin, at a point where at least my new code is finally being called.
Following Shagul's helpful direction I have extended the JournalArticleAssetRenderer hasViewPermission(..) method (along with with JournalArticleAssetRendererFactory getAssetRenderer methods) to implement new logic to include assets that in addition to containing ActionKeys.VIEW, contain a new action-key (VIEW_ABSTRACT) I added to the journal model-resource. I am able to set and persist the VIEW ABSTRACT check box on Web Content, however my logic is not working. I have implemented in my asset renderer as follows:

public boolean hasViewPermission(PermissionChecker permissionChecker) {
return (JournalArticlePermission.contains(permissionChecker,_article, "VIEW_ABSTRACT") ||
super.hasViewPermission(permissionChecker));
}

Please advise what I may be missing.
much appreciated!
Marc Piparo, modificado hace 12 años.

RE: asset publisher - display assets without view permission

Junior Member Mensajes: 43 Fecha de incorporación: 14/03/11 Mensajes recientes
sorry for the self-conversation.. but to document my results for anyone interested, the issue was caused by the fact that the results were already permission filtered by the filterQuery (AssetEntryServiceImpl), prior to being processed by the asset renderer. Overiding the filterQuery method and implementing my view logic in there resolved my issue.