001
014
015 package com.liferay.portlet.exportimport.backgroundtask;
016
017 import com.liferay.portal.kernel.util.ArrayUtil;
018 import com.liferay.portal.kernel.util.Constants;
019 import com.liferay.portal.kernel.util.Validator;
020
021 import java.io.Serializable;
022
023 import java.util.Date;
024 import java.util.HashMap;
025 import java.util.Map;
026
027
032 @Deprecated
033 public class BackgroundTaskContextMapFactory {
034
035 public static Map<String, Serializable> buildTaskContextMap(
036 long userId, long groupId, boolean privateLayout, long[] layoutIds,
037 Map<String, String[]> parameterMap, String cmd, Date startDate,
038 Date endDate, String fileName) {
039
040 Map<String, Serializable> taskContextMap = new HashMap<>();
041
042 if (cmd != null) {
043 taskContextMap.put(Constants.CMD, cmd);
044 }
045
046 if (endDate != null) {
047 taskContextMap.put("endDate", endDate);
048 }
049
050 taskContextMap.put("fileName", fileName);
051 taskContextMap.put("groupId", groupId);
052
053 if (ArrayUtil.isNotEmpty(layoutIds)) {
054 taskContextMap.put("layoutIds", layoutIds);
055 }
056
057 if (parameterMap != null) {
058 HashMap<String, String[]> serializableParameterMap = new HashMap<>(
059 parameterMap);
060
061 taskContextMap.put("parameterMap", serializableParameterMap);
062 }
063
064 taskContextMap.put("privateLayout", privateLayout);
065
066 if (startDate != null) {
067 taskContextMap.put("startDate", startDate);
068 }
069
070 taskContextMap.put("userId", userId);
071
072 return taskContextMap;
073 }
074
075 public static Map<String, Serializable> buildTaskContextMap(
076 long userId, long plid, long groupId, String portletId,
077 Map<String, String[]> parameterMap, String cmd, Date startDate,
078 Date endDate, String fileName) {
079
080 Map<String, Serializable> taskContextMap = new HashMap<>();
081
082 if (cmd != null) {
083 taskContextMap.put(Constants.CMD, cmd);
084 }
085
086 if (endDate != null) {
087 taskContextMap.put("endDate", endDate);
088 }
089
090 taskContextMap.put("fileName", fileName);
091 taskContextMap.put("groupId", groupId);
092
093 if (parameterMap != null) {
094 HashMap<String, String[]> serializableParameterMap = new HashMap<>(
095 parameterMap);
096
097 taskContextMap.put("parameterMap", serializableParameterMap);
098 }
099
100 taskContextMap.put("plid", plid);
101
102 if (Validator.isNotNull(portletId)) {
103 taskContextMap.put("portletId", portletId);
104 }
105
106 if (startDate != null) {
107 taskContextMap.put("startDate", startDate);
108 }
109
110 taskContextMap.put("userId", userId);
111
112 return taskContextMap;
113 }
114
115 }