Example usage for com.liferay.portal.kernel.backgroundtask BackgroundTaskManagerUtil addBackgroundTaskAttachment

List of usage examples for com.liferay.portal.kernel.backgroundtask BackgroundTaskManagerUtil addBackgroundTaskAttachment

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.backgroundtask BackgroundTaskManagerUtil addBackgroundTaskAttachment.

Prototype

public static void addBackgroundTaskAttachment(long userId, long backgroundTaskId, String fileName, File file)
            throws PortalException 

Source Link

Usage

From source file:com.liferay.exportimport.internal.background.task.LayoutExportBackgroundTaskExecutor.java

License:Open Source License

@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws PortalException {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    long userId = MapUtil.getLong(settingsMap, "userId");

    StringBundler sb = new StringBundler(4);

    sb.append(StringUtil.replace(exportImportConfiguration.getName(), CharPool.SPACE, CharPool.UNDERLINE));
    sb.append(StringPool.DASH);/*  ww  w.  ja  v a 2 s. com*/
    sb.append(Time.getTimestamp());
    sb.append(".lar");

    File larFile = ExportImportLocalServiceUtil.exportLayoutsAsFile(exportImportConfiguration);

    BackgroundTaskManagerUtil.addBackgroundTaskAttachment(userId, backgroundTask.getBackgroundTaskId(),
            sb.toString(), larFile);

    return BackgroundTaskResult.SUCCESS;
}

From source file:com.liferay.exportimport.internal.background.task.PortletExportBackgroundTaskExecutor.java

License:Open Source License

@Override
public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception {

    ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask);

    Map<String, Serializable> settingsMap = exportImportConfiguration.getSettingsMap();

    long userId = MapUtil.getLong(settingsMap, "userId");
    String fileName = MapUtil.getString(settingsMap, "fileName");

    File larFile = ExportImportLocalServiceUtil.exportPortletInfoAsFile(exportImportConfiguration);

    BackgroundTaskManagerUtil.addBackgroundTaskAttachment(userId, backgroundTask.getBackgroundTaskId(),
            fileName, larFile);//from w w  w.j a va 2  s.c om

    return BackgroundTaskResult.SUCCESS;
}