@Override protected void doImportStagedModel(PortletDataContext portletDataContext, AssetTag assetTag) throws Exception { long userId = portletDataContext.getUserId(assetTag.getUserUuid()); ServiceContext serviceContext = createServiceContext(portletDataContext, assetTag); AssetTag existingAssetTag = fetchStagedModelByUuidAndGroupId(assetTag.getUuid(), portletDataContext.getScopeGroupId()); AssetTag importedAssetTag = null; if (existingAssetTag == null) { serviceContext.setUuid(assetTag.getUuid()); importedAssetTag = AssetTagLocalServiceUtil.addTag( userId, portletDataContext.getScopeGroupId(), assetTag.getName(), serviceContext); } else { importedAssetTag = AssetTagLocalServiceUtil.updateTag( userId, existingAssetTag.getTagId(), assetTag.getName(), serviceContext); } portletDataContext.importClassedModel(assetTag, importedAssetTag); }
protected void exportAssetTag( PortletDataContext portletDataContext, AssetTag assetTag, Element assetTagsElement) throws SystemException, PortalException { String path = getAssetTagPath(portletDataContext, assetTag.getTagId()); if (!portletDataContext.isPathNotProcessed(path)) { return; } Element assetTagElement = assetTagsElement.addElement("tag"); assetTagElement.addAttribute("path", path); assetTag.setUserUuid(assetTag.getUserUuid()); portletDataContext.addZipEntry(path, assetTag); List<AssetTagProperty> assetTagProperties = AssetTagPropertyLocalServiceUtil.getTagProperties(assetTag.getTagId()); for (AssetTagProperty assetTagProperty : assetTagProperties) { Element propertyElement = assetTagElement.addElement("property"); propertyElement.addAttribute("key", assetTagProperty.getKey()); propertyElement.addAttribute("value", assetTagProperty.getValue()); } portletDataContext.addPermissions(AssetTag.class, assetTag.getTagId()); }