Example usage for com.liferay.portal.kernel.trash TrashHandler getRestoreMessage

List of usage examples for com.liferay.portal.kernel.trash TrashHandler getRestoreMessage

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.trash TrashHandler getRestoreMessage.

Prototype

public String getRestoreMessage(PortletRequest portletRequest, long classPK) throws PortalException;

Source Link

Document

Returns the message describing the location to which the model entity was restored.

Usage

From source file:com.liferay.trash.web.internal.util.TrashUndoUtil.java

License:Open Source License

public static void addRestoreData(ActionRequest actionRequest, List<ObjectValuePair<String, Long>> entries)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if ((entries == null) || entries.isEmpty()) {
        return;/*from  www . j a v  a2 s  . com*/
    }

    List<String> restoreClassNames = new ArrayList<>();
    List<String> restoreEntryLinks = new ArrayList<>();
    List<String> restoreEntryMessages = new ArrayList<>();
    List<String> restoreLinks = new ArrayList<>();
    List<String> restoreMessages = new ArrayList<>();

    for (ObjectValuePair<String, Long> entry : entries) {
        TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(entry.getKey());

        String restoreEntryLink = trashHandler.getRestoreContainedModelLink(actionRequest, entry.getValue());
        String restoreLink = trashHandler.getRestoreContainerModelLink(actionRequest, entry.getValue());
        String restoreMessage = trashHandler.getRestoreMessage(actionRequest, entry.getValue());

        if (Validator.isNull(restoreLink) || Validator.isNull(restoreMessage)) {

            continue;
        }

        restoreClassNames.add(trashHandler.getClassName());
        restoreEntryLinks.add(restoreEntryLink);

        TrashRenderer trashRenderer = trashHandler.getTrashRenderer(entry.getValue());

        String restoreEntryTitle = trashRenderer.getTitle(themeDisplay.getLocale());

        restoreEntryMessages.add(restoreEntryTitle);

        restoreLinks.add(restoreLink);
        restoreMessages.add(restoreMessage);
    }

    Map<String, List<String>> data = new HashMap<>();

    data.put("restoreClassNames", restoreClassNames);
    data.put("restoreEntryLinks", restoreEntryLinks);
    data.put("restoreEntryMessages", restoreEntryMessages);
    data.put("restoreLinks", restoreLinks);
    data.put("restoreMessages", restoreMessages);

    SessionMessages.add(actionRequest,
            PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_DELETE_SUCCESS_DATA, data);
}