Index: /trunk/src/org/openstreetmap/josm/actions/AboutAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/AboutAction.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/actions/AboutAction.java	(revision 1879)
@@ -58,11 +58,12 @@
         URL u = Main.class.getResource("/REVISION");
         if(u == null) {
-            try {
-                manifest = true;
-                u = new URL("jar:" + Main.class.getProtectionDomain().getCodeSource().getLocation().toString()
-                        + "!/META-INF/MANIFEST.MF");
-            } catch (MalformedURLException e) {
-                e.printStackTrace();
-            }
+            //            try {
+            manifest = true;
+            //                u = new URL("jar:" + Main.class.getProtectionDomain().getCodeSource().getLocation().toString()
+            //                        + "!/META-INF/MANIFEST.MF");
+            u = Main.class.getResource("/META-INF/MANIFEST.MF");
+            //            } catch (MalformedURLException e) {
+            //                e.printStackTrace();
+            //            }
         }
         revision = loadFile(u, manifest);
@@ -155,5 +156,5 @@
 
         JOptionPane.showMessageDialog(Main.parent, about, tr("About JOSM..."),
-        JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
+                JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
     }
 
@@ -194,6 +195,7 @@
         area.setEditable(false);
         Font font = Font.getFont("monospaced");
-        if (font != null)
+        if (font != null) {
             area.setFont(font);
+        }
         if (resource == null)
             return area;
@@ -202,6 +204,7 @@
             in = new BufferedReader(new InputStreamReader(resource.openStream()));
             String s = "";
-            for (String line = in.readLine(); line != null; line = in.readLine())
+            for (String line = in.readLine(); line != null; line = in.readLine()) {
                 s += line + "\n";
+            }
             if (manifest) {
                 s = Pattern.compile("\n ", Pattern.DOTALL).matcher(s).replaceAll("");
Index: /trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java	(revision 1879)
@@ -106,4 +106,3 @@
         return file;
     }
-
 }
Index: /trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java	(revision 1879)
@@ -65,3 +65,7 @@
     }
 
+    @Override
+    protected void updateEnabledState() {
+        setEnabled(! Main.applet);
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java	(revision 1879)
@@ -320,4 +320,8 @@
     @Override
     protected void updateEnabledState() {
+        if (Main.applet) {
+            setEnabled(false);
+            return;
+        }
         boolean check =  Main.map != null
         && Main.map.mapView !=null
Index: /trunk/src/org/openstreetmap/josm/actions/SaveAsAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/SaveAsAction.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/actions/SaveAsAction.java	(revision 1879)
@@ -7,4 +7,5 @@
 import java.io.File;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.layer.Layer;
 import org.openstreetmap.josm.tools.Shortcut;
Index: /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 1879)
@@ -7,4 +7,5 @@
 import java.util.Collection;
 import java.util.concurrent.Future;
+import java.util.logging.Logger;
 
 import javax.swing.JCheckBox;
@@ -16,4 +17,5 @@
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.DataSource;
+import org.openstreetmap.josm.gui.ExceptionDialogUtil;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
@@ -34,4 +36,6 @@
  */
 public class DownloadOsmTask implements DownloadTask {
+    private static final Logger logger = Logger.getLogger(DownloadOsmTask.class.getName());
+
     private static Bounds currentBounds;
     private Future<Task> task = null;
@@ -42,4 +46,6 @@
         private DataSet dataSet;
         private boolean newLayer;
+        private boolean cancelled;
+        private Exception lastException;
 
         public Task(boolean newLayer, OsmServerReader reader, ProgressMonitor progressMonitor) {
@@ -50,5 +56,17 @@
 
         @Override public void realRun() throws IOException, SAXException, OsmTransferException {
-            dataSet = reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
+            try {
+                dataSet = reader.parseOsm(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
+            } catch(Exception e) {
+                if (cancelled) {
+                    logger.warning(tr("Ignoring exception because download has been cancelled. Exception was: {0}" + e.toString()));
+                    return;
+                }
+                if (e instanceof OsmTransferException) {
+                    lastException = e;
+                } else {
+                    lastException = new OsmTransferException(e);
+                }
+            }
         }
 
@@ -84,4 +102,10 @@
 
         @Override protected void finish() {
+            if (cancelled)
+                return;
+            if (lastException != null) {
+                ExceptionDialogUtil.explainException(lastException);
+                return;
+            }
             if (dataSet == null)
                 return; // user canceled download or error occurred
Index: /trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java	(revision 1879)
@@ -20,4 +20,5 @@
 import java.util.StringTokenizer;
 import java.util.Map.Entry;
+import java.util.logging.Logger;
 
 import javax.swing.JOptionPane;
@@ -37,4 +38,5 @@
  */
 public class ServerSidePreferences extends Preferences {
+    static private final Logger logger = Logger.getLogger(ServerSidePreferences.class.getName());
 
     private final Connection connection;
@@ -181,8 +183,11 @@
 
     @Override public Collection<Bookmark> loadBookmarks() {
+        URL url = null;
         try {
             Collection<Bookmark> bookmarks;
-            BufferedReader in = new BufferedReader(new InputStreamReader(new URL("http://"+connection.serverUrl.getHost()+"/josm/bookmarks").openStream()));
             bookmarks = new LinkedList<Bookmark>();
+            url = new URL("http://"+connection.serverUrl.getHost()+"/josm/bookmarks");
+            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
+
             for (String line = in.readLine(); line != null; line = in.readLine()) {
                 StringTokenizer st = new StringTokenizer(line, ",");
@@ -209,4 +214,7 @@
         } catch (IOException e) {
             e.printStackTrace();
+        } catch(SecurityException e) {
+            e.printStackTrace();
+            logger.warning(tr("Failed to load bookmarks from ''{0}'' for security reasons. Exception was: {1}",  url == null ? "null" : url.toExternalForm(), e.toString()));
         }
         return Collections.emptyList();
Index: /trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java	(revision 1879)
+++ /trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java	(revision 1879)
@@ -0,0 +1,118 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.io.OsmApi;
+import org.openstreetmap.josm.io.OsmTransferException;
+
+/**
+ * This utility class provides static methods which explain various exceptions to the user.
+ * 
+ */
+public class ExceptionDialogUtil {
+
+    /**
+     * just static utility functions. no constructor
+     */
+    private ExceptionDialogUtil() {}
+
+
+    /**
+     * Explains an exception with a generic message dialog
+     * 
+     * @param e the exception
+     */
+    public static void explainGeneric(Exception e) {
+        String msg = e.getMessage();
+        if (msg == null) {
+            msg = e.toString();
+        }
+        e.printStackTrace();
+        OptionPaneUtil.showMessageDialog(
+                Main.parent,
+                msg,
+                tr("Error"),
+                JOptionPane.ERROR_MESSAGE
+        );
+    }
+
+    /**
+     * Explains a {@see SecurityException} which has caused an {@see OsmTransferException}.
+     * This is most likely happening when user tries to access the OSM API from whitin an
+     * applet which wasn't loaded from the API server.
+     * 
+     * @param e the exception
+     */
+
+    public static void explainSecurityException(OsmTransferException e) {
+        String apiUrl = OsmApi.getOsmApi().getBaseUrl();
+        String host = tr("unknown");
+        try {
+            host = new URL(apiUrl).getHost();
+        } catch(MalformedURLException ex) {
+            // shouldn't happen
+        }
+
+        String message = tr("<html>Failed to open a connection to the remote server<br>"
+                + "''{0}''<br>"
+                + "for security reasons. This is most likely because you are running<br>"
+                + "in an applet and because you didn''t load your applet from ''{1}''.</html>",
+                apiUrl, host
+        );
+        OptionPaneUtil.showMessageDialog(
+                Main.parent,
+                message,
+                tr("Security exception"),
+                JOptionPane.ERROR_MESSAGE
+        );
+
+    }
+
+    /**
+     * Replies the first {@see SecurityException} in a chain of nested exceptions.
+     * null, if no {@see SecurityException} is in this chain.
+     * 
+     * @param e the root exception
+     * @return the first {@see SecurityException} in a chain of nested exceptions
+     */
+    protected static SecurityException getSecurityChildException(Exception e) {
+        Throwable t = e;
+        while(t != null && ! (t instanceof SecurityException)) {
+            t = t.getCause();
+        }
+        return (SecurityException)t;
+    }
+
+    /**
+     * Explains an {@see OsmTransferException} to the user.
+     * 
+     * @param e the {@see OsmTransferException}
+     */
+    public static void explainOsmTransferException(OsmTransferException e) {
+        if (getSecurityChildException(e) != null) {
+            explainSecurityException(e);
+            return;
+        }
+        explainGeneric(e);
+    }
+
+    /**
+     * Explains an {@see Exception} to the user.
+     * 
+     * @param e the {@see Exception}
+     */
+    public static void explainException(Exception e) {
+        if (e instanceof OsmTransferException) {
+            explainOsmTransferException((OsmTransferException)e);
+            return;
+        }
+        explainGeneric(e);
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/GettingStarted.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/gui/GettingStarted.java	(revision 1879)
@@ -5,36 +5,25 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Future;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import java.awt.BorderLayout;
 import java.awt.EventQueue;
 
-import javax.swing.JScrollPane;
 import javax.swing.JEditorPane;
 import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.EmptyBorder;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
-import javax.swing.border.EmptyBorder;
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.AboutAction;
 import org.openstreetmap.josm.io.CacheCustomContent;
 import org.openstreetmap.josm.tools.LanguageInfo;
 import org.openstreetmap.josm.tools.OpenBrowser;
 import org.openstreetmap.josm.tools.WikiReader;
-import org.openstreetmap.josm.actions.AboutAction;
 
 public class GettingStarted extends JPanel {
     private String content = "";
-    static private String styles = "<style type=\"text/css\">\n"+
-            "body { font-family: sans-serif; font-weight: bold; }\n"+
-            "h1 {text-align: center;}\n"+
-            "</style>\n";
+    static private String styles = "<style type=\"text/css\">\n"
+        + "body { font-family: sans-serif; font-weight: bold; }\n" + "h1 {text-align: center;}\n" + "</style>\n";
 
     public class LinkGeneral extends JEditorPane implements HyperlinkListener {
@@ -46,4 +35,5 @@
             addHyperlinkListener(this);
         }
+
         public void hyperlinkUpdate(HyperlinkEvent e) {
             if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
@@ -56,6 +46,6 @@
      * Grabs current MOTD from cache or webpage and parses it.
      */
-    private class assignContent extends CacheCustomContent {
-        public assignContent() {
+    private class MotdContent extends CacheCustomContent {
+        public MotdContent() {
             super("motd.html", CacheCustomContent.INTERVAL_DAILY);
         }
@@ -68,18 +58,12 @@
          * @see org.openstreetmap.josm.io.CacheCustomContent#updateData()
          */
+        @Override
         protected byte[] updateData() {
             String motd = new WikiReader().readLang("StartupPage");
-            if(motd.length() == 0)
-            {
-                motd = "<html>" + styles + "<body><h1>" +
-                "JOSM - " + tr("Java OpenStreetMap Editor") +
-                "</h1>\n<h2 align=\"center\">(" +
-                tr("Message of the day not available") +
-                ")</h2></html>";
-            }
-            else
-            {
-                motd = motd.replace("<!-- VERSION -->", tr("- running version is {0}",
-                AboutAction.getVersionString()));
+            if (motd.length() == 0) {
+                motd = "<html>" + styles + "<body><h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")
+                + "</h1>\n<h2 align=\"center\">(" + tr("Message of the day not available") + ")</h2></html>";
+            } else {
+                motd = motd.replace("<!-- VERSION -->", tr("- running version is {0}", AboutAction.getVersionString()));
             }
             // Save this to prefs in case JOSM is updated so MOTD can be refreshed
@@ -98,5 +82,5 @@
             // 1. Not yet written - but so isn't the interval variable, so it gets updated anyway
             // 2. Cannot be written (e.g. while developing). Obviously we don't want to update
-            //    everytime because of something we can't read.
+            // everytime because of something we can't read.
             return (Main.pref.getInteger("cache.motd.html.version", -999) == myVersion)
             && Main.pref.get("cache.motd.html.lang").equals(myLang);
@@ -105,20 +89,13 @@
 
     /**
-     * Initializes getting the MOTD as well as enabling the FileDrop Listener.
-     * Displays a message while the MOTD is downloading.
+     * Initializes getting the MOTD as well as enabling the FileDrop Listener. Displays a message
+     * while the MOTD is downloading.
      */
     public GettingStarted() {
         super(new BorderLayout());
-        final LinkGeneral lg = new LinkGeneral(
-            "<html>" +
-            styles +
-            "<h1>" +
-            "JOSM - " +
-            tr("Java OpenStreetMap Editor") +
-            "</h1><h2 align=\"center\">" +
-            tr("Downloading \"Message of the day\"") +
-            "</h2>");
+        final LinkGeneral lg = new LinkGeneral("<html>" + styles + "<h1>" + "JOSM - " + tr("Java OpenStreetMap Editor")
+                + "</h1><h2 align=\"center\">" + tr("Downloading \"Message of the day\"") + "</h2>");
         JScrollPane scroller = new JScrollPane(lg);
-        scroller.setViewportBorder(new EmptyBorder(10,100,10,100));
+        scroller.setViewportBorder(new EmptyBorder(10, 100, 10, 100));
         add(scroller, BorderLayout.CENTER);
 
@@ -126,11 +103,12 @@
         Thread t = new Thread(new Runnable() {
             public void run() {
-                if (content.length() == 0 && Main.pref.getBoolean("help.displaymotd", true))
-                    content = new assignContent().updateIfRequiredString();
+                if (content.length() == 0 && Main.pref.getBoolean("help.displaymotd", true)) {
+                    content = new MotdContent().updateIfRequiredString();
+                }
 
                 EventQueue.invokeLater(new Runnable() {
                     public void run() {
-                       lg.setText(content);
-                       //lg.moveCaretPosition(0);
+                        lg.setText(content);
+                        // lg.moveCaretPosition(0);
                     }
                 });
Index: /trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java	(revision 1879)
@@ -66,5 +66,12 @@
     public SlippyMapChooser() {
         super();
-        cachedLoader = new OsmFileCacheTileLoader(this);
+        try {
+            cachedLoader = new OsmFileCacheTileLoader(this);
+        } catch(SecurityException e) {
+            // set to null if a SecurityException was thrown
+            // while creating the cachedLoader
+            //
+            cachedLoader = null;
+        }
         uncachedLoader = new OsmTileLoader(this);
         setZoomContolsVisible(false);
@@ -74,5 +81,9 @@
         // the area before the component has been displayed the first time
         setBounds(new Rectangle(getMinimumSize()));
-        setFileCacheEnabled(Main.pref.getBoolean("slippy_map_chooser.file_cache", true));
+        if (cachedLoader == null) {
+            setFileCacheEnabled(false);
+        } else {
+            setFileCacheEnabled(Main.pref.getBoolean("slippy_map_chooser.file_cache", true));
+        }
         setMaxTilesInMemory(Main.pref.getInteger("slippy_map_chooser.max_tiles", 1000));
 
Index: /trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java	(revision 1879)
@@ -99,27 +99,21 @@
     public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
         progressMonitor.beginTask(tr("Contacting OSM Server..."), 10);
+        InputStream in = null;
         try {
             progressMonitor.indeterminateSubTask(null);
-            final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, progressMonitor.createSubTaskMonitor(9, false));
+            in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, progressMonitor.createSubTaskMonitor(9, false));
             if (in == null)
                 return null;
-            final DataSet data = OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
-            in.close();
-            activeConnection = null;
-            return data;
-        } catch (IOException e) {
-            if (cancel)
-                return null;
-            throw new OsmTransferException(e);
-        } catch (SAXException e) {
-            throw new OsmTransferException(e);
+            return OsmReader.parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
         } catch(OsmTransferException e) {
             throw e;
         } catch (Exception e) {
-            if (cancel)
-                return null;
             throw new OsmTransferException(e);
         } finally {
             progressMonitor.finishTask();
+            if (in != null) {
+                try {in.close();} catch(IOException e) {}
+            }
+            activeConnection = null;
         }
     }
Index: unk/src/org/openstreetmap/josm/io/MyHttpHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/MyHttpHandler.java	(revision 1878)
+++ 	(revision )
@@ -1,33 +1,0 @@
-/* Dummy handler just to load the override URLConnection class */
-package org.openstreetmap.josm.io;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.Proxy;
-
-// This is also a java.net.URLStreamHandler
-// Basically a copy of sun.net.www.protocol.http.Handler
-public class MyHttpHandler extends sun.net.www.protocol.http.Handler  {
-    protected String proxy;
-    protected int proxyPort;
-
-    public MyHttpHandler() {
-        super();
-        proxy = null;
-        proxyPort = -1;
-    }
-
-    protected java.net.URLConnection openConnection(URL u)
-    throws IOException {
-        return openConnection(u, (Proxy) null);
-    }
-    public MyHttpHandler(String proxy, int port) {
-        this.proxy = proxy;
-        proxyPort = port;
-    }
-
-    protected java.net.URLConnection openConnection(URL u, Proxy p)
-    throws IOException {
-        return new MyHttpURLConnection(u, p, this);
-    }
-}
Index: unk/src/org/openstreetmap/josm/io/MyHttpURLConnection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/MyHttpURLConnection.java	(revision 1878)
+++ 	(revision )
@@ -1,22 +1,0 @@
-/* Stupid package to override the restriction on payloads with DELETEs */
-package org.openstreetmap.josm.io;
-
-import java.io.*;
-import java.net.URL;
-import java.net.Proxy;
-
-public class MyHttpURLConnection extends sun.net.www.protocol.http.HttpURLConnection {
-            protected MyHttpURLConnection(URL u, Proxy p, sun.net.www.protocol.http.Handler handler)
-            {
-              super(u,p,handler);
-            }
-
-public synchronized OutputStream getOutputStream()
-                    throws IOException {
-                String oldmethod = method;
-                method = "POST";
-                OutputStream temp = super.getOutputStream();
-                method = oldmethod;
-                return temp;
-}
-}
Index: /trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 1879)
@@ -21,4 +21,5 @@
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Properties;
@@ -268,8 +269,11 @@
      * @throws OsmTransferException if something goes wrong
      */
-    public void deletePrimitive(OsmPrimitive osm) throws OsmTransferException {
+    public void deletePrimitive(OsmPrimitive osm, ProgressMonitor monitor) throws OsmTransferException {
         initialize();
-        // legacy mode does not require payload. normal mode (0.6 and up) requires payload for version matching.
-        sendRequest("DELETE", OsmPrimitiveType.from(osm).getAPIName()+"/" + osm.id, version.equals("0.5") ? null : toXml(osm, false));
+        // can't use a the individual DELETE method in the 0.6 API. Java doesn't allow
+        // submitting a DELETE request with content, the 0.6 API requires it, however. Falling back
+        // to diff upload.
+        //
+        uploadDiff(Collections.singleton(osm), monitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
     }
 
@@ -400,5 +404,5 @@
         while(true) { // the retry loop
             try {
-                URL url = new URL(new URL(getBaseUrl()), urlSuffix, new MyHttpHandler());
+                URL url = new URL(new URL(getBaseUrl()), urlSuffix);
                 System.out.print(requestMethod + " " + url + "... ");
                 activeConnection = (HttpURLConnection)url.openConnection();
Index: /trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 1879)
@@ -136,5 +136,5 @@
                                     NAME_FORMATTER.getName(osm),
                                     osm.id));
-                    makeApiRequest(osm);
+                    makeApiRequest(osm,progressMonitor);
                     processed.add(osm);
                     progressMonitor.worked(1);
@@ -148,7 +148,7 @@
     }
 
-    void makeApiRequest(OsmPrimitive osm) throws OsmTransferException {
+    void makeApiRequest(OsmPrimitive osm, ProgressMonitor progressMonitor) throws OsmTransferException {
         if (osm.deleted) {
-            api.deletePrimitive(osm);
+            api.deletePrimitive(osm, progressMonitor);
         } else if (osm.id == 0) {
             api.createPrimitive(osm);
Index: /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 1879)
@@ -43,5 +43,7 @@
      * @author imi
      */
-    public static enum OverlayPosition {NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST}
+    public static enum OverlayPosition {
+        NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST
+    }
 
     /**
@@ -51,6 +53,6 @@
 
     /**
-     * Add here all ClassLoader whose ressource should be searched.
-     * Plugin's class loaders are added by main.
+     * Add here all ClassLoader whose ressource should be searched. Plugin's class loaders are added
+     * by main.
      */
     public static final List<ClassLoader> sources = new LinkedList<ClassLoader>();
@@ -58,7 +60,7 @@
     /**
      * Return an image from the specified location.
-     *
-     * @param subdir    The position of the directory, e.g. "layer"
-     * @param name      The icons name (without the ending of ".png")
+     * 
+     * @param subdir The position of the directory, e.g. "layer"
+     * @param name The icons name (without the ending of ".png")
      * @return The requested Image.
      */
@@ -67,42 +69,35 @@
         if (icon == null) {
             String ext = name.indexOf('.') != -1 ? "" : ".png";
-            throw new NullPointerException("/images/"+subdir+"/"+name+ext+" not found");
+            throw new NullPointerException("/images/" + subdir + "/" + name + ext + " not found");
         }
         return icon;
     }
 
-    public static ImageIcon getIfAvailable(String subdir, String name)
-    {
-        return getIfAvailable((Collection<String>)null, null, subdir, name);
-    }
-    public static final ImageIcon getIfAvailable(String[] dirs, String id, String subdir, String name)
-    {
+    public static ImageIcon getIfAvailable(String subdir, String name) {
+        return getIfAvailable((Collection<String>) null, null, subdir, name);
+    }
+
+    public static final ImageIcon getIfAvailable(String[] dirs, String id, String subdir, String name) {
         return getIfAvailable(Arrays.asList(dirs), id, subdir, name);
     }
 
     /**
-     * Like {@link #get(String)}, but does not throw and return <code>null</code>
-     * in case of nothing is found. Use this, if the image to retrieve is optional.
-     */
-    public static ImageIcon getIfAvailable(Collection<String> dirs, String id, String subdir, String name)
-    {
+     * Like {@link #get(String)}, but does not throw and return <code>null</code> in case of nothing
+     * is found. Use this, if the image to retrieve is optional.
+     */
+    public static ImageIcon getIfAvailable(Collection<String> dirs, String id, String subdir, String name) {
         if (name == null)
             return null;
-        if (name.startsWith("http://"))
-        {
+        if (name.startsWith("http://")) {
             Image img = cache.get(name);
-            if(img == null)
-            {
-                try
-                {
-                    MirroredInputStream is = new MirroredInputStream(name,
-                            new File(Main.pref.getPreferencesDir(), "images").toString());
-                    if(is != null)
-                    {
+            if (img == null) {
+                try {
+                    MirroredInputStream is = new MirroredInputStream(name, new File(Main.pref.getPreferencesDir(),
+                    "images").toString());
+                    if (is != null) {
                         img = Toolkit.getDefaultToolkit().createImage(is.getFile().toURI().toURL());
                         cache.put(name, img);
                     }
-                }
-                catch(IOException e) {
+                } catch (IOException e) {
                 }
             }
@@ -115,9 +110,9 @@
         }
         String ext = name.indexOf('.') != -1 ? "" : ".png";
-        String full_name = subdir+name+ext;
+        String full_name = subdir + name + ext;
         String cache_name = full_name;
         /* cache separately */
-        if(dirs != null && dirs.size() > 0) {
-            cache_name = "id:"+id+":"+full_name;
+        if (dirs != null && dirs.size() > 0) {
+            cache_name = "id:" + id + ":" + full_name;
         }
 
@@ -125,5 +120,5 @@
         if (img == null) {
             // getImageUrl() does a ton of "stat()" calls and gets expensive
-            // and redundant when you have a whole ton of objects.  So,
+            // and redundant when you have a whole ton of objects. So,
             // index the cache by the name of the icon we're looking for
             // and don't bother to create a URL unless we're actually
@@ -139,55 +134,71 @@
     }
 
-    private static URL getImageUrl(String path, String name)
-    {
-        if(path.startsWith("resource://"))
-        {
+    private static URL getImageUrl(String path, String name) {
+        if (path.startsWith("resource://")) {
             String p = path.substring("resource://".length());
-            for (ClassLoader source : sources)
-            {
+            for (ClassLoader source : sources) {
                 URL res;
-                if ((res = source.getResource(p+name)) != null)
+                if ((res = source.getResource(p + name)) != null)
                     return res;
             }
-        }
-        else
-        {
+        } else {
             try {
                 File f = new File(path, name);
-                if(f.exists())
+                if (f.exists())
                     return f.toURI().toURL();
-            } catch (MalformedURLException e) {}
+            } catch (MalformedURLException e) {
+            }
         }
         return null;
     }
 
-    private static URL getImageUrl(String imageName, Collection<String> dirs)
-    {
-        URL u;
+    private static URL getImageUrl(String imageName, Collection<String> dirs) {
+        URL u = null;
+
         // Try passed directories first
-        if(dirs != null)
-        {
-            for (String name : dirs)
-            {
-                u = getImageUrl(name, imageName);
-                if(u != null) return u;
+        if (dirs != null) {
+            for (String name : dirs) {
+                try {
+                    u = getImageUrl(name, imageName);
+                    if (u != null)
+                        return u;
+                } catch (SecurityException e) {
+                    System.out.println(tr(
+                            "Warning: failed to acccess directory ''{0}'' for security reasons. Exception was: {1}",
+                            name, e.toString()));
+                }
+
             }
         }
         // Try user-preference directory
-        u = getImageUrl(Main.pref.getPreferencesDir()+"images", imageName);
-        if(u != null) return u;
+        String dir = Main.pref.getPreferencesDir() + "images";
+        try {
+            u = getImageUrl(dir, imageName);
+            if (u != null)
+                return u;
+        } catch (SecurityException e) {
+            System.out.println(tr(
+                    "Warning: failed to acccess directory ''{0}'' for security reasons. Exception was: {1}", dir, e
+                    .toString()));
+        }
 
         // Try plugins and josm classloader
         u = getImageUrl("resource://images/", imageName);
-        if(u != null) return u;
+        if (u != null)
+            return u;
 
         // Try all other ressource directories
-        for (String location : Main.pref.getAllPossiblePreferenceDirs())
-        {
-            u = getImageUrl(location+"images", imageName);
-            if(u != null) return u;
+        for (String location : Main.pref.getAllPossiblePreferenceDirs()) {
+            u = getImageUrl(location + "images", imageName);
+            if (u != null)
+                return u;
             u = getImageUrl(location, imageName);
-            if(u != null) return u;
-        }
+            if (u != null)
+                return u;
+        }
+        System.out
+        .println(tr(
+                "Fatal: failed to locate image ''{0}''. This is a serious configuration problem. JOSM will stop working.",
+                imageName));
         return null;
     }
@@ -201,19 +212,20 @@
 
     public static Cursor getCursor(String name, String overlay) {
-        ImageIcon img = get("cursor",name);
+        ImageIcon img = get("cursor", name);
         if (overlay != null) {
-            img = overlay(img, "cursor/modifier/"+overlay, OverlayPosition.SOUTHEAST);
+            img = overlay(img, "cursor/modifier/" + overlay, OverlayPosition.SOUTHEAST);
         }
         Cursor c = Toolkit.getDefaultToolkit().createCustomCursor(img.getImage(),
-                name.equals("crosshair") ? new Point(10,10) : new Point(3,2), "Cursor");
+                name.equals("crosshair") ? new Point(10, 10) : new Point(3, 2), "Cursor");
         return c;
     }
 
     /**
-     * @return an icon that represent the overlay of the two given icons. The
-     * second icon is layed on the first relative to the given position.
+     * @return an icon that represent the overlay of the two given icons. The second icon is layed
+     * on the first relative to the given position.
      */
     public static ImageIcon overlay(Icon ground, String overlayImage, OverlayPosition pos) {
-        GraphicsConfiguration conf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
+        GraphicsConfiguration conf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
+        .getDefaultConfiguration();
         int w = ground.getIconWidth();
         int h = ground.getIconHeight();
@@ -221,5 +233,5 @@
         int wo = overlay.getIconWidth();
         int ho = overlay.getIconHeight();
-        BufferedImage img = conf.createCompatibleImage(w,h, Transparency.TRANSLUCENT);
+        BufferedImage img = conf.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
         Graphics g = img.createGraphics();
         ground.paintIcon(null, g, 0, 0);
@@ -231,14 +243,14 @@
             break;
         case NORTHEAST:
-            x = w-wo;
+            x = w - wo;
             y = 0;
             break;
         case SOUTHWEST:
             x = 0;
-            y = h-ho;
+            y = h - ho;
             break;
         case SOUTHEAST:
-            x = w-wo;
-            y = h-ho;
+            x = w - wo;
+            y = h - ho;
             break;
         }
@@ -256,6 +268,7 @@
     }
 
-    /* from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/
-     * License: "feel free to use"
+    /*
+     * from: http://www.jidesoft.com/blog/2008/02/29/rotate-an-icon-in-java/ License:
+     * "feel free to use"
      */
     final static double DEGREE_90 = 90.0 * Math.PI / 180.0;
@@ -263,11 +276,11 @@
     /**
      * Creates a rotated version of the input image.
-     *
-     * @param c            The component to get properties useful for painting, e.g. the foreground
-     *                     or background color.
-     * @param icon         the image to be rotated.
+     * 
+     * @param c The component to get properties useful for painting, e.g. the foreground or
+     * background color.
+     * @param icon the image to be rotated.
      * @param rotatedAngle the rotated angle, in degree, clockwise. It could be any double but we
-     *                     will mod it with 360 before using it.
-     *
+     * will mod it with 360 before using it.
+     * 
      * @return the image after rotating.
      */
@@ -295,6 +308,5 @@
             w = (int) (iw * Math.sin(DEGREE_90 - radian) + ih * Math.sin(radian));
             h = (int) (iw * Math.sin(radian) + ih * Math.sin(DEGREE_90 - radian));
-        }
-        else {
+        } else {
             w = (int) (ih * Math.sin(DEGREE_90 - radian) + iw * Math.sin(radian));
             h = (int) (ih * Math.sin(radian) + iw * Math.sin(DEGREE_90 - radian));
@@ -309,5 +321,5 @@
 
         // move the graphics center point to the center of the icon.
-        g2d.translate(w/2, h/2);
+        g2d.translate(w / 2, h / 2);
 
         // rotate the graphics about the center point of the icon
@@ -329,5 +341,5 @@
         if (type == null)
             throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "type"));
-        return get("data",type.getAPIName());
+        return get("data", type.getAPIName());
     }
 }
Index: /trunk/src/org/openstreetmap/josm/tools/WikiReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/WikiReader.java	(revision 1878)
+++ /trunk/src/org/openstreetmap/josm/tools/WikiReader.java	(revision 1879)
@@ -4,4 +4,5 @@
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
@@ -10,7 +11,9 @@
 import org.openstreetmap.josm.tools.LanguageInfo;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
 /**
  * Read a trac-wiki page.
- *
+ * 
  * @author imi
  */
@@ -29,8 +32,8 @@
     /**
      * Read the page specified by the url and return the content.
-     *
-     * If the url is within the baseurl path, parse it as an trac wikipage and
-     * replace relative pathes etc..
-     *
+     * 
+     * If the url is within the baseurl path, parse it as an trac wikipage and replace relative
+     * pathes etc..
+     * 
      * @return Either the string of the content of the wiki page.
      * @throws IOException Throws, if the page could not be loaded.
@@ -45,15 +48,53 @@
     public String readLang(String text) {
         String languageCode = LanguageInfo.getLanguageCodeWiki();
-        String url = baseurl + "/wiki/"+languageCode+text;
+        String url = baseurl + "/wiki/" + languageCode + text;
         String res = "";
+        InputStream in = null;
         try {
-            res = readFromTrac(new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8")));
-        } catch (IOException ioe) {}
-        if(res.length() == 0 && languageCode.length() != 0)
-        {
-            url = baseurl + "/wiki/"+text;
+            in = new URL(url).openStream();
+            res = readFromTrac(new BufferedReader(new InputStreamReader(in, "utf-8")));
+        } catch (IOException ioe) {
+            System.out.println(tr("Warning: failed to read MOTD from ''{0}''. Exception was: {1}", url, ioe
+                    .toString()));
+        } catch(SecurityException e) {
+            System.out.println(tr(
+                    "Warning: failed to read MOTD from ''{0}'' for security reasons. Exception was: {1}", url, e
+                    .toString()));
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                }
+            }
+        }
+        if (res.length() == 0 && languageCode.length() != 0) {
+            url = baseurl + "/wiki/" + text;
             try {
-                res = readFromTrac(new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8")));
-            } catch (IOException ioe) {}
+                in = new URL(url).openStream();
+            } catch (IOException e) {
+                System.out.println(tr("Warning: failed to read MOTD from ''{0}''. Exception was: {1}", url, e
+                        .toString()));
+                return res;
+            } catch (SecurityException e) {
+                System.out.println(tr(
+                        "Warning: failed to read MOTD from ''{0}'' for security reasons. Exception was: {1}", url, e
+                        .toString()));
+                return res;
+            }
+            try {
+                res = readFromTrac(new BufferedReader(new InputStreamReader(in, "utf-8")));
+            } catch (IOException ioe) {
+                System.out.println(tr("Warning: failed to read MOTD from ''{0}''. Exception was: {1}", url, ioe
+                        .toString()));
+                return res;
+            } finally {
+                if (in != null) {
+                    try {
+                        in.close();
+                    } catch (IOException e) {
+                    }
+                }
+            }
         }
         return res;
@@ -63,6 +104,7 @@
         String b = "";
         for (String line = in.readLine(); line != null; line = in.readLine()) {
-            if(!line.contains("[[TranslatedPages]]"))
+            if (!line.contains("[[TranslatedPages]]")) {
                 b += line.replaceAll(" />", ">") + "\n";
+            }
         }
         return "<html>" + b + "</html>";
@@ -74,21 +116,22 @@
         String b = "";
         for (String line = in.readLine(); line != null; line = in.readLine()) {
-            if (line.contains("<div id=\"searchable\">"))
+            if (line.contains("<div id=\"searchable\">")) {
                 inside = true;
-            else if (line.contains("<div class=\"wiki-toc trac-nav\""))
+            } else if (line.contains("<div class=\"wiki-toc trac-nav\"")) {
                 transl = true;
-            else if (line.contains("<div class=\"wikipage searchable\">"))
+            } else if (line.contains("<div class=\"wikipage searchable\">")) {
                 inside = true;
-            else if (line.contains("<div class=\"buttons\">"))
+            } else if (line.contains("<div class=\"buttons\">")) {
                 inside = false;
+            }
             if (inside && !transl) {
-                b += line.replaceAll("<img src=\"/", "<img src=\""+baseurl+"/")
-                         .replaceAll("href=\"/", "href=\""+baseurl+"/")
-                         .replaceAll(" />", ">") + "\n";
+                b += line.replaceAll("<img src=\"/", "<img src=\"" + baseurl + "/").replaceAll("href=\"/",
+                        "href=\"" + baseurl + "/").replaceAll(" />", ">")
+                        + "\n";
+            } else if (transl && line.contains("</div>")) {
+                transl = false;
             }
-            else if (transl && line.contains("</div>"))
-                transl = false;
         }
-        if(b.indexOf("      Describe ") >= 0)
+        if (b.indexOf("      Describe ") >= 0)
             return "";
         return "<html>" + b + "</html>";
