@Override protected void doExportStagedModel(PortletDataContext portletDataContext, BlogsEntry entry) throws Exception { Element entryElement = portletDataContext.getExportDataElement(entry); if (entry.isSmallImage()) { Image smallImage = _imageLocalService.fetchImage(entry.getSmallImageId()); if (smallImage != null) { String smallImagePath = ExportImportPathUtil.getModelPath( entry, smallImage.getImageId() + StringPool.PERIOD + smallImage.getType()); entryElement.addAttribute("small-image-path", smallImagePath); entry.setSmallImageType(smallImage.getType()); portletDataContext.addZipEntry(smallImagePath, smallImage.getTextObj()); } } if (entry.getSmallImageFileEntryId() != 0) { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(entry.getSmallImageFileEntryId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, entry, fileEntry, PortletDataContext.REFERENCE_TYPE_WEAK); } if (entry.getCoverImageFileEntryId() != 0) { FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(entry.getCoverImageFileEntryId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, entry, fileEntry, PortletDataContext.REFERENCE_TYPE_WEAK); } String content = _blogsEntryExportImportContentProcessor.replaceExportContentReferences( portletDataContext, entry, entry.getContent(), portletDataContext.getBooleanParameter("blogs", "referenced-content"), true); entry.setContent(content); portletDataContext.addClassedModel( entryElement, ExportImportPathUtil.getModelPath(entry), entry); }
protected void exportMetaData( PortletDataContext portletDataContext, Element fileEntryElement, FileEntry fileEntry) throws Exception { LiferayFileEntry liferayFileEntry = (LiferayFileEntry) fileEntry; DLFileEntry dlFileEntry = liferayFileEntry.getDLFileEntry(); long fileEntryTypeId = dlFileEntry.getFileEntryTypeId(); DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.fetchFileEntryType(fileEntryTypeId); if ((dlFileEntryType == null) || !dlFileEntryType.isExportable()) { return; } StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, fileEntry, dlFileEntryType, PortletDataContext.REFERENCE_TYPE_STRONG); List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures(); for (DDMStructure ddmStructure : ddmStructures) { FileVersion fileVersion = fileEntry.getFileVersion(); DLFileEntryMetadata dlFileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.fetchFileEntryMetadata( ddmStructure.getStructureId(), fileVersion.getFileVersionId()); if (dlFileEntryMetadata == null) { continue; } Element structureFields = fileEntryElement.addElement("structure-fields"); String path = ExportImportPathUtil.getModelPath( ddmStructure, String.valueOf(dlFileEntryMetadata.getDDMStorageId())); structureFields.addAttribute("path", path); structureFields.addAttribute("structureUuid", ddmStructure.getUuid()); DDMFormValues ddmFormValues = StorageEngineUtil.getDDMFormValues(dlFileEntryMetadata.getDDMStorageId()); portletDataContext.addZipEntry(path, ddmFormValues); } }
protected void exportLayoutIconImage( PortletDataContext portletDataContext, Layout layout, Element layoutElement) throws Exception { Image image = _imageLocalService.getImage(layout.getIconImageId()); if (image != null) { String iconPath = ExportImportPathUtil.getModelPath( portletDataContext.getScopeGroupId(), Image.class.getName(), image.getImageId()); Element iconImagePathElement = layoutElement.addElement("icon-image-path"); iconImagePathElement.addText(iconPath); portletDataContext.addZipEntry(iconPath, image.getTextObj()); } }
protected void exportKBArticleAttachments( PortletDataContext portletDataContext, Element kbArticleElement, KBArticle kbArticle) throws Exception { List<FileEntry> attachmentsFileEntries = kbArticle.getAttachmentsFileEntries(); for (FileEntry fileEntry : attachmentsFileEntries) { String path = ExportImportPathUtil.getModelPath(kbArticle, fileEntry.getTitle()); Element fileEntryElement = portletDataContext.getExportDataElement(fileEntry); fileEntryElement.addAttribute("path", path); fileEntryElement.addAttribute("file-name", fileEntry.getTitle()); portletDataContext.addZipEntry(path, fileEntry.getContentStream()); portletDataContext.addReferenceElement( kbArticle, kbArticleElement, fileEntry, PortletDataContext.REFERENCE_TYPE_WEAK, false); } }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, FileEntry fileEntry) throws Exception { Element fileEntryElement = portletDataContext.getExportDataElement(fileEntry); String fileEntryPath = ExportImportPathUtil.getModelPath(fileEntry); if (!fileEntry.isDefaultRepository()) { Repository repository = RepositoryLocalServiceUtil.getRepository(fileEntry.getRepositoryId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, fileEntry, repository, PortletDataContext.REFERENCE_TYPE_STRONG); portletDataContext.addClassedModel(fileEntryElement, fileEntryPath, fileEntry); long portletRepositoryClassNameId = PortalUtil.getClassNameId(PortletRepository.class.getName()); if (repository.getClassNameId() != portletRepositoryClassNameId) { return; } } if (fileEntry.getFolderId() != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, fileEntry, fileEntry.getFolder(), PortletDataContext.REFERENCE_TYPE_PARENT); } LiferayFileEntry liferayFileEntry = (LiferayFileEntry) fileEntry; liferayFileEntry.setCachedFileVersion(fileEntry.getFileVersion()); if (!portletDataContext.isPerformDirectBinaryImport()) { InputStream is = null; try { is = FileEntryUtil.getContentStream(fileEntry); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to retrieve content for file entry " + fileEntry.getFileEntryId(), e); } } if (is == null) { fileEntryElement.detach(); return; } try { String binPath = ExportImportPathUtil.getModelPath(fileEntry, fileEntry.getVersion()); portletDataContext.addZipEntry(binPath, is); fileEntryElement.addAttribute("bin-path", binPath); } finally { try { is.close(); } catch (IOException ioe) { _log.error(ioe, ioe); } } } if (portletDataContext.getBooleanParameter( DLPortletDataHandler.NAMESPACE, "previews-and-thumbnails")) { DLProcessorRegistryUtil.exportGeneratedFiles(portletDataContext, fileEntry, fileEntryElement); } exportMetaData(portletDataContext, fileEntryElement, fileEntry); portletDataContext.addClassedModel( fileEntryElement, fileEntryPath, liferayFileEntry, DLFileEntry.class); }