use of bndtools.central.RefreshFileJob in project bndtools by bndtools.
the class AddFilesToRepositoryWizard method performFinishAddFiles.
private IStatus performFinishAddFiles(IProgressMonitor monitor) {
MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "Failed to install one or more bundles", null);
List<File> files = fileSelectionPage.getFiles();
selectedBundles = new LinkedList<Pair<String, String>>();
monitor.beginTask("Processing files", files.size());
for (File file : files) {
monitor.subTask(file.getName());
try (Jar jar = new Jar(file)) {
jar.setDoNotTouchManifest();
Attributes mainAttribs = jar.getManifest().getMainAttributes();
String bsn = BundleUtils.getBundleSymbolicName(mainAttribs);
String version = mainAttribs.getValue(Constants.BUNDLE_VERSION);
if (version == null)
version = "0";
selectedBundles.add(Pair.newInstance(bsn, version));
} catch (Exception e) {
status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to analyse JAR: {0}", file.getPath()), e));
continue;
}
try {
RepositoryPlugin.PutResult result = repository.put(new BufferedInputStream(IO.stream(file)), new RepositoryPlugin.PutOptions());
if (result.artifact != null && result.artifact.getScheme().equals("file")) {
File newFile = new File(result.artifact);
RefreshFileJob refreshJob = new RefreshFileJob(newFile, false);
if (refreshJob.needsToSchedule())
refreshJob.schedule();
}
} catch (Exception e) {
status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to add JAR to repository: {0}", file.getPath()), e));
continue;
}
monitor.worked(1);
}
return status;
}
Aggregations