r53941 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53940‎ | r53941 | r53942 >
Date:14:19, 29 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
Parse thread data from XML dumps where present, put it in the Page object for further processing (which is to come in the next commit)
Modified paths:
  • /trunk/mwdumper/src/org/mediawiki/importer/Page.java (modified) (history)
  • /trunk/mwdumper/src/org/mediawiki/importer/XmlDumpReader.java (modified) (history)

Diff [purge]

Index: trunk/mwdumper/src/org/mediawiki/importer/Page.java
@@ -25,13 +25,17 @@
2626
2727 package org.mediawiki.importer;
2828
 29+import java.util.Hashtable;
 30+
2931 public class Page {
3032 public Title Title;
3133 public int Id;
 34+ public Hashtable DiscussionThreadingInfo;
3235 public String Restrictions;
3336
3437 public Page() {
3538 // <restrictions> is optional...
3639 Restrictions = "";
 40+ DiscussionThreadingInfo = new Hashtable();
3741 }
3842 }
Index: trunk/mwdumper/src/org/mediawiki/importer/XmlDumpReader.java
@@ -114,6 +114,15 @@
115115 startElements.put("namespaces","namespaces");
116116 startElements.put("namespace","namespace");
117117
 118+ endElements.put("ThreadSubject","ThreadSubject");
 119+ endElements.put("ThreadParent","ThreadParent");
 120+ endElements.put("ThreadAncestor","ThreadAncestor");
 121+ endElements.put("ThreadPage","ThreadPage");
 122+ endElements.put("ThreadID","ThreadID");
 123+ endElements.put("ThreadSummaryPage","ThreadSummaryPage");
 124+ endElements.put("ThreadAuthor","ThreadAuthor");
 125+ endElements.put("ThreadEditStatus","ThreadEditStatus");
 126+ endElements.put("ThreadType","ThreadType");
118127 endElements.put("base","base");
119128 endElements.put("case","case");
120129 endElements.put("comment","comment");
@@ -193,6 +202,7 @@
194203 else if (qName == "title") readTitle();
195204 else if (qName == "restrictions") readRestrictions();
196205 // rare tags:
 206+ else if (qName.startsWith("Thread")) threadAttribute(qName);
197207 else if (qName == "mediawiki") closeMediaWiki();
198208 else if (qName == "siteinfo") closeSiteinfo();
199209 else if (qName == "sitename") readSitename();
@@ -201,6 +211,7 @@
202212 else if (qName == "case") readCase();
203213 else if (qName == "namespaces") closeNamespaces();
204214 else if (qName == "namespace") closeNamespace();
 215+// else throw(SAXException)new SAXException("Unrecognised "+qName+"(substring "+qName.length()+qName.substring(0,6)+")");
205216 } catch (IOException e) {
206217 throw (SAXException)new SAXException(e.getMessage()).initCause(e);
207218 }
@@ -208,6 +219,10 @@
209220
210221 // ----------
211222
 223+ void threadAttribute(String attrib) throws IOException {
 224+ page.DiscussionThreadingInfo.put(attrib, bufferContents());
 225+ }
 226+
212227 void openMediaWiki() throws IOException {
213228 siteinfo = null;
214229 writer.writeStartWiki();

Status & tagging log