Fix ONOS CI by removing the usage of getRegisteredApps

getRegisteredApps is deprecated and it has been discontinued

This patch partially reverts:
- https://gerrit.onosproject.org/c/onos/+/22325
- https://gerrit.onosproject.org/c/onos/+/22362
- https://gerrit.onosproject.org/c/onos/+/22382

Change-Id: I652d814a006709bd40a673699697ba229955b0e4
diff --git a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
index 6b18a04..8ebfa4c 100644
--- a/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
+++ b/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java
@@ -15,14 +15,9 @@
  */
 package org.onosproject.app.impl;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Multimap;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -37,9 +32,6 @@
 import org.onosproject.app.ApplicationStoreDelegate;
 import org.onosproject.core.Application;
 import org.onosproject.core.ApplicationId;
-import org.onosproject.core.DefaultApplication;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.core.Version;
 import org.onosproject.core.VersionService;
 import org.onosproject.event.AbstractListenerManager;
 import org.onosproject.security.Permission;
@@ -51,19 +43,17 @@
 import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.slf4j.Logger;
 
-import java.io.IOException;
 import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Iterator;
 import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.app.ApplicationEvent.Type.*;
+import static org.onosproject.app.ApplicationEvent.Type.APP_ACTIVATED;
+import static org.onosproject.app.ApplicationEvent.Type.APP_DEACTIVATED;
+import static org.onosproject.app.ApplicationEvent.Type.APP_INSTALLED;
+import static org.onosproject.app.ApplicationEvent.Type.APP_UNINSTALLED;
 import static org.onosproject.security.AppGuard.checkPermission;
 import static org.onosproject.security.AppPermission.Type.APP_READ;
 import static org.slf4j.LoggerFactory.getLogger;
@@ -78,8 +68,6 @@
 
     private final Logger log = getLogger(getClass());
 
-    private static final String APP_REGISTRY_URL = "http://api.onosproject.org:8080/api/applications";
-
     private static final String APP_ID_NULL = "Application ID cannot be null";
     private static final long DEFAULT_OPERATION_TIMEOUT_MILLIS = 2000;
     private final ApplicationStoreDelegate delegate = new InternalStoreDelegate();
@@ -336,67 +324,7 @@
 
     @Override
     public Set<Application> getRegisteredApplications() {
-        ImmutableSet.Builder<Application> builder = ImmutableSet.builder();
-        ObjectMapper mapper = new ObjectMapper();
-        String vers = versionService.version().toString();
-        vers = vers.substring(0, vers.lastIndexOf(".") + 2);
-        // Get input stream from the URL
-        try {
-            URL serverUrl = new URL(APP_REGISTRY_URL + "?onosVersion=" + vers);
-            HttpURLConnection serverHttp = (HttpURLConnection) serverUrl.openConnection();
-            InputStream githubStream = serverHttp.getInputStream();
-
-            // Read input stream into an ArrayNode
-            ArrayNode rootTree = (ArrayNode) mapper.readTree(githubStream);
-
-            // Iterate over the array node for each object add each version as application object to the set
-            rootTree.forEach(n -> {
-                mapObject(builder, (ObjectNode) n);
-            });
-
-            //Iterate through Builder to remove unnecessary apps
-            Set<Application> apps = builder.build();
-
-            return apps;
-        } catch (MalformedURLException e) {
-            throw new IllegalStateException("Bad URL: " + APP_REGISTRY_URL + "?onosVersion=" + vers, e);
-        } catch (IOException e) {
-            throw new IllegalStateException("Unable to fetch URL: " + APP_REGISTRY_URL + "?onosVersion=" + vers, e);
-        }
+        return ImmutableSet.of();
     }
 
-    private void mapObject(ImmutableSet.Builder<Application> apps, ObjectNode node) {
-        String appIDs = node.get("id").asText();
-        ApplicationId appID = new DefaultApplicationId(1, appIDs);
-        String title = node.get("title").asText();
-        String readme = node.get("readme").asText();
-        String category = node.get("category").asText();
-        String url = node.get("url").asText();
-        String origin = node.get("maintainer").asText();
-        JsonNode it = node.get("versions");
-        Iterator iterate = it.iterator();
-        while (iterate.hasNext()) {
-            DefaultApplication.Builder app = new DefaultApplication.Builder();
-            JsonNode jsonNode = (JsonNode) iterate.next();
-            URL imageUrl = null;
-            try {
-                imageUrl = new URL(jsonNode.get("oarURL").asText());
-            } catch (MalformedURLException e) {
-                e.printStackTrace();
-            }
-            Version version1 = Version.version(jsonNode.get("onosVersion").asText());
-            app.withImageUrl(imageUrl)
-                    .withAppId(new DefaultApplicationId(1, node.get("id").asText()))
-                    .withVersion(version1)
-                    .withAppId(appID)
-                    .withReadme(readme)
-                    .withDescription(readme)
-                    .withTitle(title)
-                    .withFeatures(ImmutableList.of("none"))
-                    .withCategory(category)
-                    .withUrl(url)
-                    .withOrigin(origin);
-            apps.add(app.build());
-        }
-    }
 }
\ No newline at end of file