001
014
015 package com.liferay.portal.lar.backgroundtask;
016
017 import com.liferay.portal.kernel.backgroundtask.BackgroundTaskResult;
018 import com.liferay.portal.kernel.backgroundtask.BaseBackgroundTaskExecutor;
019 import com.liferay.portal.kernel.util.MapUtil;
020 import com.liferay.portal.model.BackgroundTask;
021 import com.liferay.portal.service.BackgroundTaskLocalServiceUtil;
022 import com.liferay.portal.service.LayoutLocalServiceUtil;
023
024 import java.io.File;
025 import java.io.Serializable;
026
027 import java.util.Date;
028 import java.util.Map;
029
030
034 public class PortletExportBackgroundTaskExecutor
035 extends BaseBackgroundTaskExecutor {
036
037 public PortletExportBackgroundTaskExecutor() {
038 setBackgroundTaskStatusMessageTranslator(
039 new ExportBackgroundTaskStatusMessageTranslator());
040 setSerial(true);
041 }
042
043 @Override
044 public BackgroundTaskResult execute(BackgroundTask backgroundTask)
045 throws Exception {
046
047 Map<String, Serializable> taskContextMap =
048 backgroundTask.getTaskContextMap();
049
050 long userId = MapUtil.getLong(taskContextMap, "userId");
051 String fileName = MapUtil.getString(taskContextMap, "fileName");
052
053 long plid = MapUtil.getLong(taskContextMap, "plid");
054 long groupId = MapUtil.getLong(taskContextMap, "groupId");
055 String portletId = MapUtil.getString(taskContextMap, "portletId");
056 Map<String, String[]> parameterMap =
057 (Map<String, String[]>)taskContextMap.get("parameterMap");
058 Date startDate = (Date)taskContextMap.get("startDate");
059 Date endDate = (Date)taskContextMap.get("endDate");
060
061 File larFile = LayoutLocalServiceUtil.exportPortletInfoAsFile(
062 plid, groupId, portletId, parameterMap, startDate, endDate);
063
064 BackgroundTaskLocalServiceUtil.addBackgroundTaskAttachment(
065 userId, backgroundTask.getBackgroundTaskId(), fileName, larFile);
066
067 return BackgroundTaskResult.SUCCESS;
068 }
069
070 }