* @param repoDir
* @return
* @throws IOException
*/
private Repository createRepository(File repoFile, File repoDir) throws IOException {
DataModelHelper dmh = getRepositoryAdmin().getHelper();
List<Resource> resources = new ArrayList<Resource>();
for (File jar : findAllJars(repoDir)) {
Resource r = dmh.createResource(jar.toURI().toURL());
if (r == null) {
logger.logp(Level.WARNING, "ObrHandler", "createRepository", "{0} not an OSGi bundle", jar.toURI().toURL());
} else {
resources.add(r);
}
}
Repository repository = dmh.repository(resources.toArray(new Resource[resources.size()]));
logger.logp(Level.INFO, "ObrHandler", "createRepository", "Created {0} containing {1} resources.",
new Object[]{repoFile, resources.size()});
if (repoFile != null) {
saveRepository(repoFile, repository);
}