[josm-plugins] 01/05: Imported Upstream version 0.0.svn31893+ds

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Thu Dec 31 15:12:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository josm-plugins.

commit 842b2244c011dfce3a24e614ca82ff74d64a49e0
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Thu Dec 31 15:19:25 2015 +0100

    Imported Upstream version 0.0.svn31893+ds
---
 DirectUpload/build.xml                             |  2 +-
 .../josm/plugins/DirectUpload/UploadDataGui.java   | 40 +++++++++-------------
 .../plugins/DirectUpload/UploadOsmConnection.java  | 16 ++++-----
 build-common.xml                                   |  4 +--
 svn-info.xml                                       | 10 +++---
 5 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/DirectUpload/build.xml b/DirectUpload/build.xml
index 7c0275d..2c291ad 100644
--- a/DirectUpload/build.xml
+++ b/DirectUpload/build.xml
@@ -4,7 +4,7 @@
     <!-- enter the SVN commit message -->
     <property name="commit.message" value="applied JOSM Ticket 4498 (patch by ax) - oauth support for gpx upload (I accidentally committed parts of the path in [24236])"/>
     <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
-    <property name="plugin.main.version" value="7001"/>
+    <property name="plugin.main.version" value="9179"/>
 
     <!-- Configure these properties (replace "..." accordingly).
          See http://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
diff --git a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java
index 30a9ca3..331a229 100644
--- a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java
+++ b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java
@@ -12,12 +12,8 @@ import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
 import java.net.URL;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
@@ -44,7 +40,8 @@ import org.openstreetmap.josm.gui.widgets.UrlLabel;
 import org.openstreetmap.josm.io.GpxWriter;
 import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.tools.GBC;
-import org.openstreetmap.josm.tools.Utils;
+import org.openstreetmap.josm.tools.HttpClient;
+import org.openstreetmap.josm.tools.HttpClient.Response;
 
 /**
  *
@@ -235,16 +232,17 @@ public class UploadDataGui extends ExtendedDialog {
             writeField(baos, "visibility", visi);
             writeString(baos, "--" + BOUNDARY + "--" + LINE_END);
 
-            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-            HttpURLConnection conn = setupConnection(baos.size());
+            HttpClient conn = setupConnection(baos.size());
 
             progressMonitor.setTicksCount(baos.size());
             progressMonitor.subTask(null);
 
-            flushToServer(bais, conn.getOutputStream(), progressMonitor);
+            // FIXME previous method allowed to see real % progress (each 10 Kb of data)
+            //flushToServer(bais, conn.getOutputStream(), progressMonitor);
+            Response response = conn.setRequestBody(baos.toByteArray()).connect(progressMonitor);
 
             if (canceled) {
-                conn.disconnect();
+            	response.disconnect();
                 GuiHelper.runInEDT(new Runnable() {
                     @Override public void run() {
                         outputDisplay.setText(tr("Upload canceled"));
@@ -254,7 +252,7 @@ public class UploadDataGui extends ExtendedDialog {
                 canceled = false;
             }
             else {
-                final boolean success = finishUpConnection(conn);
+                final boolean success = finishUpConnection(response);
                 GuiHelper.runInEDT(new Runnable() {
                     @Override public void run() {
                         buttons.get(0).setEnabled(!success);
@@ -284,25 +282,20 @@ public class UploadDataGui extends ExtendedDialog {
      * @param int The length of the content to be sent to the server
      * @return HttpURLConnection The set up conenction
      */
-    private HttpURLConnection setupConnection(int contentLength) throws Exception {
+    private HttpClient setupConnection(int contentLength) throws Exception {
 
         // Upload URL
         URL url = new URL(OsmApi.getOsmApi().getBaseUrl() + "gpx/create");
 
         // Set up connection and log in
-        HttpURLConnection c = Utils.openHttpConnection(url);
-        c.setFixedLengthStreamingMode(contentLength);
-        c.setConnectTimeout(15000);
-        c.setRequestMethod("POST");
-        c.setDoOutput(true);
+        HttpClient c = HttpClient.create(url, "POST").setFixedLengthStreamingMode(contentLength).setConnectTimeout(15000);
         // unfortunately, addAuth() is protected, so we need to subclass OsmConnection
         // XXX make addAuth public.
         UploadOsmConnection.getInstance().addAuthHack(c);
 
-        c.addRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
-        c.addRequestProperty("Connection", "close"); // counterpart of keep-alive
-        c.addRequestProperty("Expect", "");
-        c.connect();
+        c.setHeader("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
+        c.setHeader("Connection", "close"); // counterpart of keep-alive
+        c.setHeader("Expect", "");
 
         return c;
     }
@@ -313,7 +306,7 @@ public class UploadDataGui extends ExtendedDialog {
 
      * @param HttpURLConnection The connection to check/finish up
      */
-    private boolean finishUpConnection(HttpURLConnection c) throws Exception {
+    private boolean finishUpConnection(Response c) throws Exception {
         String returnMsg = c.getResponseMessage();
         final boolean success = returnMsg.equals("OK");
 
@@ -341,7 +334,7 @@ public class UploadDataGui extends ExtendedDialog {
      * @param InputSteam
      * @param OutputStream
      */
-    private void flushToServer(InputStream in, OutputStream out, ProgressMonitor progressMonitor) throws Exception {
+/*    private void flushToServer(InputStream in, OutputStream out, ProgressMonitor progressMonitor) throws Exception {
         // Upload in 10 kB chunks
         byte[] buffer = new byte[10000];
         int nread;
@@ -363,7 +356,7 @@ public class UploadDataGui extends ExtendedDialog {
         progressMonitor.subTask("Waiting for server reply...");
         buffer = null;
     }
-
+*/
     /**
      * Generates the output string displayed in the PleaseWaitDialog.
      * @param int Bytes already uploaded
@@ -372,6 +365,7 @@ public class UploadDataGui extends ExtendedDialog {
     private String getProgressText(int cur, ProgressMonitor progressMonitor) {
         int max = progressMonitor.getTicksCount();
         int percent = Math.round(cur * 100 / max);
+        // FIXME method kept because of translated string
         return tr("Uploading GPX track: {0}% ({1} of {2})",
                         percent, formatBytes(cur), formatBytes(max));
     }
diff --git a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
index fa0bb64..e396af8 100644
--- a/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
+++ b/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadOsmConnection.java
@@ -2,7 +2,6 @@
 
 package org.openstreetmap.josm.plugins.DirectUpload;
 
-import java.net.HttpURLConnection;
 import java.util.List;
 
 import org.openstreetmap.josm.Main;
@@ -13,10 +12,11 @@ import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.io.OsmConnection;
 import org.openstreetmap.josm.io.OsmTransferException;
+import org.openstreetmap.josm.tools.HttpClient;
 
 /**
  * Work-around and utility class for DirectUpload.
- * 
+ *
  * @author ax
  */
 public class UploadOsmConnection extends OsmConnection {
@@ -33,15 +33,15 @@ public class UploadOsmConnection extends OsmConnection {
     }
 
     // make protected OsmConnection::addAuth() available to others
-    public void addAuthHack(HttpURLConnection connection) throws OsmTransferException {
+    public void addAuthHack(HttpClient connection) throws OsmTransferException {
         addAuth(connection);
     }
 
     /**
      * find which gpx layer holds the trace to upload. layers are tried in this order:
-     * 
+     *
      * 1. selected (*not* active - think "zoom to layer"), from first to last
-     * 2. not selectd - if there is only one 
+     * 2. not selectd - if there is only one
      * 3. active
      *
      * @return data of the selected gpx layer, or null if there is none
@@ -64,11 +64,11 @@ public class UploadOsmConnection extends OsmConnection {
             if (traceLayer == null) {
                 // if there is none, try the none selected gpx layers. if there is only one, use it.
                 if (gpxLayersRemaining.size() == 1) {
-                    traceLayer = gpxLayersRemaining.get(0); 
+                    traceLayer = gpxLayersRemaining.get(0);
                 }
                 // active layer
                 else if (mv.getActiveLayer() instanceof GpxLayer) {
-                    traceLayer = (GpxLayer) mv.getActiveLayer(); 
+                    traceLayer = (GpxLayer) mv.getActiveLayer();
                 }
             }
 
@@ -77,7 +77,7 @@ public class UploadOsmConnection extends OsmConnection {
                 return data;
             }
         }
-        
+
         return null;
     }
 }
diff --git a/build-common.xml b/build-common.xml
index 713ab88..69ccb99 100644
--- a/build-common.xml
+++ b/build-common.xml
@@ -220,7 +220,7 @@
             %ai: author date, ISO 8601 format
             -->
             <arg value="--pretty=format:%B%n%ai"/>
-            <arg value="HEAD"/>
+            <arg value="."/>
         </exec>
         <replaceregexp file="REVISION.XML" flags="s"
                        match=".*git-svn-id: [^@]*@([0-9]+).*(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
@@ -243,7 +243,7 @@
             <arg value="log"/>
             <arg value="-1"/>
             <arg value="--pretty=format:%at%n%ai"/>
-            <arg value="HEAD"/>
+            <arg value="."/>
         </exec>
         <replaceregexp file="REVISION.XML" flags="s"
                        match="\s*(\d*)\s+(\d{4}-\d{2}-\d{2}.\d{2}\:\d{2}\:\d{2}\s*[+-]\d{2}:?\d{2})\s*$"
diff --git a/svn-info.xml b/svn-info.xml
index 1f45c0a..eb275eb 100644
--- a/svn-info.xml
+++ b/svn-info.xml
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <info>
 <entry
-   path="plugins"
-   revision="31779"
-   kind="dir">
+   revision="31893"
+   kind="dir"
+   path="plugins">
 <url>https://svn.openstreetmap.org/applications/editors/josm/plugins</url>
 <relative-url>^/applications/editors/josm/plugins</relative-url>
 <repository>
@@ -11,9 +11,9 @@
 <uuid>b9d5c4c9-76e1-0310-9c85-f3177eceb1e4</uuid>
 </repository>
 <commit
-   revision="31774">
+   revision="31890">
 <author>donvip</author>
-<date>2015-11-21T01:59:09.598829Z</date>
+<date>2015-12-30T22:11:38.692650Z</date>
 </commit>
 </entry>
 </info>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/josm-plugins.git



More information about the Pkg-grass-devel mailing list