@Override
public void create(String repoName, List<String> features, PrintStream console) {
FileOutputStream fos = null;
JarOutputStream jos = null;
try {
Repository repo = featuresService.getRepository(repoName);
if (repo == null) {
throw new RuntimeException("Could not find a repository with name " + repoName);
}
String karPath = storage + File.separator + repoName + ".kar";
File karFile = new File(karPath);
karFile.getParentFile().mkdirs();
fos = new FileOutputStream(karFile);
Manifest manifest = createNonAutoStartManifest(repo.getURI());
jos = new JarOutputStream(new BufferedOutputStream(fos, 100000), manifest);
Map<URI, Integer> locationMap = new HashMap<URI, Integer>();
copyResourceToJar(jos, repo.getURI(), locationMap);
Map<String, Feature> featureMap = new HashMap<String, Feature>();
for (Feature feature : repo.getFeatures()) {
featureMap.put(feature.getName(), feature);
}
Set<Feature> featuresToCopy = getFeatures(featureMap, features, 1);