List of usage examples for com.liferay.portal.kernel.backgroundtask BackgroundTaskManagerUtil addBackgroundTask
public static BackgroundTask addBackgroundTask(long userId, long groupId, String name, String taskExecutorClassName, Map<String, Serializable> taskContextMap, ServiceContext serviceContext) throws PortalException
From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java
License:Open Source License
@Override public long exportContactsAsFileInBackground(long userId, ExportImportConfiguration exportImportConfiguration) throws PortalException { // TODO: The export may have different file types / extensions: // - .csv//from ww w.ja v a 2 s .co m // - .xml // - .txt // - .json // if // (!DLValidatorUtil.isValidName(exportImportConfiguration.getName())) { // throw new LARFileNameException(exportImportConfiguration.getName()); // } Map<String, Serializable> taskContextMap = new HashMap<>(); taskContextMap.put("exportImportConfigurationId", exportImportConfiguration.getExportImportConfigurationId()); BackgroundTask backgroundTask = BackgroundTaskManagerUtil.addBackgroundTask(userId, exportImportConfiguration.getGroupId(), exportImportConfiguration.getName(), ContactExportBackgroundTaskExecutor.class.getName(), taskContextMap, new ServiceContext()); return backgroundTask.getBackgroundTaskId(); }
From source file:ch.inofix.contact.service.impl.ContactLocalServiceImpl.java
License:Open Source License
@Override public long importContactsInBackground(long userId, ExportImportConfiguration exportImportConfiguration, File file) throws PortalException { Map<String, Serializable> taskContextMap = new HashMap<>(); taskContextMap.put("exportImportConfigurationId", exportImportConfiguration.getExportImportConfigurationId()); BackgroundTask backgroundTask = BackgroundTaskManagerUtil.addBackgroundTask(userId, exportImportConfiguration.getGroupId(), exportImportConfiguration.getName(), ContactImportBackgroundTaskExecutor.class.getName(), taskContextMap, new ServiceContext()); backgroundTask.addAttachment(userId, file.getName(), file); return backgroundTask.getBackgroundTaskId(); }