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, SystemException { DDMStructure ddmStructure = DDMStructureLocalServiceUtil.fetchDDMStructureByUuidAndGroupId(uuid, groupId); if (ddmStructure != null) { DDMStructureLocalServiceUtil.deleteStructure(ddmStructure); } }
protected DDMStructure fetchExistingStructure( String uuid, long groupId, long classNameId, String structureKey, boolean preloaded) throws Exception { DDMStructure existingStructure = null; if (!preloaded) { existingStructure = DDMStructureLocalServiceUtil.fetchDDMStructureByUuidAndGroupId(uuid, groupId); } else { existingStructure = DDMStructureLocalServiceUtil.fetchStructure(groupId, classNameId, structureKey); } return existingStructure; }
protected void exportImportJournalArticle(boolean companyScopeDependencies) throws Exception { JournalArticle article = null; DDMStructure ddmStructure = null; DDMTemplate ddmTemplate = null; long groupId = group.getGroupId(); Company company = CompanyLocalServiceUtil.fetchCompany(group.getCompanyId()); Group companyGroup = company.getGroup(); if (companyScopeDependencies) { groupId = companyGroup.getGroupId(); } ddmStructure = DDMStructureTestUtil.addStructure(groupId, JournalArticle.class.getName()); ddmTemplate = DDMTemplateTestUtil.addTemplate(groupId, ddmStructure.getStructureId()); String content = DDMStructureTestUtil.getSampleStructuredContent(); article = JournalTestUtil.addArticleWithXMLContent( group.getGroupId(), content, ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey()); exportImportPortlet(PortletKeys.JOURNAL); int articlesCount = JournalArticleLocalServiceUtil.getArticlesCount(importedGroup.getGroupId()); Assert.assertEquals(1, articlesCount); JournalArticle groupArticle = JournalArticleLocalServiceUtil.fetchJournalArticleByUuidAndGroupId( article.getUuid(), importedGroup.getGroupId()); Assert.assertNotNull(groupArticle); groupId = importedGroup.getGroupId(); if (companyScopeDependencies) { DDMStructure importedDDMStructure = DDMStructureLocalServiceUtil.fetchDDMStructureByUuidAndGroupId( ddmStructure.getUuid(), groupId); Assert.assertNull(importedDDMStructure); DDMTemplate importedDDMTemplate = DDMTemplateLocalServiceUtil.fetchDDMTemplateByUuidAndGroupId( ddmTemplate.getUuid(), groupId); Assert.assertNull(importedDDMTemplate); groupId = companyGroup.getGroupId(); } DDMStructure dependentDDMStructure = DDMStructureLocalServiceUtil.fetchDDMStructureByUuidAndGroupId( ddmStructure.getUuid(), groupId); Assert.assertNotNull(dependentDDMStructure); DDMTemplate dependentDDMTemplate = DDMTemplateLocalServiceUtil.fetchDDMTemplateByUuidAndGroupId( ddmTemplate.getUuid(), groupId); Assert.assertNotNull(dependentDDMTemplate); Assert.assertEquals(article.getDDMStructureKey(), dependentDDMStructure.getStructureKey()); Assert.assertEquals(article.getDDMTemplateKey(), dependentDDMTemplate.getTemplateKey()); Assert.assertEquals(dependentDDMTemplate.getClassPK(), dependentDDMStructure.getStructureId()); }