[Schmitzm-commits] r1319 - trunk/src/skrueger
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 1 02:09:57 CET 2010
Author: alfonx
Date: 2010-12-01 02:09:52 +0100 (Wed, 01 Dec 2010)
New Revision: 1319
Modified:
trunk/src/skrueger/Sitemap.java
Log:
Added automatic sumbitting of sitemap.xml .. untested
Modified: trunk/src/skrueger/Sitemap.java
===================================================================
--- trunk/src/skrueger/Sitemap.java 2010-12-01 00:03:04 UTC (rev 1318)
+++ trunk/src/skrueger/Sitemap.java 2010-12-01 01:09:52 UTC (rev 1319)
@@ -1,8 +1,11 @@
package skrueger;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Date;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -30,8 +33,10 @@
*/
public class Sitemap {
- Logger log = Logger.getLogger(Sitemap.class);
+ static String[] SEARCHENGINES = new String[] { "http://www.sitemapwriter.com/notify.php?crawler=all&url=" };
+ final static Logger log = Logger.getLogger(Sitemap.class);
+
private Document document;
final private Element urlsetElement;
@@ -151,7 +156,7 @@
// with indenting to make it human-readable
final TransformerFactory tf = TransformerFactory.newInstance();
- // TODO Ging mit xerces, geht nicht mehr mit xalan ?!
+ // TODO Ging mit xerces, geht nicht mehr mit xalan ?!
// tf.setAttribute("indent-number", new Integer(2));
final Transformer xformer = tf.newTransformer();
@@ -175,4 +180,18 @@
public int getSize() {
return size;
}
+
+ public static void submitToSearchEngines(String urlToSitemap) {
+ for (String se : SEARCHENGINES) {
+ log.info("Submitting " + urlToSitemap + " to " + se);
+ try {
+ URL url = new URL(se + urlToSitemap);
+
+ url.openConnection().connect();
+
+ } catch (Exception e) {
+ log.error("failed to submit " + urlToSitemap + " to " + se, e);
+ }
+ }
+ }
}
More information about the Schmitzm-commits
mailing list