Changeset 12431 in osm for applications/editors/josm


Ignore:
Timestamp:
2008-12-20T02:02:42+01:00 (16 years ago)
Author:
frederik
Message:
  • new import command for JOSM remote control plugin
File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/remotecontrol/src/org/openstreetmap/josm/plugins/remotecontrol/RequestProcessor.java

    r9465 r12431  
    77import java.io.*;
    88import java.net.Socket;
     9import java.net.URLDecoder;
    910import java.util.Date;
    1011import java.util.HashMap;
     
    4142         * Constructor
    4243         *
    43          * @param request The WMS request
     44         * @param request
    4445         */
    4546        public RequestProcessor(Socket request)
     
    109110                if (Main.pref.getBoolean("remotecontrol.always-confirm", false)) {
    110111                        if (JOptionPane.showConfirmDialog(Main.parent,
    111                                 tr("Remote Control has been asked to load data from the API. Request details: {0}. Do you want to allow this?", url),
     112                                "<html>" + tr("Remote Control has been asked to load data from the API.") +
     113                        "<br>" + tr("Request details: {0}", url) + "<br>" + tr("Do you want to allow this?"),
    112114                                tr("Confirm Remote Control action"),
    113115                                JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
     
    202204                                        });
    203205                                }
     206            } else if (command.equals("/import")) {
     207                if (Main.pref.getBoolean("remotecontrol.always-confirm", false)) {
     208                        if (JOptionPane.showConfirmDialog(Main.parent,
     209                                "<html>" + tr("Remote Control has been asked to import data from the following URL:") +
     210                        "<br>" + url +
     211                        "<br>" + tr("Do you want to allow this?"),
     212                                tr("Confirm Remote Control action"),
     213                                JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
     214                                        sendForbidden(out);
     215                                        return;
     216                        }
     217                }
     218                                if (!(args.containsKey("url"))) {
     219                                        sendBadRequest(out);
     220                                        System.out.println("'import' remote control request must have url parameter");
     221                                        return;
     222                                }
     223                                try {
     224                                        if (!Main.pref.getBoolean("remotecontrol.permission.import", true))
     225                                                throw new LoadDeniedException();
     226                                       
     227                    DownloadTask osmTask = new DownloadOsmTask();
     228                                        osmTask.loadUrl(false, URLDecoder.decode(args.get("url"), "UTF-8"));
     229                                } catch (LoadDeniedException ex) {
     230                                        System.out.println("RemoteControl: import forbidden by preferences");
     231                                } catch (Exception ex) {
     232                                        sendError(out);
     233                                        System.out.println("RemoteControl: Error parsing import remote control request:");
     234                                        ex.printStackTrace();
     235                                        return;
     236                                }
     237                // TODO: select/zoom to downloaded
    204238            }
    205239                        sendHeader(out, "200 OK", "text/plain", false);
Note: See TracChangeset for help on using the changeset viewer.