protected void validateParentStructureId( long groupId, String structureId, String parentStructureId) throws PortalException, SystemException { if (Validator.isNull(parentStructureId)) { return; } if (parentStructureId.equals(structureId)) { throw new StructureInheritanceException(); } JournalStructure parentStructure = journalStructurePersistence.fetchByG_S(groupId, parentStructureId); while (parentStructure != null) { if ((parentStructure != null) && (parentStructure.getStructureId().equals(structureId)) || (parentStructure.getParentStructureId().equals(structureId))) { throw new StructureInheritanceException(); } parentStructure = journalStructurePersistence.fetchByG_S(groupId, parentStructure.getParentStructureId()); } }
@Test public void testAddStrucuture() throws Exception { String structureId = generateId(); JournalStructure structure = addStructure(groupId, structureId, getDefultXsd()); Assert.assertEquals(structureId, structure.getStructureId()); }
public void deleteStructure(JournalStructure structure) throws PortalException, SystemException { if (journalArticlePersistence.countByG_S(structure.getGroupId(), structure.getStructureId()) > 0) { throw new RequiredStructureException(); } if (journalStructurePersistence.countByG_P(structure.getGroupId(), structure.getStructureId()) > 0) { throw new RequiredStructureException(); } if (journalTemplatePersistence.countByG_S(structure.getGroupId(), structure.getStructureId()) > 0) { throw new RequiredStructureException(); } // WebDAVProps webDAVPropsLocalService.deleteWebDAVProps(JournalStructure.class.getName(), structure.getId()); // Expando expandoValueLocalService.deleteValues(JournalStructure.class.getName(), structure.getId()); // Resources resourceLocalService.deleteResource( structure.getCompanyId(), JournalStructure.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, structure.getId()); // Structure journalStructurePersistence.remove(structure); }
@Test public void testCopyStructure() throws Exception { String oldStructureId = generateId(); String xsd = getDefultXsd(); addStructure(groupId, oldStructureId, xsd); String newStructureId = generateId(); JournalStructure structure = JournalStructureLocalServiceUtil.copyStructure( TestPropsValues.getUserId(), groupId, oldStructureId, newStructureId, false); Assert.assertEquals(newStructureId, structure.getStructureId()); Assert.assertEquals( JournalTestUtil.getXsdMap(xsd), JournalTestUtil.getXsdMap(structure.getXsd())); }
protected void doAddJournalStructures(String name, InputStream inputStream) throws Exception { name = getName(name); Map<Locale, String> nameMap = getNameMap(name); String xsd = StringUtil.read(inputStream); JournalStructure journalStructure = JournalStructureLocalServiceUtil.addStructure( userId, groupId, StringPool.BLANK, true, StringPool.BLANK, nameMap, null, xsd, serviceContext); addJournalTemplates(journalStructure.getStructureId(), "/journal/templates/" + name); }