protected void importAssetVocabulary( PortletDataContext portletDataContext, Map<Long, Long> assetVocabularyPKs, Element assetVocabularyElement, AssetVocabulary assetVocabulary) throws Exception { long userId = portletDataContext.getUserId(assetVocabulary.getUserUuid()); long groupId = portletDataContext.getScopeGroupId(); ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setCreateDate(assetVocabulary.getCreateDate()); serviceContext.setModifiedDate(assetVocabulary.getModifiedDate()); serviceContext.setScopeGroupId(portletDataContext.getScopeGroupId()); AssetVocabulary importedAssetVocabulary = null; AssetVocabulary existingAssetVocabulary = AssetVocabularyUtil.fetchByG_N(groupId, assetVocabulary.getName()); if (existingAssetVocabulary == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); existingAssetVocabulary = AssetVocabularyUtil.fetchByG_N(companyGroup.getGroupId(), assetVocabulary.getName()); } if (existingAssetVocabulary == null) { serviceContext.setUuid(assetVocabulary.getUuid()); importedAssetVocabulary = AssetVocabularyLocalServiceUtil.addVocabulary( userId, assetVocabulary.getTitle(), getAssetVocabularyTitleMap(assetVocabulary), assetVocabulary.getDescriptionMap(), assetVocabulary.getSettings(), serviceContext); } else { importedAssetVocabulary = AssetVocabularyLocalServiceUtil.updateVocabulary( existingAssetVocabulary.getVocabularyId(), assetVocabulary.getTitle(), getAssetVocabularyTitleMap(assetVocabulary), assetVocabulary.getDescriptionMap(), assetVocabulary.getSettings(), serviceContext); } assetVocabularyPKs.put( assetVocabulary.getVocabularyId(), importedAssetVocabulary.getVocabularyId()); portletDataContext.importPermissions( AssetVocabulary.class, assetVocabulary.getVocabularyId(), importedAssetVocabulary.getVocabularyId()); }
protected void exportAssetVocabulary( PortletDataContext portletDataContext, Element assetVocabulariesElement, AssetVocabulary assetVocabulary) throws Exception { String path = getAssetVocabulariesPath(portletDataContext, assetVocabulary.getVocabularyId()); if (!portletDataContext.isPathNotProcessed(path)) { return; } Element assetVocabularyElement = assetVocabulariesElement.addElement("vocabulary"); assetVocabularyElement.addAttribute("path", path); assetVocabulary.setUserUuid(assetVocabulary.getUserUuid()); portletDataContext.addZipEntry(path, assetVocabulary); portletDataContext.addPermissions(AssetVocabulary.class, assetVocabulary.getVocabularyId()); }