@Test public void testXSDImport() throws IOException { XSDRepositoryStore xsdStore = (XSDRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(XSDRepositoryStore.class); int countBefore = xsdStore.getChildren().size(); String xsdFilePath = createXSDFileToImport(); XSDImport.importXSD(xsdFilePath); int countAfter = xsdStore.getChildren().size(); Assert.assertEquals("XSD import doesn't work", countBefore + 1, countAfter); }
@BonitaAPI public static void importXSD(String filePath) { File file = new File(filePath); XSDRepositoryStore xsdStore = (XSDRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(XSDRepositoryStore.class); IRepositoryFileStore fileStore = xsdStore.createRepositoryFileStore(file.getName()); Resource resource = new XSDResourceFactoryImpl().createResource(URI.createFileURI(file.getAbsolutePath())); try { resource.load(Collections.EMPTY_MAP); } catch (IOException e1) { BonitaStudioLog.error(e1); } if (!resource.getContents().isEmpty()) { XSDSchema content = (XSDSchema) resource.getContents().get(0); fileStore.save(content); } }