List of usage examples for com.liferay.portal.kernel.backgroundtask BackgroundTask getAttachmentsFileEntries
public List<FileEntry> getAttachmentsFileEntries() throws PortalException;
From source file:com.liferay.exportimport.internal.background.task.LayoutImportBackgroundTaskExecutor.java
License:Open Source License
@Override public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception { ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask); List<FileEntry> attachmentsFileEntries = backgroundTask.getAttachmentsFileEntries(); File file = null;//from w w w . java2 s . com for (FileEntry attachmentsFileEntry : attachmentsFileEntries) { try { file = FileUtil.createTempFile("lar"); FileUtil.write(file, attachmentsFileEntry.getContentStream()); TransactionInvokerUtil.invoke(transactionConfig, new LayoutImportCallable(exportImportConfiguration, file)); } catch (IOException ioe) { StringBundler sb = new StringBundler(3); sb.append("Unable to process LAR file while executing "); sb.append("LayoutImportBackgroundTaskExecutor: "); if (!Objects.isNull(attachmentsFileEntry) && Validator.isNotNull(attachmentsFileEntry.getFileName())) { sb.append(attachmentsFileEntry.getFileName()); } else { sb.append("unknown file name"); } throw new SystemException(sb.toString(), ioe); } catch (Throwable t) { if (_log.isDebugEnabled()) { _log.debug(t, t); } else if (_log.isWarnEnabled()) { _log.warn("Unable to import layouts: " + t.getMessage()); } throw new SystemException(t); } finally { FileUtil.delete(file); } } return BackgroundTaskResult.SUCCESS; }
From source file:com.liferay.exportimport.internal.background.task.PortletImportBackgroundTaskExecutor.java
License:Open Source License
@Override public BackgroundTaskResult execute(BackgroundTask backgroundTask) throws Exception { ExportImportConfiguration exportImportConfiguration = getExportImportConfiguration(backgroundTask); List<FileEntry> attachmentsFileEntries = backgroundTask.getAttachmentsFileEntries(); File file = null;/* ww w. java2 s.c o m*/ for (FileEntry attachmentsFileEntry : attachmentsFileEntries) { try { file = FileUtil.createTempFile("lar"); FileUtil.write(file, attachmentsFileEntry.getContentStream()); TransactionInvokerUtil.invoke(transactionConfig, new PortletImportCallable(exportImportConfiguration, file)); } catch (Throwable t) { if (_log.isDebugEnabled()) { _log.debug(t, t); } else if (_log.isWarnEnabled()) { _log.warn("Unable to import portlet: " + t.getMessage()); } throw new SystemException(t); } finally { FileUtil.delete(file); } } return BackgroundTaskResult.SUCCESS; }