RepositoryServiceImpl implements RepositoryService { @Override public void updateBundleRepositoryDescriptor(String name) throws Exception { if (repositories.get(name) == null) { throw new IllegalArgumentException("Repository " + name + " doesn't exist"); } if (repositories.get(name).getLocation() != null && !repositories.get(name).getLocation().isEmpty()) { Path bundleRepositoryXmlPath = Paths.get(repositories.get(name).getLocation()).resolve("repository.xml"); BundleRepository bundleRepository = new BundleRepository(bundleRepositoryXmlPath.toUri().toString(), name); if (!Files.exists(bundleRepositoryXmlPath)) { try (Writer writer = Files.newBufferedWriter(bundleRepositoryXmlPath, StandardCharsets.UTF_8)) { bundleRepository.writeRepository(writer); } } List<Resource> resources = new ArrayList<>(); updateBundleRepositoryDescriptor(new File(repositories.get(name).getLocation()), resources, repositories.get(name).getLocation()); addResources(bundleRepository, resources); } }  @Activate void activate(ComponentContext componentContext); @Deactivate void deactivate(ComponentContext componentContext); @Override Repository create(String name); @Override Repository create(String name, String location); @Override Repository create(String name, String location, String proxy); @Override Repository create(String name, String location, String proxy, boolean mirror); @Override Repository create(String name, String location, String url, String proxy, boolean mirror, String realm, String downloadRole, String uploadRole, String scheduling, String schedulingAction, int poolSize); @Override void changeLocation(String name, String location); @Override void changeUrl(String name, String url); @Override void changeProxy(String name, String proxy, boolean mirror); @Override void changeSecurity(String name, String realm, String downloadRole, String uploadRole); @Override void changeScheduling(String name, String scheduling, String schedulingAction); @Override void copy(String sourceRepositoryName, String destinationRepositoryName); @Override void remove(String name); @Override void remove(String name, boolean storageCleanup); @Override void purge(String name); @Override synchronized Collection<Repository> repositories(); @Override synchronized Repository repository(String name); @Override void addArtifact(String artifactUrl, String name); @Override void addArtifact(String artifactUrl, String groupId, String artifactId, String version, String type, String classifier, String name); @Override void deleteArtifact(String artifactUrl, String name); @Override void deleteArtifact(String groupId, String artifactId, String version, String type, String classifier, String name); @Override void updateBundleRepositoryDescriptor(String name);  }
@Test public void testUpdateBundleRepositoryDescriptor() throws Exception { repositoryService.create("test"); repositoryService.addArtifact("mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch/7.3.2_1", "test"); repositoryService.updateBundleRepositoryDescriptor("test"); Assert.assertTrue(Files.exists(Paths.get("target/repositories/test/repository.xml"))); }