This is an automated email from the ASF dual-hosted git repository.
jimjag pushed a commit to branch AOO50X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO50X by this push:
new 5cd02f6fe1 Wiki Publisher: publish thru the MediaWiki API; drop
Tomcat, commons-httpclient and commons-codec since no longer needed
5cd02f6fe1 is described below
commit 5cd02f6fe181247fd94d5ba9dc6906332c3596d9
Author: Jim Jagielski <[email protected]>
AuthorDate: Thu Oct 22 09:19:12 2026 -0400
Wiki Publisher: publish thru the MediaWiki API; drop Tomcat,
commons-httpclient and commons-codec since no longer needed
Scraping index.php no longer worked with current MediaWiki, and failed
saves were reported as
success. Tomcat was only built for commons-logging's servlet class.
(cherry picked from commit 33efb51f76a78baf5a276c335781687d66cf274a)
---
main/NOTICE | 46 +--
main/apache-commons/java/codec/makefile.mk | 74 ----
main/apache-commons/java/httpclient/makefile.mk | 76 ----
main/apache-commons/java/logging/makefile.mk | 12 +-
main/apache-commons/patches/codec.patch | 20 --
main/apache-commons/patches/httpclient.patch | 31 --
.../patches/httpclient_no_javadoc.patch | 11 -
main/apache-commons/patches/logging.patch | 8 +
main/apache-commons/prj/build.lst | 4 +-
main/apache-commons/prj/d.lst | 2 -
main/configure.ac | 73 +---
main/external_deps.lst | 20 +-
main/set_soenv.in | 4 -
main/solenv/ant/externals.xml | 12 -
main/swext/mediawiki/build.xml | 13 -
main/swext/mediawiki/makefile.mk | 20 +-
.../mediawiki/src/THIRDPARTYLICENSEREADME.html | 148 --------
.../src/com/sun/star/wiki/EditPageParser.java | 137 +-------
.../mediawiki/src/com/sun/star/wiki/Helper.java | 379 +++++++-------------
.../sun/star/wiki/MainThreadDialogExecutor.java | 45 +--
.../src/com/sun/star/wiki/WikiArticle.java | 256 ++++----------
.../com/sun/star/wiki/WikiEditSettingDialog.java | 33 +-
.../sun/star/wiki/WikiProtocolSocketFactory.java | 163 ---------
.../src/com/sun/star/wiki/WikiSession.java | 389 +++++++++++++++++++++
main/swext/mediawiki/src/description.xml | 2 +-
main/swext/prj/build.lst | 2 +-
main/tomcat/makefile.mk | 60 ----
main/tomcat/prj/build.lst | 2 -
main/tomcat/prj/d.lst | 1 -
main/tomcat/tomcat.patch | 25 --
30 files changed, 652 insertions(+), 1416 deletions(-)
diff --git a/main/NOTICE b/main/NOTICE
index ba57742e19..2f98062f20 100644
--- a/main/NOTICE
+++ b/main/NOTICE
@@ -19,10 +19,8 @@ Apache projects:
- Apache Lucene
- Apache Portable Runtime
- Apache Portable Runtime Utility Library
-- Apache Commons - used by MediaWiki Publisher extension
-- Apache Jakarta HttpClient - used by MediaWiki Publisher extension
+- Apache Commons
- Apache POI - OOXML encryption code from Apache POI was ported to our
main/oox/source/core/encryption.cxx
-- Apache Tomcat - used by MediaWiki Publisher extension
The notices from these projects are following:
@@ -72,25 +70,6 @@ modifications by Spyglass Inc., Carnegie Mellon University,
and
Bell Communications Research, Inc (Bellcore).
-Apache Commons Codec
-Copyright 2002-2012 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (https://www.apache.org/).
-
-src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java contains
-test data from http://aspell.sourceforge.net/test/batch0.tab.
-
-Copyright (C) 2002 Kevin Atkinson ([email protected]). Verbatim copying
-and distribution of this entire article is permitted in any medium,
-provided this notice is preserved.
-
-Apache Jakarta HttpClient
-Copyright 1999-2007 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (https://www.apache.org/).
-
Apache Commons Lang
Copyright 2001-2012 The Apache Software Foundation
@@ -145,29 +124,6 @@ Scala includes software developed at
LAMP/EPFL (https://lamp.epfl.ch/) and
Lightbend, Inc. (https://www.lightbend.com/).
-
-Apache Tomcat
-Copyright 1999-2012 The Apache Software Foundation
-
-This product includes software developed by
-The Apache Software Foundation (https://www.apache.org/).
-
-Java Management Extensions (JMX) support is provided by
-the MX4J package, which is open source software. The
-original software and related information is available
-at http://mx4j.sourceforge.net/.
-
-The Windows Installer is built with the Nullsoft
-Scriptable Install System (NSIS), which is
-open source software. The original software and
-related information is available at
-http://nsis.sourceforge.net/.
-
-Java compilation software for JSP pages is provided by Eclipse,
-which is open source software. The original software and
-related information is available at
-https://www.eclipse.org/.
-
____
As part of the base system this product also includes code from the following
diff --git a/main/apache-commons/java/codec/makefile.mk
b/main/apache-commons/java/codec/makefile.mk
deleted file mode 100644
index 1932e18381..0000000000
--- a/main/apache-commons/java/codec/makefile.mk
+++ /dev/null
@@ -1,74 +0,0 @@
-#**************************************************************
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#**************************************************************
-
-
-
-PRJ=..$/..
-
-PRJNAME=apache-commons
-TARGET=commons-codec
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-# override buildfile
-ANT_BUILDFILE=build.xml
-
-.INCLUDE : antsettings.mk
-
-.IF "$(SOLAR_JAVA)" != "" && "$(ENABLE_MEDIAWIKI)" == "YES"
-# --- Files --------------------------------------------------------
-
-TARFILE_NAME=commons-codec-1.9-src
-TARFILE_MD5=db87f7004cefc9d17f7ac841f86122bd
-#TARFILE_NAME=commons-codec-1.6-src
-#TARFILE_MD5=2e482c7567908d334785ce7d69ddfff7
-
-TARFILE_ROOTDIR=commons-codec-1.9-src
-#TARFILE_ROOTDIR=commons-codec-1.6-src
-
-#PATCH_FILES=
-#PATCH_FILES=$(PRJ)$/patches$/codec.patch
-
-#CONVERTFILES=build.xml
-
-OUT2CLASS=dist$/commons-codec-1.9.jar
-#OUT2CLASS=dist$/commons-codec-1.6-SNAPSHOT.jar
-
-.IF "$(JAVACISGCJ)"=="yes"
-JAVA_HOME=
-.EXPORT : JAVA_HOME
-BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj
-f $(ANT_BUILDFILE) jar
-.ELSE
-BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE)
jar
-.ENDIF
-
-.ENDIF # $(SOLAR_JAVA)!= ""
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : set_ext.mk
-.INCLUDE : target.mk
-
-.IF "$(SOLAR_JAVA)" != "" && "$(ENABLE_MEDIAWIKI)" == "YES"
-.INCLUDE : tg_ext.mk
-.ENDIF
diff --git a/main/apache-commons/java/httpclient/makefile.mk
b/main/apache-commons/java/httpclient/makefile.mk
deleted file mode 100644
index cf1339e563..0000000000
--- a/main/apache-commons/java/httpclient/makefile.mk
+++ /dev/null
@@ -1,76 +0,0 @@
-#**************************************************************
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#**************************************************************
-
-
-
-PRJ=..$/..
-
-PRJNAME=apache-commons
-TARGET=commons-httpclient
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-
-# override buildfile
-ANT_BUILDFILE=build.xml
-
-.INCLUDE : antsettings.mk
-
-TAR!:=$(GNUTAR)
-
-.IF "$(SOLAR_JAVA)" != "" && "$(ENABLE_MEDIAWIKI)" == "YES"
-# --- Files --------------------------------------------------------
-
-TARFILE_NAME=commons-httpclient-3.1-src
-TARFILE_MD5=2c9b0f83ed5890af02c0df1c1776f39b
-
-TARFILE_ROOTDIR=commons-httpclient-3.1
-
-PATCH_FILES=
\
- $(PRJ)$/patches$/httpclient.patch \
- $(PRJ)$/patches$/httpclient_no_javadoc.patch
-
-#CONVERTFILES=build.xml
-
-OUT2CLASS=dist$/commons-httpclient.jar
-
-COMMONS_LOGGING_JAR=..$/..$/..$/..$/$(INPATH)$/class$/commons-logging-1.1.3.jar
-COMMONS_CODEC_JAR=..$/..$/..$/..$/$/$(INPATH)$/class$/commons-codec-1.9.jar
-
-.IF "$(JAVACISGCJ)"=="yes"
-JAVA_HOME=
-.EXPORT : JAVA_HOME
-BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj
-Dcommons-logging.jar=$(COMMONS_LOGGING_JAR)
-Dcommons-codec.jar=$(COMMONS_CODEC_JAR) -f $(ANT_BUILDFILE) dist
-.ELSE
-BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)"
-Dcommons-logging.jar=$(COMMONS_LOGGING_JAR)
-Dcommons-codec.jar=$(COMMONS_CODEC_JAR) -f $(ANT_BUILDFILE) dist
-.ENDIF
-
-.ENDIF # $(SOLAR_JAVA)!= ""
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : set_ext.mk
-.INCLUDE : target.mk
-
-.IF "$(SOLAR_JAVA)" != "" && "$(ENABLE_MEDIAWIKI)" == "YES"
-.INCLUDE : tg_ext.mk
-.ENDIF
diff --git a/main/apache-commons/java/logging/makefile.mk
b/main/apache-commons/java/logging/makefile.mk
index 4474558231..57a332cceb 100644
--- a/main/apache-commons/java/logging/makefile.mk
+++ b/main/apache-commons/java/logging/makefile.mk
@@ -35,7 +35,7 @@ ANT_BUILDFILE=build.xml
.INCLUDE : antsettings.mk
-.IF "$(SOLAR_JAVA)" != "" && ( "$(ENABLE_MEDIAWIKI)" == "YES" ||
"$(ENABLE_REPORTBUILDER)" == "YES" )
+.IF "$(SOLAR_JAVA)" != "" && "$(ENABLE_REPORTBUILDER)" == "YES"
# --- Files --------------------------------------------------------
TARFILE_NAME=commons-logging-1.1.3-src
@@ -53,16 +53,12 @@ CONVERTFILES=build.xml
OUT2CLASS=target$/commons-logging-1.1.3.jar
#OUT2CLASS=target$/commons-logging-1.1.1-SNAPSHOT.jar
-.IF "$(SYSTEM_TOMCAT)" != "YES"
-SERVLETAPI_JAR := $(SOLARVER)$/$(INPATH)$/bin$(UPDMINOREXT)$/servlet-api.jar
-.ENDIF
-
.IF "$(JAVACISGCJ)"=="yes"
JAVA_HOME=
.EXPORT : JAVA_HOME
-BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj
-Dservletapi.jar=$(SERVLETAPI_JAR) -f $(ANT_BUILDFILE) compile build-jar
+BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -Dbuild.compiler=gcj
-f $(ANT_BUILDFILE) compile build-jar
.ELSE
-BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE)
-Dservletapi.jar=$(SERVLETAPI_JAR) compile build-jar
+BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f $(ANT_BUILDFILE)
compile build-jar
.ENDIF
.ENDIF # $(SOLAR_JAVA)!= ""
@@ -72,6 +68,6 @@ BUILD_ACTION=$(ANT) -Dbuild.label="build-$(RSCREVISION)" -f
$(ANT_BUILDFILE) -Ds
.INCLUDE : set_ext.mk
.INCLUDE : target.mk
-.IF "$(SOLAR_JAVA)" != "" && ( "$(ENABLE_MEDIAWIKI)" == "YES" ||
"$(ENABLE_REPORTBUILDER)" == "YES" )
+.IF "$(SOLAR_JAVA)" != "" && "$(ENABLE_REPORTBUILDER)" == "YES"
.INCLUDE : tg_ext.mk
.ENDIF
diff --git a/main/apache-commons/patches/codec.patch
b/main/apache-commons/patches/codec.patch
deleted file mode 100644
index ca3bcc9f71..0000000000
--- a/main/apache-commons/patches/codec.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- misc/build/commons-codec-1.9-src/build.xml-old 2012-05-05
22:12:32.000000000 -0500
-+++ misc/build/commons-codec-1.9-src/build.xml 2012-05-05 22:16:00.000000000
-0500
-@@ -96,7 +96,6 @@
- </target>
- <target name="dist" depends="compile, javadoc" description="Create binary
distribution">
- <mkdir dir="${dist.home}"/>
-- <copy file="${basedir}/LICENSE.txt" todir="${dist.home}"/>
- <copy file="${basedir}/NOTICE.txt" todir="${dist.home}"/>
- <copy file="${basedir}/RELEASE-NOTES.txt" todir="${dist.home}"/>
- <antcall target="jar"/>
-@@ -104,8 +103,7 @@
- <target name="jar" depends="compile" description="Create jar">
- <mkdir dir="${dist.home}"/>
- <mkdir dir="${build.home}/classes/META-INF"/>
-- <copy file="${basedir}/LICENSE.txt"
tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
-- <copy file="${basedir}/LICENSE.txt"
tofile="${build.home}/classes/META-INF/NOTICE.txt"/>
-+ <copy file="${basedir}/NOTICE.txt"
tofile="${build.home}/classes/META-INF/NOTICE.txt"/>
- <jar jarfile="${dist.home}/${final.name}.jar"
basedir="${build.home}/classes">
- <manifest>
- <attribute name="Specification-Title" value="Commons Codec"/>
diff --git a/main/apache-commons/patches/httpclient.patch
b/main/apache-commons/patches/httpclient.patch
deleted file mode 100644
index 315cd7b1e3..0000000000
--- a/main/apache-commons/patches/httpclient.patch
+++ /dev/null
@@ -1,31 +0,0 @@
---- misc/commons-httpclient-3.1/build.xml 2007-08-18 11:02:14.000000000
+0200
-+++ misc/build/commons-httpclient-3.1/build.xml 2014-03-11
15:25:51.000000000 +0100
-@@ -181,14 +181,16 @@
- destdir ="${build.home}/classes"
- debug ="${compile.debug}"
- deprecation ="${compile.deprecation}"
-- optimize ="${compile.optimize}">
-+ optimize ="${compile.optimize}"
-+ encoding ="iso8859-1">
- <classpath refid="compile.classpath"/>
- </javac>
- <javac srcdir ="${source.home}/examples"
- destdir ="${build.home}/examples"
- debug ="${compile.debug}"
- deprecation ="${compile.deprecation}"
-- optimize ="${compile.optimize}">
-+ optimize ="${compile.optimize}"
-+ encoding ="iso8859-1">
- <classpath refid="compile.classpath"/>
- </javac>
- </target>
-@@ -199,7 +201,8 @@
- destdir ="${build.home}/tests"
- debug ="${compile.debug}"
- deprecation ="${compile.deprecation}"
-- optimize ="${compile.optimize}">
-+ optimize ="${compile.optimize}"
-+ encoding ="iso8859-1">
- <classpath refid="test.classpath"/>
- </javac>
- <copy todir="${build.home}/tests" filtering="on">
diff --git a/main/apache-commons/patches/httpclient_no_javadoc.patch
b/main/apache-commons/patches/httpclient_no_javadoc.patch
deleted file mode 100644
index a9bd95de1d..0000000000
--- a/main/apache-commons/patches/httpclient_no_javadoc.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- misc/commons-httpclient-3.1/build.xml 2007-08-18 11:02:14.000000000
+0200
-+++ misc/build/commons-httpclient-3.1/build.xml 2012-07-09
09:59:21.364830700 +0200
-@@ -142,7 +142,7 @@
-
- <!-- ========== Targets: "External" Targets ===============================
-->
-
-- <target name="dist" depends="compile,doc"
-+ <target name="dist" depends="compile"
- description="Create binary distribution">
- <mkdir dir="${dist.home}"/>
- <copy file="LICENSE.txt" todir="${dist.home}"/>
diff --git a/main/apache-commons/patches/logging.patch
b/main/apache-commons/patches/logging.patch
index 653360e45a..0c5d3a3448 100644
--- a/main/apache-commons/patches/logging.patch
+++ b/main/apache-commons/patches/logging.patch
@@ -13,3 +13,11 @@
<!-- Should Java compilations set the 'debug' compiler option? -->
<property name="compile.debug" value="true"/>
+@@ -364,6 +364,7 @@
+ <classpath refid="compile.classpath"/>
+
+ <exclude name="org/apache/commons/logging/impl/Log4J*.java"/>
++ <exclude
name="org/apache/commons/logging/impl/ServletContextCleaner.java"/>
+
+ <exclude
name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"
+ unless="jdk.1.4.present"/>
diff --git a/main/apache-commons/prj/build.lst
b/main/apache-commons/prj/build.lst
index c509ce0336..b6d8458bf0 100644
--- a/main/apache-commons/prj/build.lst
+++ b/main/apache-commons/prj/build.lst
@@ -1,6 +1,4 @@
-ac apache-commons : solenv TOMCAT:tomcat NULL
+ac apache-commons : solenv NULL
ac apache-commons
usr1 - all ac_mkout
NULL
-ac apache-commons\java\codec nmake
- all ac_codec
NULL
ac apache-commons\java\lang nmake
- all ac_lang
NULL
ac apache-commons\java\logging nmake
- all ac_logging
NULL
-ac apache-commons\java\httpclient nmake
- all ac_httpclient ac_logging ac_codec
NULL
diff --git a/main/apache-commons/prj/d.lst b/main/apache-commons/prj/d.lst
index bdcb54906b..3f94df83d0 100644
--- a/main/apache-commons/prj/d.lst
+++ b/main/apache-commons/prj/d.lst
@@ -1,4 +1,2 @@
..\%__SRC%\class\commons-logging-1.1.3.jar
%_DEST%\bin%_EXT%\commons-logging-1.1.3.jar
-..\%__SRC%\class\commons-codec-1.9.jar %_DEST%\bin%_EXT%\commons-codec-1.9.jar
-..\%__SRC%\class\commons-httpclient.jar
%_DEST%\bin%_EXT%\commons-httpclient-3.1.jar
..\%__SRC%\class\commons-lang3-3.3.jar %_DEST%\bin%_EXT%\commons-lang3-3.3.jar
diff --git a/main/configure.ac b/main/configure.ac
index 227feb2c89..e8c6210251 100644
--- a/main/configure.ac
+++ b/main/configure.ac
@@ -515,26 +515,14 @@ AC_ARG_ENABLE(pdfimport,
AC_ARG_ENABLE(wiki-publisher,
[ --enable-wiki-publisher enables the build of the Wiki Publisher
extension
],,)
-AC_ARG_WITH(commons-codec-jar,
-[ --with-commons-codec-jar=JARFILE Specify path to jarfile manually ],
-[ COMMONS_CODEC_JAR="$withval"
-])
AC_ARG_WITH(commons-lang-jar,
[ --with-commons-lang-jar=JARFILE Specify path to jarfile manually ],
[ COMMONS_LANG_JAR="$withval"
])
-AC_ARG_WITH(commons-httpclient-jar,
-[ --with-commons-httpclient-jar=JARFILE Specify path to jarfile manually ],
-[ COMMONS_HTTPCLIENT_JAR="$withval"
-])
AC_ARG_WITH(commons-logging-jar,
[ --with-commons-logging-jar=JARFILE Specify path to jarfile manually ],
[ COMMONS_LOGGING_JAR="$withval"
])
-AC_ARG_WITH(servlet-api-jar,
-[ --servlet-api-jar=JARFILE Specify path to jarfile manually ],
-[ SERVLETAPI_JAR="$withval"
-])
AC_ARG_ENABLE(report-builder,
[ --enable-report-builder enables the build of the Report Builder extension
],,)
@@ -6965,25 +6953,6 @@ else
fi
AC_SUBST(ENABLE_MEDIAWIKI)
-if test "$ENABLE_MEDIAWIKI" = "YES"; then
- AC_MSG_CHECKING([which Servlet API Jar to use])
- if test -n "$with_system_servlet_api"; then
- AC_MSG_RESULT([external])
- SYSTEM_SERVLETAPI=YES
- if test -z "$SERVLETAPI_JAR"; then
- SERVLETAPI_JAR=/usr/share/java/servlet-api.jar
- fi
- AC_CHECK_FILE($SERVLETAPI_JAR, [],
- [AC_MSG_ERROR(servlet-api.jar not found.)], [])
- else
- AC_MSG_RESULT([internal])
- SYSTEM_SERVLETAPI=NO
- BUILD_TYPE="$BUILD_TYPE TOMCAT"
- fi
-fi
-AC_SUBST(SYSTEM_SERVLETAPI)
-AC_SUBST(SERVLETAPI_JAR)
-
AC_MSG_CHECKING([whether to build the Report Builder extension])
if test -n "$enable_report_builder" -a "$enable_report_builder" != "no" &&
test "$WITH_JAVA" != "no"; then
AC_MSG_RESULT([yes])
@@ -7172,9 +7141,8 @@ AC_SUBST(LIBREPOSITORY_JAR)
AC_SUBST(LIBFONTS_JAR)
AC_SUBST(LIBSERIALIZER_JAR)
-# this has to be here because both the Wiki Publisher and the Report
-# Builder use commons-logging, while the non-optional PostgreSQL
-# connector uses commons-lang.
+# this has to be here because the Report Builder uses commons-logging,
+# while the non-optional PostgreSQL connector uses commons-lang.
AC_MSG_CHECKING([which Apache commons-* libs to use])
if test "$with_system_apache_commons" = "yes"; then
SYSTEM_APACHE_COMMONS=YES
@@ -7210,38 +7178,7 @@ if test "$with_system_apache_commons" = "yes"; then
AC_MSG_ERROR([no, you need Apache Commons Lang 3.x])
fi
- if test "$ENABLE_MEDIAWIKI" = "YES"; then
- if test -z $COMMONS_CODEC_JAR; then
- AC_CHECK_FILE(/usr/share/java/commons-codec-1.9.jar,
- [ COMMONS_CODEC_JAR=/usr/share/java/commons-codec-1.9.jar ],
- [
- AC_CHECK_FILE(/usr/share/java/commons-codec.jar,
- [ COMMONS_CODEC_JAR=/usr/share/java/commons-codec.jar ],
- [AC_MSG_ERROR(commons-codec.jar replacement not found.)]
- )
- ]
- )
- else
- AC_CHECK_FILE($COMMONS_CODEC_JAR, [],
- [AC_MSG_ERROR(commons-codec.jar not found.)], [])
- fi
-
- if test -z $COMMONS_HTTPCLIENT_JAR; then
- AC_CHECK_FILE(/usr/share/java/commons-httpclient-3.1.jar,
- [ COMMONS_HTTPCLIENT_JAR=/usr/share/java/commons-httpclient-3.1.jar ],
- [
- AC_CHECK_FILE(/usr/share/java/commons-httpclient.jar,
- [ COMMONS_HTTPCLIENT_JAR=/usr/share/java/commons-httpclient.jar ],
- [AC_MSG_ERROR(commons-httpclient.jar replacement not found.)]
- )
- ]
- )
- else
- AC_CHECK_FILE($COMMONS_HTTPCLIENT_JAR, [],
- [AC_MSG_ERROR(commons-httpclient.jar not found.)], [])
- fi
- fi
- if test "$ENABLE_MEDIAWIKI" = "YES" -o "$ENABLE_REPORTBUILDER" = "YES"; then
+ if test "$ENABLE_REPORTBUILDER" = "YES"; then
if test -z $COMMONS_LOGGING_JAR; then
AC_CHECK_FILE(/usr/share/java/commons-logging-1.1.3.jar,
[ COMMONS_LOGGING_JAR=/usr/share/java/commons-logging-1.1.3.jar ],
@@ -7260,12 +7197,10 @@ if test "$with_system_apache_commons" = "yes"; then
else
AC_MSG_RESULT([internal])
SYSTEM_APACHE_COMMONS=NO
- BUILD_TYPE="$BUILD_TYPE APACHE_COMMONS TOMCAT"
+ BUILD_TYPE="$BUILD_TYPE APACHE_COMMONS"
fi
AC_SUBST(SYSTEM_APACHE_COMMONS)
-AC_SUBST(COMMONS_CODEC_JAR)
AC_SUBST(COMMONS_LANG_JAR)
-AC_SUBST(COMMONS_HTTPCLIENT_JAR)
AC_SUBST(COMMONS_LOGGING_JAR)
dnl ===================================================================
diff --git a/main/external_deps.lst b/main/external_deps.lst
index 5af8665e1a..114d758882 100644
--- a/main/external_deps.lst
+++ b/main/external_deps.lst
@@ -108,25 +108,13 @@ if (GUI!=UNX || SYSTEM_ZLIB!=YES)
URL1 = https://www.zlib.net/fossils/$(name)
URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
-if (SOLAR_JAVA==TRUE && ENABLE_MEDIAWIKI==YES)
- MD5 = 2c9b0f83ed5890af02c0df1c1776f39b
- name = commons-httpclient-3.1-src.tar.gz
- URL1 =
https://archive.apache.org/dist/httpcomponents/commons-httpclient/source/$(name)
- URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
-
-if (SOLAR_JAVA==TRUE && ENABLE_MEDIAWIKI==YES)
- MD5 = db87f7004cefc9d17f7ac841f86122bd
- name = commons-codec-1.9-src.tar.gz
- URL1 = https://archive.apache.org/dist/commons/codec/source/$(name)
- URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
-
if ( true )
MD5 = e3738abd0d3ce1870dc1fd1f22bba5b1
name = icu4c-4_2_1-src.tgz
URL1 = https://sourceforge.net/projects/icu/files/ICU4C/4.2.1/$(name)
URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
-if (SOLAR_JAVA==TRUE && (ENABLE_MEDIAWIKI==YES || ENABLE_REPORTBUILDER==YES))
+if (SOLAR_JAVA==TRUE && ENABLE_REPORTBUILDER==YES)
MD5 = e8e197d628436490886d17cffa108fe3
name = commons-logging-1.1.3-src.tar.gz
URL1 = https://archive.apache.org/dist/commons/logging/source/$(name)
@@ -175,12 +163,6 @@ if (SYSTEM_LIBXSLT != YES)
URL1 = http://xmlsoft.org/sources/$(name)
URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
-if (SOLAR_JAVA == TRUE)
- MD5 = 63574e3ada44f473892a61a2da433a59
- name = apache-tomcat-5.5.36-src.tar.gz
- URL1 =
https://archive.apache.org/dist/tomcat/tomcat-5/v5.5.36/src/apache-tomcat-5.5.36-src.tar.gz
- URL2 = $(OOO_EXTRAS)$(MD5)-$(name)
-
if (ENABLE_MEDIAWIKI == YES)
MD5 = a7983f859eafb2677d7ff386a023bc40
name = xsltml_2.1.2.zip
diff --git a/main/set_soenv.in b/main/set_soenv.in
index a12b61ce37..38d63572ca 100644
--- a/main/set_soenv.in
+++ b/main/set_soenv.in
@@ -1781,12 +1781,8 @@ ToFile( "LIBFONTS_JAR", "@LIBFONTS_JAR@", "e" );
ToFile( "LIBSERIALIZER_JAR", "@LIBSERIALIZER_JAR@","e" );
ToFile( "ENABLE_MEDIAWIKI", "@ENABLE_MEDIAWIKI@", "e" );
ToFile( "SYSTEM_APACHE_COMMONS","@SYSTEM_APACHE_COMMONS@","e" );
-ToFile( "COMMONS_CODEC_JAR", "@COMMONS_CODEC_JAR@","e" );
ToFile( "COMMONS_LANG_JAR", "@COMMONS_LANG_JAR@", "e" );
-ToFile( "COMMONS_HTTPCLIENT_JAR","@COMMONS_HTTPCLIENT_JAR@","e" );
ToFile( "COMMONS_LOGGING_JAR","@COMMONS_LOGGING_JAR@","e" );
-ToFile( "SYSTEM_SERVLETAPI", "@SYSTEM_SERVLETAPI@", "e" );
-ToFile( "SERVLETAPI_JAR", "@SERVLETAPI_JAR@", "e" );
ToFile( "ENABLE_DBUS", "@ENABLE_DBUS@", "e" );
ToFile( "ENABLE_GCONF", "@ENABLE_GCONF@", "e" );
ToFile( "ENABLE_GNOMEVFS", "@ENABLE_GNOMEVFS@", "e" );
diff --git a/main/solenv/ant/externals.xml b/main/solenv/ant/externals.xml
index 42fe5bb6e6..f6bb8470a2 100644
--- a/main/solenv/ant/externals.xml
+++ b/main/solenv/ant/externals.xml
@@ -49,18 +49,6 @@
</sequential>
</macrodef>
- <define-external
- name="commons-codec"
- system-test="${SYSTEM_APACHE_COMMONS}"
- system-path="${COMMONS_CODEC_JAR}"
- internal-filename="commons-codec-1.9.jar"/>
-
- <define-external
- name="commons-httpclient"
- system-test="${SYSTEM_APACHE_COMMONS}"
- system-path="${COMMONS_HTTPCLIENT_JAR}"
- internal-filename="commons-httpclient-3.1.jar"/>
-
<define-external
name="hsqldb"
system-test="${SYSTEM_HSQLDB}"
diff --git a/main/swext/mediawiki/build.xml b/main/swext/mediawiki/build.xml
index b11c7ac2b6..6e6f597662 100644
--- a/main/swext/mediawiki/build.xml
+++ b/main/swext/mediawiki/build.xml
@@ -56,11 +56,6 @@
<pathelement location="${officeclasses}/jurt.jar"/>
<pathelement location="${officeclasses}/ridl.jar"/>
<pathelement location="${officeclasses}/unoil.jar"/>
- <!-- 3rd party libs -->
- <pathelement location="${commons-codec-jar}"/>
- <pathelement location="${commons-httpclient-jar}"/>
- <pathelement location="${commons-lang-jar}"/>
- <pathelement location="${commons-logging-jar}"/>
</path>
<!-- create output directories -->
@@ -93,8 +88,6 @@
<target name="jar" depends="compile, init">
<jar basedir="${classes}" compress="true"
jarfile="${dist}/${target}.jar">
<manifest>
- <!-- FIXME: Set Class-Path correctly for the system case !-->
- <attribute name="Class-Path" value="commons-codec-1.9.jar
commons-lang3-3.3.jar commons-httpclient-3.1.jar commons-logging-1.1.3.jar"/>
<attribute name="RegistrationClassName"
value="com.sun.star.wiki.WikiEditorImpl"/>
</manifest>
</jar>
@@ -125,10 +118,6 @@
<zip destfile="${dist}/${name}.${ext}">
<fileset dir="${out}/misc/${target}/package_tmp"
casesensitive="yes"/>
<fileset dir="${dist}" includes="${target}.jar"
casesensitive="yes"/>
- <file file="${commons-codec-jar}"/>
- <file file="${commons-httpclient-jar}"/>
- <file file="${commons-lang-jar}"/>
- <file file="${commons-logging-jar}"/>
<zipfileset file="src/filter/odt2mediawiki.xsl"
casesensitive="yes" fullpath="filter/odt2mediawiki.xsl"/>
<zipfileset file="src/filter/mediawiki.ott" casesensitive="yes"
fullpath="templates/MediaWiki/mediawiki.ott"/>
<zipfileset dir="${solar.bin}/xslt/export/xsltml"
casesensitive="yes" prefix="filter/math"/>
@@ -137,7 +126,6 @@
<zipfileset dir="${out}/misc/${target}/license"
includes="LICENSE*" casesensitive="yes" prefix="license"/>
<zipfileset dir="${out}/misc/${target}/help"
includes="**/*.idxl/*,**/*.*_,**/*.jar" casesensitive="yes" prefix="help"/>
<zipfileset dir="${out}/misc/${target}/help" includes="**/*.xhp"
casesensitive="yes" prefix="help"/>
- <zipfileset dir="src" includes="THIRDPARTYLICENSEREADME.html"
casesensitive="yes" prefix="license"/>
</zip>
</target>
@@ -161,7 +149,6 @@
<zipfileset dir="dialogs" includes="**/*.xdl,**/*.xba,**/*.xlb"
casesensitive="yes" prefix="WikiEditor" filemode="664" dirmode="775"/>
<zipfileset dir="src" includes="uno-extension-manifest.xml"
casesensitive="yes" fullpath="META-INF/manifest.xml" filemode="664"
dirmode="775"/>
<zipfileset dir="${out}/misc/${target}/license"
includes="LICENSE*" casesensitive="yes" prefix="license" filemode="664"
dirmode="775"/>
- <zipfileset dir="src" includes="THIRDPARTYLICENSEREADME.html"
casesensitive="yes" prefix="license" filemode="664" dirmode="775"/>
</zip>
</target>
diff --git a/main/swext/mediawiki/makefile.mk b/main/swext/mediawiki/makefile.mk
index 362a1e5b53..02b0386191 100644
--- a/main/swext/mediawiki/makefile.mk
+++ b/main/swext/mediawiki/makefile.mk
@@ -28,32 +28,16 @@ TARGET=mediawiki
.IF "$(ENABLE_MEDIAWIKI)" == "YES"
.INCLUDE : ant.mk
-.IF "$(SYSTEM_APACHE_COMMONS)" != "YES"
-COMMONS_CODEC_JAR=$(SOLARVER)$/$(INPATH)$/bin$(UPDMINOREXT)$/commons-codec-1.9.jar
-COMMONS_LANG_JAR=$(SOLARVER)$/$(INPATH)$/bin$(UPDMINOREXT)$/commons-lang3-3.3.jar
-COMMONS_HTTPCLIENT_JAR=$(SOLARVER)$/$(INPATH)$/bin$(UPDMINOREXT)$/commons-httpclient-3.1.jar
-COMMONS_LOGGING_JAR=$(SOLARVER)$/$(INPATH)$/bin$(UPDMINOREXT)$/commons-logging-1.1.3.jar
-.ELSE
-COMP=fix_system_commons
-.ENDIF
-
.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)
+ANT_FLAGS+=-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
-
-fix_system_commons:
- @echo "Fix Java Class-Path entry for Apache Commons libraries from
system."
- @$(SED) -i.bak -r -e "s#(name=\"Class-Path\"
value=\").*\"#\1file://$(COMMONS_CODEC_JAR) file://$(COMMONS_LANG_JAR) \
-file://$(COMMONS_HTTPCLIENT_JAR) file://$(COMMONS_LOGGING_JAR)\"#" build.xml
- @echo "Unbundle Apache Commons libraries from Mediawiki Presentation
extension."
- @$(SED) -i.bak '/file="..commons/d' build.xml
+ALLTAR: ANTBUILD
.ELSE
@all:
diff --git a/main/swext/mediawiki/src/THIRDPARTYLICENSEREADME.html
b/main/swext/mediawiki/src/THIRDPARTYLICENSEREADME.html
deleted file mode 100644
index fbd8b0bfdc..0000000000
--- a/main/swext/mediawiki/src/THIRDPARTYLICENSEREADME.html
+++ /dev/null
@@ -1,148 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
- <meta content="text/html; charset=iso-8859-1"
- http-equiv="Content-Type">
- <title>THIRDPARTYLICENSEREADME</title>
-</head>
-<body>
-DO NOT TRANSLATE OR LOCALIZE THIS DOCUMENT<br>
-<br>
-<ul id="mozToc">
-<!--mozToc h2 1 h3 2-->
- <li><a href="#mozTocId445655">The Apache Software Foundation
- </a>
- <ul>
- <li><a href="#mozTocId662146">Commons Codec
- </a></li>
- </ul>
- </li>
- <li><a href="#mozTocId954021">The Apache Software Foundation
- </a>
- <ul>
- <li><a href="#mozTocId934893">Commons HTTP Client
- </a></li>
- </ul>
- </li>
- <li><a href="#mozTocId478594">The Apache Software Foundation
- </a>
- <ul>
- <li><a href="#mozTocId789223">Commons Lang
- </a></li>
- </ul>
- </li>
- <li><a href="#mozTocId877758">The Apache Software Foundation
- </a>
- <ul>
- <li><a href="#mozTocId959568">Commons Logging
- </a></li>
- </ul>
- </li>
- <li><a href="#mozTocId3503">The Apache Software
-Foundation
- </a>
- <ul>
- <li><a href="#mozTocId520856">Tomcat
- </a></li>
- </ul>
- </li>
-</ul>
-<br>
-<hr style="width: 100%; height: 2px;">The following software may be
-included in this product: Jakarta Commons Codec; Use of any of this
-software is governed by the terms of the license below:<br>
-<h2><a class="mozTocH2" name="mozTocId445655"></a>The Apache Software
-Foundation<br>
-</h2>
-<h3><a class="mozTocH3" name="mozTocId662146"></a>Commons Codec<br>
-</h3>
-<pre> Apache License<br>
Version 2.0, January 2004<br>
http://www.apache.org/licenses/<br><br> TERMS AND CONDITIONS FOR USE,
REPRODUCTION, AND DISTRIBUTION<br><br> 1. Definitions.<br><br> "License"
shall mean the terms and conditions for use, reproduction,<br> and
distribution as defined by Sections 1 through 9 of this document.<br><br>
"Licensor" shall mean the copyright owner or entity a [...]
-<hr style="width: 100%; height: 2px;">The following software may be
-included in this product: Jakarta Commons HTTP Client 2; Use of any of
-this
-software is governed by the terms of the license below:<br>
-<h2><a class="mozTocH2" name="mozTocId954021"></a>The Apache Software
-Foundation<br>
-</h2>
-<h3><a class="mozTocH3" name="mozTocId934893"></a>Commons HTTP Client<br>
-</h3>
-<pre> Apache License<br>
Version 2.0, January 2004<br>
http://www.apache.org/licenses/<br><br> TERMS AND CONDITIONS FOR USE,
REPRODUCTION, AND DISTRIBUTION<br><br> 1. Definitions.<br><br> "License"
shall mean the terms and conditions for use, reproduction,<br> and
distribution as defined by Sections 1 through 9 of this document.<br><br>
"Licensor" shall mean the copyright owner or entity a [...]
-<hr style="width: 100%; height: 2px;">The following software may be
-included in this product: Jakarta Commons Lang 2.1; Use of any of this
-software is governed by the terms of the license below:<br>
-<h2><a class="mozTocH2" name="mozTocId478594"></a>The Apache Software
-Foundation<br>
-</h2>
-<h3><a class="mozTocH3" name="mozTocId789223"></a>Commons Lang<br>
-</h3>
-<pre> Apache License<br>
Version 2.0, January 2004<br>
http://www.apache.org/licenses/<br><br> TERMS AND CONDITIONS FOR USE,
REPRODUCTION, AND DISTRIBUTION<br><br> 1. Definitions.<br><br> "License"
shall mean the terms and conditions for use, reproduction,<br> and
distribution as defined by Sections 1 through 9 of this document.<br><br>
"Licensor" shall mean the copyright owner or entity a [...]
-<hr style="width: 100%; height: 2px;">The following software may be
-included in this product: Jakarta Commons Codec; Use of any of this
-software is governed by the terms of the license below:<br>
-<h2><a class="mozTocH2" name="mozTocId877758"></a>The Apache Software
-Foundation<br>
-</h2>
-<h3><a class="mozTocH3" name="mozTocId959568"></a>Commons Logging<br>
-</h3>
-<pre> Apache License<br>
Version 2.0, January 2004<br>
http://www.apache.org/licenses/<br><br> TERMS AND CONDITIONS FOR USE,
REPRODUCTION, AND DISTRIBUTION<br><br> 1. Definitions.<br><br> "License"
shall mean the terms and conditions for use, reproduction,<br> and
distribution as defined by Sections 1 through 9 of this document.<br><br>
"Licensor" shall mean the copyright owner or entity a [...]
-<hr style="width: 100%; height: 2px;">The following software may be
-included in this product: Tomcat 4.0 or higher; Use of any of this
-software is governed by the terms of the license below:<br>
-<h2><a class="mozTocH2" name="mozTocId3503"></a>The Apache Software
-Foundation<br>
-</h2>
-<h3><a class="mozTocH3" name="mozTocId520856"></a>Tomcat<br>
-</h3>
-<br>
-The Apache Software License, Version 1.1
-<br>
-<br>
-Copyright (c) 2001 The Apache Software Foundation. All rights
-reserved.
-<br>
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-<br>
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer. <br>
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution. <br>
-3. The end-user documentation included with the redistribution, if any,
-must include the following acknowledgment: "This product includes
-software developed by the Apache Software Foundation
-(http://www.apache.org/)." Alternately, this acknowledgment may appear
-in the software itself, if and wherever such third-party
-acknowledgments normally appear. <br>
-4. The names "XML-RPC" and "Apache Software Foundation" must not be
-used to endorse or promote products derived from this software without
-prior written permission. For written permission, please contact
[email protected]. <br>
-5. Products derived from this software may not be called "Apache", nor
-may "Apache" appear in their name, without prior written permission of
-the Apache Software Foundation. <br>
-THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
-ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-<br>
-====================================================================
-<br>
-This software consists of voluntary contributions made by many
-individuals on behalf of the Apache Software Foundation. For more
-information on the Apache Software Foundation, please see
-<http:>.
-<br>
-</http:>
-<br>
-</body>
-</html>
diff --git a/main/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
b/main/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
index f12c972103..aa10c4c2f6 100644
--- a/main/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
+++ b/main/swext/mediawiki/src/com/sun/star/wiki/EditPageParser.java
@@ -29,159 +29,58 @@ import javax.swing.text.MutableAttributeSet;
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;
- private boolean m_bHTMLStartFound = false;
private boolean m_bInHead = false;
-
- protected int m_nWikiArticleStart = -1;
- protected int m_nWikiArticleEnd = -1;
- protected int m_nHTMLArticleStart = -1;
- protected int m_nHTMLArticleEnd = -1;
- protected int m_nNoArticleInd = -1;
- protected int m_nErrorInd = -1;
+ private boolean m_bAPIFound = false;
/** Creates a new instance of WikiHTMLParser */
public EditPageParser()
{
}
- public void handleComment( char[] data,int pos )
- {
- // insert code to handle comments
- }
-
public void handleEndTag( HTML.Tag t,int pos )
{
- if ( t == HTML.Tag.TEXTAREA )
- {
- m_nWikiArticleEnd = pos;
- }
- else if ( t == HTML.Tag.DIV )
- {
- if ( m_bHTMLStartFound )
- {
- m_nHTMLArticleStart = pos+6;
- m_bHTMLStartFound = false;
- }
- }
- else if ( t == HTML.Tag.HEAD )
+ if ( t == HTML.Tag.HEAD )
{
m_bInHead = false;
}
}
- public void handleError( String errorMsg,int pos )
- {
- //System.out.println( errorMsg );
- }
-
public void handleSimpleTag( HTML.Tag t, MutableAttributeSet a,int pos )
{
- // insert code to handle simple tags
-
- if ( t == HTML.Tag.INPUT )
+ if ( t == HTML.Tag.LINK && m_bInHead && !m_bAPIFound )
{
- String sName = ( String ) a.getAttribute( HTML.Attribute.NAME );
- if ( sName != null )
+ String sHref = ( String ) a.getAttribute( HTML.Attribute.HREF );
+ if ( sHref != null )
{
- if ( sName.equalsIgnoreCase( "wpEdittime" ) )
- {
- this.m_sEditTime = ( String ) a.getAttribute(
HTML.Attribute.VALUE );
- }
- else if ( sName.equalsIgnoreCase( "wpEditToken" ) )
- {
- this.m_sEditToken = ( String ) a.getAttribute(
HTML.Attribute.VALUE );
- }
- else if ( sName.equalsIgnoreCase( "wpLoginToken" ) )
+ // MediaWiki advertises its API with <link rel="EditURI"
href=".../api.php?action=rsd">
+ String sRel = ( String ) a.getAttribute( HTML.Attribute.REL );
+ int nAPIStart = sHref.indexOf( "api.php" );
+ if ( sRel != null && sRel.equalsIgnoreCase( "EditURI" ) &&
nAPIStart >= 0 )
{
- this.m_sLoginToken = ( String ) a.getAttribute(
HTML.Attribute.VALUE );
+ m_sMainURL = sHref.substring( 0, nAPIStart );
+ m_bAPIFound = true;
+ return;
}
- }
- }
- else if ( t == HTML.Tag.LINK )
- {
- if ( m_bInHead )
- {
- String sName = ( String ) a.getAttribute( HTML.Attribute.HREF
);
- if ( sName != null )
+ int nIndexStart = sHref.indexOf( "index.php" );
+ // otherwise get the main URL from the first header-link with
index.php
+ // the link with "action=edit" inside is preferable
+ if ( nIndexStart>= 0
+ && ( m_sMainURL.length() == 0 || sHref.indexOf(
"action=edit" ) >= 0 ) )
{
- int nIndexStart = sName.indexOf( "index.php" );
- // get the main URL from the first header-link with
index.php
- // the link with "action=edit" inside is preferable
- if ( nIndexStart>= 0
- && ( m_sMainURL.length() == 0 || sName.indexOf(
"action=edit" ) >= 0 ) )
- {
- m_sMainURL = sName.substring( 0, nIndexStart );
- }
+ m_sMainURL = sHref.substring( 0, nIndexStart );
}
}
}
-
}
public void handleStartTag( HTML.Tag t, MutableAttributeSet a,int pos )
{
- // insert code to handle starting tags
- String sName = "";
- String sId = "";
- String sClass = "";
-
if ( t == HTML.Tag.HEAD )
{
m_bInHead = true;
}
- if ( t == HTML.Tag.TEXTAREA )
- {
- sName = ( String ) a.getAttribute( HTML.Attribute.NAME );
- if ( sName != null )
- {
- if ( sName.equalsIgnoreCase( "wpTextbox1" ) )
- {
- m_nWikiArticleHash = t.hashCode();
- m_nWikiArticleStart = pos;
- }
- }
- }
- else if ( t == HTML.Tag.DIV )
- {
- sId = ( String ) a.getAttribute( HTML.Attribute.ID );
- sClass = ( String ) a.getAttribute( HTML.Attribute.CLASS );
- if ( sId != null )
- {
- if ( sId.equalsIgnoreCase( "contentSub" ) )
- {
- m_bHTMLStartFound = true;
- }
- }
- if ( sClass != null )
- {
- if ( sClass.equalsIgnoreCase( "printfooter" ) )
- {
- m_nHTMLArticleEnd = pos;
- }
- else if ( sClass.equalsIgnoreCase( "noarticletext" ) )
- {
- m_nNoArticleInd = pos;
- }
- else if ( sClass.equalsIgnoreCase( "errorbox" ) )
- {
- m_nErrorInd = pos;
- }
- }
- }
- else if ( t == HTML.Tag.P )
- {
- sClass = ( String ) a.getAttribute( HTML.Attribute.CLASS );
- if ( sClass != null && sClass.equalsIgnoreCase( "error" ) )
- {
- m_nErrorInd = pos;
- }
- }
}
}
diff --git a/main/swext/mediawiki/src/com/sun/star/wiki/Helper.java
b/main/swext/mediawiki/src/com/sun/star/wiki/Helper.java
index 1b78307afe..76a47222df 100644
--- a/main/swext/mediawiki/src/com/sun/star/wiki/Helper.java
+++ b/main/swext/mediawiki/src/com/sun/star/wiki/Helper.java
@@ -60,20 +60,15 @@ import com.sun.star.uno.XComponentContext;
import com.sun.star.util.XChangesBatch;
import java.net.*;
import java.io.*;
-import java.util.Hashtable;
-import java.util.Random;
-import javax.net.ssl.SSLException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Callable;
import javax.swing.text.html.HTMLEditorKit;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.URI;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class Helper
{
@@ -154,11 +149,8 @@ public class Helper
private static final String sHTMLHeader = "<html><head><meta
http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"
/><title></title></head><body>";
private static final String sHTMLFooter = "</body></html>";
- private static Random m_aRandom;
- private static MultiThreadedHttpConnectionManager m_aConnectionManager;
- private static HttpClient m_aClient;
+ private static Set<HttpURLConnection> m_aActiveConnections = new
HashSet<HttpURLConnection>();
private static boolean m_bAllowConnection = true;
- private static Hashtable m_aAcceptedUnknownCerts;
private static Boolean m_bShowInBrowser = null;
@@ -188,34 +180,28 @@ public class Helper
return m_pConfigStrings[nID];
}
- synchronized protected static HttpClient GetHttpClient()
+ synchronized protected static void RegisterConnection( HttpURLConnection
aConn )
throws WikiCancelException
{
if ( !m_bAllowConnection )
throw new WikiCancelException();
- if ( m_aConnectionManager == null )
- m_aConnectionManager = new MultiThreadedHttpConnectionManager();
-
- if ( m_aClient == null )
- {
- m_aClient = new HttpClient( m_aConnectionManager );
- m_aClient.getParams().setParameter( "http.protocol.cookie-policy",
CookiePolicy.BROWSER_COMPATIBILITY );
- m_aClient.getParams().setParameter(
"http.protocol.single-cookie-header", Boolean.TRUE );
- m_aClient.getParams().setParameter(
"http.protocol.content-charset", "UTF-8" );
- }
+ m_aActiveConnections.add( aConn );
+ }
- return m_aClient;
+ synchronized protected static void UnregisterConnection( HttpURLConnection
aConn )
+ {
+ m_aActiveConnections.remove( aConn );
}
synchronized protected static void AllowConnection( boolean bAllow )
{
m_bAllowConnection = bAllow;
- if ( !bAllow && m_aConnectionManager != null )
+ if ( !bAllow )
{
- m_aClient = null;
- m_aConnectionManager.shutdown();
- m_aConnectionManager = null;
+ for ( Iterator<HttpURLConnection> aIter =
m_aActiveConnections.iterator(); aIter.hasNext(); )
+ aIter.next().disconnect();
+ m_aActiveConnections.clear();
}
}
@@ -296,12 +282,8 @@ public class Helper
return m_xInteractionHandler;
}
- protected static Protocol GetOwnHttps( int nPort )
- {
- return new Protocol( "https", new WikiProtocolSocketFactory(), ( (
nPort < 0 ) ? 443 : nPort ) );
- }
-
- protected static String GetMainURL( String sWebPage, String sVURL )
+ /** Returns the wiki's main URL (the directory holding index.php and
api.php), or "" if the page is no MediaWiki page. */
+ protected static String GetMainURL( String sWebPage, URL aPageURL )
{
String sResultURL = "";
try
@@ -311,14 +293,8 @@ public class Helper
EditPageParser aCallback = new EditPageParser();
aParser.parse( aReader, aCallback, true );
- sResultURL = aCallback.m_sMainURL;
-
- if ( !sResultURL.startsWith( "http" ) )
- {
- // if the url is only relative then complete it
- URL aURL = new URL( sVURL );
- sResultURL = aURL.getProtocol() + "://" + aURL.getHost() +
sResultURL;
- }
+ if ( aCallback.m_sMainURL.length() > 0 )
+ sResultURL = new URL( aPageURL, aCallback.m_sMainURL
).toString();
}
catch( Exception e )
{
@@ -329,6 +305,7 @@ public class Helper
{
// usually that should not happen
// workaround: try to get index.php from the provided URL
+ String sVURL = aPageURL.toString();
int nIndex = sVURL.indexOf( "index.php" );
if ( nIndex >= 0 )
sResultURL = sVURL.substring( 0, nIndex );
@@ -337,7 +314,7 @@ public class Helper
return sResultURL;
}
- protected static String GetRedirectURL( String sWebPage, String sURL )
+ protected static String GetRedirectURL( String sWebPage, URL aPageURL )
{
// scrape the HTML source and find the EditURL
// TODO/LATER: Use parser in future
@@ -360,24 +337,17 @@ public class Helper
try
{
- URL aURL = new URL( sURL );
- if ( !sResultURL.startsWith( aURL.getProtocol() ))
- {
- // if the url is only relative then complete it
- if ( sResultURL.startsWith( "/" ) )
- sResultURL = aURL.getProtocol() + "://" +
aURL.getHost() + sResultURL;
- else
- sResultURL = aURL.getProtocol() + "://" +
aURL.getHost() + aURL.getPath() + sResultURL;
- }
+ if ( sResultURL.length() > 0 )
+ sResultURL = new URL( aPageURL, sResultURL ).toString();
}
catch ( MalformedURLException ex )
{
ex.printStackTrace();
+ sResultURL = "";
}
}
return sResultURL;
-
}
protected static XInputStream SaveHTMLTemp( XComponentContext xContext,
String sArticle )
@@ -644,10 +614,11 @@ public class Helper
return xNameAccess;
}
- protected static void SetConfigurationProxy( HostConfiguration
aHostConfig, XComponentContext xContext )
+ /** Returns the proxy configured in the office for aURL, or null to use
the system proxy settings. */
+ protected static Proxy GetProxy( XComponentContext xContext, URL aURL )
{
- if ( aHostConfig == null || xContext == null )
- return;
+ if ( xContext == null )
+ return null;
try
{
@@ -655,45 +626,41 @@ public class Helper
int nProxyType = AnyConverter.toInt( xNameAccess.getByName(
"ooInetProxyType" ) );
if ( nProxyType == 0 )
- aHostConfig.setProxyHost( null );
- else
+ return Proxy.NO_PROXY;
+ else if ( nProxyType == 2 )
{
- if ( nProxyType == 1 )
+ String aProxyNameProp = "ooInetHTTPProxyName";
+ String aProxyPortProp = "ooInetHTTPProxyPort";
+
+ if ( aURL.getProtocol().equals( "https" ) )
{
- // system proxy
+ aProxyNameProp = "ooInetHTTPSProxyName";
+ aProxyPortProp = "ooInetHTTPSProxyPort";
}
- else if ( nProxyType == 2 )
- {
- String aProxyNameProp = "ooInetHTTPProxyName";
- String aProxyPortProp = "ooInetHTTPProxyPort";
-
- if ( aHostConfig.getProtocol().getScheme().equals( "https"
) )
- {
- aProxyNameProp = "ooInetHTTPSProxyName";
- aProxyPortProp = "ooInetHTTPSProxyPort";
- }
- String aNoProxyList = AnyConverter.toString(
xNameAccess.getByName( "ooInetNoProxy" ) );
- String aProxyName = AnyConverter.toString(
xNameAccess.getByName( aProxyNameProp ) );
+ String aProxyName = AnyConverter.toString(
xNameAccess.getByName( aProxyNameProp ) );
+ if ( aProxyName.length() == 0 )
+ return Proxy.NO_PROXY;
- int nProxyPort = 80;
+ int nProxyPort = 80;
- Object aPortNo = xNameAccess.getByName( aProxyPortProp );
- if ( !AnyConverter.isVoid( aPortNo ) )
- nProxyPort = AnyConverter.toInt( aPortNo );
+ Object aPortNo = xNameAccess.getByName( aProxyPortProp );
+ if ( !AnyConverter.isVoid( aPortNo ) )
+ nProxyPort = AnyConverter.toInt( aPortNo );
- if ( nProxyPort == -1 )
- nProxyPort = 80;
+ if ( nProxyPort == -1 )
+ nProxyPort = 80;
- // TODO: check whether the URL is in the NoProxy list
- aHostConfig.setProxy( aProxyName, nProxyPort );
- }
+ // TODO: check whether the URL is in the NoProxy list
+ return new Proxy( Proxy.Type.HTTP,
InetSocketAddress.createUnresolved( aProxyName, nProxyPort ) );
}
}
catch( java.lang.Exception e )
{
e.printStackTrace();
}
+
+ return null;
}
protected static void ShowURLInBrowser( XComponentContext xContext, String
sURL )
@@ -713,36 +680,6 @@ public class Helper
}
}
- protected static void ExecuteMethod( HttpMethodBase aMethod,
HostConfiguration aHostConfig, URI aURI, XComponentContext xContext, boolean
bSetHost )
- throws WikiCancelException, IOException, SSLException
- {
- if ( aMethod != null && aHostConfig != null && aURI != null &&
xContext != null )
- {
- if ( bSetHost )
- {
- aHostConfig.setHost( aURI );
- SetConfigurationProxy( aHostConfig, xContext );
- }
-
- boolean bNoUnknownCertNotification = false;
- if ( aHostConfig.getProtocol().getScheme().equals( "https" )
- && AllowUnknownCert( xContext, aURI.getHost() ) )
- {
- // let unknown certificates be accepted
- {
- {
- aHostConfig.setHost( aHostConfig.getHost(), (
aURI.getPort() < 0 ? 443 : aURI.getPort() ), Helper.GetOwnHttps( aURI.getPort()
) );
- Helper.GetHttpClient().executeMethod( aHostConfig,
aMethod );
- }
- }
- }
- else
- {
- Helper.GetHttpClient().executeMethod( aHostConfig, aMethod );
- }
- }
- }
-
static private class HTMLParse extends HTMLEditorKit
{
@@ -757,122 +694,57 @@ public class Helper
return new HTMLParse().getParser();
}
- static protected boolean LoginReportsError( String sRespond )
+ /** Logs in through the MediaWiki Action API; returns the logged-in
session, or null if the login was refused. */
+ static protected WikiSession Login( URL aMainURL, String sWikiUser, String
sWikiPass, XComponentContext xContext )
+ throws java.io.IOException, WikiCancelException
{
- boolean bResult = true;
- if ( sRespond != null )
- {
- try
- {
- StringReader aReader = new StringReader( sRespond );
- HTMLEditorKit.Parser aParser = GetHTMLParser();
- EditPageParser aCallback = new EditPageParser();
+ if ( sWikiUser == null || sWikiUser.length() == 0 || sWikiPass == null
|| xContext == null )
+ return null;
- aParser.parse( aReader, aCallback, true );
- bResult = ( aCallback.m_nErrorInd >= 0 );
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- }
+ WikiSession aSession = new WikiSession( xContext, aMainURL );
+ String sToken = aSession.GetToken( "login" );
+ if ( sToken == null )
+ return null;
- return bResult;
- }
-
- static protected String GetLoginToken( String sLoginPage )
- {
- String sResult = "";
- if ( sLoginPage != null && sLoginPage.length() > 0 )
+ List<String[]> aParams = new ArrayList<String[]>();
+ boolean bBotPassword = ( sWikiUser.indexOf( '@' ) >= 0 );
+ if ( bBotPassword )
{
- 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();
- }
+ // "user@botname" bot passwords are only accepted by action=login,
user passwords by action=clientlogin
+ aParams.add( new String[] { "action", "login" } );
+ aParams.add( new String[] { "lgname", sWikiUser } );
+ aParams.add( new String[] { "lgpassword", sWikiPass } );
}
-
- return sResult;
- }
-
- static protected HostConfiguration Login( URI aMainURL, String sWikiUser,
String sWikiPass, XComponentContext xContext )
- throws com.sun.star.uno.Exception, java.io.IOException,
WikiCancelException
- {
- HostConfiguration aHostConfig = null;
-
- if ( sWikiUser != null && sWikiPass != null && xContext != null )
+ else
{
- HostConfiguration aNewHostConfig = new HostConfiguration();
-
- URI aURI = new URI( aMainURL.toString() +
"index.php?title=Special:Userlogin" );
- GetMethod aGetCookie = new GetMethod( aURI.getEscapedPathQuery() );
-
- ExecuteMethod( aGetCookie, aNewHostConfig, aURI, xContext, true );
-
- int nResultCode = aGetCookie.getStatusCode();
- 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() );
-
- 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++ )
- if ( pArgs[nArgInd].length == 2 && pArgs[nArgInd][0]
!= null && pArgs[nArgInd][1] != null )
- aPost.addParameter( pArgs[nArgInd][0],
pArgs[nArgInd][1] );
-
- ExecuteMethod( aPost, aNewHostConfig, aPostURI, xContext,
false );
-
- nResultCode = aPost.getStatusCode();
-
- while( nResultCode >= 301 && nResultCode <= 303 || nResultCode
== 307 )
- {
- String sRedirectURL = aPost.getResponseHeader( "Location"
).getValue();
- aPost.releaseConnection();
-
- aURI = new URI( sRedirectURL );
- aPost = new PostMethod();
- aPost.setPath( aURI.getEscapedPathQuery() );
- ExecuteMethod( aPost, aNewHostConfig, aURI, xContext,
false );
+ aParams.add( new String[] { "action", "clientlogin" } );
+ aParams.add( new String[] { "username", sWikiUser } );
+ aParams.add( new String[] { "password", sWikiPass } );
+ aParams.add( new String[] { "loginreturnurl", aMainURL.toString()
} );
+ }
- nResultCode = aPost.getStatusCode();
- }
+ String[][] pArgs = GetSpecialArgs( xContext, aMainURL.getHost() );
+ if ( pArgs != null )
+ for ( int nArgInd = 0; nArgInd < pArgs.length; nArgInd++ )
+ if ( pArgs[nArgInd].length == 2 && pArgs[nArgInd][0] != null
&& pArgs[nArgInd][1] != null )
+ aParams.add( pArgs[nArgInd] );
- if ( nResultCode == 200 )
- {
- String sResult = aPost.getResponseBodyAsString();
- if ( !LoginReportsError( sResult ) )
- aHostConfig = aNewHostConfig;
- }
+ aParams.add( new String[] { bBotPassword ? "lgtoken" : "logintoken",
sToken } );
- aPost.releaseConnection();
- }
+ Document aResult = aSession.CallAPI( aParams.toArray( new
String[aParams.size()][] ) );
+ boolean bSuccess;
+ if ( bBotPassword )
+ {
+ Element aLogin = WikiSession.GetElement( aResult, "login" );
+ bSuccess = ( aLogin != null && "Success".equals(
aLogin.getAttribute( "result" ) ) );
+ }
+ else
+ {
+ Element aLogin = WikiSession.GetElement( aResult, "clientlogin" );
+ bSuccess = ( aLogin != null && "PASS".equals( aLogin.getAttribute(
"status" ) ) );
}
- return aHostConfig;
+ return bSuccess ? aSession : null;
}
private static XControl GetControlFromDialog( XDialog xDialog, String
aControlName )
@@ -969,8 +841,6 @@ public class Helper
if ( xContext != null && nErrorID >= 0 && nErrorID < STRINGS_NUM )
{
- boolean bShown = false;
-
String sError = null;
String sTitle = "";
@@ -992,59 +862,62 @@ public class Helper
if ( xParentPeer != null )
{
- XMessageBoxFactory xMBFactory = null;
- XMessageBox xMB = null;
- try
+ final XComponentContext xCtx = xContext;
+ final XWindowPeer xPeer = xParentPeer;
+ final boolean bAsk = bQuery;
+ final String sBoxTitle = sTitle;
+ final String sBoxText = sError;
+ bResult = MainThreadDialogExecutor.Run( xContext, new
Callable<Boolean>()
{
- XMultiComponentFactory xFactory =
xContext.getServiceManager();
- if ( xFactory != null )
- xMBFactory = UnoRuntime.queryInterface(
+ public Boolean call() throws Exception
+ {
+ XMessageBoxFactory xMBFactory =
UnoRuntime.queryInterface(
XMessageBoxFactory.class,
- xFactory.createInstanceWithContext(
"com.sun.star.awt.Toolkit", xContext ) );
+
xCtx.getServiceManager().createInstanceWithContext( "com.sun.star.awt.Toolkit",
xCtx ) );
+ if ( xMBFactory == null )
+ return Boolean.FALSE;
- if ( xMBFactory != null )
- {
- if ( bQuery )
+ XMessageBox xMB;
+ if ( bAsk )
{
xMB = xMBFactory.createMessageBox(
- xParentPeer,
+ xPeer,
MessageBoxType.QUERYBOX,
MessageBoxButtons.BUTTONS_YES_NO | MessageBoxButtons.DEFAULT_BUTTON_NO,
- sTitle,
- sError );
+ sBoxTitle,
+ sBoxText );
}
else
{
xMB = xMBFactory.createMessageBox(
- xParentPeer,
+ xPeer,
MessageBoxType.ERRORBOX,
MessageBoxButtons.BUTTONS_OK,
- sTitle,
- sError );
+ sBoxTitle,
+ sBoxText );
+ }
+ if ( xMB == null )
+ return Boolean.FALSE;
+
+ try
+ {
+ short nRes = xMB.execute();
+ return Boolean.valueOf( nRes ==
com.sun.star.awt.MessageBoxResults.OK
+ || nRes ==
com.sun.star.awt.MessageBoxResults.YES );
}
- if ( xMB != null )
+ finally
{
- bResult = MainThreadDialogExecutor.Execute(
xContext, xMB );
- bShown = true;
+ Dispose( xMB );
}
}
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- finally
- {
- if ( xMB != null )
- Dispose( xMB );
- }
+ } );
}
}
return bResult;
}
- private static boolean AllowUnknownCert( XComponentContext xContext,
String aURL )
+ protected static boolean AllowUnknownCert( XComponentContext xContext,
String aURL )
{
try
{
diff --git
a/main/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java
b/main/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java
index e979ea6f23..5345348df8 100644
--- a/main/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java
+++ b/main/swext/mediawiki/src/com/sun/star/wiki/MainThreadDialogExecutor.java
@@ -26,24 +26,25 @@ package com.sun.star.wiki;
import com.sun.star.uno.Any;
import com.sun.star.awt.XDialog;
import com.sun.star.awt.XCallback;
-import com.sun.star.awt.XMessageBox;
import com.sun.star.awt.XRequestCallback;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
+import java.util.concurrent.Callable;
public class MainThreadDialogExecutor implements XCallback
{
- private WikiDialog m_aWikiDialog;
+ private Callable<Boolean> m_aTask;
private XDialog m_xDialog;
- private XMessageBox m_xMessageBox;
private boolean m_bResult = false;
private boolean m_bCalled = false;
private boolean m_bClose = false;
- static public boolean Show( XComponentContext xContext, WikiDialog
aWikiDialog )
+ /** Runs aTask on the main thread. Dialogs and message boxes must also be
created there:
+ on macOS a window created on another thread gets no native window and
its modal execute never returns. */
+ static public boolean Run( XComponentContext xContext, Callable<Boolean>
aTask )
{
- MainThreadDialogExecutor aExecutor = new MainThreadDialogExecutor(
aWikiDialog );
+ MainThreadDialogExecutor aExecutor = new MainThreadDialogExecutor(
aTask );
return GetCallback( xContext, aExecutor );
}
@@ -53,12 +54,6 @@ public class MainThreadDialogExecutor implements XCallback
return GetCallback( xContext, aExecutor );
}
- static public boolean Execute( XComponentContext xContext, XMessageBox
xMessageBox )
- {
- MainThreadDialogExecutor aExecutor = new MainThreadDialogExecutor(
xMessageBox );
- return GetCallback( xContext, aExecutor );
- }
-
static public boolean Close( XComponentContext xContext, XDialog xDialog )
{
MainThreadDialogExecutor aExecutor = new MainThreadDialogExecutor(
xDialog, true );
@@ -111,9 +106,9 @@ public class MainThreadDialogExecutor implements XCallback
return aExecutor.GetResult();
}
- private MainThreadDialogExecutor( WikiDialog aWikiDialog )
+ private MainThreadDialogExecutor( Callable<Boolean> aTask )
{
- m_aWikiDialog = aWikiDialog;
+ m_aTask = aTask;
}
private MainThreadDialogExecutor( XDialog xDialog )
@@ -128,11 +123,6 @@ public class MainThreadDialogExecutor implements XCallback
m_bCalled = true; // no yielding, asynchronous closing
}
- private MainThreadDialogExecutor( XMessageBox xMessageBox )
- {
- m_xMessageBox = xMessageBox;
- }
-
private boolean GetResult()
{
return m_bResult;
@@ -140,8 +130,17 @@ public class MainThreadDialogExecutor implements XCallback
public void notify( Object aData )
{
- if ( m_aWikiDialog != null )
- m_bResult = m_aWikiDialog.show();
+ if ( m_aTask != null )
+ {
+ try
+ {
+ m_bResult = m_aTask.call().booleanValue();
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
else if ( m_xDialog != null )
{
if ( !m_bClose )
@@ -159,12 +158,6 @@ public class MainThreadDialogExecutor implements XCallback
m_bResult = true;
}
}
- else if ( m_xMessageBox != null )
- {
- int nRes = m_xMessageBox.execute();
- m_bResult = ( nRes == com.sun.star.awt.MessageBoxResults.OK
- || nRes == com.sun.star.awt.MessageBoxResults.YES );
- }
m_bCalled = true;
}
diff --git a/main/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
b/main/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
index e18e531f1c..eed4eebf4c 100644
--- a/main/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
+++ b/main/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java
@@ -23,24 +23,18 @@
package com.sun.star.wiki;
-import com.sun.star.task.UrlRecord;
-import java.io.*;
+import java.net.URL;
import java.util.Hashtable;
-import javax.swing.text.html.*;
+import java.util.concurrent.Callable;
import com.sun.star.uno.XComponentContext;
-
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class WikiArticle
{
private XComponentContext m_xContext;
- private String m_sEditTime = "";
- private String m_sEditToken = "";
-
- protected String m_sHTMLCode;
private boolean m_bNoArticle = true;
protected String m_sWikiUser;
@@ -48,8 +42,8 @@ public class WikiArticle
protected String m_sTitle = "";
- private URI m_aMainURI;
- private HostConfiguration m_aHostConfig;
+ private URL m_aMainURL;
+ private WikiSession m_aSession;
/** Creates a new instance of WikiArticle */
@@ -63,55 +57,55 @@ public class WikiArticle
m_sWikiPass = (String) wikiSettings.get("Password");
m_sTitle = sTitle;
- m_aMainURI = new URI( sMainUrl );
-
-// viewURL = sMainUrl + "index.php?title=" + m_sTitle;
-// editURL = sMainUrl + "index.php?title=" + m_sTitle + "&action=edit";
-// submitURL = sMainUrl + "index.php?title=" + m_sTitle +
"&action=submit";
-// loginURL = sMainUrl + "index.php?title=Special:Userlogin";
-// loginSubmitURL = sMainUrl +
"index.php?title=Special:Userlogin&action=submitlogin";
+ m_aMainURL = new URL( sMainUrl );
if ( bLogin )
{
- WikiEditSettingDialog aDialog = new
WikiEditSettingDialog(m_xContext,
"vnd.sun.star.script:WikiEditor.EditSetting?location=application",
wikiSettings, false );
- try
+ final XComponentContext xDialogContext = xContext;
+ final Hashtable aDialogSettings = wikiSettings;
+ Callable<Boolean> aAskForLogin = new Callable<Boolean>()
{
- while( !Login() )
+ public Boolean call()
{
- if ( aPropDialog != null )
- aPropDialog.SetThrobberActive( false );
-
- if ( MainThreadDialogExecutor.Show( xContext, aDialog ) )
+ WikiEditSettingDialog aDialog = new WikiEditSettingDialog(
xDialogContext,
"vnd.sun.star.script:WikiEditor.EditSetting?location=application",
aDialogSettings, false );
+ try
{
- m_sWikiUser = (String) wikiSettings.get("Username");
- m_sWikiPass = (String) wikiSettings.get("Password");
+ return Boolean.valueOf( aDialog.show() );
}
- else
- throw new WikiCancelException();
-
- if ( aPropDialog != null )
+ finally
{
- aPropDialog.SetThrobberActive( true );
- Thread.yield();
+ aDialog.DisposeDialog();
}
}
- }
- finally
+ };
+
+ while( !Login() )
{
- aDialog.DisposeDialog();
+ if ( aPropDialog != null )
+ aPropDialog.SetThrobberActive( false );
+
+ if ( MainThreadDialogExecutor.Run( xContext, aAskForLogin ) )
+ {
+ m_sWikiUser = (String) wikiSettings.get("Username");
+ m_sWikiPass = (String) wikiSettings.get("Password");
+ }
+ else
+ throw new WikiCancelException();
+
+ if ( aPropDialog != null )
+ {
+ aPropDialog.SetThrobberActive( true );
+ Thread.yield();
+ }
}
}
- // in case of loading the HTML contents are used
- // in case of saving the contents should be checked whether they are
empty
- InitArticleHTML();
-
- // getArticleWiki();
+ InitArticleExistence();
}
public String GetMainURL()
{
- return m_aMainURI.toString();
+ return m_aMainURL.toString();
}
public String GetTitle()
@@ -119,172 +113,56 @@ public class WikiArticle
return m_sTitle;
}
- public String GetViewURL()
- {
- return m_aMainURI.toString() + "index.php?title=" + m_sTitle;
- }
-
- private String getArticleWiki()
- throws com.sun.star.uno.Exception, java.io.IOException,
WikiCancelException
- {
- String sWikiCode = null;
-
- if ( m_aHostConfig != null )
- {
- URI aURI = new URI( m_aMainURI.toString() + "index.php?title=" +
m_sTitle + "&action=edit" );
- GetMethod aRequest = new GetMethod( aURI.getEscapedPathQuery() );
-
- Helper.ExecuteMethod( aRequest, m_aHostConfig, aURI, m_xContext,
false );
-
- int nResultCode = aRequest.getStatusCode();
- String sWebPage = null;
- if ( nResultCode == 200 )
- sWebPage = aRequest.getResponseBodyAsString();
-
- aRequest.releaseConnection();
-
- if ( sWebPage != null )
- {
- StringReader r = new StringReader(sWebPage);
- HTMLEditorKit.Parser parse = Helper.GetHTMLParser();
- EditPageParser callback = new EditPageParser();
-
- parse.parse(r,callback,true);
- m_sEditTime = callback.m_sEditTime;
- m_sEditToken = callback.m_sEditToken;
-
- int iPosStart = callback.m_nWikiArticleStart;
- int iPosEnd = callback.m_nWikiArticleEnd;
-
- if ( iPosStart >= 0 && iPosEnd > 0 )
- {
- String sArticle = sWebPage.substring(iPosStart, iPosEnd);
- iPosStart = sArticle.indexOf(">") + 1;
- sWikiCode = sArticle.substring( iPosStart,
sArticle.length() );
- }
- }
- }
-
- return sWikiCode;
- }
-
- private void InitArticleHTML()
- throws com.sun.star.uno.Exception, java.io.IOException,
WikiCancelException
+ private void InitArticleExistence()
+ throws java.io.IOException, WikiCancelException
{
- if ( m_aHostConfig != null )
+ if ( m_aSession != null )
{
- URI aURI = new URI( m_aMainURI.toString() + "index.php?title=" +
m_sTitle );
- GetMethod aRequest = new GetMethod( aURI.getEscapedPathQuery() );
-
- Helper.ExecuteMethod( aRequest, m_aHostConfig, aURI, m_xContext,
false );
-
- int nResultCode = aRequest.getStatusCode();
- String sWebPage = null;
- if ( nResultCode == 200 )
- sWebPage = aRequest.getResponseBodyAsString();
-
- if ( sWebPage != null )
- {
- StringReader r = new StringReader(sWebPage);
- HTMLEditorKit.Parser parse = Helper.GetHTMLParser();
- EditPageParser callback = new EditPageParser();
-
- parse.parse(r,callback,true);
-
- int iPosStart = callback.m_nHTMLArticleStart;
- int iPosEnd = callback.m_nHTMLArticleEnd;
- int nPosNoArt = callback.m_nNoArticleInd;
-
- if ( iPosStart >= 0 && iPosEnd > 0 )
- {
- m_sHTMLCode = sWebPage.substring(iPosStart, iPosEnd);
- m_bNoArticle = ( nPosNoArt >= 0 && nPosNoArt >= iPosStart
&& nPosNoArt <= iPosEnd );
- }
- }
+ Document aResult = m_aSession.CallAPI( new String[][] {
+ { "action", "query" }, { "prop", "info" }, { "titles",
m_sTitle } } );
+ Element aPage = WikiSession.GetElement( aResult, "page" );
+ m_bNoArticle = ( aPage == null || aPage.hasAttribute( "missing" )
|| aPage.hasAttribute( "invalid" ) );
}
}
protected boolean setArticle( String sWikiCode, String sWikiComment,
boolean bMinorEdit )
- throws com.sun.star.uno.Exception, java.io.IOException,
WikiCancelException
+ throws java.io.IOException, WikiCancelException
{
boolean bResult = false;
- if ( m_aHostConfig != null && sWikiCode != null && sWikiComment !=
null )
+ if ( m_aSession != null && sWikiCode != null && sWikiComment != null )
{
- // get the edit time and token
- getArticleWiki();
-
- URI aURI = new URI( m_aMainURI.getPath() + "index.php?title=" +
m_sTitle + "&action=submit" );
- PostMethod aPost = new PostMethod();
- aPost.setPath( aURI.getEscapedPathQuery() );
-
- // aPost.addParameter( "title", m_sTitle );
- // aPost.addParameter( "action", "submit" );
- aPost.addParameter( "wpTextbox1", sWikiCode );
- aPost.addParameter( "wpSummary", sWikiComment );
- aPost.addParameter( "wpSection", "" );
- aPost.addParameter( "wpEdittime", m_sEditTime );
- aPost.addParameter( "wpSave", "Save page" );
- aPost.addParameter( "wpEditToken", m_sEditToken );
-
- if ( bMinorEdit )
- aPost.addParameter( "wpMinoredit", "1" );
-
- Helper.ExecuteMethod( aPost, m_aHostConfig, aURI, m_xContext,
false );
-
- int nResultCode = aPost.getStatusCode();
- if ( nResultCode < 400 )
- bResult = true;
-
- String aResult = aPost.getResponseBodyAsString();
-
- // TODO: remove the debug printing, try to detect the error
- System.out.print( "nSubmitCode = " + nResultCode + "\n===\n" +
aResult );
+ String sToken = m_aSession.GetToken( "csrf" );
+ if ( sToken == null )
+ return false;
+
+ Document aResult = m_aSession.CallAPI( new String[][] {
+ { "action", "edit" },
+ { "title", m_sTitle },
+ { "text", sWikiCode },
+ { "summary", sWikiComment },
+ { bMinorEdit ? "minor" : "notminor", "1" },
+ // fail instead of silently saving as an anonymous edit if
the session was lost
+ { "assert", "user" },
+ // MediaWiki recommends sending the token last
+ { "token", sToken } } );
+
+ Element aEdit = WikiSession.GetElement( aResult, "edit" );
+ bResult = ( aEdit != null && "Success".equals( aEdit.getAttribute(
"result" ) ) );
}
return bResult;
}
protected boolean Login()
- throws com.sun.star.uno.Exception, java.io.IOException,
WikiCancelException
- {
- m_aHostConfig = Helper.Login( m_aMainURI, m_sWikiUser, m_sWikiPass,
m_xContext );
- return ( m_aHostConfig != null );
- }
-
- protected void cleanHTML()
+ throws java.io.IOException, WikiCancelException
{
- if ( m_sHTMLCode != null )
- {
- //Welcome to regex hell ;)
-
- //strip comments
- m_sHTMLCode = m_sHTMLCode.replaceAll("\\<![
\\r\\n\\t]*(--([^\\-]|[\\r\\n]|-[^\\-])*--[ \\r\\n\\t]*)\\>","");
-
- //strip edit section links
- m_sHTMLCode = m_sHTMLCode.replaceAll("\\<div
class=\"editsection\".*?\\</div\\>","");
-
- //strip huge spaces
- m_sHTMLCode = m_sHTMLCode.replaceAll("\\<p\\>\\<br /\\>[
\r\n\t]*?\\</p\\>","");
-
- //strip toc
- m_sHTMLCode =
m_sHTMLCode.replaceAll("\\<table.*id=\"toc\"(.|[\r\n])*?\\</table\\>","");
-
- //strip jump-to-nav
- m_sHTMLCode = m_sHTMLCode.replaceAll("\\<div
id=\"jump-to-nav\".*?\\</div\\>","");
-
- //strip Javascript
- m_sHTMLCode =
m_sHTMLCode.replaceAll("\\<script(.|[\r\n])*?\\</script\\>","");
- }
+ m_aSession = Helper.Login( m_aMainURL, m_sWikiUser, m_sWikiPass,
m_xContext );
+ return ( m_aSession != null );
}
-
protected boolean NotExist()
{
- boolean bResult = true;
- if ( m_sHTMLCode != null )
- bResult = m_bNoArticle;
-
- return bResult;
+ return m_bNoArticle;
}
}
diff --git
a/main/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
b/main/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
index dfed526b24..7c5ea3b39e 100644
--- a/main/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
+++ b/main/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java
@@ -29,12 +29,10 @@ import com.sun.star.beans.XPropertySet;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.EventObject;
+import java.net.URL;
import java.util.Hashtable;
import javax.net.ssl.SSLException;
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.methods.*;
-
public class WikiEditSettingDialog extends WikiDialog
{
@@ -202,8 +200,6 @@ public class WikiEditSettingDialog extends WikiDialog
String sUserName = ( String ) GetPropSet( "UsernameField"
).getPropertyValue( "Text" );
String sPassword = ( String ) GetPropSet( "PasswordField"
).getPropertyValue( "Text" );
- HostConfiguration aHostConfig = new HostConfiguration();
- boolean bInitHost = true;
boolean bAllowIndex = true;
do
@@ -216,32 +212,23 @@ public class WikiEditSettingDialog extends WikiDialog
if ( sURL.length() > 0 )
{
- URI aURI = new URI( sURL );
- GetMethod aRequest = new GetMethod(
aURI.getEscapedPathQuery() );
- aRequest.setFollowRedirects( false );
- Helper.ExecuteMethod( aRequest, aHostConfig, aURI,
m_xContext, bInitHost );
- bInitHost = false;
+ WikiSession.Response aResponse = new WikiSession(
m_xContext, null ).Get( new URL( sURL ) );
- int nResultCode = aRequest.getStatusCode();
String sWebPage = null;
- if ( nResultCode == 200 )
- sWebPage = aRequest.getResponseBodyAsString();
- else if ( nResultCode >= 301 && nResultCode <= 303 ||
nResultCode == 307 )
- sRedirectURL = aRequest.getResponseHeader( "Location"
).getValue();
-
- aRequest.releaseConnection();
+ if ( aResponse.m_nStatus == 200 )
+ sWebPage = aResponse.m_sBody;
if ( sWebPage != null && sWebPage.length() > 0 )
{
//the URL is valid
- String sMainURL = Helper.GetMainURL( sWebPage, sURL );
+ String sMainURL = Helper.GetMainURL( sWebPage,
aResponse.m_aURL );
if ( sMainURL.equals( "" ) )
{
// TODO:
// it's not a Wiki Page, check first whether a
redirect is requested
// happens usually in case of https
- sRedirectURL = Helper.GetRedirectURL( sWebPage,
sURL );
+ sRedirectURL = Helper.GetRedirectURL( sWebPage,
aResponse.m_aURL );
if ( sRedirectURL.equals( "" ) )
{
// show error
@@ -255,10 +242,10 @@ public class WikiEditSettingDialog extends WikiDialog
}
else
{
- URI aMainURI = new URI( sMainURL, true ); // it
must be an escaped URL, otherwise an exception should be thrown
+ URL aMainURL = new URL( sMainURL );
if ( ( sUserName.length() > 0 ||
sPassword.length() > 0 )
- && Helper.Login( aMainURI, sUserName, sPassword,
m_xContext ) == null )
+ && Helper.Login( aMainURL, sUserName, sPassword,
m_xContext ) == null )
{
// a wrong login information is provided
// show error
@@ -271,7 +258,7 @@ public class WikiEditSettingDialog extends WikiDialog
}
else
{
- setting.put( "Url", aMainURI.getEscapedURI() );
+ setting.put( "Url", aMainURL.toString() );
setting.put( "Username", sUserName );
setting.put( "Password", sPassword );
if ( addMode )
@@ -285,7 +272,7 @@ public class WikiEditSettingDialog extends WikiDialog
}
}
}
- else if ( sRedirectURL == null || sRedirectURL.length() ==
0 )
+ else
{
if ( sURL.length() > 0 && !sURL.endsWith( "index.php"
) && bAllowIndex )
{
diff --git
a/main/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java
b/main/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java
deleted file mode 100644
index 75dacb64dd..0000000000
--- a/main/swext/mediawiki/src/com/sun/star/wiki/WikiProtocolSocketFactory.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-
-package com.sun.star.wiki;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.KeyStore;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import org.apache.commons.httpclient.ConnectTimeoutException;
-import org.apache.commons.httpclient.HttpClientError;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
-import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
-
-class WikiProtocolSocketFactory implements SecureProtocolSocketFactory
-{
- private SSLContext m_aSSLContext;
-
- public WikiProtocolSocketFactory()
- {
- super();
- }
-
- public synchronized SSLContext GetNotSoSecureSSLContext()
- {
- if ( m_aSSLContext == null )
- {
- TrustManager[] pTrustUnknownCerts = new TrustManager[]
- {
- new X509TrustManager() {
- private X509TrustManager m_aOrgTrustManager;
-
- private X509TrustManager GetOrgTrustManager()
- {
- if ( m_aOrgTrustManager == null )
- {
- try
- {
- TrustManagerFactory aFactory =
TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
- aFactory.init( (KeyStore)null );
- TrustManager[] pTrustmanagers =
aFactory.getTrustManagers();
- if ( pTrustmanagers.length != 0 &&
pTrustmanagers[0] != null )
- m_aOrgTrustManager =
(X509TrustManager)pTrustmanagers[0];
- }
- catch( Exception e )
- {
- throw new RuntimeException( "No access to the
default trust manager!" );
- }
- }
-
- return m_aOrgTrustManager;
- }
-
- public X509Certificate[] getAcceptedIssuers()
- {
- return GetOrgTrustManager().getAcceptedIssuers();
- }
-
- public void checkClientTrusted(X509Certificate[] certs,
String authType) throws CertificateException
- {
- GetOrgTrustManager().checkClientTrusted( certs,
authType );
- }
-
- public void checkServerTrusted(X509Certificate[] certs,
String authType) throws CertificateException
- {
- if ( certs == null || certs.length == 0 )
- GetOrgTrustManager().checkServerTrusted( certs,
authType );
- else
- for ( int nInd = 0; nInd < certs.length; nInd++ )
- certs[nInd].checkValidity();
- }
- }
- };
-
- try
- {
- SSLContext aContext = SSLContext.getInstance("SSL");
- if ( aContext != null )
- {
- aContext.init( null, pTrustUnknownCerts, null );
- m_aSSLContext = aContext;
- }
- }
- catch ( Exception e )
- {
- }
- }
-
- if ( m_aSSLContext == null )
- throw new HttpClientError();
-
- return m_aSSLContext;
- }
-
- public Socket createSocket( String sHost, int nPort, InetAddress
clientHost, int clientPort )
- throws IOException, UnknownHostException
- {
- return GetNotSoSecureSSLContext().getSocketFactory().createSocket(
sHost, nPort, clientHost, clientPort );
- }
-
- public Socket createSocket( final String sHost, final int nPort, final
InetAddress aLocalAddress, final int nLocalPort, final HttpConnectionParams
params )
- throws IOException, UnknownHostException, ConnectTimeoutException
- {
- if ( params == null )
- return createSocket( sHost, nPort, aLocalAddress, nLocalPort );
-
- int nTimeout = params.getConnectionTimeout();
- Socket aSocket =
GetNotSoSecureSSLContext().getSocketFactory().createSocket();
- aSocket.bind( new InetSocketAddress( aLocalAddress, nLocalPort ) );
- aSocket.connect( new InetSocketAddress( sHost, nPort ), nTimeout );
- return aSocket;
- }
-
- public Socket createSocket( String sHost, int nPort )
- throws IOException, UnknownHostException
- {
- return GetNotSoSecureSSLContext().getSocketFactory().createSocket(
sHost, nPort );
- }
-
- public Socket createSocket( Socket aSocket, String sHost, int nPort,
boolean bAutoClose )
- throws IOException, UnknownHostException
- {
- return GetNotSoSecureSSLContext().getSocketFactory().createSocket(
aSocket, sHost, nPort, bAutoClose );
- }
-
- public boolean equals(Object obj)
- {
- return ((obj != null) &&
obj.getClass().equals(WikiProtocolSocketFactory.class));
- }
-
- public int hashCode()
- {
- return WikiProtocolSocketFactory.class.hashCode();
- }
-}
diff --git a/main/swext/mediawiki/src/com/sun/star/wiki/WikiSession.java
b/main/swext/mediawiki/src/com/sun/star/wiki/WikiSession.java
new file mode 100644
index 0000000000..7a8f3065ec
--- /dev/null
+++ b/main/swext/mediawiki/src/com/sun/star/wiki/WikiSession.java
@@ -0,0 +1,389 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package com.sun.star.wiki;
+
+import com.sun.star.uno.XComponentContext;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.CookieManager;
+import java.net.CookiePolicy;
+import java.net.HttpURLConnection;
+import java.net.Proxy;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.security.KeyStore;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/** An HTTP session with one MediaWiki server, talking to its Action API
(api.php). */
+public class WikiSession
+{
+ public static class Response
+ {
+ public int m_nStatus;
+ public String m_sBody;
+ public URL m_aURL;
+ }
+
+ private static final int MAX_REDIRECTS = 10;
+ private static final int CONNECT_TIMEOUT_MS = 30000;
+ private static final String USER_AGENT =
"Apache-OpenOffice-Wiki-Publisher";
+
+ private static SSLSocketFactory m_aUnknownCertSocketFactory;
+
+ private XComponentContext m_xContext;
+ private URL m_aMainURL;
+ // not CookieHandler.setDefault(): that would be shared by everything in
the office JVM
+ private CookieManager m_aCookies = new CookieManager( null,
CookiePolicy.ACCEPT_ORIGINAL_SERVER );
+
+ public WikiSession( XComponentContext xContext, URL aMainURL )
+ {
+ m_xContext = xContext;
+ m_aMainURL = aMainURL;
+ }
+
+ public URL GetMainURL()
+ {
+ return m_aMainURL;
+ }
+
+ public Response Get( URL aURL )
+ throws IOException, WikiCancelException
+ {
+ for ( int nRedirect = 0; ; nRedirect++ )
+ {
+ HttpURLConnection aConn = Open( aURL );
+ Response aResponse = Execute( aConn, aURL, null );
+ int nStatus = aResponse.m_nStatus;
+ String sLocation = aConn.getHeaderField( "Location" );
+ if ( nStatus < 300 || nStatus > 399 || sLocation == null ||
nRedirect >= MAX_REDIRECTS )
+ return aResponse;
+
+ aURL = new URL( aURL, sLocation );
+ }
+ }
+
+ public Response Post( URL aURL, String[][] pParams )
+ throws IOException, WikiCancelException
+ {
+ StringBuilder aBody = new StringBuilder();
+ for ( int nInd = 0; nInd < pParams.length; nInd++ )
+ {
+ if ( pParams[nInd] == null || pParams[nInd][0] == null ||
pParams[nInd][1] == null )
+ continue;
+ if ( aBody.length() > 0 )
+ aBody.append( '&' );
+ aBody.append( URLEncoder.encode( pParams[nInd][0], "UTF-8" ) );
+ aBody.append( '=' );
+ aBody.append( URLEncoder.encode( pParams[nInd][1], "UTF-8" ) );
+ }
+
+ HttpURLConnection aConn = Open( aURL );
+ aConn.setRequestMethod( "POST" );
+ aConn.setDoOutput( true );
+ aConn.setRequestProperty( "Content-Type",
"application/x-www-form-urlencoded; charset=UTF-8" );
+ return Execute( aConn, aURL, aBody.toString().getBytes( "UTF-8" ) );
+ }
+
+ /** Calls api.php; HTTP errors and non-XML answers throw, API-level errors
are left in the returned document. */
+ public Document CallAPI( String[][] pParams )
+ throws IOException, WikiCancelException
+ {
+ String[][] pAllParams = new String[pParams.length + 1][];
+ pAllParams[0] = new String[] { "format", "xml" };
+ System.arraycopy( pParams, 0, pAllParams, 1, pParams.length );
+
+ Response aResponse = Post( new URL( m_aMainURL, "api.php" ),
pAllParams );
+ if ( aResponse.m_nStatus != 200 )
+ throw new IOException( "MediaWiki API request failed with HTTP
status " + aResponse.m_nStatus );
+
+ try
+ {
+ DocumentBuilderFactory aFactory =
DocumentBuilderFactory.newInstance();
+ aFactory.setFeature(
"http://apache.org/xml/features/disallow-doctype-decl", true );
+ aFactory.setExpandEntityReferences( false );
+ DocumentBuilder aBuilder = aFactory.newDocumentBuilder();
+ Document aDoc = aBuilder.parse( new ByteArrayInputStream(
aResponse.m_sBody.getBytes( "UTF-8" ) ) );
+ if ( !"api".equals( aDoc.getDocumentElement().getTagName() ) )
+ throw new IOException( "Not a MediaWiki API response" );
+ return aDoc;
+ }
+ catch ( IOException e )
+ {
+ throw e;
+ }
+ catch ( Exception e )
+ {
+ IOException aIOEx = new IOException( "Not a MediaWiki API
response" );
+ aIOEx.initCause( e );
+ throw aIOEx;
+ }
+ }
+
+ /** Returns the requested token ("login", "csrf"), or null if the wiki
does not provide it. */
+ public String GetToken( String sType )
+ throws IOException, WikiCancelException
+ {
+ Document aDoc = CallAPI( new String[][] { { "action", "query" }, {
"meta", "tokens" }, { "type", sType } } );
+ Element aTokens = GetElement( aDoc, "tokens" );
+ if ( aTokens == null || !aTokens.hasAttribute( sType + "token" ) )
+ return null;
+ return aTokens.getAttribute( sType + "token" );
+ }
+
+ public static Element GetElement( Document aDoc, String sTagName )
+ {
+ NodeList aList = aDoc.getElementsByTagName( sTagName );
+ return aList.getLength() > 0 ? (Element) aList.item( 0 ) : null;
+ }
+
+ private HttpURLConnection Open( URL aURL )
+ throws IOException, WikiCancelException
+ {
+ if ( !Helper.IsConnectionAllowed() )
+ throw new WikiCancelException();
+
+ String sProtocol = aURL.getProtocol();
+ if ( !sProtocol.equals( "http" ) && !sProtocol.equals( "https" ) )
+ throw new IOException( "Unsupported protocol: " + sProtocol );
+
+ Proxy aProxy = Helper.GetProxy( m_xContext, aURL );
+ HttpURLConnection aConn = (HttpURLConnection) ( aProxy == null ?
aURL.openConnection() : aURL.openConnection( aProxy ) );
+ aConn.setInstanceFollowRedirects( false );
+ aConn.setConnectTimeout( CONNECT_TIMEOUT_MS );
+ aConn.setUseCaches( false );
+ aConn.setRequestProperty( "User-Agent", USER_AGENT );
+
+ if ( aConn instanceof HttpsURLConnection && Helper.AllowUnknownCert(
m_xContext, aURL.getHost() ) )
+ ( (HttpsURLConnection) aConn ).setSSLSocketFactory(
GetUnknownCertSocketFactory() );
+
+ try
+ {
+ Map<String, List<String>> aCookieHeaders = m_aCookies.get(
aURL.toURI(), new HashMap<String, List<String>>() );
+ List<String> aCookies = aCookieHeaders.get( "Cookie" );
+ if ( aCookies != null && !aCookies.isEmpty() )
+ {
+ StringBuilder aCookie = new StringBuilder();
+ for ( String sCookie : aCookies )
+ {
+ if ( aCookie.length() > 0 )
+ aCookie.append( "; " );
+ aCookie.append( sCookie );
+ }
+ aConn.setRequestProperty( "Cookie", aCookie.toString() );
+ }
+ }
+ catch ( URISyntaxException e )
+ {
+ throw new IOException( e.getMessage() );
+ }
+
+ return aConn;
+ }
+
+ private Response Execute( HttpURLConnection aConn, URL aURL, byte[] pBody )
+ throws IOException, WikiCancelException
+ {
+ Helper.RegisterConnection( aConn );
+ try
+ {
+ // disconnect() is a no-op until the TCP connect has finished, so
recheck a cancel that came during it
+ aConn.connect();
+ if ( !Helper.IsConnectionAllowed() )
+ throw new WikiCancelException();
+
+ if ( pBody != null )
+ {
+ OutputStream aOut = aConn.getOutputStream();
+ try
+ {
+ aOut.write( pBody );
+ }
+ finally
+ {
+ aOut.close();
+ }
+ }
+
+ Response aResponse = new Response();
+ aResponse.m_nStatus = aConn.getResponseCode();
+ aResponse.m_aURL = aURL;
+
+ try
+ {
+ m_aCookies.put( aURL.toURI(), aConn.getHeaderFields() );
+ }
+ catch ( URISyntaxException e )
+ {
+ throw new IOException( e.getMessage() );
+ }
+
+ InputStream aIn = aResponse.m_nStatus >= 400 ?
aConn.getErrorStream() : aConn.getInputStream();
+ aResponse.m_sBody = ( aIn == null ) ? "" : ReadAll( aIn,
GetCharset( aConn.getContentType() ) );
+ return aResponse;
+ }
+ catch ( IOException e )
+ {
+ if ( !Helper.IsConnectionAllowed() )
+ throw new WikiCancelException();
+ throw e;
+ }
+ finally
+ {
+ Helper.UnregisterConnection( aConn );
+ }
+ }
+
+ private static String GetCharset( String sContentType )
+ {
+ if ( sContentType != null )
+ {
+ String[] pParts = sContentType.split( ";" );
+ for ( int nInd = 1; nInd < pParts.length; nInd++ )
+ {
+ String sPart = pParts[nInd].trim();
+ if ( sPart.regionMatches( true, 0, "charset=", 0, 8 ) )
+ return sPart.substring( 8 ).replace( "\"", "" ).trim();
+ }
+ }
+ return "UTF-8";
+ }
+
+ private static String ReadAll( InputStream aIn, String sCharset )
+ throws IOException
+ {
+ try
+ {
+ ByteArrayOutputStream aOut = new ByteArrayOutputStream();
+ byte[] pBuf = new byte[8192];
+ int nRead;
+ while ( ( nRead = aIn.read( pBuf ) ) != -1 )
+ aOut.write( pBuf, 0, nRead );
+ try
+ {
+ return aOut.toString( sCharset );
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ return aOut.toString( "UTF-8" );
+ }
+ }
+ finally
+ {
+ aIn.close();
+ }
+ }
+
+ private static synchronized SSLSocketFactory GetUnknownCertSocketFactory()
+ throws IOException
+ {
+ if ( m_aUnknownCertSocketFactory == null )
+ {
+ try
+ {
+ TrustManagerFactory aFactory =
TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
+ aFactory.init( (KeyStore) null );
+ X509TrustManager aDefault = null;
+ TrustManager[] pManagers = aFactory.getTrustManagers();
+ for ( int nInd = 0; nInd < pManagers.length && aDefault ==
null; nInd++ )
+ if ( pManagers[nInd] instanceof X509TrustManager )
+ aDefault = (X509TrustManager) pManagers[nInd];
+ if ( aDefault == null )
+ throw new IOException( "No default trust manager" );
+
+ SSLContext aContext = SSLContext.getInstance( "TLS" );
+ aContext.init( null, new TrustManager[] { new
UnknownCertTrustManager( aDefault ) }, null );
+ m_aUnknownCertSocketFactory = aContext.getSocketFactory();
+ }
+ catch ( IOException e )
+ {
+ throw e;
+ }
+ catch ( Exception e )
+ {
+ IOException aIOEx = new IOException( "Cannot initialize TLS" );
+ aIOEx.initCause( e );
+ throw aIOEx;
+ }
+ }
+
+ return m_aUnknownCertSocketFactory;
+ }
+
+ /** For servers the configuration marks with AllowUnknownCertificate: a
server certificate
+ that does not chain to a trusted root is accepted if it is within its
validity period.
+ The host name is still verified by HttpsURLConnection. */
+ private static class UnknownCertTrustManager implements X509TrustManager
+ {
+ private X509TrustManager m_aDefault;
+
+ UnknownCertTrustManager( X509TrustManager aDefault )
+ {
+ m_aDefault = aDefault;
+ }
+
+ public X509Certificate[] getAcceptedIssuers()
+ {
+ return m_aDefault.getAcceptedIssuers();
+ }
+
+ public void checkClientTrusted( X509Certificate[] pCerts, String
sAuthType ) throws CertificateException
+ {
+ m_aDefault.checkClientTrusted( pCerts, sAuthType );
+ }
+
+ public void checkServerTrusted( X509Certificate[] pCerts, String
sAuthType ) throws CertificateException
+ {
+ try
+ {
+ m_aDefault.checkServerTrusted( pCerts, sAuthType );
+ }
+ catch ( CertificateException e )
+ {
+ if ( pCerts == null || pCerts.length == 0 )
+ throw e;
+ pCerts[0].checkValidity();
+ }
+ }
+ }
+}
diff --git a/main/swext/mediawiki/src/description.xml
b/main/swext/mediawiki/src/description.xml
index 207fd52ac3..68e1a751a1 100644
--- a/main/swext/mediawiki/src/description.xml
+++ b/main/swext/mediawiki/src/description.xml
@@ -20,7 +20,7 @@
*
***********************************************************-->
<description xmlns="http://openoffice.org/extensions/description/2006"
xmlns:d="http://openoffice.org/extensions/description/2006"
xmlns:xlink="http://www.w3.org/1999/xlink">
- <version value="1.2.1"/>
+ <version value="1.3.0"/>
<identifier value="@WIKIEXTENSIONID@"/>
<display-name>
<name lang="en-US">@WIKIEXTENSIONPRODUCTNAME@</name>
diff --git a/main/swext/prj/build.lst b/main/swext/prj/build.lst
index c99175fe81..ab29c703ea 100644
--- a/main/swext/prj/build.lst
+++ b/main/swext/prj/build.lst
@@ -1,4 +1,4 @@
-swext swext : officecfg L10N:l10n javaunohelper ridljar unoil jurt
APACHE_COMMONS:apache-commons readlicense_oo xsltml xmlhelp NULL
+swext swext : officecfg L10N:l10n javaunohelper ridljar unoil jurt
readlicense_oo xsltml xmlhelp NULL
swext swext usr1 - all swext_mkout NULL
swext swext\mediawiki\help nmake
- all swext_mwhelp NULL
swext swext\mediawiki\src\registry\schema\org\openoffice\Office\Custom nmake
- all swext_mwschema NULL
diff --git a/main/tomcat/makefile.mk b/main/tomcat/makefile.mk
deleted file mode 100644
index aade6273d9..0000000000
--- a/main/tomcat/makefile.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-#**************************************************************
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#**************************************************************
-
-
-
-PRJ=.
-
-PRJNAME=tomcat
-TARGET=servlet
-
-.IF "$(SOLAR_JAVA)" != ""
-# --- Settings -----------------------------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : antsettings.mk
-
-# --- Files --------------------------------------------------------
-
-TARFILE_NAME=apache-tomcat-5.5.36-src
-TARFILE_MD5=63574e3ada44f473892a61a2da433a59
-
-TARFILE_ROOTDIR=apache-tomcat-5.5.36-src
-
-ADDITIONAL_FILES = servletapi/build.xml
-#CONVERTFILES=build$/build.xml
-
-PATCH_FILES=tomcat.patch
-
-BUILD_DIR=servletapi
-BUILD_ACTION=$(ANT)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : set_ext.mk
-.INCLUDE : target.mk
-
-.INCLUDE : tg_ext.mk
-
-.ELSE
-@all:
- @echo java disabled
-.ENDIF
diff --git a/main/tomcat/prj/build.lst b/main/tomcat/prj/build.lst
deleted file mode 100644
index 184f6dd19b..0000000000
--- a/main/tomcat/prj/build.lst
+++ /dev/null
@@ -1,2 +0,0 @@
-to tomcat : solenv NULL
-to tomcat nmake - all to_mkout NULL
diff --git a/main/tomcat/prj/d.lst b/main/tomcat/prj/d.lst
deleted file mode 100644
index 9e3d64f4de..0000000000
--- a/main/tomcat/prj/d.lst
+++ /dev/null
@@ -1 +0,0 @@
-..\%__SRC%\misc\build\apache-tomcat-5.5.36-src\servletapi\jsr154\dist\lib\servlet-api.jar
%_DEST%\bin%_EXT%\servlet-api.jar
diff --git a/main/tomcat/tomcat.patch b/main/tomcat/tomcat.patch
deleted file mode 100644
index 3ec194448f..0000000000
--- a/main/tomcat/tomcat.patch
+++ /dev/null
@@ -1,25 +0,0 @@
---- misc/apache-tomcat-5.5.36-src/servletapi/build.xml Thu Jun 19 16:03:59 2008
-+++ misc/build/apache-tomcat-5.5.36-src/servletapi/build.xml Thu Jun 19
15:56:18 2008
-@@ -1,1 +1,21 @@
--dummy
-+<project name="jsr154 in Apache OpenOffice" default="debuild" basedir=".">
-+
-+ <target name="debuild"
-+ description="Build jsr154 for Apache OpenOffice (Default)">
-+ <echo message="Building Servlet 2.4 API"/>
-+ <ant antfile="jsr154/build.xml"
-+ target="jar"
-+ inheritAll="false"
-+ />
-+ </target>
-+
-+ <target name="clean" description="Clean">
-+ <echo message="Cleaning Servlet 2.4 API"/>
-+ <ant antfile="jsr154/build.xml"
-+ target="clean"
-+ inheritAll="false"
-+ />
-+ <delete dir="tmp"/>
-+ </target>
-+
-+</project>