public static Iterable loadIndices()

in remoting/ide/api/src/org/netbeans/modules/jackpot30/remoting/api/RemoteIndex.java [123:157]


    public static Iterable<? extends RemoteIndex> loadIndices(boolean includeAll) {
        List<RemoteIndex> result = new LinkedList<RemoteIndex>();
        Preferences prefs = NbPreferences.forModule(RemoteIndex.class).node(KEY_REMOTE_INDICES);

        if (prefs != null) {
            try {
                for (String key : prefs.keys()) {
                    if (key.startsWith("index")) {
                        RemoteIndex idx = Pojson.load(RemoteIndex.class, prefs.get(key, null));

                        if (idx.enabled && idx.useLocalCache == UseLocalCache.ALWAYS) {
                            if (localServerPort == (-2)) {
                                localServerPort = Lookup.getDefault().lookup(LocalServer.class).startLocalServer();
                            }

                            if (localServerPort != (-1)) {
                                try {
                                    idx = new RemoteIndex(true, UseLocalCache.ALWAYS, idx.folder, new URL("http://localhost:" + localServerPort + "/index"), idx.remoteSegment);
                                } catch (MalformedURLException ex) {
                                    Exceptions.printStackTrace(ex);
                                }
                            }
                        }

                        if (includeAll || idx.enabled)
                            result.add(idx);
                    }
                }
            } catch (BackingStoreException ex) {
                Exceptions.printStackTrace(ex);
            }
        }

        return result;
    }