Ignore:
Timestamp:
2018-08-11T17:51:12+02:00 (6 years ago)
Author:
Don-vip
Message:

see #15229 - deprecate all Main methods related to network features. New NetworkManager class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r14120 r14121  
    1111import java.util.Collection;
    1212import java.util.Collections;
    13 import java.util.EnumSet;
    14 import java.util.HashMap;
    1513import java.util.List;
    1614import java.util.Map;
     
    3634import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3735import org.openstreetmap.josm.io.FileWatcher;
     36import org.openstreetmap.josm.io.NetworkManager;
    3837import org.openstreetmap.josm.io.OnlineResource;
    3938import org.openstreetmap.josm.spi.preferences.Config;
     
    8079     */
    8180    public static final FileWatcher fileWatcher = new FileWatcher();
    82 
    83     private static final Map<String, Throwable> NETWORK_ERRORS = new HashMap<>();
    84 
    85     private static final Set<OnlineResource> OFFLINE_RESOURCES = EnumSet.noneOf(OnlineResource.class);
    8681
    8782    /**
     
    423418     * @param t The network error
    424419     * @return The previous error associated to the given resource, if any. Can be {@code null}
     420     * @deprecated Use {@link NetworkManager#addNetworkError(URL, Throwable)}
    425421     * @since 6642
    426422     */
     423    @Deprecated
    427424    public static Throwable addNetworkError(URL url, Throwable t) {
    428         if (url != null && t != null) {
    429             Throwable old = addNetworkError(url.toExternalForm(), t);
    430             if (old != null) {
    431                 Logging.warn("Already here "+old);
    432             }
    433             return old;
    434         }
    435         return null;
     425        return NetworkManager.addNetworkError(url, t);
    436426    }
    437427
     
    443433     * @param t The network error
    444434     * @return The previous error associated to the given resource, if any. Can be {@code null}
     435     * @deprecated Use {@link NetworkManager#addNetworkError(String, Throwable)}
    445436     * @since 6642
    446437     */
     438    @Deprecated
    447439    public static Throwable addNetworkError(String url, Throwable t) {
    448         if (url != null && t != null) {
    449             return NETWORK_ERRORS.put(url, t);
    450         }
    451         return null;
     440        return NetworkManager.addNetworkError(url, t);
    452441    }
    453442
     
    455444     * Returns the network errors that occured until now.
    456445     * @return the network errors that occured until now, indexed by URL
     446     * @deprecated Use {@link NetworkManager#getNetworkErrors}
    457447     * @since 6639
    458448     */
     449    @Deprecated
    459450    public static Map<String, Throwable> getNetworkErrors() {
    460         return new HashMap<>(NETWORK_ERRORS);
     451        return NetworkManager.getNetworkErrors();
    461452    }
    462453
    463454    /**
    464455     * Clears the network errors cache.
     456     * @deprecated Use {@link NetworkManager#clearNetworkErrors}
    465457     * @since 12011
    466458     */
     459    @Deprecated
    467460    public static void clearNetworkErrors() {
    468         NETWORK_ERRORS.clear();
     461        NetworkManager.clearNetworkErrors();
    469462    }
    470463
     
    546539     * @param r the online resource
    547540     * @return {@code true} if {@code r} is offline and should not be accessed
     541     * @deprecated Use {@link NetworkManager#isOffline}
    548542     * @since 7434
    549543     */
     544    @Deprecated
    550545    public static boolean isOffline(OnlineResource r) {
    551         return OFFLINE_RESOURCES.contains(r) || OFFLINE_RESOURCES.contains(OnlineResource.ALL);
     546        return NetworkManager.isOffline(r);
    552547    }
    553548
     
    556551     * @param r the online resource
    557552     * @return {@code true} if {@code r} was not already offline
     553     * @deprecated Use {@link NetworkManager#setOffline}
    558554     * @since 7434
    559555     */
     556    @Deprecated
    560557    public static boolean setOffline(OnlineResource r) {
    561         return OFFLINE_RESOURCES.add(r);
     558        return NetworkManager.setOffline(r);
    562559    }
    563560
     
    566563     * @param r the online resource
    567564     * @return {@code true} if {@code r} was offline
     565     * @deprecated Use {@link NetworkManager#setOnline}
    568566     * @since 8506
    569567     */
     568    @Deprecated
    570569    public static boolean setOnline(OnlineResource r) {
    571         return OFFLINE_RESOURCES.remove(r);
     570        return NetworkManager.setOnline(r);
    572571    }
    573572
     
    575574     * Replies the set of online resources currently offline.
    576575     * @return the set of online resources currently offline
     576     * @deprecated Use {@link NetworkManager#getOfflineResources}
    577577     * @since 7434
    578578     */
     579    @Deprecated
    579580    public static Set<OnlineResource> getOfflineResources() {
    580         return EnumSet.copyOf(OFFLINE_RESOURCES);
     581        return NetworkManager.getOfflineResources();
    581582    }
    582583}
Note: See TracChangeset for help on using the changeset viewer.