diff options
author | David A. Madore <david+git@madore.org> | 2011-08-31 18:00:39 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2011-08-31 18:00:39 +0200 |
commit | 3d44424a1738ce3f70c82780f4441e077c1194a3 (patch) | |
tree | 409c76b95dbde797771a56839c7feff2be95f6df /org/madore | |
parent | 1565d0be33cb4d83ee6fa63081bf09ae0a68693d (diff) | |
download | damlengine-3d44424a1738ce3f70c82780f4441e077c1194a3.tar.gz damlengine-3d44424a1738ce3f70c82780f4441e077c1194a3.tar.bz2 damlengine-3d44424a1738ce3f70c82780f4441e077c1194a3.zip |
Allow the source file to force ctime on blog entries.
Diffstat (limited to 'org/madore')
-rw-r--r-- | org/madore/damlengine/WeblogPopulate.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/org/madore/damlengine/WeblogPopulate.java b/org/madore/damlengine/WeblogPopulate.java index 24c61dc..0d28d92 100644 --- a/org/madore/damlengine/WeblogPopulate.java +++ b/org/madore/damlengine/WeblogPopulate.java @@ -45,8 +45,10 @@ public final class WeblogPopulate { final PreparedStatement checkSt = conn.prepareStatement("SELECT sha1 FROM entries WHERE id=?"); - final PreparedStatement insertSt + final PreparedStatement insertNSt = conn.prepareStatement("INSERT INTO entries(id,edate,lang,title,title_xml,content,sha1) VALUES (?,?,?,?,?::xml,?::xml,?)"); + final PreparedStatement insertCSt + = conn.prepareStatement("INSERT INTO entries(id,edate,lang,title,title_xml,content,sha1,cdate) VALUES (?,?,?,?,?::xml,?::xml,?,?::timestamptz)"); final PreparedStatement updateSt = conn.prepareStatement("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1)=(?,DEFAULT,?,?,?::xml,?::xml,?) WHERE id=?"); final PreparedStatement clearCatSt @@ -71,6 +73,11 @@ public final class WeblogPopulate { String date = ent.getAttributeNS(null, "date"); if ( ! Pattern.matches("^\\d{4}-\\d{2}-\\d{2}$", date) ) throw new IllegalArgumentException("entry date attribute must be of the form YYYY-MM-DD"); + String cdate; + if ( ent.hasAttributeNS(null, "cdate") ) + cdate = ent.getAttributeNS(null, "cdate"); + else + cdate = null; String catStr = ent.getAttributeNS(null, "cat"); String[] catList = catStr.split("\\s+"); String lang = LangHelper.getLangRec(ent); @@ -95,9 +102,15 @@ public final class WeblogPopulate { updateSt.setString(4, titleXml); updateSt.setString(5, content); updateSt.setString(6, digest); + updateSt.setInt(7, id); updateSt.executeUpdate(); } else { System.err.println("Registering entry "+id); + PreparedStatement insertSt; + if ( cdate == null ) + insertSt = insertNSt; + else + insertSt = insertCSt; insertSt.setInt(1, id); insertSt.setString(2, date); insertSt.setString(3, lang); @@ -105,6 +118,8 @@ public final class WeblogPopulate { insertSt.setString(5, titleXml); insertSt.setString(6, content); insertSt.setString(7, digest); + if ( cdate != null ) + insertSt.setString(8, cdate); insertSt.executeUpdate(); } clearCatSt.setInt(1, id); @@ -121,7 +136,8 @@ public final class WeblogPopulate { } checkSt.close(); - insertSt.close(); + insertNSt.close(); + insertCSt.close(); updateSt.close(); clearCatSt.close(); setCatSt.close(); |