[Schmitzm-commits] r2266 - in trunk/schmitzm-core/src/main: java/de/schmitzm/io java/de/schmitzm/swing resources/de/schmitzm/io/resource/locales

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Fri Mar 1 10:42:10 CET 2013


Author: mojays
Date: 2013-03-01 10:42:10 +0100 (Fri, 01 Mar 2013)
New Revision: 2266

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/WebFilesChooserPanel.java
   trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle.properties
   trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle_de.properties
Log:
IOUtil: Exception messages on remote access refined
WebFilesChooserPanel: parent component for ExceptionDialog

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java	2013-03-01 00:56:49 UTC (rev 2265)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/IOUtil.java	2013-03-01 09:42:10 UTC (rev 2266)
@@ -58,6 +58,7 @@
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLDecoder;
+import java.net.UnknownHostException;
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
 import java.security.MessageDigest;
@@ -869,6 +870,8 @@
           // if all retries fail and FileNotFoundException we throw a special message
           if ( err instanceof FileNotFoundException )
             throw new FileNotFoundException(R("IOUtil.downloadUrlToFile.err.remote.file",err.getMessage()));
+          if ( err instanceof UnknownHostException )
+            throw new UnknownHostException(R("IOUtil.downloadUrlToFile.err.unknown.host",err.getMessage()));
           // otherwise we throw the error
           throw err;
         }
@@ -1928,12 +1931,20 @@
 	    return new ArrayList<String>();
 	  if ( proxy == null )
         proxy = getGlobalConnectionSettings().getProxyForConnection();
-	  // load document from URL
-	  URLConnection conn = url.openConnection(proxy);
-	  conn.setConnectTimeout(1000);
-	  conn.setReadTimeout(1000);
-	  String str = IOUtil.convertStreamToString(conn.getInputStream()); 
-	  closeInputStream(conn.getInputStream());
+	 
+	  String str = "";
+	  try {
+  	    // load document from URL
+	    URLConnection conn = url.openConnection(proxy);
+  	    conn.setConnectTimeout(1000);
+  	    conn.setReadTimeout(1000);
+  	    str = IOUtil.convertStreamToString(conn.getInputStream()); 
+  	    closeInputStream(conn.getInputStream());
+	  } catch (UnknownHostException err) {
+        throw new UnknownHostException(R("IOUtil.extractLinksFromURL.err.unknown.host",err.getMessage()));
+      } catch (FileNotFoundException err) {
+        throw new FileNotFoundException(R("IOUtil.extractLinksFromURL.err.file.remote",err.getMessage()));
+      }
 
 	  // create matcher to extract "href" tags from document
 	  final String  regEx = "href=\"([^\"]*)\"";

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/WebFilesChooserPanel.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/WebFilesChooserPanel.java	2013-03-01 00:56:49 UTC (rev 2265)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/WebFilesChooserPanel.java	2013-03-01 09:42:10 UTC (rev 2266)
@@ -349,9 +349,9 @@
         dirsTable.setFiles(new ArrayList<URL>(dirs));
         setText( baseURL != null ? baseURL.toExternalForm() : "" );
       } catch (SocketTimeoutException err) {
-        ExceptionDialog.show(err);
+        ExceptionDialog.show(this,err);
       } catch (IOException err) {
-        ExceptionDialog.show(err);
+        ExceptionDialog.show(this,err);
         filesTable.setFiles(null);
         dirsTable.setFiles(null);
       } finally {

Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle.properties	2013-03-01 00:56:49 UTC (rev 2265)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle.properties	2013-03-01 09:42:10 UTC (rev 2266)
@@ -32,5 +32,9 @@
 # ------ in Package de.schmitzm.io                     ------
 # -----------------------------------------------------------
 
+IOUtil.extractLinksFromURL.err.remote.file=URL can not be accessed on server: ${0}
+IOUtil.extractLinksFromURL.err.unknown.host=Server is not available: ${0}
+
 IOUtil.downloadUrlToFile.err.local.file=Download file can not be saved (locally): ${0}
 IOUtil.downloadUrlToFile.err.remote.file=Download file can not be accessed on server: ${0}
+IOUtil.downloadUrlToFile.err.unknown.host=Download server is not available: ${0}

Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle_de.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle_de.properties	2013-03-01 00:56:49 UTC (rev 2265)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/io/resource/locales/IOResourceBundle_de.properties	2013-03-01 09:42:10 UTC (rev 2266)
@@ -32,5 +32,9 @@
 # ------ in Package de.schmitzm.io          ------
 # ------------------------------------------------
 
-IOUtil.downloadUrlToFile.err.local.file=Download-Datei kann (lokal) nicht gespeichert werden ${0}
-IOUtil.downloadUrlToFile.err.remote.file=Datei kann nicht vom Server geladen werden: ${0}
+IOUtil.extractLinksFromURL.err.remote.file=URL kann nicht vom Server geladen werden: ${0}
+IOUtil.extractLinksFromURL.err.unknown.host=Server ist nicht erreichbar: ${0}
+
+IOUtil.downloadUrlToFile.err.local.file=Die Download-Datei kann (lokal) nicht gespeichert werden ${0}
+IOUtil.downloadUrlToFile.err.remote.file=Die Datei kann nicht vom Server geladen werden: ${0}
+IOUtil.downloadUrlToFile.err.unknown.host=Der Download-Server ist nicht erreichbar: ${0}



More information about the Schmitzm-commits mailing list