X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/post/PostJob.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/post/PostJob.java index 24f807e..4ee5c35 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/post/PostJob.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/post/PostJob.java @@ -2,6 +2,7 @@ package net.sourceforge.phpeclipse.wiki.actions.mediawiki.post; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.StringWriter; import java.util.HashMap; @@ -9,7 +10,6 @@ import net.sourceforge.phpeclipse.wiki.actions.ProblemConsole; import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia; import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.Content; import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.MediaWikiConnector; -import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.XMLReader; import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.MethodException; import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.PageNotEditableException; import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.UnexpectedAnswerException; @@ -17,6 +17,8 @@ import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin; import net.sourceforge.phpeclipse.wiki.internal.Configuration; import net.sourceforge.phpeclipse.wiki.preferences.Util; import net.sourceforge.phpeclipse.wiki.velocity.EditorText; +import net.sourceforge.phpeclipse.wiki.xml.Page; +import net.sourceforge.phpeclipse.wiki.xml.XStreamManager; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; @@ -81,7 +83,7 @@ public class PostJob extends WorkspaceJob { return template; } - private void selectWiki(String timestamp, String body, MediaWikiConnector connector, String actionUrl, String wikiName) + private void uploadWiki(String timestamp, String body, MediaWikiConnector connector, String actionUrl, String wikiName) throws UnexpectedAnswerException, MethodException, PageNotEditableException, InterruptedException { String url = generateUrl(configuration.getURL(), wikiName); @@ -104,7 +106,7 @@ public class PostJob extends WorkspaceJob { actionUrl = wikipedia.getActionUrl(); } try { - if (files.length>0) { + if (files.length > 0) { // prefetch for error messages file = files[0]; } @@ -113,9 +115,9 @@ public class PostJob extends WorkspaceJob { int work = 0; StringBuffer buffer = new StringBuffer(); HashMap map = new HashMap(); - String wikiTitle; + String wikiURLTitle; - monitor.subTask("Login user:"+user); + monitor.subTask("Login user:" + user); connector = new MediaWikiConnector(); success = connector.login(wikipedia, actionUrl, user, password, false); if (success) { @@ -123,34 +125,40 @@ public class PostJob extends WorkspaceJob { try { file = files[i]; is = file.getContents(); - String wikiName = Util.getFileWikiName(file); + wikiURLTitle = Util.getURLWikiName(file); String body = StoreWikipediaAction.getInputStreamAsString(is, wikipedia.getCharSet()); char ch; boolean noContent = checkNoContent(body); String srcBasePath = Util.getWikiTextsPath(file); String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH); - String filename = Util.getXMLFileName(file, binBasePath, srcBasePath); - IPath path = new Path(filename); + String fileXMLName = Util.getXMLFileName(file, binBasePath, srcBasePath); + IPath path = new Path(fileXMLName); IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); - String timestamp = null; + + String timestamp = ""; if (xmlFile.exists()) { try { - timestamp = XMLReader.getDateTimestamp(xmlFile.getContents()); + Page page = XStreamManager.fromXML(xmlFile.getContents()); + if (page != null) { + // we've stored information about the article at download time which + // may be more exactly as the standard information + if (!page.isEmpty()) { + // at least one revision exists: + timestamp = page.get(0).getTimestamp(); + } + wikiURLTitle = page.getURLTitle(); + } + // timestamp = XMLReader.getDateTimestamp(xmlFile.getContents()); } catch (Exception e2) { } } - if (timestamp == null) { - // Date d = new Date(); - // timestamp = String.valueOf(d.getTime()); - timestamp = ""; - } if (noContent) { console.println("File: " + file.getLocation().toString() + "\n==>upload not allowed; Wiki text contains no content"); } else { monitor.subTask("Upload: " + file.getLocation().toString()); - selectWiki(timestamp, body, connector, actionUrl, wikiName); + uploadWiki(timestamp, body, connector, actionUrl, wikiURLTitle); } } catch (CoreException e1) { @@ -168,7 +176,6 @@ public class PostJob extends WorkspaceJob { if (isModal(this)) { // The progress dialog is still open show the message - console.reportError(); } else { setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); // setProperty(IProgressConstants.ACTION_PROPERTY, getWikisCompletedAction()); @@ -219,7 +226,6 @@ public class PostJob extends WorkspaceJob { } if (isModal(this)) { // The progress dialog is still open show the message - console.reportError(); } return Status.CANCEL_STATUS; }