for (String repositoryLocation : repositoryLocations) {
File repositoryDirectory;
if (repositoryLocation.startsWith("${") && repositoryLocation.endsWith("}")) {
String location = System.getenv(repositoryLocation.substring(2, repositoryLocation.length() - 1));
if (location == null) {
throw new InitializationError("Repository environment variable " + repositoryLocation + " is not defined");
}
repositoryDirectory = new File(location);
} else {
repositoryDirectory = new File(repositoryLocation);
}
if (!repositoryDirectory.exists() || !repositoryDirectory.isDirectory()) {
throw new InitializationError("Repository " + repositoryDirectory + " does not exist or is not a directory");
}
BundleRepositoryPersister persister = new BundleRepositoryPersister(repositoryDirectory);
try {
repositories.add(persister.load());
} catch (IOException e) {
List<Throwable> list = new ArrayList<Throwable>(1);
list.add(e);
throw new InitializationError(list);
}
}
return (BundleRepository[]) repositories.toArray(new BundleRepository[repositories.size()]);
}