Ignore:
Timestamp:
2008-12-23T15:07:05+01:00 (17 years ago)
Author:
stoecker
Message:

removed usage of tab stops

File:
1 edited

Legend:

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

    r1137 r1169  
    7979
    8080    long uploadStartTime;
    81    
     81
    8282    public String timeLeft(int progress, int list_size) {
    8383        long now = System.currentTimeMillis();
     
    9696        return time_left_str;
    9797    }
    98    
     98
    9999    public void uploadOsm(Collection<OsmPrimitive> list) throws SAXException {
    100100        processed = new LinkedList<OsmPrimitive>();
     
    103103        Main.pleaseWaitDlg.progress.setMaximum(list.size());
    104104        Main.pleaseWaitDlg.progress.setValue(0);
    105        
     105
    106106        // controls whether or not we open and close a changeset. API 0.6 requires changesets.
    107107        boolean useChangesets = Main.pref.get("osm-server.version", "0.5").equals("0.6");
    108        
     108
    109109        // controls whether or not we try and uplaod the whole bunch in one go
    110         boolean useDiffUploads = Main.pref.getBoolean("osm-server.atomic-upload", 
     110        boolean useDiffUploads = Main.pref.getBoolean("osm-server.atomic-upload",
    111111            Main.pref.get("osm-server.version", "0.5").equals("0.6"));
    112        
     112
    113113        String comment = null;
    114114        while (useChangesets && comment == null) {
    115             comment = JOptionPane.showInputDialog(Main.parent, 
     115            comment = JOptionPane.showInputDialog(Main.parent,
    116116                 tr("Provide a brief comment as to the changes to you are uploading:"),
    117117                 tr("Commit comment"), JOptionPane.QUESTION_MESSAGE);
     
    131131            return;
    132132        }
    133    
     133
    134134        try {
    135135            if (useDiffUploads) {
     
    166166            }
    167167            catch (OsmTransferException ex) {
    168                 dealWithTransferException(ex);   
     168                dealWithTransferException(ex);
    169169            }
    170170            dealWithTransferException(e);
    171171        }
    172172    }
    173    
     173
    174174    /* FIXME: This code is terrible, please fix it!!!! */
    175175
     
    183183     * can fix the issue where hitting cancel doesn't do anything while
    184184     * retrying. - Mv0 Apr 2008
    185      * 
     185     *
    186186     * Cancelling has an effect now, maybe it does not always catch on. Florian Heer, Aug 08
    187187     */
     
    198198                    Main.pref.get("osm-server.url") +
    199199                    "/" + version +
    200                     "/" + "changeset" + 
     200                    "/" + "changeset" +
    201201                    "/" + "create");
    202202            System.out.print("upload to: "+url+ "..." );
     
    205205            activeConnection.setRequestMethod("PUT");
    206206            addAuth(activeConnection);
    207            
     207
    208208            activeConnection.setDoOutput(true);
    209209            OutputStream out = activeConnection.getOutputStream();
    210210            OsmWriter.output(out, changeset);
    211211            out.close();
    212            
     212
    213213            activeConnection.connect();
    214214            System.out.println("connected");
     
    224224            }
    225225            if (retCode != 200 && retCode != 412) {
    226                
     226
    227227                if (retries >= 0) {
    228228                    retries--;
     
    232232                    return startChangeset(retries, comment);
    233233                }
    234                
     234
    235235                // Look for a detailed error message from the server
    236236                retMsg += "\n" + readString(activeConnection.getInputStream());
     
    262262                throw new OsmTransferException (e.getMessage()+ " " + e.getClass().getCanonicalName(), e);
    263263        }
    264        
     264
    265265        catch (Exception e) {
    266266            if (cancel)
     
    274274        return true;
    275275    }
    276    
     276
    277277    private void uploadDiff(int retries, Collection<OsmPrimitive> list) throws OsmTransferException {
    278        
     278
    279279        CreateOsmChangeVisitor duv = new CreateOsmChangeVisitor(changeset);
    280280
     
    290290        String diff = duv.getDocument();
    291291        System.out.println(diff);
    292        
     292
    293293        Main.pleaseWaitDlg.currentAction.setText(tr("Uploading..."));
    294294        try {
     
    299299                    Main.pref.get("osm-server.url") +
    300300                    "/" + version +
    301                     "/" + "changeset" + 
     301                    "/" + "changeset" +
    302302                    "/" + changeset.id +
    303303                    "/upload" );
     
    307307            activeConnection.setRequestMethod("POST");
    308308            addAuth(activeConnection);
    309            
     309
    310310            activeConnection.setDoOutput(true);
    311311            PrintWriter out;
     
    317317            out.print(diff);
    318318            out.close();
    319            
     319
    320320            activeConnection.connect();
    321321            System.out.println("connected");
     
    323323            int retCode = activeConnection.getResponseCode();
    324324            String retMsg = "";
    325            
     325
    326326            if (retCode == 200) {
    327327                DiffResultReader.parseDiffResult(activeConnection.getInputStream(), list, processed, duv.getNewIdMap(), Main.pleaseWaitDlg);
     
    333333                    System.out.println("retrying ("+retries+" left)");
    334334                    stopChangeset(retries);
    335                 } else { 
     335                } else {
    336336                    // Look for a detailed error message from the server
    337337                    retMsg += "\n" + readString(activeConnection.getInputStream());
     
    372372        }
    373373    }
    374    
    375    
     374
     375
    376376    private void stopChangeset(int retries) throws OsmTransferException {
    377377        Main.pleaseWaitDlg.currentAction.setText(tr("Closing changeset..."));
     
    383383                    Main.pref.get("osm-server.url") +
    384384                    "/" + version +
    385                     "/" + "changeset" + 
     385                    "/" + "changeset" +
    386386                    "/" + changeset.id +
    387387                    "/close" );
     
    391391            activeConnection.setRequestMethod("PUT");
    392392            addAuth(activeConnection);
    393            
     393
    394394            activeConnection.setDoOutput(true);
    395395            OutputStream out = activeConnection.getOutputStream();
    396396            OsmWriter.output(out, changeset);
    397397            out.close();
    398            
     398
    399399            activeConnection.connect();
    400400            System.out.println("connected");
     
    415415                    System.out.println("retrying ("+retries+" left)");
    416416                    stopChangeset(retries);
    417                 } else { 
     417                } else {
    418418                    // Look for a detailed error message from the server
    419419                    retMsg += readString(activeConnection.getInputStream());
    420                    
     420
    421421                    // Report our error
    422422                    ByteArrayOutputStream o = new ByteArrayOutputStream();
     
    490490        processed.add(e);
    491491    }
    492    
     492
    493493    /**
    494494     * Read a long from the input stream and return it.
     
    540540                    new URL(Main.pref.get("osm-server.url") +
    541541                    "/" + version + "/"),
    542                     urlSuffix + 
     542                    urlSuffix +
    543543                    "/" + (osm.id==0 ? "create" : osm.id),
    544544                    new MyHttpHandler());
     
    622622        }
    623623    }
    624    
     624
    625625    private void sendRequest(String requestMethod, String urlSuffix,
    626626            OsmPrimitive osm, boolean addBody)  {
     
    636636        }
    637637    }
    638    
     638
    639639    private void dealWithTransferException (OsmTransferException e) {
    640640        Main.pleaseWaitDlg.currentAction.setText(tr("Transfer aborted due to error (will wait for 5 seconds):") + e.getMessage());
Note: See TracChangeset for help on using the changeset viewer.