@Override protected void doImportStagedModel(PortletDataContext portletDataContext, Website website) throws Exception { long userId = portletDataContext.getUserId(website.getUserUuid()); ServiceContext serviceContext = portletDataContext.createServiceContext(website); Website existingWebsite = _websiteLocalService.fetchWebsiteByUuidAndCompanyId( website.getUuid(), portletDataContext.getCompanyGroupId()); Website importedWebsite = null; if (existingWebsite == null) { serviceContext.setUuid(website.getUuid()); importedWebsite = _websiteLocalService.addWebsite( userId, website.getClassName(), website.getClassPK(), website.getUrl(), website.getTypeId(), website.isPrimary(), serviceContext); } else { importedWebsite = _websiteLocalService.updateWebsite( existingWebsite.getWebsiteId(), website.getUrl(), website.getTypeId(), website.isPrimary()); } portletDataContext.importClassedModel(website, importedWebsite); }
protected void readAssetLinks(PortletDataContext portletDataContext) throws Exception { String xml = portletDataContext.getZipEntryAsString( ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/links.xml"); if (xml == null) { return; } Document document = SAXReaderUtil.read(xml); Element rootElement = document.getRootElement(); List<Element> assetLinkGroupElements = rootElement.elements("asset-link-group"); for (Element assetLinkGroupElement : assetLinkGroupElements) { String sourceUuid = assetLinkGroupElement.attributeValue("source-uuid"); AssetEntry sourceAssetEntry = AssetEntryLocalServiceUtil.fetchEntry(portletDataContext.getScopeGroupId(), sourceUuid); if (sourceAssetEntry == null) { sourceAssetEntry = AssetEntryLocalServiceUtil.fetchEntry( portletDataContext.getCompanyGroupId(), sourceUuid); } if (sourceAssetEntry == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to find asset entry with uuid " + sourceUuid); } continue; } List<Element> assetLinksElements = assetLinkGroupElement.elements("asset-link"); for (Element assetLinkElement : assetLinksElements) { String path = assetLinkElement.attributeValue("path"); if (!portletDataContext.isPathNotProcessed(path)) { continue; } String targetUuid = assetLinkElement.attributeValue("target-uuid"); AssetEntry targetAssetEntry = AssetEntryLocalServiceUtil.fetchEntry(portletDataContext.getScopeGroupId(), targetUuid); if (targetAssetEntry == null) { targetAssetEntry = AssetEntryLocalServiceUtil.fetchEntry( portletDataContext.getCompanyGroupId(), targetUuid); } if (targetAssetEntry == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to find asset entry with uuid " + targetUuid); } continue; } AssetLink assetLink = (AssetLink) portletDataContext.getZipEntryAsObject(path); long userId = portletDataContext.getUserId(assetLink.getUserUuid()); AssetLinkLocalServiceUtil.updateLink( userId, sourceAssetEntry.getEntryId(), targetAssetEntry.getEntryId(), assetLink.getType(), assetLink.getWeight()); } } }