protected void exportAssetLinks(PortletDataContext portletDataContext) throws Exception { Document document = SAXReaderUtil.createDocument(); Element rootElement = document.addElement("links"); Element exportDataRootElement = portletDataContext.getExportDataRootElement(); try { portletDataContext.setExportDataRootElement(rootElement); ActionableDynamicQuery linkActionableDynamicQuery = _assetLinkLocalService.getExportActionbleDynamicQuery(portletDataContext); linkActionableDynamicQuery.performActions(); for (long linkId : portletDataContext.getAssetLinkIds()) { AssetLink assetLink = _assetLinkLocalService.getAssetLink(linkId); StagedAssetLink stagedAssetLink = ModelAdapterUtil.adapt(assetLink, AssetLink.class, StagedAssetLink.class); portletDataContext.addClassedModel( portletDataContext.getExportDataElement(stagedAssetLink), ExportImportPathUtil.getModelPath(stagedAssetLink), stagedAssetLink); } } finally { portletDataContext.setExportDataRootElement(exportDataRootElement); } portletDataContext.addZipEntry( ExportImportPathUtil.getRootPath(portletDataContext) + "/links.xml", document.formattedString()); }
@Override protected void doExportStagedModel( PortletDataContext portletDataContext, MDRRuleGroupInstance ruleGroupInstance) throws Exception { MDRRuleGroup ruleGroup = _mdrRuleGroupLocalService.getRuleGroup(ruleGroupInstance.getRuleGroupId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, ruleGroupInstance, ruleGroup, PortletDataContext.REFERENCE_TYPE_PARENT); Element ruleGroupInstanceElement = portletDataContext.getExportDataElement(ruleGroupInstance); String className = ruleGroupInstance.getClassName(); if (className.equals(Layout.class.getName())) { Layout layout = _layoutLocalService.getLayout(ruleGroupInstance.getClassPK()); ruleGroupInstanceElement.addAttribute("layout-uuid", layout.getUuid()); } portletDataContext.addClassedModel( ruleGroupInstanceElement, ExportImportPathUtil.getModelPath(ruleGroupInstance), ruleGroupInstance); }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, WikiPage page) throws Exception { Element pageElement = portletDataContext.getExportDataElement(page); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, page, page.getNode(), PortletDataContext.REFERENCE_TYPE_PARENT); String content = _wikiPageExportImportContentProcessor.replaceExportContentReferences( portletDataContext, page, page.getContent(), portletDataContext.getBooleanParameter("wiki", "referenced-content"), true); page.setContent(content); if (page.isHead()) { for (FileEntry fileEntry : page.getAttachmentsFileEntries()) { StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, page, fileEntry, PortletDataContext.REFERENCE_TYPE_WEAK); } } WikiPageResource pageResource = _wikiPageResourceLocalService.getPageResource(page.getResourcePrimKey()); pageElement.addAttribute("page-resource-uuid", pageResource.getUuid()); portletDataContext.addClassedModel(pageElement, ExportImportPathUtil.getModelPath(page), page); }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, Gadget gadget) throws Exception { Element gadgetElement = portletDataContext.getExportDataElement(gadget); portletDataContext.addClassedModel( gadgetElement, ExportImportPathUtil.getModelPath(gadget), gadget); }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, KBTemplate kbTemplate) throws Exception { Element kbTemplateElement = portletDataContext.getExportDataElement(kbTemplate); portletDataContext.addClassedModel( kbTemplateElement, ExportImportPathUtil.getModelPath(kbTemplate), kbTemplate); }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, UserGroup userGroup) throws Exception { Element userGroupElement = portletDataContext.getExportDataElement(userGroup); portletDataContext.addClassedModel( userGroupElement, ExportImportPathUtil.getModelPath(userGroup), userGroup); }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, Calendar calendar) throws Exception { StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, calendar, calendar.getCalendarResource(), PortletDataContext.REFERENCE_TYPE_STRONG); Element calendarElement = portletDataContext.getExportDataElement(calendar); portletDataContext.addClassedModel( calendarElement, ExportImportPathUtil.getModelPath(calendar), calendar); }
@Override protected void doExportStagedModel( PortletDataContext portletDataContext, LayoutSetPrototype layoutSetPrototype) throws Exception { Element layoutSetPrototypeElement = portletDataContext.getExportDataElement(layoutSetPrototype); portletDataContext.addClassedModel( layoutSetPrototypeElement, ExportImportPathUtil.getModelPath(layoutSetPrototype), layoutSetPrototype); exportLayouts(layoutSetPrototype, portletDataContext); exportLayoutPrototypes(portletDataContext, layoutSetPrototype, layoutSetPrototypeElement); }
protected void importLayouts( PortletDataContext portletDataContext, LayoutSetPrototype layoutSetPrototype, LayoutSetPrototype importedLayoutSetPrototype, ServiceContext serviceContext) throws PortalException { InputStream inputStream = null; try { String layoutSetPrototypeLARPath = ExportImportPathUtil.getModelPath( layoutSetPrototype, getLayoutSetPrototypeLARFileName(layoutSetPrototype)); inputStream = portletDataContext.getZipEntryAsInputStream(layoutSetPrototypeLARPath); SitesUtil.importLayoutSetPrototype(importedLayoutSetPrototype, inputStream, serviceContext); } finally { StreamUtil.cleanUp(inputStream); } }
protected void exportLayouts( LayoutSetPrototype layoutSetPrototype, PortletDataContext portletDataContext) throws Exception { File file = null; InputStream inputStream = null; try { file = SitesUtil.exportLayoutSetPrototype(layoutSetPrototype, new ServiceContext()); inputStream = new FileInputStream(file); String layoutSetPrototypeLARPath = ExportImportPathUtil.getModelPath( layoutSetPrototype, getLayoutSetPrototypeLARFileName(layoutSetPrototype)); portletDataContext.addZipEntry(layoutSetPrototypeLARPath, inputStream); List<Layout> layoutSetPrototypeLayouts = _layoutLocalService.getLayouts(layoutSetPrototype.getGroupId(), true); Element layoutSetPrototypeElement = portletDataContext.getExportDataElement(layoutSetPrototype); for (Layout layoutSetPrototypeLayout : layoutSetPrototypeLayouts) { portletDataContext.addReferenceElement( layoutSetPrototype, layoutSetPrototypeElement, layoutSetPrototypeLayout, PortletDataContext.REFERENCE_TYPE_EMBEDDED, false); } } finally { StreamUtil.cleanUp(inputStream); if (file != null) { file.delete(); } } }
@Override protected void doExportStagedModel(PortletDataContext portletDataContext, MDRAction action) throws Exception { MDRRuleGroupInstance ruleGroupInstance = _mdrRuleGroupInstanceLocalService.getRuleGroupInstance(action.getRuleGroupInstanceId()); StagedModelDataHandlerUtil.exportReferenceStagedModel( portletDataContext, action, ruleGroupInstance, PortletDataContext.REFERENCE_TYPE_PARENT); Element actionElement = portletDataContext.getExportDataElement(action); String type = action.getType(); if (type.equals(SiteRedirectActionHandler.class.getName())) { UnicodeProperties typeSettingsProperties = action.getTypeSettingsProperties(); long plid = GetterUtil.getLong(typeSettingsProperties.getProperty("plid")); try { Layout layout = _layoutLocalService.getLayout(plid); actionElement.addAttribute("layout-uuid", layout.getUuid()); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn( "Unable to set the layout uuid of layout " + plid + ". Site redirect may not match after import.", e); } } } portletDataContext.addClassedModel( actionElement, ExportImportPathUtil.getModelPath(action), action); }