RE: AssetPublisher context menu for web context - adding an item

thumbnail
Olaf Kock, modified 2 Years ago. New Member Posts: 12 Join Date: 10/13/08 Recent Posts

In Liferay 7.4 AssetPublisher has an option to show content completely. For web content articles, there is a context menu for each item that contains, by default, the items "Edit" and "Permissions". We need to add the option "Expire" to that menu to make things easier for the end user. I have gone through source code to find how to do this, but I have not yet found a way. I have a hunch that in the default AssetPublisher/JournalContent code this is handled by a dynamic include, but I did not find the code that actually implements the include for JournalArticles. I have checked code for 7.4.3 ga4, ga23 and the ga76.

We already have an ext module for AssetPublisher, but this code is probably on the Journal side.

Best Regards,

Pasi

thumbnail
Pasi Kössi, modified 2 Years ago. New Member Posts: 12 Join Date: 10/13/08 Recent Posts

I managed to (sort of) sove this, with the help of Olaf Kock in Slack.

Basically adding an entry to this context menu for Web Content is straight-forward. All you have to do is to implement com.liferay.asset.kernel.action.AssetEntryAction for JournalContent, and the entry pops up in your AssetPublishers (for web content).

Here is the relevant part of the component declaration:

@Component(
    property = {
        "javax.portlet.name=" + JournalPortletKeys.JOURNAL,
        "model.class.name=com.liferay.journal.model.JournalArticle"
    },
    service = AssetEntryAction.class
)
public class MyJournalExpireAssetEntryAction
    implements AssetEntryAction<JournalArticle> {

 

You can look at a full example in the source of  "....\modules\apps\journal\journal-web\src\main\java\com\liferay\journal\web\internal\portlet\action\JournalPermissionAssetEntryAction.java" (sorry about the Windows path).

In this case this was not enough, though, as the current implementation only works with GET requests and the actionCommand to expire an article only accepts POST requests (actually it seems to be designed to show a dialog for further actions, but we do not have one available). As we already have an ext-module for AssetPublisher, I decided to implement the required "fix" in there. 

The jsp file in question is asset_actions.jsp directly under resources/META-INF/resources. I added code that sends a POST request instead of a GET when the URL string contains javax.portlet.action parameter.

This was done for Liferay version 7.4.2-ga3.

I do think there may be a better solution for this, but this one seems to work for this particular customer case. If anyone has better suggestions, feel free to comment..