Changeset 9720 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-02-03T00:53:09+01:00 (9 years ago)
Author:
Don-vip
Message:

remove deprecated stuff

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r9170 r9720  
    88import java.io.InputStream;
    99import java.io.OutputStream;
    10 import java.net.URL;
    1110import java.nio.charset.StandardCharsets;
    1211import java.util.zip.GZIPOutputStream;
     
    103102
    104103    /**
    105      * Returns an un-compressing {@link InputStream} for the {@link URL} {@code url}.
    106      * @param url URL
    107      * @return un-compressing input stream
    108      *
    109      * @throws IOException if any I/O error occurs
    110      * @deprecated Use {@link org.openstreetmap.josm.tools.HttpClient} instead
    111      */
    112     @Deprecated
    113     public static InputStream getUncompressedURLInputStream(URL url) throws IOException {
    114         return Utils.openURLAndDecompress(url, true);
    115     }
    116 
    117     /**
    118104     * Returns a compressing {@link OutputStream} for {@code out}.
    119105     * @param out raw output stream
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r9645 r9720  
    2525import java.io.InputStreamReader;
    2626import java.io.UnsupportedEncodingException;
    27 import java.net.HttpURLConnection;
    2827import java.net.MalformedURLException;
    2928import java.net.URL;
    30 import java.net.URLConnection;
    3129import java.net.URLDecoder;
    3230import java.net.URLEncoder;
     
    6866import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    6967import org.openstreetmap.josm.Main;
    70 import org.openstreetmap.josm.data.Version;
    7168import org.xml.sax.InputSource;
    7269import org.xml.sax.SAXException;
     
    827824    }
    828825
    829     private static final Pattern HTTP_PREFFIX_PATTERN = Pattern.compile("https?");
    830 
    831     /**
    832      * Opens a HTTP connection to the given URL and sets the User-Agent property to JOSM's one.
    833      * @param httpURL The HTTP url to open (must use http:// or https://)
    834      * @return An open HTTP connection to the given URL
    835      * @throws java.io.IOException if an I/O exception occurs.
    836      * @since 5587
    837      * @deprecated Use {@link HttpClient} instead
    838      */
    839     @Deprecated
    840     public static HttpURLConnection openHttpConnection(URL httpURL) throws IOException {
    841         if (httpURL == null || !HTTP_PREFFIX_PATTERN.matcher(httpURL.getProtocol()).matches()) {
    842             throw new IllegalArgumentException("Invalid HTTP url");
    843         }
    844         if (Main.isDebugEnabled()) {
    845             Main.debug("Opening HTTP connection to "+httpURL.toExternalForm());
    846         }
    847         HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
    848         connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString());
    849         connection.setUseCaches(false);
    850         return connection;
    851     }
    852 
    853     /**
    854      * Opens a connection to the given URL and sets the User-Agent property to JOSM's one.
    855      * @param url The url to open
    856      * @return An stream for the given URL
    857      * @throws java.io.IOException if an I/O exception occurs.
    858      * @since 5867
    859      * @deprecated Use {@link HttpClient} instead
    860      */
    861     @Deprecated
    862     public static InputStream openURL(URL url) throws IOException {
    863         return HttpClient.create(url).connect().getContent();
    864     }
    865 
    866     /**
    867      * Opens a connection to the given URL, sets the User-Agent property to JOSM's one, and decompresses stream if necessary.
    868      * @param url The url to open
    869      * @param decompress whether to wrap steam in a {@link GZIPInputStream} or {@link BZip2CompressorInputStream}
    870      *                   if the {@code Content-Type} header is set accordingly.
    871      * @return An stream for the given URL
    872      * @throws IOException if an I/O exception occurs.
    873      * @since 6421
    874      * @deprecated Use {@link HttpClient} instead
    875      */
    876     @Deprecated
    877     public static InputStream openURLAndDecompress(final URL url, final boolean decompress) throws IOException {
    878         return HttpClient.create(url).connect().uncompress(decompress).getContent();
    879     }
    880 
    881826    /**
    882827     * Returns a Bzip2 input stream wrapping given input stream.
     
    925870        }
    926871        return zis;
    927     }
    928 
    929     /***
    930      * Setups the given URL connection to match JOSM needs by setting its User-Agent and timeout properties.
    931      * @param connection The connection to setup
    932      * @return {@code connection}, with updated properties
    933      * @since 5887
    934      * @deprecated Use {@link HttpClient} instead
    935      */
    936     @Deprecated
    937     public static URLConnection setupURLConnection(URLConnection connection) {
    938         if (connection != null) {
    939             connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString());
    940             connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect", 15)*1000);
    941             connection.setReadTimeout(Main.pref.getInteger("socket.timeout.read", 30)*1000);
    942         }
    943         return connection;
    944     }
    945 
    946     /**
    947      * Opens a connection to the given URL and sets the User-Agent property to JOSM's one.
    948      * @param url The url to open
    949      * @return An buffered stream reader for the given URL (using UTF-8)
    950      * @throws java.io.IOException if an I/O exception occurs.
    951      * @since 5868
    952      * @deprecated Use {@link HttpClient} instead
    953      */
    954     @Deprecated
    955     public static BufferedReader openURLReader(URL url) throws IOException {
    956         return HttpClient.create(url).connect().getContentReader();
    957     }
    958 
    959     /**
    960      * Opens a connection to the given URL and sets the User-Agent property to JOSM's one.
    961      * @param url The url to open
    962      * @param decompress whether to wrap steam in a {@link GZIPInputStream} or {@link BZip2CompressorInputStream}
    963      *                   if the {@code Content-Type} header is set accordingly.
    964      * @return An buffered stream reader for the given URL (using UTF-8)
    965      * @throws IOException if an I/O exception occurs.
    966      * @since 6421
    967      * @deprecated Use {@link HttpClient} instead
    968      */
    969     @Deprecated
    970     public static BufferedReader openURLReaderAndDecompress(final URL url, final boolean decompress) throws IOException {
    971         return HttpClient.create(url).connect().uncompress(decompress).getContentReader();
    972     }
    973 
    974     /**
    975      * Opens a HTTP connection to the given URL, sets the User-Agent property to JOSM's one and optionnaly disables Keep-Alive.
    976      * @param httpURL The HTTP url to open (must use http:// or https://)
    977      * @param keepAlive whether not to set header {@code Connection=close}
    978      * @return An open HTTP connection to the given URL
    979      * @throws java.io.IOException if an I/O exception occurs.
    980      * @since 5587
    981      * @deprecated Use {@link HttpClient} instead
    982      */
    983     @Deprecated
    984     public static HttpURLConnection openHttpConnection(URL httpURL, boolean keepAlive) throws IOException {
    985         HttpURLConnection connection = openHttpConnection(httpURL);
    986         if (!keepAlive) {
    987             connection.setRequestProperty("Connection", "close");
    988         }
    989         if (Main.isDebugEnabled()) {
    990             try {
    991                 Main.debug("REQUEST: "+ connection.getRequestProperties());
    992             } catch (IllegalStateException e) {
    993                 Main.warn(e);
    994             }
    995         }
    996         return connection;
    997     }
    998 
    999     /**
    1000      * Opens a HTTP connection to given URL, sets the User-Agent property to JOSM's one, optionally disables Keep-Alive, and
    1001      * optionally - follows redirects. It means, that it's not possible to send custom headers with method
    1002      *
    1003      * @param httpURL The HTTP url to open (must use http:// or https://)
    1004      * @param keepAlive whether not to set header {@code Connection=close}
    1005      * @param followRedirects wheter or not to follow HTTP(S) redirects
    1006      * @return An open HTTP connection to the given URL
    1007      * @throws IOException if an I/O exception occurs
    1008      * @since 8650
    1009      * @deprecated Use {@link HttpClient} instead
    1010      */
    1011     @Deprecated
    1012     public static HttpURLConnection openHttpConnection(URL httpURL, boolean keepAlive, boolean followRedirects) throws IOException {
    1013         HttpURLConnection connection = openHttpConnection(httpURL, keepAlive);
    1014         if (followRedirects) {
    1015             for (int i = 0; i < 5; i++) {
    1016                 if (connection.getResponseCode() == 302) {
    1017                     connection = openHttpConnection(new URL(connection.getHeaderField("Location")), keepAlive);
    1018                 } else {
    1019                     break;
    1020                 }
    1021             }
    1022         }
    1023         return connection;
    1024872    }
    1025873
Note: See TracChangeset for help on using the changeset viewer.