[Schmitzm-commits] r1325 - in trunk: src/skrueger src_junit/schmitzm/lang
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 1 15:05:09 CET 2010
Author: alfonx
Date: 2010-12-01 15:05:08 +0100 (Wed, 01 Dec 2010)
New Revision: 1325
Modified:
trunk/src/skrueger/Sitemap.java
trunk/src_junit/schmitzm/lang/LangUtilTest.java
Log:
Modified: trunk/src/skrueger/Sitemap.java
===================================================================
--- trunk/src/skrueger/Sitemap.java 2010-12-01 13:26:03 UTC (rev 1324)
+++ trunk/src/skrueger/Sitemap.java 2010-12-01 14:05:08 UTC (rev 1325)
@@ -3,7 +3,9 @@
import java.io.FileWriter;
import java.io.StringWriter;
import java.io.Writer;
+import java.net.HttpURLConnection;
import java.net.URL;
+import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Date;
@@ -187,18 +189,31 @@
}
public static void submitToSearchEngines(String urlToSitemap) {
- for (String se : SEARCHENGINES) {
- log.info("Submitting " + urlToSitemap + " to " + se);
- try {
- URL url = new URL(se + urlToSitemap);
+ try {
- urlToSitemap = URLEncoder.encode(urlToSitemap);
+ urlToSitemap = URLEncoder.encode(urlToSitemap, "UTF-8");
+ for (String se : SEARCHENGINES) {
+ log.info("Submitting " + urlToSitemap + " to " + se);
+ try {
+ URL url = new URL(se + urlToSitemap);
- url.openConnection().connect();
+ URLConnection openConnection = url.openConnection();
+ if (openConnection instanceof HttpURLConnection) {
+ HttpURLConnection httpconnection = ((HttpURLConnection) openConnection);
+ if (httpconnection.getResponseCode() != 200) {
+ log.error("se returned ResponseCode "
+ + httpconnection.getResponseCode()
+ + " for " + urlToSitemap);
+ }
+ }
- } catch (Exception e) {
- log.error("failed to submit " + urlToSitemap + " to " + se, e);
+ } catch (Exception e) {
+ log.error("failed to submit " + urlToSitemap + " to " + se,
+ e);
+ }
}
+ } catch (Exception e) {
+ log.error("Error URL encoding " + urlToSitemap, e);
}
}
}
Modified: trunk/src_junit/schmitzm/lang/LangUtilTest.java
===================================================================
--- trunk/src_junit/schmitzm/lang/LangUtilTest.java 2010-12-01 13:26:03 UTC (rev 1324)
+++ trunk/src_junit/schmitzm/lang/LangUtilTest.java 2010-12-01 14:05:08 UTC (rev 1325)
@@ -1,8 +1,8 @@
package schmitzm.lang;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Enumeration;
More information about the Schmitzm-commits
mailing list