protected void validateCompanyDependenciesImport( Map<String, List<StagedModel>> dependentStagedModelsMap, Group group) throws Exception { List<StagedModel> ddmStructureDependentStagedModels = dependentStagedModelsMap.get(DDMStructure.class.getSimpleName()); Assert.assertEquals(1, ddmStructureDependentStagedModels.size()); DDMStructure ddmStructure = (DDMStructure) ddmStructureDependentStagedModels.get(0); Assert.assertNull( "Company DDM structure dependency should not be imported", DDMStructureLocalServiceUtil.fetchDDMStructureByUuidAndGroupId( ddmStructure.getUuid(), group.getGroupId())); List<StagedModel> dlFileEntryTypesDependentStagedModels = dependentStagedModelsMap.get(DLFileEntryType.class.getSimpleName()); Assert.assertEquals(1, dlFileEntryTypesDependentStagedModels.size()); DLFileEntryType dlFileEntryType = (DLFileEntryType) dlFileEntryTypesDependentStagedModels.get(0); Assert.assertNull( "Company DL file entry should not be imported", DLFileEntryTypeLocalServiceUtil.fetchDLFileEntryTypeByUuidAndGroupId( dlFileEntryType.getUuid(), group.getGroupId())); }
@Override public void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException { DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.fetchDLFileEntryTypeByUuidAndGroupId(uuid, groupId); if (dlFileEntryType != null) { DLFileEntryTypeLocalServiceUtil.deleteFileEntryType(dlFileEntryType); } }
protected DLFileEntryType fetchExistingFileEntryType( String uuid, long groupId, String fileEntryTypeKey, boolean preloaded) { DLFileEntryType existingDLFileEntryType = null; if (!preloaded) { existingDLFileEntryType = DLFileEntryTypeLocalServiceUtil.fetchDLFileEntryTypeByUuidAndGroupId(uuid, groupId); } else { existingDLFileEntryType = DLFileEntryTypeLocalServiceUtil.fetchFileEntryType(groupId, fileEntryTypeKey); } return existingDLFileEntryType; }
@Override public DLFileEntryType fetchStagedModelByUuidAndGroupId(String uuid, long groupId) { return DLFileEntryTypeLocalServiceUtil.fetchDLFileEntryTypeByUuidAndGroupId(uuid, groupId); }
@Override protected void doImportStagedModel( PortletDataContext portletDataContext, DLFileEntryType fileEntryType) throws Exception { long userId = portletDataContext.getUserId(fileEntryType.getUserUuid()); List<Element> ddmStructureElements = portletDataContext.getReferenceDataElements(fileEntryType, DDMStructure.class); for (Element ddmStructureElement : ddmStructureElements) { StagedModelDataHandlerUtil.importStagedModel(portletDataContext, ddmStructureElement); } List<Element> ddmStructureReferenceElements = portletDataContext.getReferenceElements(fileEntryType, DDMStructure.class); long[] ddmStructureIdsArray = new long[ddmStructureReferenceElements.size()]; Map<Long, Long> ddmStructureIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(DDMStructure.class); for (int i = 0; i < ddmStructureReferenceElements.size(); i++) { Element ddmStructureReferenceElement = ddmStructureReferenceElements.get(i); long ddmStructureId = GetterUtil.getLong(ddmStructureReferenceElement.attributeValue("class-pk")); ddmStructureIdsArray[i] = MapUtil.getLong(ddmStructureIds, ddmStructureId); } ServiceContext serviceContext = portletDataContext.createServiceContext(fileEntryType, DLPortletDataHandler.NAMESPACE); DLFileEntryType importedDLFileEntryType = null; if (portletDataContext.isDataStrategyMirror()) { DLFileEntryType existingDLFileEntryType = DLFileEntryTypeLocalServiceUtil.fetchDLFileEntryTypeByUuidAndGroupId( fileEntryType.getUuid(), portletDataContext.getScopeGroupId()); if (existingDLFileEntryType == null) { existingDLFileEntryType = DLFileEntryTypeLocalServiceUtil.fetchDLFileEntryTypeByUuidAndGroupId( fileEntryType.getUuid(), portletDataContext.getCompanyGroupId()); } if (existingDLFileEntryType == null) { serviceContext.setUuid(fileEntryType.getUuid()); importedDLFileEntryType = DLFileEntryTypeLocalServiceUtil.addFileEntryType( userId, portletDataContext.getScopeGroupId(), fileEntryType.getFileEntryTypeKey(), fileEntryType.getNameMap(), fileEntryType.getDescriptionMap(), ddmStructureIdsArray, serviceContext); } else if (portletDataContext.isCompanyStagedGroupedModel(existingDLFileEntryType)) { return; } else { DLFileEntryTypeLocalServiceUtil.updateFileEntryType( userId, existingDLFileEntryType.getFileEntryTypeId(), fileEntryType.getNameMap(), fileEntryType.getDescriptionMap(), ddmStructureIdsArray, serviceContext); } } else { importedDLFileEntryType = DLFileEntryTypeLocalServiceUtil.addFileEntryType( userId, portletDataContext.getScopeGroupId(), fileEntryType.getFileEntryTypeKey(), fileEntryType.getNameMap(), fileEntryType.getDescriptionMap(), ddmStructureIdsArray, serviceContext); } portletDataContext.importClassedModel( fileEntryType, importedDLFileEntryType, DLPortletDataHandler.NAMESPACE); String importedDLFileEntryDDMStructureKey = DLUtil.getDDMStructureKey(importedDLFileEntryType); List<DDMStructure> importedDDMStructures = importedDLFileEntryType.getDDMStructures(); for (DDMStructure importedDDMStructure : importedDDMStructures) { String ddmStructureKey = importedDDMStructure.getStructureKey(); if (!DLUtil.isAutoGeneratedDLFileEntryTypeDDMStructureKey(ddmStructureKey)) { continue; } if (ddmStructureKey.equals(importedDLFileEntryDDMStructureKey)) { continue; } importedDDMStructure.setStructureKey(importedDLFileEntryDDMStructureKey); DDMStructureLocalServiceUtil.updateDDMStructure(importedDDMStructure); } }