Added Method InstallRegisteredApps to CLI
Change-Id: Ib795c0c5ad4511ad138b32820038c6cf96aa926d
diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
index 9b5e91f..67bd6ba 100644
--- a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
@@ -54,7 +54,7 @@
protected VersionService versionService;
@Argument(index = 0, name = "command",
- description = "Command name (install|activate|deactivate|uninstall|download)",
+ description = "Command name (install|activate|deactivate|uninstall|download|installreg)",
required = true)
@Completion(ApplicationCommandCompleter.class)
String command = null;
@@ -90,24 +90,31 @@
// Installs the application from input of the specified URL
private boolean installApp(ApplicationAdminService service, String url) {
+
try {
if ("-".equals(url)) {
service.install(System.in);
+ } else if (url.contains("oar")) {
+ service.install(new URL(url).openStream());
} else {
Set<Application> app = get(ApplicationService.class)
- .getRegisteredApplications().stream()
- .filter(ra -> ra.id().toString().equals(url))
- .collect(Collectors.toSet());
+ .getRegisteredApplications();
if (app.isEmpty()) {
- service.install(new URL(url).openStream());
+ System.out.println("Could Not Install " + url);
+ return false;
}
Iterator<Application> iterator = app.iterator();
+ Application recent = null;
while (iterator.hasNext()) {
Application application = iterator.next();
- if (application.version().toString().equals(versionService.version().toString())) {
- service.install(application.imageUrl().openStream());
+ if (recent == null && application.id().name().equals(url)) {
+ recent = application;
+ } else if (application.version().compareTo(recent.version()) > 0 &&
+ application.id().name().equals(url)) {
+ recent = application;
}
}
+ service.install(recent.imageUrl().openStream());
}
} catch (IOException e) {
error("Unable to get URL: %s", url);