Example usage for com.liferay.portal.kernel.backgroundtask.display BackgroundTaskDisplay getDisplayName

List of usage examples for com.liferay.portal.kernel.backgroundtask.display BackgroundTaskDisplay getDisplayName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.backgroundtask.display BackgroundTaskDisplay getDisplayName.

Prototype

public String getDisplayName(HttpServletRequest httpServletRequest);

Source Link

Usage

From source file:com.liferay.exportimport.internal.notifications.ExportImportUserNotificationHandler.java

License:Open Source License

@Override
protected String getBody(UserNotificationEvent userNotificationEvent, ServiceContext serviceContext)
        throws Exception {

    Locale locale = _portal.getLocale(serviceContext.getRequest());

    ResourceBundle resourceBundle = _resourceBundleLoader.loadResourceBundle(locale);

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload());

    ExportImportConfiguration exportImportConfiguration = null;

    try {// w  w  w.ja v a  2 s  .  com
        exportImportConfiguration = _exportImportConfigurationLocalService
                .getExportImportConfiguration(jsonObject.getLong("exportImportConfigurationId"));
    } catch (PortalException pe) {
        if (_log.isDebugEnabled()) {
            _log.debug(pe, pe);
        }

        return LanguageUtil.get(resourceBundle, "the-process-referenced-by-this-notification-does-not-exist");
    }

    String message = "x-"
            + ExportImportConfigurationConstants.getTypeLabel(exportImportConfiguration.getType());

    int status = jsonObject.getInt("status");

    if (status == BackgroundTaskConstants.STATUS_SUCCESSFUL) {
        message += "-process-finished-successfully";
    } else if (status == BackgroundTaskConstants.STATUS_FAILED) {
        message += "-process-failed";
    } else {
        return "Unable to process notification: " + HtmlUtil.escape(jsonObject.toString());
    }

    long backgroundTaskId = jsonObject.getLong("backgroundTaskId");

    BackgroundTaskDisplay backgroundTaskDisplay = _backgroundTaskDisplayFactory
            .getBackgroundTaskDisplay(backgroundTaskId);

    String processName = backgroundTaskDisplay.getDisplayName(serviceContext.getRequest());

    return LanguageUtil.format(resourceBundle, message, processName);
}