Ticket #2633: 2633.patch
File 2633.patch, 3.9 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/io/OsmApi.java
128 128 129 129 /** 130 130 * 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 131 136 */ 132 public void initialize() {137 public void initialize() throws UnknownHostException,SocketTimeoutException, ConnectException,Exception { 133 138 initAuthentication(); 134 139 try { 135 140 initialized = true; // note: has to be before the sendRequest or that will throw! … … 152 157 osmWriter.setVersion(version); 153 158 } catch (Exception ex) { 154 159 initialized = false; 155 ex.printStackTrace();160 throw ex; 156 161 } 157 162 } 158 163 -
src/org/openstreetmap/josm/io/OsmServerReader.java
11 11 import java.util.zip.InflaterInputStream; 12 12 import java.util.zip.GZIPInputStream; 13 13 14 import javax.swing.JOptionPane; 15 14 16 import org.openstreetmap.josm.Main; 15 17 import org.openstreetmap.josm.data.osm.DataSet; 16 18 import org.openstreetmap.josm.gui.PleaseWaitDialog; … … 37 39 * @return An reader reading the input stream (servers answer) or <code>null</code>. 38 40 */ 39 41 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 41 62 urlStr = api.getBaseUrl() + urlStr; 42 63 return getInputStreamRaw(urlStr, pleaseWaitDlg); 43 64 } -
src/org/openstreetmap/josm/io/OsmServerWriter.java
67 67 */ 68 68 public void uploadOsm(String the_version, Collection<OsmPrimitive> list) { 69 69 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 71 90 72 91 Main.pleaseWaitDlg.progress.setMaximum(list.size()); 73 92 Main.pleaseWaitDlg.progress.setValue(0);