[Libreoffice-commits] .: 3 commits - swext/mediawiki
Jan Holesovsky
kendy at kemper.freedesktop.org
Wed Oct 13 05:41:17 PDT 2010
swext/mediawiki/build.xml | 4 -
swext/mediawiki/makefile.mk | 8 ++-
swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java | 5 +
swext/mediawiki/src/com/sun/star/wiki/Helper.java | 36 +++++++++++++-
swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java | 2
5 files changed, 50 insertions(+), 5 deletions(-)
New commits:
commit 6b3c101e0f0b4387a565855451435b899f535fca
Merge: cabb081... 6f71b2b...
Author: Jan Holesovsky <kendy at suse.cz>
Date: Wed Oct 13 11:30:56 2010 +0200
Merge commit 'ooo/OOO330_m10'
commit 6f71b2b3129763f356bb36d53dfdf13bd9a41a3a
Merge: 4582083... 3cc58dd...
Author: obo <obo at openoffice.org>
Date: Fri Oct 8 08:07:42 2010 +0200
CWS-TOOLING: integrate CWS fwk159
commit 3cc58ddaf37e1c0e2564dbc3296c221c9b2b9f7a
Author: Mikhail Voytenko <mav at openoffice.org>
Date: Wed Sep 22 14:42:41 2010 +0200
fwk159: #i114231# use login token if there is any
diff --git a/swext/mediawiki/build.xml b/swext/mediawiki/build.xml
index daa51e9..22f44e2 100644
--- a/swext/mediawiki/build.xml
+++ b/swext/mediawiki/build.xml
@@ -53,7 +53,7 @@
<!-- build options -->
<property name="sourcelevel" value="1.4"/>
<property name="verbose" value="false"/>
- <property name="debug" value="true"/>
+ <property name="debug" value="${antdebug}"/>
<!-- build classpath -->
<path id="classpath">
@@ -75,7 +75,7 @@
</target>
<target name="compile" depends="init">
- <javac debug="${debug}" destdir="${classes}" classpathref="classpath"
+ <javac debug="${debug}" debuglevel="lines,vars,source" destdir="${classes}" classpathref="classpath"
source="${sourcelevel}" verbose="${verbose}">
<src path="src"/>
</javac>
diff --git a/swext/mediawiki/makefile.mk b/swext/mediawiki/makefile.mk
index 9d05139..52d9900 100644
--- a/swext/mediawiki/makefile.mk
+++ b/swext/mediawiki/makefile.mk
@@ -41,7 +41,13 @@ COMMONS_LOGGING_JAR=$(SOLARVER)$/$(INPATH)$/bin$(UPDMINOREXT)$/commons-logging-1
COMP=fix_system_commons
.ENDIF
-ANT_FLAGS+=-Dcommons-codec-jar=$(COMMONS_CODEC_JAR) -Dcommons-lang-jar=$(COMMONS_LANG_JAR) -Dcommons-httpclient-jar=$(COMMONS_HTTPCLIENT_JAR) -Dcommons-logging-jar=$(COMMONS_LOGGING_JAR)
+.IF defined(debug) || defined(DEBUG)
+ANTDEBUG=true
+.ELSE
+ANTDEBUG=off
+.ENDIF
+
+ANT_FLAGS+=-Dcommons-codec-jar=$(COMMONS_CODEC_JAR) -Dcommons-lang-jar=$(COMMONS_LANG_JAR) -Dcommons-httpclient-jar=$(COMMONS_HTTPCLIENT_JAR) -Dcommons-logging-jar=$(COMMONS_LOGGING_JAR) -Dantdebug=$(ANTDEBUG)
# creates two files wiki-publisher.oxt and mediawiki_develop.zip, the second one might be used in further build process
ALLTAR: $(COMP) ANTBUILD
diff --git a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
index 27440e0..42cc7a8 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
@@ -35,6 +35,7 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback
protected String m_sEditTime = "";
protected String m_sEditToken = "";
+ protected String m_sLoginToken = "";
protected String m_sMainURL = "";
private int m_nWikiArticleHash = 0;
@@ -100,6 +101,10 @@ public class EditPageParser extends HTMLEditorKit.ParserCallback
{
this.m_sEditToken = ( String ) a.getAttribute( HTML.Attribute.VALUE );
}
+ else if ( sName.equalsIgnoreCase( "wpLoginToken" ) )
+ {
+ this.m_sLoginToken = ( String ) a.getAttribute( HTML.Attribute.VALUE );
+ }
}
}
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
index 8e20f44..a94dfc0 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java
@@ -784,6 +784,29 @@ public class Helper
return bResult;
}
+ static protected String GetLoginToken( String sLoginPage )
+ {
+ String sResult = "";
+ if ( sLoginPage != null && sLoginPage.length() > 0 )
+ {
+ try
+ {
+ StringReader aReader = new StringReader( sLoginPage );
+ HTMLEditorKit.Parser aParser = Helper.GetHTMLParser();
+ EditPageParser aCallbacks = new EditPageParser();
+
+ aParser.parse( aReader, aCallbacks, true );
+ sResult = aCallbacks.m_sLoginToken;
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return sResult;
+ }
+
static protected HostConfiguration Login( URI aMainURL, String sWikiUser, String sWikiPass, XComponentContext xContext )
throws com.sun.star.uno.Exception, java.io.IOException, WikiCancelException
{
@@ -799,10 +822,16 @@ public class Helper
ExecuteMethod( aGetCookie, aNewHostConfig, aURI, xContext, true );
int nResultCode = aGetCookie.getStatusCode();
- aGetCookie.releaseConnection();
-
+ String sLoginPage = null;
if ( nResultCode == 200 )
+ sLoginPage = aGetCookie.getResponseBodyAsString();
+
+ aGetCookie.releaseConnection();
+
+ if ( sLoginPage != null )
{
+ String sLoginToken = GetLoginToken( sLoginPage );
+
PostMethod aPost = new PostMethod();
URI aPostURI = new URI( aMainURL.getPath() + "index.php?title=Special:Userlogin&action=submitlogin" );
aPost.setPath( aPostURI.getEscapedPathQuery() );
@@ -810,6 +839,9 @@ public class Helper
aPost.addParameter( "wpName", sWikiUser );
aPost.addParameter( "wpRemember", "1" );
aPost.addParameter( "wpPassword", sWikiPass );
+ if ( sLoginToken.length() > 0 )
+ aPost.addParameter( "wpLoginToken", sLoginToken );
+
String[][] pArgs = GetSpecialArgs( xContext, aMainURL.getHost() );
if ( pArgs != null )
for ( int nArgInd = 0; nArgInd < pArgs.length; nArgInd++ )
diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
index a7d8369..1859ca5 100644
--- a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
+++ b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
@@ -145,6 +145,8 @@ public class WikiArticle
if ( nResultCode == 200 )
sWebPage = aRequest.getResponseBodyAsString();
+ aRequest.releaseConnection();
+
if ( sWebPage != null )
{
StringReader r = new StringReader(sWebPage);
More information about the Libreoffice-commits
mailing list