Changeset 1559 in josm for trunk/src/org
- Timestamp:
- 2009-04-27T23:21:28+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r1546 r1559 6 6 import java.io.BufferedReader; 7 7 import java.io.BufferedWriter; 8 import java.io.IOException; 9 import java.io.InputStream; 8 10 import java.io.InputStreamReader; 9 11 import java.io.OutputStream; … … 19 21 import java.util.ArrayList; 20 22 import java.util.Collection; 21 import java.util.HashMap;22 23 import java.util.Properties; 23 24 import java.util.StringTokenizer; … … 78 79 */ 79 80 private boolean initialized = false; 80 81 /**82 * list of server error messages (as transported in the Error: header) and their translations.83 */84 public static final HashMap<String,String> serverErrorTranslations;85 86 static {87 serverErrorTranslations = new HashMap<String,String>();88 serverErrorTranslations.put("Database offline for maintenance",89 tr("Database offline for maintenance"));90 serverErrorTranslations.put("You must make your edits public to upload new data",91 tr("You must make your edits public to upload new data"));92 // FIXME there is one additional server error message that goes93 // "You requested too many nodes (limit is #{APP_CONFIG['max_number_of_nodes']}). Either request a smaller area, or use planet.osm"94 // but we would have to switch this mechanism to using regular expressions if we wanted to translate that...95 }96 81 97 82 private StringWriter swriter = new StringWriter(); … … 400 385 out.close(); 401 386 } 387 402 388 activeConnection.connect(); 403 389 System.out.println(activeConnection.getResponseMessage()); 404 405 390 int retCode = activeConnection.getResponseCode(); 406 391 … … 414 399 // populate return fields. 415 400 responseBody.setLength(0); 416 BufferedReader in = new BufferedReader(new InputStreamReader(activeConnection.getInputStream())); 401 402 // If the API returned an error code like 403 forbidden, getInputStream 403 // will fail with an IOException. 404 InputStream i = null; 405 try { 406 i = activeConnection.getInputStream(); 407 } catch (IOException ioe) { 408 i = activeConnection.getErrorStream(); 409 } 410 BufferedReader in = new BufferedReader(new InputStreamReader(i)); 411 417 412 String s; 418 413 while((s = in.readLine()) != null) { … … 422 417 423 418 statusMessage.setLength(0); 424 statusMessage.append (activeConnection.getResponseMessage());425 419 // Look for a detailed error message from the server 426 420 if (activeConnection.getHeaderField("Error") != null) { 427 statusMessage.append(": ");428 421 String er = activeConnection.getHeaderField("Error"); 429 if (serverErrorTranslations.containsKey(er)) er = serverErrorTranslations.get(er); 430 statusMessage.append(er); 422 System.err.println("Error header: " + er); 423 statusMessage.append(tr(er)); 424 } else if (retCode != 200 && responseBody.length()>0) { 425 System.err.println("Error body: " + responseBody); 426 statusMessage.append(tr(responseBody.toString())); 427 } else { 428 statusMessage.append(activeConnection.getResponseMessage()); 431 429 } 432 430 activeConnection.disconnect(); -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r1546 r1559 6 6 import java.util.Collection; 7 7 import java.util.LinkedList; 8 9 import javax.swing.JOptionPane; 8 10 9 11 import org.openstreetmap.josm.Main; … … 125 127 126 128 private void dealWithTransferException (OsmTransferException e) { 127 Main.pleaseWaitDlg.currentAction.setText(tr("Transfer aborted due to error (will wait for 5 seconds):") + e.getMessage()); 128 try { 129 Thread.sleep(5000); 130 } 131 catch (InterruptedException ex) {} 129 JOptionPane.showMessageDialog(Main.parent, 130 /* tr("Error during upload: ") + */ e.getMessage()); 132 131 } 133 132 }
Note:
See TracChangeset
for help on using the changeset viewer.