Ticket #2633: 2633.patch

File 2633.patch, 3.9 KB (added by Gubaer, 16 years ago)
  • src/org/openstreetmap/josm/io/OsmApi.java

     
    128128
    129129    /**
    130130     * Initializes this component by negotiating a protocol version with the server.
     131     *
     132     * @exception UnknownHostException thrown, if the API host is unknown
     133     * @exception SocketTimeoutException thrown, if the connection to the API host  times out
     134     * @exception ConnectException throw, if the connection to the API host fails
     135     * @exception Exception any other exception
    131136     */
    132     public void initialize() {
     137    public void initialize() throws UnknownHostException,SocketTimeoutException, ConnectException,Exception {
    133138        initAuthentication();
    134139        try {
    135140            initialized = true; // note: has to be before the sendRequest or that will throw!
     
    152157            osmWriter.setVersion(version);
    153158        } catch (Exception ex) {
    154159            initialized = false;
    155             ex.printStackTrace();
     160            throw ex;
    156161        }
    157162    }
    158163
  • src/org/openstreetmap/josm/io/OsmServerReader.java

     
    1111import java.util.zip.InflaterInputStream;
    1212import java.util.zip.GZIPInputStream;
    1313
     14import javax.swing.JOptionPane;
     15
    1416import org.openstreetmap.josm.Main;
    1517import org.openstreetmap.josm.data.osm.DataSet;
    1618import org.openstreetmap.josm.gui.PleaseWaitDialog;
     
    3739     * @return An reader reading the input stream (servers answer) or <code>null</code>.
    3840     */
    3941    protected InputStream getInputStream(String urlStr, PleaseWaitDialog pleaseWaitDlg) throws IOException {
    40         api.initialize();
     42       
     43        // initialize API. Abort download in case of configuration or network
     44        // errors
     45        //
     46        try {
     47            api.initialize();
     48        } catch(Exception e) {
     49            JOptionPane.showMessageDialog(
     50                null,
     51                tr(   "Failed to initialize communication with the OSM server {0}.\n"
     52                    + "Check the server URL in your preferences and your internet connection.",
     53                    Main.pref.get("osm-server.url")
     54                ),
     55                tr("Error"),
     56                JOptionPane.ERROR_MESSAGE
     57            );
     58            e.printStackTrace();
     59            return null;
     60        }
     61
    4162        urlStr = api.getBaseUrl() + urlStr;
    4263        return getInputStreamRaw(urlStr, pleaseWaitDlg);
    4364    }
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

     
    6767     */
    6868    public void uploadOsm(String the_version, Collection<OsmPrimitive> list) {
    6969        processed = new LinkedList<OsmPrimitive>();
    70         api.initialize();
     70       
     71        // initialize API. Abort upload in case of configuration or network
     72        // errors
     73        //
     74        try {
     75            api.initialize();
     76        } catch(Exception e) {
     77            JOptionPane.showMessageDialog(
     78                null,
     79                tr(   "Failed to initialize communication with the OSM server {0}.\n"
     80                    + "Check the server URL in your preferences and your internet connection.",
     81                    Main.pref.get("osm-server.url")
     82                ),
     83                tr("Error"),
     84                JOptionPane.ERROR_MESSAGE
     85            );
     86            e.printStackTrace();
     87            return;
     88        }
     89       
    7190
    7291        Main.pleaseWaitDlg.progress.setMaximum(list.size());
    7392        Main.pleaseWaitDlg.progress.setValue(0);