pax_global_header00006660000000000000000000000064125772467220014530gustar00rootroot0000000000000052 comment=b683b64a23718364afa502be73ae2a45fee02e99 dokuJClient-dokujclient-3.5.2/000077500000000000000000000000001257724672200162635ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/.gitignore000066400000000000000000000001671257724672200202570ustar00rootroot00000000000000bin tmpForInstallation *.jar .*.sw* *.class target maven-build.properties maven-build.xml .classpath .project aXMLRPC/ dokuJClient-dokujclient-3.5.2/Changelog000066400000000000000000000027241257724672200201020ustar00rootroot000000000000003.5.2 * fix Java 6 compatibility 3.5.1 * fix man page 3.5.0 * add man page 3.4.0 * Upgrade dependency on aXMLRPC (1.8.1) to fix compatibility with DW Detritus. Hence build depends on JCenter * login command returns a boolean to indicate whether it succeeded 3.3.0 * [FIX] Throws DoukMisConfiguredException instead of Unauthorized, when we fail because of the wiki's configuration * [FIX] Throw DokuPageDoesNotExistException when trying to getPageInfo on unexisting page * [FIX] Throw NotAuthorizedException when trying to upload a file without permissions * Added methods and commands addAcl and delAcl * putPage and appendPage can read from stdin * Added method logoff 3.2.0 * Added option --password-interactive 3.1.0 * getPagelist also compute the page hashes 3.0.0 * Added a command line tool * Fixed a few bugs 2.0.0 * ObjectConverter isn't public anymore * Implemented timeout * Also handles DW 2012-01-25b * Uses aXMLRPC instead of Apache xmlrpc, to enhance cookie handling 1.0.0 * Let pass options when editing a page * Added DokuJClientConfig * Let build a DokuJClient with an arbitrary XmlRpcClient * Let pass arbitrary options when editing a page * Throw a relevant exception when trying to create an empty new page 0.3.0 * Enhanced attachment manipularions * Added getRecentChanges(java.util.Date date) * Fixed bug when reading modification date with getPageInfo 0.2.0 * Added getPageVersions(String pageId) * Fixed bug when reading page version with gePagelist 0.1.0 dokuJClient-dokujclient-3.5.2/LICENSE.txt000066400000000000000000000246401257724672200201140ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed 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. dokuJClient-dokujclient-3.5.2/NOTICE.txt000066400000000000000000000040321257724672200200040ustar00rootroot00000000000000========================================================================= == NOTICE file corresponding to section 4(d) of the Apache License, == == Version 2.0, in this case for DokuJClient == ========================================================================= DokuJClient Copyright 2012-2015 Guillaume Turri ######################################################################### ## DokuJClient DEPENDENCIES ## ######################################################################### A binary distribution of DokuJClient which is built from source, includes a number of dependent packages with separate copyright notices and license terms. The following notices apply to these dependencies. ========================================================================= == Apache Maven Notice == ========================================================================= Apache Maven Copyright 2001-2011 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). This product includes software (Plexus and Classworlds) developed by The Codehaus Foundation (http://www.codehaus.org/). This product includes software (Aether, Sisu, Spice, Plexus Ciper and Sec Dispatcher) developed by Sonatype Inc. (http://www.sonatype.org/). This product includes software (NekoHTML) developed by SourceForge (http://www.sourceforge.net/). This product includes software (Guice) developed by Google Code (http://code.google.com/). ========================================================================= == Apache Ant Notice == ========================================================================= Apache Ant Copyright 1999-2012 The Apache Software Foundation The task is based on code Copyright (c) 2002, Landmark Graphics Corp that has been kindly donated to the Apache Software Foundation. dokuJClient-dokujclient-3.5.2/README.md000066400000000000000000000150511257724672200175440ustar00rootroot00000000000000Dokujclient is both a command line tool to interact with instances of Dokwiki, and a Java library for [Dokuwiki xmlrpc interface](https://www.dokuwiki.org/devel:xmlrpc). Currently tested with: * Detritus (dokuwiki-2015-08-10) * Hrun (dokuwiki-2014-09-29) * Ponder Stibbons (dokuwiki-2014-05-05) * Binky (dokuwiki-2013-12-08) * Weatherwax (dokuwiki-2013-05-10) * Adora Belle (dokuwiki-2012-10-03) * Angua (dokuwiki-2012-01-25b) See the "Compatibility" section for more info Command line tool ================= Getting started --------------- Here's a glimpse of what this tool can do: dokujclient --user myUser --password myPassword --url http://mywiki/lib/lib/exe/xmlrpc.php getTitle > myWiki title dokujclient help > [(-u|--user) ] --url [(-p|--password) ] [-h|--help] [--version] [--password-interactive] command > > Available commands: > [...skipped...] #put user, password, and url, in the config file vim ~/.dokujclientrc #get the list of pages of all the wiki dokujclient getPagelist . > [...skipped...] dokujclient appendPage builds:synthesis "Build launched at 12:23 took 3'24" dokujclient getPage builds:synthesis > Build launched at 11:12 took 3'19 > Build launched at 12:23 took 3'24 #help command can give information about a given command dokujclient help putAttachment > Syntax for putAttachment: [-f|--force] dokujclient putAttachment some:file.jpg ~/results.jpg Just make sure that your wiki is configured so that the xmlrpc interface is enabled, and so that your user is allowed to use it (ie: "remote" and "remoteuser" entries in your configuration). Installation ------------ * Download the [binaries](http://turri.fr/dokujclient). * Extract it, and add the extracted directoy to your path * Ensure it's correctly installed, typing e.g.: dokujclient --version Config file ----------- To avoid typing your url, user, and password each time, you may create in your home a .dokujclientrc, and put some or all of this info in it. echo "url=http://myhost/mywiki/lib/exe/xmlrpc.php" > ~/.dokujclientrc echo "user=toto" >> ~/.dokujclientrc echo "password=myPassword" >> ~/.dokujclientrc dokuJClient.jar ========== If you want to build your own application, if you don't want to deal with xmlrpc request yourself, or if you don't want to handle the different versions of Dokuwiki, you may use this library. Getting started --------------- Everything is done through the DokuJClient: just create one and play with its methods. Here is a quick example which displays the title of the wiki and the list of its pages: import dw.xmlrpc.DokuJClient; import dw.xmlrpc.Page; public class Main { public static void main(String[] args) throws Exception{ String url = "http://mywiki/lib/exe/xmlrpc.php"; String user = "myUser"; String pwd = "myPassword"; DokuJClient client = new DokuJClient(url, user, pwd); System.out.println("Pages in the wiki " + client.getTitle() + " are:"); for(Page page : client.getAllPages()){ System.out.println(page.id()); } } } Make sure to add the jar listed in the Dependencies section below, as well as dokujclient.jar to your classpath. Also make sure to configure your wiki so that xmlrpc interface is enabled, and so that your user is allowed to use it (ie: "remote" and "remoteuser" entries in your configuration) Getting the binaries -------------------- JAR files are available via [Maven Central](http://repo1.maven.org/maven2/fr/turri/): ```xml fr.turri dokujclient 3.2.0 ``` Binaries may alse be [downloaded](http://turri.fr/dokujclient) directly. To build them from the sources, see below. Compiling from the command line ------------------------------- On ubuntu, at the root of the project run: # You need maven to compiler sudo apt-get install maven #Actually build mvn package It will generate in the directory `target` a dokujclient-x.y.z-bin.zip which contains both the .jar and the executable command line tool Hacking with Eclipse -------------------- This project uses Maven. To be able [to use Eclipse](http://maven.apache.org/guides/mini/guide-ide-eclipse.html) you should: # Install Maven sudo apt-get install maven # Set the M2_REPO classpath variable mvn -Declipse.workspace= eclipse:add-maven-repo # Generate the Eclipe project files mvn eclipse:eclipse To use the Eclipse projet, you need to ensure every dependencies are available. Just compile once from the command line (see above) to ensure it will be ok. Documentation ------------ To build documentation you must have doxygen installed. Then, run at the root of the repo: mvn javadoc:javadoc To browse the generated docs, point your browser to target/site/apidocs/index.html You may also directly [browse it](http://turri.fr/dokujclient/doc) online. Running integration tests -------------------------- To run the tests you'll need to set up a fake wiki. Please see src/test/resources/README.md to know how to set it up. After that, to run the tests, just run, at the root of the repo: mvn test You can also run mvn site in order to generate a test report and a test coverage report. Compatibility ============= dokuJClient aims at providing the same behavior for every supported version of Dokuwiki. There are however, some discrepancies: * getAttachmentInfo can't retrieve the page title with Angua (dokuwiki-2012-01-25b). It will set it to the page id instead * addAcl and delAcl are supported for dokuwiki-2013-12-08 (Binky) or newer * logoff will always clear the local cookies, but it will clear the server side ones only if you have dokuwiki-2014-05-05 (Ponder Stibbons) or a more recent one Mailing list ============ The mailing list is oriented toward development and usage of DokuJClient. You can subscribe and unsubscribe from https://www.freelists.org/list/dokujclient After subscribing, messages can be sent to dokujclient@freelists.org Donate ====== Dokujclient is a personal open source project started in 2012. I have put hundreds of hours to maintain and enhance it. Donations to Dokujclient will help support bugfix, keeping up to date with the evolutions of Dokuwiki xmlrpc interface, and adding new features. If you have found this tool useful, consider [donating](https://pledgie.com/campaigns/29371), to help for its development. dokuJClient-dokujclient-3.5.2/dokujclient_completion000066400000000000000000000004761257724672200227610ustar00rootroot00000000000000#!bash #Completion support for dokujclient _dokujclient () { local cur cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=($(compgen -W "$(dokujclient --help | grep -v "\[" | grep -v "To get help" | grep -v "Available commands" | tr "\n" " " )" -- $cur)) } complete -o default -o nospace -F _dokujclient dokujclient dokuJClient-dokujclient-3.5.2/man/000077500000000000000000000000001257724672200170365ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/man/build_man.sh000077500000000000000000000012671257724672200213350ustar00rootroot00000000000000#!/bin/bash if [ -z $DOKUJCLIENT_MAN_PATH ]; then DOKUJCLIENT_MAN_PATH=. fi if [ -z "$DOKUJCLIENT_CMD" ]; then if ! which dokujclient >/dev/null; then echo dokujclient must be in your PATH in order to run this script exit -1 fi DOKUJCLIENT_CMD=dokujclient fi rm -rf man1 mkdir man1 cat man.header.txt > $DOKUJCLIENT_MAN_PATH/man1/dokujclient.1 for COMMAND in $($DOKUJCLIENT_CMD --help | grep -v "\[" | grep -v "To get help" | grep -v "Available commands" | grep -v help | sort); do echo .br >> $DOKUJCLIENT_MAN_PATH/man1/dokujclient.1 echo "\fB$COMMAND\fR" >> $DOKUJCLIENT_MAN_PATH/man1/dokujclient.1 done cat man.footer.txt >> $DOKUJCLIENT_MAN_PATH/man1/dokujclient.1 dokuJClient-dokujclient-3.5.2/man/man.footer.txt000066400000000000000000000027621257724672200216560ustar00rootroot00000000000000 .SH FILES To avoid typing your url, user, and password each time, you may create in your home a file .dokujclientrc, and put some or all of this info in it. echo "url=http://myhost/mywiki/lib/exe/xmlrpc.php" > ~/.dokujclientrc echo "user=toto" >> ~/.dokujclientrc echo "password=myPassword" >> ~/.dokujclientrc .SH EXAMPLES dokujclient \-\-user myUser \-\-password myPassword \-\-url http://mywiki/lib/lib/exe/xmlrpc.php getTitle > myWiki title dokujclient help > [(\-u|\-\-user) ] \-\-url [(\-p|\-\-password) ] [\-h|\-\-help] [\-\-version] [\-\-password\-interactive] command > > Available commands: > [...skipped...] #put user, password, and url, in the config file vim ~/.dokujclientrc #get the list of pages of all the wiki dokujclient getPagelist . > [...skipped...] dokujclient appendPage builds:synthesis "Build launched at 12:23 took 3'24" dokujclient getPage builds:synthesis > Build launched at 11:12 took 3'19 > Build launched at 12:23 took 3'24 #help command can give information about a given command dokujclient help putAttachment > Syntax for putAttachment: [\-f|\-\-force] dokujclient putAttachment some:file.jpg ~/results.jpg .SH REPORTING BUGS You are welcome to report bugs to the bugtracker https://github.com/gturri/dokujclient/issues .br You may also ask questions on the mailing list dokujclient@freelists.org .SH SEE ALSO The documentation of the server API is available at https://www.dokuwiki.org/devel:xmlrpc dokuJClient-dokujclient-3.5.2/man/man.header.txt000066400000000000000000000030121257724672200215750ustar00rootroot00000000000000.TH DOKUJCLIENT "1" .SH NAME dokujclient \- interact (read, write, ...) with an instance of Dokuwiki .SH SYNOPSIS .B dokujclient \fIGENERAL_OPTIONS COMMAND COMMAND_OPTIONS\fR .SH DESCRIPTION Dokuwiki is an open source wiki engine. It's hence meant to be mainly used through a web browser. However, it also has an xmlrpc API. .br Dokujclient uses this xmlrpc API, so that it's possible to interact with an instance of Dokuwiki through a console or a shell script. .SH GENERAL OPTIONS .TP \fB\-\-url\fR \fIURL\fR The url to the xmlrpc interface. Should look like http[s]://server/mywiki\fI/lib/exe/xmlrpc.php\fR. .br Obviously, the wiki should be configured to accept incoming xmlrpc queries. See Dokuwiki's \fIremote\fR config. .br This parameter is mandatory. .TP \fB\-u\fR \fIUSER\fR, \fB\-\-user\fR \fIUSER\fR Specify the username \fIUSER\fR to use to connect to the server. .br Obviously, the \fIUSER\fR should be authorized to use the xmlrpc interface. See Dokuwiki's \fIremoteuser\fR config. .TP \fB\-p\fR \fIPASSWORD\fR, \fB\-\-password\fR \fIPASSWORD\fR The password of the \fIUSER\fR .TP \fB\-\-password-interactive\fR You will be prompted to enter the user's password interactively. Useful to avoid writing the password in clear text in the command line. .TP \fB\-\-version\fR Prints the version of dokujclient .TP \fB\-h\fR \fB\-\-help\fR Prints the general help .SH COMMANDS .TP \fBhelp\fR Prints the general help .TP \fBhelp\fR \fICOMMAND\fR Prints the help and the \fICOMMAND_OPTIONS\fR for \fICOMMAND\fR .TP Other commands are: dokuJClient-dokujclient-3.5.2/pom.xml000066400000000000000000000257451257724672200176150ustar00rootroot00000000000000 4.0.0 fr.turri dokujclient jar 3.5.2 ${project.groupId}:${project.artifactId} Library to use the xmlrpc interface of Dokuwiki http://turri.fr/dokujclient The Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.txt Guillaume Turri guillaume.turri@gmail.com scm:git:https://github.com/gturri/dokuJClient.git scm:git:git@github.com:gturri/dokuJClient.git https://github.com/gturri/DokuJClient dokujclient-3.5.2 UTF-8 1.6 1.6 com.github.tomakehurst wiremock 1.54 test standalone org.mortbay.jetty jetty com.google.guava guava com.fasterxml.jackson.core jackson-core com.fasterxml.jackson.core jackson-annotations com.fasterxml.jackson.core jackson-databind org.apache.httpcomponents httpclient org.skyscreamer jsonassert xmlunit xmlunit com.jayway.jsonpath json-path net.sf.jopt-simple jopt-simple com.google.guava guava 15.0 de.timroes aXMLRPC 1.8.1 junit junit 4.10 test junit-addons junit-addons 1.4 test org.mockito mockito-all 1.9.5 test com.martiansoftware jsap 2.1 org.apache.maven.plugins maven-surefire-report-plugin 2.16 org.codehaus.mojo cobertura-maven-plugin 2.6 org.apache.maven.plugins maven-javadoc-plugin 2.9.1 javadoc doc-${project.version} org.codehaus.mojo findbugs-maven-plugin 2.5.3 org.apache.maven.plugins maven-release-plugin 2.5 false release deploy org.apache.maven.plugins maven-jar-plugin true org.pitest pitest-maven 1.1.4 dw* dw* org.sonatype.plugins nexus-staging-maven-plugin 1.6.3 true ossrh https://oss.sonatype.org/ true org.apache.maven.plugins maven-javadoc-plugin 2.9.1 attach-javadocs jar org.apache.maven.plugins maven-assembly-plugin 2.4 scripts/descriptorRef.xml package single org.apache.maven.plugins maven-dependency-plugin 2.8 copy-dependencies runtime ${project.build.directory} org.apache.maven.plugins maven-antrun-plugin 1.6 process-test-classes process-test-classes run org.apache.maven.plugins maven-surefire-plugin 2.16 skip-tests-pre-warning true actual-tests test test src/main/resources true release org.apache.maven.plugins maven-source-plugin 2.2.1 attach-sources jar-no-fork org.apache.maven.plugins maven-javadoc-plugin 2.9.1 attach-javadocs jar org.apache.maven.plugins maven-gpg-plugin 1.5 sign-artifacts verify sign ossrh https://oss.sonatype.org/content/repositories/snapshots ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ dokuJClient-dokujclient-3.5.2/scripts/000077500000000000000000000000001257724672200177525ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/scripts/descriptorRef.xml000066400000000000000000000023401257724672200233060ustar00rootroot00000000000000 bin tar.gz tar.bz2 zip ${project.basedir} / README* LICENSE* NOTICE* ${project.build.directory} / *.jar ${project.build.directory}/site docs ${project.build.directory}/classes dokujclient / dokuJClient-dokujclient-3.5.2/src/000077500000000000000000000000001257724672200170525ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/000077500000000000000000000000001257724672200177765ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/000077500000000000000000000000001257724672200207175ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/000077500000000000000000000000001257724672200213315ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/000077500000000000000000000000001257724672200221005ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/CliOptions.java000066400000000000000000000005711257724672200250310ustar00rootroot00000000000000package dw.cli; import java.net.URL; public class CliOptions { public URL url; public String user; public String password; public String command; public String[] commandArguments; @Override public String toString(){ return "user: " + user + ", password: " + password + ", url: " + (url == null ? "null" : url.toString() + ", command: " + command); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/Command.java000066400000000000000000000045251257724672200243270ustar00rootroot00000000000000package dw.cli; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.JSAPResult; import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.UnflaggedOption; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuUnauthorizedException; public abstract class Command { protected JSAPResult _config; public Output run(DokuJClient dokuClient, String[] commandArguments){ try { parseArguments(commandArguments); } catch (ParseOptionException e){ return new Output(e.getMessage(), -1); } try { return run(dokuClient); } catch (DokuUnauthorizedException e){ String helpMessage = getCauseMessage(e) + "\nYou can check permissions with command 'aclCheck'"; return new Output(helpMessage, -1); } catch (DokuException e){ return new Output(getCauseMessage(e), -1); } } protected void addLongFormatSwitch(JSAP jsap) throws JSAPException{ jsap.registerParameter(new Switch("longFormat").setShortFlag('l')); } protected void addPageIdOption(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("pageId").setRequired(true)); } private String getCauseMessage(Throwable e){ if ( e.getCause() != null ){ return e.getCause().getMessage(); } else { return e.getMessage(); } } protected void parseArguments(String[] arguments) throws ParseOptionException{ JSAP jsap = new JSAP(); try { registerParameters(jsap); } catch (JSAPException e) { throw new ParseOptionException(e.toString(), e); } _config = jsap.parse(arguments); if ( ! _config.success() ){ String helpMessage = ""; for (@SuppressWarnings("rawtypes") java.util.Iterator errs = _config.getErrorMessageIterator(); errs.hasNext();) { helpMessage += errs.next() + "\n"; } helpMessage += jsap.getUsage(); throw new ParseOptionException(helpMessage); } } protected abstract void registerParameters(JSAP jsap) throws JSAPException; protected abstract Output run(DokuJClient dokuClient) throws DokuException; public String getUsage() { JSAP jsap = new JSAP(); try { registerParameters(jsap); } catch (JSAPException e) { throw new RuntimeException("Something wrong happened", e); } return jsap.getUsage(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/CommandFactory.java000066400000000000000000000067501257724672200256610ustar00rootroot00000000000000package dw.cli; import java.util.HashMap; import java.util.Map; import java.util.Set; import dw.cli.commands.AclChanger; import dw.cli.commands.AclChecker; import dw.cli.commands.AllPageGetter; import dw.cli.commands.AttachmentDeleter; import dw.cli.commands.AttachmentGetter; import dw.cli.commands.AttachmentInfoGetter; import dw.cli.commands.AttachmentPutter; import dw.cli.commands.AttachmentReader; import dw.cli.commands.BackLinksGetter; import dw.cli.commands.CliVersion; import dw.cli.commands.HelpPrinter; import dw.cli.commands.LinksLister; import dw.cli.commands.LocksSetter; import dw.cli.commands.PageGetter; import dw.cli.commands.PageHtmlGetter; import dw.cli.commands.PageInfoGetter; import dw.cli.commands.PageListGetter; import dw.cli.commands.PagePutter; import dw.cli.commands.PageVersionGetter; import dw.cli.commands.PageVersionsGetter; import dw.cli.commands.RPCVersionSupportedGetter; import dw.cli.commands.RecentChangesGetter; import dw.cli.commands.RecentMediaChangesGetter; import dw.cli.commands.Searcher; import dw.cli.commands.TimeGetter; import dw.cli.commands.TitleGetter; import dw.cli.commands.VersionGetter; import dw.cli.commands.XMLRPCAPIVersionGetter; public class CommandFactory { private Map _mapping = buildMapping(); public Command build(String command){ if ( _mapping.containsKey(command) ){ return _mapping.get(command); } return new HelpPrinter(false); } public boolean commandExists(String command){ return _mapping.containsKey(command); } private static Map buildMapping(){ Map mapping = new HashMap(); mapping.put("aclCheck", new AclChecker()); mapping.put("appendPage", new PagePutter(true)); mapping.put("deleteAttachment", new AttachmentDeleter()); mapping.put("getAllPages", new AllPageGetter()); mapping.put("getAttachment", new AttachmentGetter()); mapping.put("getAttachmentInfo", new AttachmentInfoGetter()); mapping.put("getAttachments", new AttachmentReader()); mapping.put("getBackLinks", new BackLinksGetter()); mapping.put("getPage", new PageGetter()); mapping.put("getPageHTML", new PageHtmlGetter()); mapping.put("getPageHTMLVersion", new PageHtmlGetter(true)); mapping.put("getPageInfo", new PageInfoGetter()); mapping.put("getPageInfoVersion", new PageInfoGetter(true)); mapping.put("getPageVersion", new PageVersionGetter()); mapping.put("getPageVersions", new PageVersionsGetter()); mapping.put("getPagelist", new PageListGetter()); mapping.put("getRecentChanges", new RecentChangesGetter()); mapping.put("getRecentMediaChanges", new RecentMediaChangesGetter()); mapping.put("getRPCVersionSupported", new RPCVersionSupportedGetter()); mapping.put("getTime", new TimeGetter()); mapping.put("getTitle", new TitleGetter()); mapping.put("getVersion", new VersionGetter()); mapping.put("getXMLRPCAPIVersion", new XMLRPCAPIVersionGetter()); mapping.put("help", new HelpPrinter(true)); mapping.put("listLinks", new LinksLister()); mapping.put("lock", new LocksSetter(false)); mapping.put("putAttachment", new AttachmentPutter()); mapping.put("putPage", new PagePutter()); mapping.put("search", new Searcher()); mapping.put("unlock", new LocksSetter(true)); mapping.put("version", new CliVersion()); mapping.put("addAcl", new AclChanger(AclChanger.aclAction.add)); mapping.put("delAcl", new AclChanger(AclChanger.aclAction.delete)); return mapping; } public static Set commandList(){ return buildMapping().keySet(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/OptionParser.java000066400000000000000000000130041257724672200253660ustar00rootroot00000000000000package dw.cli; import java.util.ArrayList; import java.util.List; import com.martiansoftware.jsap.FlaggedOption; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.JSAPResult; import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.defaultsources.PropertyDefaultSource; public class OptionParser { private boolean _success; private CliOptions _cliOptions; private String _helpMessage; private final PasswordReader _pwdReader; private List _genericArguments = new ArrayList(); private List _commandArguments = new ArrayList(); private String _command; public String[] getCommandArguments(){ return _commandArguments.toArray(new String[]{}); } private static final String PASSWORD_OPTION = "password"; private static final String PASSWORD_INTERACTIVE_OPTION = "password-interactive"; private JSAP _genericOptionsJSAP = buildJsap(); public OptionParser(String[] args){ this(args, new PasswordReader()); } public OptionParser(String[] args, PasswordReader pwdReader){ _pwdReader = pwdReader; feedGenericAndCommandOptions(args); } public void parse(){ boolean success; String helpMessage; CliOptions cliOptions; JSAPResult config = _genericOptionsJSAP.parse(_genericArguments.toArray(new String[]{})); if ( ! config.success() || !checkOptionsAreConsistent(config, _command) ){ success = false; helpMessage = ""; for (@SuppressWarnings("rawtypes") java.util.Iterator errs = config.getErrorMessageIterator(); errs.hasNext();) { helpMessage += errs.next() + "\n"; } helpMessage += getUsage(); cliOptions = null; } else { success = true; helpMessage = getUsage(); if ( _command == null && config.getBoolean("help")){ _command = "help"; } if ( _command == null && config.getBoolean("version")){ _command = "version"; } cliOptions = new CliOptions(); cliOptions.password = getPassword(config); cliOptions.user = config.getString("user"); cliOptions.url = config.getURL("url"); cliOptions.command = _command; cliOptions.commandArguments = _commandArguments.toArray(new String[]{}); } _success = success; _helpMessage = helpMessage; _cliOptions = cliOptions; } private void feedGenericAndCommandOptions(String[] args){ boolean alreadyReadCommand = false; for ( int i=0 ; i < args.length ; i++ ){ String arg = args[i]; if ( alreadyReadCommand){ _commandArguments.add(arg); } else { if ( arg.startsWith("-") ){ _genericArguments.add(arg); if ( ! arg.equals("--" + PASSWORD_INTERACTIVE_OPTION)){ i++; if ( i < args.length ){ _genericArguments.add(args[i]); } } } else { _command = arg; alreadyReadCommand = true; } } } } public boolean userAskForHelp(){ JSAP jsap = new JSAP(); try { registerHelpParameter(jsap); } catch (JSAPException e) { throw new RuntimeException("Something went really wrong", e); } JSAPResult parsed = jsap.parse(_genericArguments.toArray(new String[]{})); return (_command != null && _command.equals("help")) || parsed.getBoolean("help"); } private static JSAP buildJsap(){ JSAP jsap = new JSAP(); try { jsap.registerParameter(new FlaggedOption("user") .setStringParser(JSAP.STRING_PARSER) .setRequired(false) .setShortFlag('u') .setLongFlag("user")); jsap.registerParameter(new FlaggedOption("url") .setStringParser(JSAP.URL_PARSER) .setRequired(true) .setShortFlag(JSAP.NO_SHORTFLAG) .setLongFlag("url")); jsap.registerParameter(new FlaggedOption(PASSWORD_OPTION) .setStringParser(JSAP.STRING_PARSER) .setRequired(false) .setShortFlag('p') .setLongFlag(PASSWORD_OPTION)); jsap.registerParameter(new Switch("version") .setLongFlag("version")); jsap.registerParameter(new Switch(PASSWORD_INTERACTIVE_OPTION) .setLongFlag(PASSWORD_INTERACTIVE_OPTION)); registerHelpParameter(jsap); } catch (JSAPException e){ throw new RuntimeException("Something went really wrong", e); } registerDefaultSource(jsap); return jsap; } private static void registerHelpParameter(JSAP jsap) throws JSAPException{ jsap.registerParameter(new Switch("help") .setShortFlag('h') .setLongFlag("help")); } private static void registerDefaultSource(JSAP jsap) { String home = System.getProperty("user.home"); PropertyDefaultSource source = new PropertyDefaultSource(home + "/.dokujclientrc", false); jsap.registerDefaultSource(source); } public boolean success(){ return _success; } public CliOptions getCliOptions(){ return _cliOptions; } public String getHelpMessage(){ return _helpMessage; } public static String getUsage(){ String message = buildJsap().getUsage() + " command"; message += "\n\nAvailable commands:"; for(String command : CommandFactory.commandList()){ message += "\n\t" + command; } message += "\n\nTo get help for a given command: help "; return message; } private boolean checkOptionsAreConsistent(JSAPResult config, String command){ if (command == null && !config.getBoolean("help") && !config.getBoolean("version")){ return false; } if (config.contains(PASSWORD_OPTION) && config.getBoolean(PASSWORD_INTERACTIVE_OPTION)) { return false; } return true; } private String getPassword(JSAPResult config){ if (config.contains(PASSWORD_OPTION)){ return config.getString(PASSWORD_OPTION); } if (config.getBoolean(PASSWORD_INTERACTIVE_OPTION)){ return _pwdReader.readPassword(); } return ""; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/Output.java000066400000000000000000000004301257724672200242400ustar00rootroot00000000000000package dw.cli; public class Output { public String out = ""; public String err = ""; public int exitCode = 0; public Output(){ } public Output(String out){ this.out = out; } public Output(String err, int exitCode){ this.err = err; this.exitCode = exitCode; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/ParseOptionException.java000066400000000000000000000004621257724672200270670ustar00rootroot00000000000000package dw.cli; public class ParseOptionException extends Exception { private static final long serialVersionUID = -3917728150229940890L; public ParseOptionException(String message) { super(message); } public ParseOptionException(String message, Throwable cause) { super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/PasswordReader.java000066400000000000000000000005661257724672200256770ustar00rootroot00000000000000package dw.cli; import java.io.Console; public class PasswordReader { public String readPassword(){ Console console = System.console(); if ( console != null ){ char[] password = console.readPassword("Enter password: "); return new String(password); } else { throw new NullPointerException("Can't get an instance of console to read the password"); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/Program.java000066400000000000000000000042101257724672200243470ustar00rootroot00000000000000package dw.cli; import java.net.MalformedURLException; import dw.cli.commands.HelpPrinter; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.DokuJClientConfig; import dw.xmlrpc.exception.DokuException; public class Program { public static void main(String[] args) { try { Output output = run(args); printOutput(output); System.exit(output.exitCode); } catch (Exception e){ printException(e); System.exit(-1); } } public static Output run(String[] args) throws DokuException { OptionParser parser = new OptionParser(args); if ( parser.userAskForHelp() ){ return new HelpPrinter(true).run(buildNullDokuJClient(), parser.getCommandArguments()); } parser.parse(); if ( ! parser.success() ){ Output result = new Output(); result.err = parser.getHelpMessage(); result.exitCode = parser.success() ? 0 : -1; return result; } CliOptions options = parser.getCliOptions(); DokuJClient dokuClient = buildDokuClient(options); Command command = new CommandFactory().build(options.command); return command.run(dokuClient, options.commandArguments); } private static void printOutput(Output output) { if ( output.err != null && !output.err.isEmpty() ){ System.err.println(output.err); } if ( output.out != null && !output.out.isEmpty() ){ System.out.println(output.out); } } private static void printException(Exception e) { System.err.println("Error: " + e.getMessage()); } private static DokuJClient buildDokuClient(CliOptions options) throws DokuException{ if ( ! options.url.toString().endsWith("lib/exe/xmlrpc.php") ){ throw new RuntimeException("Url should look like http[s]://server/mywiki/lib/exe/xmlrpc.php"); } DokuJClientConfig clientConfig = new DokuJClientConfig(options.url); if ( options.user != null ){ clientConfig.setUser(options.user, options.password); } DokuJClient dokuClient = new DokuJClient(clientConfig); dokuClient.setLogger(null); return dokuClient; } private static DokuJClient buildNullDokuJClient() throws DokuException{ try { return new DokuJClient("http://whatever"); } catch (MalformedURLException e) { throw new RuntimeException(e); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/StdinReader.java000066400000000000000000000010101257724672200251370ustar00rootroot00000000000000package dw.cli; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class StdinReader { public String readStdin() throws IOException{ StringBuilder result = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String input; while((input=br.readLine())!=null){ result.append(input + "\n"); } if (result.length() > 0){ result.delete(result.length()-1, result.length()); } return result.toString(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/000077500000000000000000000000001257724672200237015ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AclChanger.java000066400000000000000000000030271257724672200265350ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.FlaggedOption; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class AclChanger extends Command { public enum aclAction { add, delete } private final aclAction _action; public AclChanger(aclAction action){ _action = action; } @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new FlaggedOption("scope") .setStringParser(JSAP.STRING_PARSER) .setRequired(true) .setLongFlag("scope")); jsap.registerParameter(new FlaggedOption("username") .setStringParser(JSAP.STRING_PARSER) .setRequired(true) .setLongFlag("username")); if ( _action == aclAction.add ){ jsap.registerParameter(new FlaggedOption("permission") .setStringParser(JSAP.INTEGER_PARSER) .setRequired(true) .setLongFlag("permission")); } } @Override protected Output run(DokuJClient dokuClient) throws DokuException { String scope = _config.getString("scope"); String username = _config.getString("username"); boolean success; if ( _action == aclAction.add ){ int permission = _config.getInt("permission"); success = dokuClient.addAcl(scope, username, permission); } else { success = dokuClient.delAcl(scope, username); } if ( success ){ return new Output(); } else { return new Output("Acl change returned false.", 1); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AclChecker.java000066400000000000000000000010761257724672200265340ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class AclChecker extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { String pageId = _config.getString("pageId"); return new Output(dokuClient.aclCheck(pageId).toString()); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AllPageGetter.java000066400000000000000000000013561257724672200272310ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.Page; import dw.xmlrpc.exception.DokuException; public class AllPageGetter extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addLongFormatSwitch(jsap); } @Override protected List query(DokuJClient dokuClient) throws DokuException { return dokuClient.getAllPages(); } @Override protected String itemToString(Page page) { if ( !_config.getBoolean("longFormat") ){ return page.id(); } else { return page.id() + " " + page.perms() + " " + page.size(); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AttachmentDeleter.java000066400000000000000000000017471257724672200301520ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuDeleteAttachmentException; import dw.xmlrpc.exception.DokuException; public class AttachmentDeleter extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new Switch("force").setShortFlag('f').setLongFlag("force")); jsap.registerParameter(new UnflaggedOption("attachmentId").setRequired(true)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { try { dokuClient.deleteAttachment(_config.getString("attachmentId")); } catch (DokuDeleteAttachmentException e){ if ( ! _config.getBoolean("force") ){ return new Output(e.getMessage(), -1); } } return new Output(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AttachmentGetter.java000066400000000000000000000020101257724672200300000ustar00rootroot00000000000000package dw.cli.commands; import java.io.IOException; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuDistantFileDoesntExistException; import dw.xmlrpc.exception.DokuException; public class AttachmentGetter extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("fileId").setRequired(true)); jsap.registerParameter(new UnflaggedOption("localFile").setRequired(true)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { try { dokuClient.getAttachment(_config.getString("fileId"), _config.getString("localFile")); } catch (IOException e) { return new Output(e.getMessage(), -1); } catch (DokuDistantFileDoesntExistException e){ return new Output(e.getMessage(), -1); } return new Output(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AttachmentInfoGetter.java000066400000000000000000000015671257724672200306340ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.AttachmentInfo; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class AttachmentInfoGetter extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("mediaId").setRequired(true)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { AttachmentInfo info = dokuClient.getAttachmentInfo(_config.getString("mediaId")); return new Output(attachmentInfoToString(info)); } private String attachmentInfoToString(AttachmentInfo info) { return info.id() + " " + info.size() + " " + info.lastModified(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AttachmentPutter.java000066400000000000000000000022521257724672200300410ustar00rootroot00000000000000package dw.cli.commands; import java.io.IOException; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuAttachmentUploadException; import dw.xmlrpc.exception.DokuException; public class AttachmentPutter extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new Switch("overwrite").setShortFlag('f').setLongFlag("force")); jsap.registerParameter(new UnflaggedOption("attachmentId").setRequired(true)); jsap.registerParameter(new UnflaggedOption("localFile").setRequired(true)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { try { dokuClient.putAttachment(_config.getString("attachmentId"), _config.getString("localFile"), _config.getBoolean("overwrite")); } catch (IOException e) { return new Output(e.getMessage(), -1); } catch (DokuAttachmentUploadException e){ return new Output(e.getMessage(), -1); } return new Output(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/AttachmentReader.java000066400000000000000000000024241257724672200277610ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.xmlrpc.AttachmentDetails; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class AttachmentReader extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addLongFormatSwitch(jsap); jsap.registerParameter(new UnflaggedOption("namespace").setRequired(true)); } @Override protected List query(DokuJClient dokuClient) throws DokuException{ return dokuClient.getAttachments(_config.getString("namespace")); } @Override protected String itemToString(AttachmentDetails attachmentsDetails){ if ( _config.getBoolean("longFormat") ){ return attachmentDetailsToLongString(attachmentsDetails); } else { return attachmentDetailsToString(attachmentsDetails); } } private String attachmentDetailsToLongString(AttachmentDetails details){ return details.perms() + " " + details.size() + " " + details.lastModified().toString() + " " + details.id(); } private String attachmentDetailsToString(AttachmentDetails details){ return details.id(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/BackLinksGetter.java000066400000000000000000000011561257724672200275630ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class BackLinksGetter extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); } @Override protected List query(DokuJClient dokuClient) throws DokuException { return dokuClient.getBackLinks(_config.getString("pageId")); } @Override protected String itemToString(String item) { return item; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/CliVersion.java000066400000000000000000000015411257724672200266220ustar00rootroot00000000000000package dw.cli.commands; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import java.lang.RuntimeException; public class CliVersion extends SimpleCommand { @Override protected String query(DokuJClient dokuClient) throws DokuException { Properties prop = new Properties(); InputStream input = null; try { input = CliVersion.class.getResourceAsStream("/application.properties"); // load a properties file prop.load(input); return prop.getProperty("application.version"); } catch (IOException e) { throw new RuntimeException("Can't open property file to read version", e); } finally { if (input != null) { try { input.close(); } catch (IOException e) { //Shouldn't matter that much } } } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/HelpPrinter.java000066400000000000000000000025071257724672200270040ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.CommandFactory; import dw.cli.OptionParser; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class HelpPrinter extends Command { private final boolean _helpExplicitlyWanted; public HelpPrinter(boolean helpExplicitlyWanted){ _helpExplicitlyWanted = helpExplicitlyWanted; } @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("command") .setStringParser(JSAP.STRING_PARSER) .setRequired(false)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { if ( ! _helpExplicitlyWanted ){ return new Output(OptionParser.getUsage(), -1); } else { if ( _config.contains("command") ){ String commandName = _config.getString("command"); if ( new CommandFactory().commandExists(commandName) ){ Command command = new CommandFactory().build(commandName); return new Output("Syntax for " + commandName + ": " + command.getUsage()); } else { return new Output(OptionParser.getUsage()); } } else { return new Output(OptionParser.getUsage()); } } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/ItemListToStringCommand.java000066400000000000000000000016161257724672200312730ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; abstract public class ItemListToStringCommand extends Command { @Override protected Output run(DokuJClient dokuClient) throws DokuException { List items = query(dokuClient); return new Output(itemsToString(items)); } abstract protected List query(DokuJClient dokuClient) throws DokuException; private String itemsToString(List items) { Function converter = new Function(){ @Override public String apply(T item) { return itemToString(item); } }; return Joiner.on("\n").join(Lists.transform(items, converter)); } abstract protected String itemToString(T item); } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/LinksLister.java000066400000000000000000000014601257724672200270100ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.LinkInfo; import dw.xmlrpc.exception.DokuException; public class LinksLister extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addLongFormatSwitch(jsap); addPageIdOption(jsap); } @Override protected List query(DokuJClient dokuClient) throws DokuException { return dokuClient.listLinks(_config.getString("pageId")); } @Override protected String itemToString(LinkInfo link){ if ( !_config.getBoolean("longFormat") ){ return link.page(); } else { return link.type() + " " + link.page() + " " + link.href(); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/LocksSetter.java000066400000000000000000000026441257724672200270140ustar00rootroot00000000000000package dw.cli.commands; import java.util.ArrayList; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.LockResult; import dw.xmlrpc.exception.DokuException; public class LocksSetter extends Command { private final boolean _shouldUnlock; public LocksSetter(boolean shouldUnlock){ _shouldUnlock = shouldUnlock; } @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("pageId").setRequired(true).setGreedy(true)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { List pages = getPageList(); LockResult result; if ( _shouldUnlock ){ result = dokuClient.setLocks(new ArrayList(), pages); } else { result = dokuClient.setLocks(pages, new ArrayList()); } return buildOutput(result); } private List getPageList() { List pages = new ArrayList(); for(String page : _config.getStringArray("pageId")){ pages.add(page); } return pages; } private Output buildOutput(LockResult result) { Output output = new Output(); if ( result.hasFailure() ){ output.err = "A lock or unlock operation, failed"; output.exitCode = -1; } return output; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PageGetter.java000066400000000000000000000010311257724672200265660ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class PageGetter extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { return new Output(dokuClient.getPage(_config.getString("pageId"))); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PageHtmlGetter.java000066400000000000000000000020731257724672200274220ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class PageHtmlGetter extends Command { private final boolean _withVersion; public PageHtmlGetter(){ this(false); } public PageHtmlGetter(boolean withVersion){ _withVersion = withVersion; } @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); if (_withVersion){ jsap.registerParameter(new UnflaggedOption("timestamp").setStringParser(JSAP.INTEGER_PARSER).setRequired(true)); } } @Override protected Output run(DokuJClient dokuClient) throws DokuException { String pageId = _config.getString("pageId"); if ( _withVersion ){ int timestamp = _config.getInt("timestamp"); return new Output(dokuClient.getPageHTMLVersion(pageId, timestamp)); } else { return new Output(dokuClient.getPageHTML(pageId)); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PageInfoGetter.java000066400000000000000000000024331257724672200274110ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.PageInfo; import dw.xmlrpc.exception.DokuException; public class PageInfoGetter extends Command { private final boolean _withVersion; public PageInfoGetter(){ this(false); } public PageInfoGetter(boolean withVersion){ _withVersion = withVersion; } @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); if (_withVersion){ jsap.registerParameter(new UnflaggedOption("timestamp").setStringParser(JSAP.INTEGER_PARSER).setRequired(true)); } } @Override protected Output run(DokuJClient dokuClient) throws DokuException { String pageId = _config.getString("pageId"); PageInfo pageInfo; if ( _withVersion ){ int timestamp = _config.getInt("timestamp"); pageInfo = dokuClient.getPageInfoVersion(pageId, timestamp); } else { pageInfo = dokuClient.getPageInfo(pageId); } return new Output(pageInfoToString(pageInfo)); } private String pageInfoToString(PageInfo pageInfo){ return pageInfo.id() + " " + pageInfo.version() + " " + pageInfo.author(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PageListGetter.java000066400000000000000000000031511257724672200274270ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import java.util.Map; import java.util.TreeMap; import com.martiansoftware.jsap.FlaggedOption; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.PageDW; import dw.xmlrpc.exception.DokuException; public class PageListGetter extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addLongFormatSwitch(jsap); jsap.registerParameter(new UnflaggedOption("namespace").setRequired(true)); jsap.registerParameter(new FlaggedOption("depth") .setStringParser(JSAP.INTEGER_PARSER) .setRequired(false) .setLongFlag("depth")); } @Override protected List query(DokuJClient dokuClient) throws DokuException { Map clientOptions = buildClientOption(); return dokuClient.getPagelist(_config.getString("namespace"), clientOptions); } private Map buildClientOption() { Map result = new TreeMap(); if ( _config.contains("depth") ){ result.put("depth", _config.getInt("depth")); } return result; } @Override protected String itemToString(PageDW page) { if ( _config.getBoolean("longFormat") ){ return pageToLongString(page); } else { return pageToString(page); } } private String pageToLongString(PageDW page) { return page.size() + " " + page.mtime() + " " + page.version() + " " + page.id(); } private String pageToString(PageDW page) { return page.id(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PagePutter.java000066400000000000000000000040621257724672200266260ustar00rootroot00000000000000package dw.cli.commands; import java.io.IOException; import com.google.common.base.Joiner; import com.martiansoftware.jsap.FlaggedOption; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.cli.StdinReader; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class PagePutter extends Command { private final boolean _appendInsteadOfPut; private final StdinReader _stdinReader; public PagePutter(){ this(false); } public PagePutter(boolean appendInsteadOfPut){ this(appendInsteadOfPut, new StdinReader()); } public PagePutter(boolean appendInsteadOfPut, StdinReader stdinReader){ _appendInsteadOfPut = appendInsteadOfPut; _stdinReader = stdinReader; } @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new FlaggedOption("summary") .setLongFlag("summary") .setDefault("") .setStringParser(JSAP.STRING_PARSER)); addPageIdOption(jsap); jsap.registerParameter(new UnflaggedOption("rawWikiText").setRequired(false).setGreedy(true)); jsap.registerParameter(new Switch("minor").setLongFlag("minor")); } @Override protected Output run(DokuJClient dokuClient)throws DokuException { String pageId = _config.getString("pageId"); String rawWikiText; try { rawWikiText = buildContent(); } catch (IOException e) { return new Output("Failed to read stdin: " + e.getMessage(), 1); } String summary = _config.getString("summary"); boolean minor = _config.getBoolean("minor"); if ( _appendInsteadOfPut ){ dokuClient.appendPage(pageId, rawWikiText, summary, minor); } else { dokuClient.putPage(pageId, rawWikiText, summary, minor); } return new Output(); } private String buildContent() throws IOException { if ( _config.contains("rawWikiText")){ return Joiner.on(" ").join(_config.getStringArray("rawWikiText")); } else { return _stdinReader.readStdin(); } } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PageVersionGetter.java000066400000000000000000000013501257724672200301400ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class PageVersionGetter extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); jsap.registerParameter(new UnflaggedOption("timestamp").setStringParser(JSAP.INTEGER_PARSER).setRequired(true)); } @Override protected Output run(DokuJClient dokuClient) throws DokuException { return new Output(dokuClient.getPageVersion(_config.getString("pageId"), _config.getInt("timestamp"))); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/PageVersionsGetter.java000066400000000000000000000022311257724672200303220ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.FlaggedOption; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.PageVersion; import dw.xmlrpc.exception.DokuException; public class PageVersionsGetter extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { addPageIdOption(jsap); jsap.registerParameter(new FlaggedOption("offset") .setStringParser(JSAP.INTEGER_PARSER) .setRequired(false) .setLongFlag("offset")); } @Override protected List query(DokuJClient dokuClient) throws DokuException { String pageId = _config.getString("pageId"); if ( _config.contains("offset" ) ){ return dokuClient.getPageVersions(pageId, _config.getInt("offset")); } else { return dokuClient.getPageVersions(pageId); } } @Override protected String itemToString(PageVersion version) { return version.pageId() + " " + version.version() + " " + version.ip() + " " + version.type() + " " + version.author() + " - " + version.summary(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/RPCVersionSupportedGetter.java000066400000000000000000000004631257724672200316220ustar00rootroot00000000000000package dw.cli.commands; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class RPCVersionSupportedGetter extends SimpleCommand { @Override protected String query(DokuJClient dokuClient) throws DokuException { return dokuClient.getRPCVersionSupported().toString(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/RecentChangesGetter.java000066400000000000000000000016731257724672200304370ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.PageChange; import dw.xmlrpc.exception.DokuException; public class RecentChangesGetter extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("timestamp").setStringParser(JSAP.INTEGER_PARSER).setRequired(true)); } @Override protected List query(DokuJClient dokuClient) throws DokuException { return dokuClient.getRecentChanges(_config.getInt("timestamp")); } @Override protected String itemToString(PageChange pageChange) { return pageChange.name() + " " + pageChange.version() + " " + pageChange.author() + " " + pageChange.perms() + " " + pageChange.size(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/RecentMediaChangesGetter.java000066400000000000000000000016511257724672200313730ustar00rootroot00000000000000package dw.cli.commands; import java.util.List; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.UnflaggedOption; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.MediaChange; import dw.xmlrpc.exception.DokuException; public class RecentMediaChangesGetter extends ItemListToStringCommand{ @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("timestamp").setStringParser(JSAP.INTEGER_PARSER).setRequired(true)); } @Override protected List query(DokuJClient dokuClient) throws DokuException { return dokuClient.getRecentMediaChanges(_config.getInt("timestamp")); } @Override protected String itemToString(MediaChange mediaChange) { return mediaChange.id() + " " + mediaChange.author() + " " + mediaChange.perms() + " " + mediaChange.size(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/Searcher.java000066400000000000000000000041151257724672200263010ustar00rootroot00000000000000package dw.cli.commands; import java.util.Arrays; import java.util.List; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.Lists; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import com.martiansoftware.jsap.Switch; import com.martiansoftware.jsap.UnflaggedOption; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.SearchResult; import dw.xmlrpc.exception.DokuException; public class Searcher extends ItemListToStringCommand { @Override protected void registerParameters(JSAP jsap) throws JSAPException { jsap.registerParameter(new UnflaggedOption("searchQuery").setRequired(true)); addLongFormatSwitch(jsap); jsap.registerParameter(new Switch("snippet").setLongFlag("snippet")); } @Override protected List query(DokuJClient dokuClient) throws DokuException { return dokuClient.search(_config.getString("searchQuery")); } @Override protected String itemToString(SearchResult searchResult) { String result; if ( _config.getBoolean("longFormat") ){ result = searchResultToLongString(searchResult); } else { result = searchResultToString(searchResult); } if ( _config.getBoolean("snippet") ){ result += "\n" + addSnippet( searchResult); } return result; } private String addSnippet(SearchResult searchResult) { Function linePrefixer = new Function(){ @Override public String apply(String line) { return "> " + line; } }; List splittedText = Arrays.asList(searchResult.snippet().split("\n")); List prefixedText = Lists.transform(splittedText, linePrefixer); return Joiner.on("\n").join(prefixedText) + "\n"; } private String searchResultToString(SearchResult searchResult) { return searchResult.id(); } private String searchResultToLongString(SearchResult searchResult) { return searchResult.score() + " " + searchResult.mtime() + " " + searchResult.rev() + " " + searchResult.title() + " " + searchResult.size() + " " + searchResult.id(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/SimpleCommand.java000066400000000000000000000010751257724672200272770ustar00rootroot00000000000000package dw.cli.commands; import com.martiansoftware.jsap.JSAP; import com.martiansoftware.jsap.JSAPException; import dw.cli.Command; import dw.cli.Output; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; abstract public class SimpleCommand extends Command { @Override protected void registerParameters(JSAP jsap) throws JSAPException { } @Override protected Output run(DokuJClient dokuClient) throws DokuException { return new Output(query(dokuClient)); } abstract protected String query(DokuJClient dokuClient) throws DokuException; } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/TimeGetter.java000066400000000000000000000004241257724672200266150ustar00rootroot00000000000000package dw.cli.commands; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class TimeGetter extends SimpleCommand { @Override protected String query(DokuJClient dokuClient) throws DokuException { return dokuClient.getTime().toString(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/TitleGetter.java000066400000000000000000000004131257724672200267760ustar00rootroot00000000000000package dw.cli.commands; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class TitleGetter extends SimpleCommand { @Override protected String query(DokuJClient dokuClient) throws DokuException { return dokuClient.getTitle(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/VersionGetter.java000066400000000000000000000004171257724672200273460ustar00rootroot00000000000000package dw.cli.commands; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class VersionGetter extends SimpleCommand { @Override protected String query(DokuJClient dokuClient) throws DokuException { return dokuClient.getVersion(); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/cli/commands/XMLRPCAPIVersionGetter.java000066400000000000000000000004531257724672200306260ustar00rootroot00000000000000package dw.cli.commands; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; public class XMLRPCAPIVersionGetter extends SimpleCommand { @Override protected String query(DokuJClient dokuClient) throws DokuException { return dokuClient.getXMLRPCAPIVersion().toString(); } }dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/000077500000000000000000000000001257724672200226365ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/Attacher.java000066400000000000000000000112621257724672200252360ustar00rootroot00000000000000package dw.xmlrpc; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.xml.bind.DatatypeConverter; import dw.xmlrpc.exception.DokuException; //! @cond class Attacher { private final CoreClient _client; public Attacher(CoreClient client){ _client = client; } byte[] serializeFile(File f) throws IOException{ byte[] b = new byte[(int)f.length()]; FileInputStream fileInputStream = new FileInputStream(f); fileInputStream.read(b); fileInputStream.close(); return b; } void deserializeFile(byte[] b, File f) throws IOException{ FileOutputStream fileOutputStream = new FileOutputStream(f); fileOutputStream.write(b); fileOutputStream.close(); } public void putAttachment(String fileId, byte[] file, boolean overwrite) throws DokuException{ Map additionalParam = new HashMap(); additionalParam.put("ow", overwrite); Object[] params = new Object[]{ fileId, file, additionalParam }; _client.genericQuery("wiki.putAttachment", params); } public List getRecentMediaChanges(Integer timestamp) throws DokuException{ Object result = _client.genericQuery("wiki.getRecentMediaChanges", timestamp); List res = new ArrayList(); for(Object o : (Object[]) result){ @SuppressWarnings("unchecked") Map map = (Map) o; String id = (String) map.get("name"); Date lastModified = (Date) map.get("lastModified"); String author = (String) map.get("author"); Integer version = (Integer) map.get("version"); Integer perms = (Integer) map.get("perms"); Object sizeObj = map.get("size"); Integer size = null; if ( sizeObj instanceof Integer ){ size = (Integer) sizeObj; } res.add(new MediaChange(id, lastModified, author, version, perms, size)); } return res; } public List getAttachments(String namespace, Map additionalParams) throws DokuException{ if ( additionalParams == null ){ additionalParams = new HashMap(); } Object[] params = new Object[]{namespace, additionalParams}; Object result = _client.genericQuery("wiki.getAttachments", params); List res = new ArrayList(); for(Object o : (Object[]) result){ res.add(buildAttachmentDetailsFromResult(o)); } return res; } @SuppressWarnings("unchecked") private AttachmentDetails buildAttachmentDetailsFromResult(Object o){ return buildAttachmentDetailsFromResult((Map) o); } private AttachmentDetails buildAttachmentDetailsFromResult(Map m){ String id = (String) m.get("id"); Integer size = (Integer) m.get("size"); Date lastModified = (Date) m.get("lastModified"); Boolean isImg = (Boolean) m.get("isimg"); Boolean writable = (Boolean) m.get("writable"); Integer perms = (Integer) m.get("perm"); if ( perms == null ){ //Because it has been renamed in API v8 perms = (Integer) m.get("perms"); } return new AttachmentDetails(id, size, lastModified, isImg, writable, perms); } public AttachmentInfo getAttachmentInfo(String fileId) throws DokuException{ Object result = _client.genericQuery("wiki.getAttachmentInfo", fileId); return buildAttachmentInfoFromResult(result, fileId); } @SuppressWarnings("unchecked") private AttachmentInfo buildAttachmentInfoFromResult(Object o, String fileId){ return buildAttachmentInfoFromResult((Map) o, fileId); } private AttachmentInfo buildAttachmentInfoFromResult(Map m, String fileId){ Integer size = (Integer) m.get("size"); Date lastModified = null; try { lastModified = (Date) m.get("lastModified"); } catch (ClassCastException e){ //for DW up to 2012-01-25b: when the file doesn't exist, //"lastModified" is int 0 lastModified = defaultDate(); } return new AttachmentInfo(fileId, size, lastModified); } private Date defaultDate(){ Calendar calendar = Calendar.getInstance(); calendar.set(1970, 0, 0); return calendar.getTime(); } public void deleteAttachment(String fileId) throws DokuException{ _client.genericQuery("wiki.deleteAttachment", fileId); } public byte[] getAttachment(String fileId) throws DokuException{ Object result = _client.genericQuery("wiki.getAttachment", fileId); try { return (byte[]) result; } catch (ClassCastException e){ //for DW up to 2012-01-25b String base64Encoded = (String) result; return DatatypeConverter.parseBase64Binary(base64Encoded); } } //! @endcond } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/AttachmentDetails.java000066400000000000000000000025711257724672200271040ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Describes a file uploaded in the wiki as getAttachments would */ public class AttachmentDetails { private final String _id; /** * Media id (namespace + name) */ public String id(){ return _id; } private final Boolean _isImg; /** * Whether the file is an image or not */ public final Boolean isImg(){ return _isImg; } private final Boolean _writable; /** * Whether the file is writable or not */ public Boolean writable(){ return _writable; } private final Integer _perms; /** * Permissions of file */ public Integer perms(){ return _perms; } private final Integer _size; /** * Size in bytes */ public Integer size(){ return _size; } private final Date _lastModified; /** * Date of last modification of the file */ public final Date lastModified(){ return _lastModified; } public AttachmentDetails(String id, Integer size, Date lastModified, Boolean isImg, Boolean writable, Integer perms){ _id = id; _size = size; _lastModified = lastModified; _isImg = isImg; _writable = writable; _perms = perms; } @Override public String toString(){ return "id: " + _id + ", size:" + _size + ", lastModified:" + (_lastModified == null ? "null" : _lastModified.toString()) + ", isImg: " + _isImg + ", writable: " + _writable + ", perms:" + _perms; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/AttachmentInfo.java000066400000000000000000000014601257724672200264060ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Describes a file uploaded in the wiki as getAttachmentInfo would */ public class AttachmentInfo { private final String _id; /** * Media id (namespace + name) */ public String id(){ return _id; } private final Integer _size; /** * Size in bytes */ public Integer size(){ return _size; } private final Date _lastModified; /** * Date of last modification of the file */ public Date lastModified(){ return _lastModified; } public AttachmentInfo(String id, Integer size, Date lastModified){ _id = id; _size = size; _lastModified = lastModified; } @Override public String toString(){ return "id: " + _id + ", size:" + _size + ", lastModified:" + (_lastModified == null ? "null" : _lastModified.toString()); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/CoreClient.java000066400000000000000000000024651257724672200255370ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import de.timroes.axmlrpc.XMLRPCClient; import de.timroes.axmlrpc.XMLRPCException; import dw.xmlrpc.exception.DokuException; //! @cond class CoreClient { private final XMLRPCClient _client; private Logger _logger = null; public void setLogger(Logger logger){ _logger = logger; } public CoreClient(XMLRPCClient client){ _client = client; } public Map cookies(){ return _client.getCookies(); } public void clearCookies(){ _client.clearCookies(); } public Object genericQuery(String action) throws DokuException { Object[] params = new Object[]{}; return genericQuery(action, params); } public Object genericQuery(String action, Object param) throws DokuException{ return genericQuery(action, new Object[]{param}); } public Object genericQuery(String action, Object[] params) throws DokuException{ try { return _client.call(action, params); } catch (XMLRPCException e){ if ( _logger != null ){ _logger.log(Level.INFO, "Caught exception when executing action " + action + ": " + e.toString()); _logger.log(Level.FINEST, "Details of the exception: ", e); } throw ExceptionConverter.Convert(e, _client.getURL().toString(), action); } } //! @endcond } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/CoreClientFactory.java000066400000000000000000000022141257724672200270570ustar00rootroot00000000000000package dw.xmlrpc; import java.net.MalformedURLException; import java.net.URL; import de.timroes.axmlrpc.XMLRPCClient; class CoreClientFactory { public static CoreClient Build(String url) throws MalformedURLException{ return Build(url, DokuJClientConfig.defaultUserAgent); } public static CoreClient Build(String url, String userAgent) throws MalformedURLException{ return Build(new URL(url), userAgent); } public static CoreClient Build(DokuJClientConfig dokuConfig){ return Build(dokuConfig.url(), dokuConfig.userAgent(), dokuConfig.timeoutInSeconds(), dokuConfig.xmlRpcClientFlags()); } public static CoreClient Build(URL url, String userAgent) { return Build(url, userAgent, DokuJClientConfig.defaultTimeoutInSeconds, DokuJClientConfig.defaultXMLRPCClientFlags); } public static CoreClient Build(URL url, String userAgent, int timeoutInSeconds, int xMLRPCClientFlags) { XMLRPCClient xmlRpcClient = new XMLRPCClient(url, userAgent, xMLRPCClientFlags); xmlRpcClient.setTimeout(timeoutInSeconds); return Build(xmlRpcClient); } public static CoreClient Build(XMLRPCClient xmlRpcClient){ return new CoreClient(xmlRpcClient); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/DokuJClient.java000066400000000000000000000556151257724672200256700ustar00rootroot00000000000000package dw.xmlrpc; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuIncompatibleVersionException; import dw.xmlrpc.exception.DokuMethodDoesNotExistsException; import dw.xmlrpc.exception.DokuMisConfiguredWikiException; import dw.xmlrpc.exception.DokuNoChangesException; import dw.xmlrpc.exception.DokuPageDoesNotExistException; /** * Main public class to actually make an xmlrpc query * * Instantiate one such client for a given wiki and a given user, then make * xmlrpc query using its methods. * * Most methods may throw DokuException because many things can go wrong * (bad url, wrong credential, no network, unreachable server, ...), so you may * want to make sure you handle them correcty */ public class DokuJClient { private final CoreClient _client; private final Locker _locker; private final Attacher _attacher; private Logger _logger; private final String COOKIE_PREFIX = "DW"; /** * Let override the default Logger */ public void setLogger(Logger logger){ _logger = logger; _client.setLogger(logger); } /** * Instantiate a client for the given user on the given wiki * * The wiki should be configured in a way to let this user access the * xmlrpc interface * * @param url Should looks like http[s]://server/mywiki/lib/exe/xmlrpc.php * @param user Login of the user * @param password Password of the user * @throws MalformedURLException * @throws DokuException */ public DokuJClient(String url, String user, String password) throws MalformedURLException, DokuException{ this(url); loginWithRetry(user, password, 2); } /** * Instantiate a client for an anonymous user on the given wiki * * Likely to be unsuitable for most wiki since anonymous user are often * not authorized to use the xmlrpc interface * * @param url Should looks like http[s]://server/mywiki/lib/exe/xmlrpc.php * @throws MalformedURLException */ public DokuJClient(String url) throws MalformedURLException{ this(CoreClientFactory.Build(url)); } public DokuJClient(DokuJClientConfig dokuConfig) throws DokuException{ this(CoreClientFactory.Build(dokuConfig)); if ( dokuConfig.user() != null){ loginWithRetry(dokuConfig.user(), dokuConfig.password(), 2); } } private DokuJClient(CoreClient client){ _client = client; _locker = new Locker(_client); _attacher = new Attacher(_client); Logger logger = Logger.getLogger(DokuJClient.class.toString()); setLogger(logger); } public boolean hasDokuwikiCookies(){ for(String cookieKey : cookies().keySet()){ if ( cookieKey.startsWith(COOKIE_PREFIX) ){ return true; } } return false; } public Map cookies(){ return _client.cookies(); } //Because it's been observed that some hosting services sometime mess up a bit with cookies... private void loginWithRetry(String user, String password, int nbMaxRetry) throws DokuException { boolean success = false; for(int retry=0 ; retry < nbMaxRetry && !success ; retry++ ){ success = login(user, password); } } public Boolean login(String user, String password) throws DokuException{ Object[] params = new Object[]{user, password}; return (Boolean) genericQuery("dokuwiki.login", params) && hasDokuwikiCookies(); } /** * Uploads a file to the wiki * * @param attachmentId Id the file should have once uploaded (eg: ns1:ns2:myfile.gif) * @param localPath The path to the file to upload * @param overwrite TRUE to overwrite if a file with this id already exist on the wiki * @throws IOException * @throws DokuException */ public void putAttachment(String attachmentId, String localPath, boolean overwrite) throws IOException, DokuException{ putAttachment(attachmentId, new File(localPath), overwrite); } /** * Uploads a file to the wiki * * @param attachmentId Id the file should have once uploaded (eg: ns1:ns2:myfile.gif) * @param localFile The file to upload * @param overwrite TRUE to overwrite if a file with this id already exist on the wiki * @throws IOException * @throws DokuException */ public void putAttachment(String attachmentId, File localFile, boolean overwrite) throws IOException, DokuException{ putAttachment(attachmentId, _attacher.serializeFile(localFile), overwrite); } /** * Uploads a file to the wiki * * @param attachmentId Id the file should have once uploaded (eg: ns1:ns2:myfile.gif) * @param localFile base64 encoded file * @param overwrite TRUE to overwrite if a file with this id already exist on the wiki * @throws IOException * @throws DokuException */ public void putAttachment(String attachmentId, byte[] localFile, boolean overwrite) throws DokuException{ _attacher.putAttachment(attachmentId, localFile, overwrite); } /** * Returns information about a media file * * @param fileId Id of the file on the wiki (eg: ns1:ns2:myfile.gif) * @throws DokuException */ public AttachmentInfo getAttachmentInfo(String fileId) throws DokuException{ return _attacher.getAttachmentInfo(fileId); } /** * Deletes a file. Fails if the file is still referenced from any page in the wiki. * * @param fileId Id of the file on the wiki (eg: ns1:ns2:myfile.gif) * @throws DokuException */ public void deleteAttachment(String fileId) throws DokuException{ _attacher.deleteAttachment(fileId); } /** * Let download a file from the wiki * * @param fileId Id of the file on the wiki (eg: ns1:ns2:myfile.gif) * @param localPath Where to put the file * @throws DokuException * @throws IOException */ public File getAttachment(String fileId, String localPath) throws DokuException, IOException{ byte[] b = getAttachment(fileId); File f = new File(localPath); _attacher.deserializeFile(b, f); return f; } /** * Let download a file from the wiki * * @param fileId Id of the file on the wiki (eg: ns1:ns2:myfile.gif) * @throws DokuException * @return the data of the file, encoded in base64 */ public byte[] getAttachment(String fileId) throws DokuException { return _attacher.getAttachment(fileId); } /** * Returns information about a list of media files in a given namespace * * @param namespace Where to look for files * @throws DokuException */ public List getAttachments(String namespace) throws DokuException{ return getAttachments(namespace, null); } /** * Returns information about a list of media files in a given namespace * * @param namespace Where to look for files * @param additionalParams Potential additional parameters directly sent to Dokuwiki. * Available parameters are: * * recursive: TRUE if also files in subnamespaces are to be included, defaults to FALSE * * pattern: an optional PREG compatible regex which has to match the file id * @throws DokuException */ public List getAttachments(String namespace, Map additionalParams) throws DokuException{ return _attacher.getAttachments(namespace, additionalParams); } /** * Returns a list of recent changed media since given timestamp * @param timestamp * @throws DokuException */ public List getRecentMediaChanges(Integer timestamp) throws DokuException{ return _attacher.getRecentMediaChanges(timestamp); } /** * Wrapper around {@link #getRecentMediaChanges(Integer)} * @param date Do not return chances older than this date */ public List getRecentMediaChanges(Date date) throws DokuException { return getRecentMediaChanges((int)(date.getTime() / 1000)); } /** * Returns the current time at the remote wiki server as Unix timestamp * @throws DokuException */ public Integer getTime() throws DokuException{ return (Integer) genericQuery("dokuwiki.getTime"); } /** * Returns the XML RPC interface version of the remote Wiki. * This is DokuWiki implementation specific and independent of the supported * standard API version returned by wiki.getRPCVersionSupported * @throws DokuException */ public Integer getXMLRPCAPIVersion() throws DokuException{ return (Integer) genericQuery("dokuwiki.getXMLRPCAPIVersion"); } /** * Returns the DokuWiki version of the remote Wiki * @throws DokuException */ public String getVersion() throws DokuException{ return (String) genericQuery("dokuwiki.getVersion"); } /** * Returns the available versions of a Wiki page. * * The number of pages in the result is controlled via the "recent" configuration setting of the wiki. * * @param pageId Id of the page (eg: ns1:ns2:mypage) * @throws DokuException */ public List getPageVersions(String pageId) throws DokuException { return getPageVersions(pageId, 0); } /** * Returns the available versions of a Wiki page. * * The number of pages in the result is controlled via the recent configuration setting of the wiki. * * @param pageId Id of the page (eg: ns1:ns2:mypage) * @param offset Can be used to list earlier versions in the history. * @throws DokuException */ public List getPageVersions(String pageId, Integer offset) throws DokuException { Object[] params = new Object[]{pageId, offset}; Object result = genericQuery("wiki.getPageVersions", params); return ObjectConverter.toPageVersion((Object[]) result, pageId); } /** * Returns the raw Wiki text for a specific revision of a Wiki page. * @param pageId Id of the page (eg: ns1:ns2:mypage) * @param timestamp Version of the page * @throws DokuException */ public String getPageVersion(String pageId, Integer timestamp) throws DokuException{ Object[]params = new Object[]{pageId, timestamp}; return (String) genericQuery("wiki.getPageVersion", params); } /** * Lists all pages within a given namespace * @param namespace Namespace to look for (eg: ns1:ns2) * @throws DokuException */ public List getPagelist(String namespace) throws DokuException { return getPagelist(namespace, null); } /** * Lists all pages within a given namespace * @param namespace Namespace to look for (eg: ns1:ns2) * @param options Options passed directly to dokuwiki's search_all_pages() * @throws DokuException */ public List getPagelist(String namespace, Map options) throws DokuException { List params = new ArrayList(); params.add(namespace); params.add(ensureWeComputeThePageHash(options)); Object result = genericQuery("dokuwiki.getPagelist", params.toArray()); return ObjectConverter.toPageDW((Object[]) result); } private Map ensureWeComputeThePageHash(Map initialOptions){ Map result; if ( initialOptions == null ){ result = new HashMap(); } else { result = new HashMap(initialOptions); } if ( !result.containsKey("hash") ){ result.put("hash", true); } return result; } /** * Returns the permission of the given wikipage. * @param pageId Id of the page (eg: ns1:ns2:mypage) * @throws DokuException */ public Integer aclCheck(String pageId) throws DokuException{ Object res = _client.genericQuery("wiki.aclCheck", pageId); return ObjectConverter.toPerms(res); } /** * Returns the supported RPC API version * * cf http://www.jspwiki.org/wiki/WikiRPCInterface2 for more info * @throws DokuException */ public Integer getRPCVersionSupported() throws DokuException{ return (Integer) genericQuery("wiki.getRPCVersionSupported"); } /** * Allows to lock or unlock a whole bunch of pages at once. * Useful when you are about to do a operation over multiple pages * @param pagesToLock Ids of pages to lock * @param pagesToUnlock Ids of pages to unlock * @throws DokuException */ public LockResult setLocks(List pagesToLock, List pagesToUnlock) throws DokuException{ return _locker.setLocks(pagesToLock, pagesToUnlock); } /** * Lock a page * @param pageId Id of the page to lock (eg: ns1:ns2:mypage) * @return TRUE the page has been successfully locked, FALSE otherwise * @throws DokuException */ public boolean lock(String pageId) throws DokuException{ return _locker.lock(pageId).locked().contains(pageId); } /** * Unlock a page * @param pageId Id of the page to unlock (eg: ns1:ns2:mypage) * @return TRUE the page has been successfully unlocked, FALSE otherwise * @throws DokuException */ public boolean unlock(String pageId) throws DokuException{ return _locker.unlock(pageId).unlocked().contains(pageId); } /** * Returns the title of the wiki * @throws DokuException */ public String getTitle() throws DokuException{ return (String) genericQuery("dokuwiki.getTitle"); } /** * Appends text to a Wiki Page. * @param pageId Id of the page to edit (eg: ns1:ns2:mypage) * @param rawWikiText Text to add to the current page content * @throws DokuException */ public void appendPage(String pageId, String rawWikiText) throws DokuException { appendPage(pageId, rawWikiText, null); } /** * Appends text to a Wiki Page. * @param pageId Id of the page to edit (eg: ns1:ns2:mypage) * @param rawWikiText Text to add to the current page content * @param summary A summary of the modification * @param minor Whether it's a minor modification * @throws DokuException */ public void appendPage(String pageId, String rawWikiText, String summary, boolean minor) throws DokuException { Map options = new HashMap(); options.put("sum", summary); options.put("minor", minor); appendPage(pageId, rawWikiText, options); } /** * Appends text to a Wiki Page. * @param pageId Id of the page to edit (eg: ns1:ns2:mypage) * @param rawWikiText Text to add to the current page content * @param options Options passed to Dokuwiki. ie: 'sum' and/or 'minor' * @throws DokuException */ public void appendPage(String pageId, String rawWikiText, Map options) throws DokuException { if ( options == null ){ options = new HashMap(); } genericQuery("dokuwiki.appendPage", new Object[]{pageId, rawWikiText, options}); } /** * Returns the raw Wiki text for a page * @param pageId Id of the page to fetch (eg: ns1:ns2:mypage) * @throws DokuException */ public String getPage(String pageId) throws DokuException { return (String) genericQuery("wiki.getPage", pageId); } /** * Saves a Wiki Page * @param pageId Id of the page to save * @param rawWikiText Text to put * @throws DokuException */ public void putPage(String pageId, String rawWikiText)throws DokuException { putPage(pageId, rawWikiText, null); } /** * Saves a Wiki Page * @param pageId Id of the page to save * @param rawWikiText Text to put * @param summary Summary of the edition * @param minor Whether it's a minor edition * @throws DokuException */ public void putPage(String pageId, String rawWikiText, String summary, boolean minor) throws DokuException{ Map options = new HashMap(); options.put("sum", summary); options.put("minor", minor); putPage(pageId, rawWikiText, options); } /** * Saves a Wiki Page * @param pageId Id of the page to save * @param rawWikiText Text to put * @param options Options passed to Dokuwiki. ie: 'sum' and/or 'minor' * @throws DokuException */ public void putPage(String pageId, String rawWikiText, Map options)throws DokuException { if (options == null){ options = new HashMap(); } genericQuery("wiki.putPage", new Object[]{pageId, rawWikiText, options}); } /** * Performs a fulltext search * @param pattern A query string as described on https://www.dokuwiki.org/search * @return Matching pages. Snippets are provided for the first 15 results. * @throws DokuException */ public List search(String pattern) throws DokuException{ Object[] results = (Object[]) genericQuery("dokuwiki.search", pattern); return ObjectConverter.toSearchResult(results); } /** * Returns information about a Wiki page * @param pageId Id of the page wanted (eg: ns1:ns2:mypage) * @throws DokuException */ public PageInfo getPageInfo(String pageId) throws DokuException{ try { Object result = genericQuery("wiki.getPageInfo",pageId); return ObjectConverter.toPageInfo(result); } catch(DokuMisConfiguredWikiException e){ //Because "Adora Belle" (DW-2013-05-10) seems to have a bug with this command when the page doesn't exist if ( ! isConfiguredToAcceptXmlRpcQueries() ){ throw e; } throw new DokuPageDoesNotExistException(null); } } /** * Returns information about a specific version of a Wiki page * @param pageId Id of the page wanted(eg: ns1:ns2:mypage) * @param timestamp version wanted * @throws DokuException */ public PageInfo getPageInfoVersion(String pageId, Integer timestamp) throws DokuException { Object[] params = new Object[]{pageId, timestamp}; Object result = genericQuery("wiki.getPageInfoVersion", params); return ObjectConverter.toPageInfo(result); } /** * Returns a list of all Wiki pages in the remote Wiki * @throws DokuException */ public List getAllPages() throws DokuException { Object result = genericQuery("wiki.getAllPages"); return ObjectConverter.toPage((Object[]) result); } /** * Returns a list of backlinks of a Wiki page * @param pageId Id of the page wanted (eg: ns1:ns2:mypage) * @throws DokuException */ public List getBackLinks(String pageId) throws DokuException{ Object result = genericQuery("wiki.getBackLinks", pageId); return ObjectConverter.toString((Object[]) result); } /** * Returns the rendered XHTML body of a Wiki page * @param pageId Id of the wanted page (eg: ns1:ns2:mypage) * @throws DokuException */ public String getPageHTML(String pageId) throws DokuException { return (String) genericQuery("wiki.getPageHTML", pageId); } /** * Returns the rendered HTML of a specific version of a Wiki page * @param pageId Id of the wanted page (eg: ns1:ns2:mypage) * @param timestamp Version wanted * @throws DokuException */ public String getPageHTMLVersion(String pageId, Integer timestamp) throws DokuException{ Object[] params = new Object[]{pageId, timestamp}; return (String) genericQuery("wiki.getPageHTMLVersion", params); } /** * Returns a list of all links contained in a Wiki page * @param pageId Id of the wanted page (eg: ns1:ns2:mypage) * @throws DokuException */ public List listLinks(String pageId) throws DokuException { Object result = genericQuery("wiki.listLinks", pageId); return ObjectConverter.toLinkInfo((Object[]) result); } /** * Returns a list of recent changes since a given timestamp * * According to Dokuwiki documentation (https://www.dokuwiki.org/recent_changes): * * * Only the most recent change for each page is listed, regardless of how many times that page was changed. * * The number of changes shown per page is controlled by the "recent" setting. * * Users are only shown pages to which they have read access * * @param timestamp Do not return changes older than this timestamp * @throws DokuException */ public List getRecentChanges(Integer timestamp) throws DokuException{ Object result; try { result = genericQuery("wiki.getRecentChanges", timestamp); } catch (DokuNoChangesException e){ return new ArrayList(); } Object[] pageChanges; try { pageChanges = (Object[]) result; } catch (ClassCastException e){ //It likely happens when there are no changes, with only a few versions of DW //(newer versions yield a DokuNoChangesException instead) //Hence it might be enough to just return an empty list... but in doubt I'd rather cast @SuppressWarnings("unchecked") Map pageChangesMap = (Map) result; pageChanges = pageChangesMap.values().toArray(); } return ObjectConverter.toPageChange(pageChanges); } /** * Wrapper around {@link #getRecentChanges(Integer)} * @param date Do not return changes older than this date */ public List getRecentChanges(Date date) throws DokuException { return getRecentChanges((int)(date.getTime() / 1000)); } /** * Tries to logoff by expiring auth cookies and the associated PHP session */ public void logoff() throws DokuException { try { _client.genericQuery("dokuwiki.logoff"); } catch(DokuMethodDoesNotExistsException e){ if (_logger != null){ _logger.log(Level.WARNING, "This Dokuwiki instance doesn't support 'logoff' (api version < 9). " + "We're clearing the cookies of this client, but we can't destroy the server side php session"); } } _client.clearCookies(); } /** * Only available for dokuwiki-2013-12-08 (Binky) or newer */ public boolean addAcl(String scope, String username, int permission) throws DokuException{ try { return (Boolean) genericQuery("plugin.acl.addAcl", new Object[]{scope, username, permission}); } catch (DokuMethodDoesNotExistsException e){ throw new DokuIncompatibleVersionException("dokuwiki-2013-12-08 (Binky)"); } } /** * Only available for dokuwiki-2013-12-08 (Binky) or newer */ public boolean delAcl(String scope, String username) throws DokuException{ try { return (Boolean) genericQuery("plugin.acl.delAcl", new Object[]{scope, username}); } catch (DokuMethodDoesNotExistsException e){ throw new DokuIncompatibleVersionException("dokuwiki-2013-12-08 (Binky)"); } } /** * Let execute any xmlrpc query without argument * @param action The name of the xmlrpc method to invoke * @return Whatever the xmlrpc should return, as an Object * @throws DokuException */ public Object genericQuery(String action) throws DokuException { return _client.genericQuery(action); } /** * Let execute any xmlrpc query with one argument * @param action The name of the xmlrpc method to invoke * @param param The unique parameter, as an Object * @return Whatever the xmlrpc should return, as an Object * @throws DokuException */ public Object genericQuery(String action, Object param) throws DokuException{ return _client.genericQuery(action, param); } /** * Let execute any xmlrpc query with an arbitrary number of arguments * @param action The name of the xmlrpc method to invoke * @param params The parameters, as an array of Objects * @return Whatever the xmlrpc should return, as an Object * @throws DokuException */ public Object genericQuery(String action, Object[] params) throws DokuException{ return _client.genericQuery(action, params); } private boolean isConfiguredToAcceptXmlRpcQueries() throws DokuException{ try { getTitle(); } catch(DokuMisConfiguredWikiException e){ return false; } return true; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/DokuJClientConfig.java000066400000000000000000000026751257724672200270140ustar00rootroot00000000000000package dw.xmlrpc; import java.net.MalformedURLException; import java.net.URL; import de.timroes.axmlrpc.XMLRPCClient; public class DokuJClientConfig { public static final String defaultUserAgent = "DokuJClient - XmlRpc client for Dokuwiki"; public static final int defaultTimeoutInSeconds = 30; public static final int defaultXMLRPCClientFlags = XMLRPCClient.FLAGS_ENABLE_COOKIES | XMLRPCClient.FLAGS_IGNORE_STATUSCODE; private final URL _url; URL url(){ return _url; } private String _user = null; String user(){ return _user; } private String _password = null; String password(){ return _password; } private String _userAgent = DokuJClientConfig.defaultUserAgent; String userAgent(){ return _userAgent; } public DokuJClientConfig(String url) throws MalformedURLException{ this(new URL(url)); } public DokuJClientConfig(URL url){ _url = url; } public void setUserAgent(String userAgent){ _userAgent = userAgent; } public void setUser(String user, String password){ _user = user; _password = password; } private int _timeoutInSeconds = defaultTimeoutInSeconds; public void setTimeOutInSeconds(int timeout){ _timeoutInSeconds = timeout; } public int timeoutInSeconds(){ return _timeoutInSeconds; } private int _xmlRpcClientFlags = defaultXMLRPCClientFlags; public void setXMLRPCClientFlags(int flags){ _xmlRpcClientFlags = flags; } public int xmlRpcClientFlags(){ return _xmlRpcClientFlags; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/ExceptionConverter.java000066400000000000000000000110711257724672200273270ustar00rootroot00000000000000package dw.xmlrpc; import org.xml.sax.SAXParseException; import de.timroes.axmlrpc.XMLRPCException; import dw.xmlrpc.exception.DokuAttachmentStillReferenced; import dw.xmlrpc.exception.DokuAttachmentUploadException; import dw.xmlrpc.exception.DokuBadUrlException; import dw.xmlrpc.exception.DokuDeleteAttachmentException; import dw.xmlrpc.exception.DokuDistantFileDoesntExistException; import dw.xmlrpc.exception.DokuEmptyNewPageException; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuInvalidTimeStampException; import dw.xmlrpc.exception.DokuMethodDoesNotExistsException; import dw.xmlrpc.exception.DokuMisConfiguredWikiException; import dw.xmlrpc.exception.DokuNoChangesException; import dw.xmlrpc.exception.DokuPageDoesNotExistException; import dw.xmlrpc.exception.DokuPageLockedException; import dw.xmlrpc.exception.DokuTimeoutException; import dw.xmlrpc.exception.DokuUnauthorizedException; import dw.xmlrpc.exception.DokuUnknownException; import dw.xmlrpc.exception.DokuWordblockException; //! @cond /** * Converts an XmlRpcException into a the most relevant DokuException. */ class ExceptionConverter { public static DokuException Convert(XMLRPCException e, String url, String action){ String message = e.getMessage(); if ( message.contains("The page is currently locked") ){ return new DokuPageLockedException(e); } if ( message.contains("The XMLRPC call timed out.")){ return new DokuTimeoutException(e); } if ( message.contains("not authorized to call method") || message.contains("forbidden to call the method") || message.contains("don't have permissions to") || message.contains("You are not allowed to") //for DW up to 2012-01-25b || message.contains("You don't have permissions to delete files") //for DW up to 2012-01-25b ){ return new DokuUnauthorizedException(e); } if ( message.contains("java.io.FileNotFoundException") || message.contains("The server responded with a http 301 or 302 status code")){ return buildGenericBadUrlException(e); } if ( e.getCause() != null && e.getCause().getClass() == java.net.UnknownHostException.class ){ String mess = "Host doesn't exist. Check url"; return new DokuBadUrlException(mess, e); } if ( message.contains("Positive wordblock check")){ return new DokuWordblockException(e); } if ( message.contains("HTTP server returned unexpected status: Forbidden")){ return new DokuUnauthorizedException(e); } if ( message.contains("Could not delete file")){ return new DokuDeleteAttachmentException(e); } if ( message.contains("The requested file does not exist")){ return new DokuDistantFileDoesntExistException(e); } if ( message.contains("The requested page does not exist")){ return new DokuPageDoesNotExistException(e); } if ( message.contains("File is still referenced")){ return new DokuAttachmentStillReferenced(e); } if ( message.contains("The provided value is not a valid timestamp")){ return new DokuInvalidTimeStampException(e); } if ( message.contains("There are no changes in the specified timeframe")){ return new DokuNoChangesException(e); } if ( message.contains("Refusing to write an empty new wiki page")){ return new DokuEmptyNewPageException(e); } if ((message.contains("requested method") && message.contains("not specified")) || message.contains("Method does not exist")){ return new DokuMethodDoesNotExistsException("Method does not exists: " + action, e); } //Won't match if the wiki's locale isn't 'en' if ( message.contains("Upload denied. This file extension is forbidden!") || ( message.contains("The uploaded content did not match the ") && message.contains("file extension.")) || message.contains("File already exists. Nothing done.")){ return new DokuAttachmentUploadException(message, e); } if ( e.getCause() != null && e.getCause().getClass() == SAXParseException.class){ return new DokuMisConfiguredWikiException("The wiki doesn't seem to be configured to accept incoming xmlrpc requests." + " Check the 'remote' option in Dokuwiki's configuration manager.", e); } //If we reach this point, we don't know what went wrong. //We try a final educated guess before giving up if ( ! url.endsWith("/lib/exe/xmlrpc.php") ){ return buildGenericBadUrlException(e); } return new DokuUnknownException(e); } private static DokuBadUrlException buildGenericBadUrlException(Throwable e){ String mess = "Couldn't find the xmlrpc interface. Make sure url looks like http[s]://server/mywiki/lib/exe/xmlrpc.php"; return new DokuBadUrlException(mess, e); } //! @endcond } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/LinkInfo.java000066400000000000000000000023401257724672200252110ustar00rootroot00000000000000package dw.xmlrpc; /** * Describes a link in a wiki page */ public class LinkInfo { public enum Type { local, extern } private final Type _type; /** * Whether it is a local or extern link */ public Type type(){ return _type; } private final String _page; /** * The wiki page (or the complete URL if extern link) */ public String page(){ return _page; } private final String _href; /** * The complete URL */ public String href(){ return _href; } public LinkInfo(String type, String page, String href){ this(Type.valueOf(type), page, href); } public LinkInfo(Type type, String page, String href){ _type = type; _page = page; _href = href; } @Override public boolean equals(Object other){ if ( this == other ){ return true; } if ( other == null ){ return false; } if ( !(other instanceof LinkInfo)){ return false; } LinkInfo link = (LinkInfo) other; return _type == link._type && _page.equals(link._page) && _href.equals(link._href); } @Override public int hashCode(){ //Any arbitrary constant will do return 0; } @Override public String toString(){ return "type:" + _type.toString() + ", page:" + _page + ", href:" + _href; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/LockResult.java000066400000000000000000000032451257724672200255740ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Set; /** * Describes the result of an attempt to (un)lock pages */ public class LockResult { private final Set _locked; /** * Pages successfully locked */ public Set locked(){ return _locked; } private final Set _lockfail; /** * Pages we failed to lock */ public Set lockfail(){ return _lockfail; } private final Set _unlocked; /** * Pages successfully unlocked */ public Set unlocked(){ return _unlocked; } private final Set _unlockfail; /** * Pages we failed to unlock */ public Set unlockfail(){ return _unlockfail; } public boolean hasFailure(){ return !_unlockfail.isEmpty() || !_lockfail.isEmpty(); } public LockResult(Set locked, Set lockfail, Set unlocked, Set unlockfail){ _locked = locked; _lockfail = lockfail; _unlocked = unlocked; _unlockfail = unlockfail; } @Override public String toString(){ return "[locked:" + _locked.toString() + "]" + "[lockfail:" + _lockfail.toString() + "]" + "[unlocked:" + _unlocked.toString() + "]" + "[unlockfail:" + _unlockfail.toString() + "]"; } @Override public boolean equals(Object o){ if ( this == o ){ return true; } if ( o == null ){ return false; } if ( !(o instanceof LockResult )){ return false; } LockResult other = (LockResult) o; return _locked.equals(other._locked) && _lockfail.equals(other._lockfail) && _unlocked.equals(other._unlocked) && _unlockfail.equals(other._unlockfail); } @Override public int hashCode(){ //Any arbitrary constant will do return 0; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/Locker.java000066400000000000000000000040301257724672200247150ustar00rootroot00000000000000package dw.xmlrpc; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import dw.xmlrpc.exception.DokuException; //! @cond class Locker { private final CoreClient _client; public Locker(CoreClient client){ _client = client; } public LockResult lock(String pageId) throws DokuException{ List pageIds = new ArrayList(); pageIds.add(pageId); return setLocks(pageIds, null); } public LockResult unlock(String pageId) throws DokuException{ List pageIds = new ArrayList(); pageIds.add(pageId); return setLocks(null, pageIds); } @SuppressWarnings("unchecked") public LockResult setLocks(List pagesToLock, List pagesToUnlock) throws DokuException{ Map params = BuildParams(pagesToLock, pagesToUnlock); Object result = _client.genericQuery("dokuwiki.setLocks", params); return BuildLockResult((Map) result); } private Map BuildParams(List pagesToLock, List pagesToUnlock){ Map params = new HashMap(); params.put("lock", pagesToLock == null ? new Object[]{} : pagesToLock.toArray()); params.put("unlock", pagesToUnlock == null ? new Object[]{} : pagesToUnlock.toArray()); return params; } private LockResult BuildLockResult(Map data){ Object lockedObj = data.get("locked"); Object lockfailObj = data.get("lockfail"); Object unlockedObj = data.get("unlocked"); Object unlockfailObj = data.get("unlockfail"); return new LockResult(objToStr(lockedObj), objToStr(lockfailObj), objToStr(unlockedObj), objToStr(unlockfailObj)); } private Set objToStr(Object objects){ return objToStr((Object[]) objects); } private Set objToStr(Object[] objects){ Set result = new HashSet(); if ( objects == null ){ return result; } for(Object o : objects){ result.add((String) o); } return result; } //! @endcond } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/MediaChange.java000066400000000000000000000026231257724672200256310ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Describes a revision of a media */ public class MediaChange { private final String _id; /** * Id of the media (namespace + name) */ public String id(){ return _id; } private final Date _lastModified; /** * Date of this modification of the media */ public Date lastModified(){ return _lastModified; } private final String _author; /** * Author of this modification of the media */ public String author(){ return _author; } private final Integer _version; /** * Version of the revision as a timestamp. * * Should correspond to {@link #lastModified()} */ public Integer version(){ return _version; } private final Integer _perms; /** * Permissions of the file */ public Integer perms(){ return _perms; } private final Integer _size; /** * Size of the file in bytes */ public Integer size(){ return _size; } public MediaChange(String id, Date lastModified, String author, Integer version, Integer perms, Integer size){ _id = id; _lastModified = lastModified; _author = author; _version = version; _perms = perms; _size = size; } @Override public String toString(){ return "id=" + _id + ", lastModified=" + (_lastModified == null ? "null" : _lastModified.toString()) + ", author=" + _author + ", version=" + _version + ", perms=" + _perms + ", size=" + _size; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/ObjectConverter.java000066400000000000000000000117531257724672200266060ustar00rootroot00000000000000package dw.xmlrpc; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; //! @cond class ObjectConverter { static List toPageDW(Object[] objs){ List result = new ArrayList(); for(Object o : objs){ result.add(toPageDW(o)); } return result; } static PageDW toPageDW(Object o){ @SuppressWarnings("unchecked") Map map = (Map) o; String id = (String) map.get("id"); Integer size = (Integer) map.get("size"); Integer version = (Integer) map.get("rev"); Integer mtime = (Integer) map.get("mtime"); String hash = (String) map.get("hash"); return new PageDW(id, size, version, mtime, hash); } static List toSearchResult(Object[] objs){ List result = new ArrayList(); for ( Object o : objs ){ result.add(toSearchResult(o)); } return result; } static SearchResult toSearchResult(Object o){ @SuppressWarnings("unchecked") Map mapResult = (Map) o; String id = (String) mapResult.get("id"); String title = (String) mapResult.get("title"); if ( title == null){ //for DW up to 2012-01-25 title = id; } Integer rev = (Integer) mapResult.get("rev"); Integer mtime = (Integer) mapResult.get("mtime"); Integer size = (Integer) mapResult.get("size"); Integer score = (Integer) mapResult.get("score"); String snippet = (String) mapResult.get("snippet"); return new SearchResult(id, title, rev, mtime, score, snippet, size); } static PageInfo toPageInfo(Object o){ @SuppressWarnings("unchecked") Map resMap = (Map) o; String name = (String) resMap.get("name"); Date modified = (Date) resMap.get("lastModified"); String author = (String) resMap.get("author"); Integer version = (Integer) resMap.get("version"); return new PageInfo(name, modified, author, version); } static List toPage(Object[] objs){ List result = new ArrayList(); for(Object o : objs){ result.add(toPage(o)); } return result; } static Page toPage(Object o){ @SuppressWarnings("unchecked") Map resMap = (Map) o; String id = (String) resMap.get("id"); Integer perms = toPerms(resMap.get("perms")); Date lastModified = (Date) resMap.get("lastModified"); Integer size = (Integer) resMap.get("size"); return new Page(id, perms, lastModified, size); } static List toString(Object[] objs){ List result = new ArrayList(); for(Object o : objs){ result.add((String) o); } return result; } static List toLinkInfo(Object[] objs){ List result = new ArrayList(); for ( Object o : objs ){ result.add(toLinkInfo(o)); } return result; } static LinkInfo toLinkInfo(Object o){ @SuppressWarnings("unchecked") Map resMap = (Map) o; String type = (String) resMap.get("type"); String page = (String) resMap.get("page"); String href = (String) resMap.get("href"); return new LinkInfo(type, page, href); } static List toPageChange(Object[] objs){ List result = new ArrayList(); for(Object o : objs){ result.add(toPageChange(o)); } return result; } static PageChange toPageChange(Object o){ @SuppressWarnings("unchecked") Map resMap = (Map) o; String id = (String) resMap.get("name"); Integer perms = toPerms(resMap.get("perms")); Date lastModified = (Date) resMap.get("lastModified"); Integer size = null; try { size = (Integer) resMap.get("size"); } catch (ClassCastException e) { //Sometimes Dokuwiki fails to get a size (it seems to be the case if the //corresponding page doesn't exist anymore) size = null; } String author = (String) resMap.get("author"); Integer version = (Integer) resMap.get("version"); return new PageChange(id, perms, lastModified, size, author, version); } static List toPageVersion(Object[] objs, String pageId){ List result = new ArrayList(); for ( Object o : objs ){ result.add(toPageVersion(o, pageId)); } return result; } static PageVersion toPageVersion(Object o, String pageId){ @SuppressWarnings("unchecked") Map resMap = (Map) o; String author = (String) resMap.get("author"); if ( author == null ){ author = (String) resMap.get("user"); } String ip = (String) resMap.get("ip"); String type = (String) resMap.get("type"); String summary = (String) resMap.get("sum"); Date modified = (Date) resMap.get("modified"); Integer version = (Integer) resMap.get("version"); return new PageVersion(pageId, author, ip, type, summary, modified, version); } static Integer toPerms(Object o){ //Because DW may sometime return a string instead //(fixed after Adora Belle (2012-10-03)) if (o instanceof Integer){ return (Integer) o; } return Integer.valueOf((String) o); } } //! @endcond dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/Page.java000066400000000000000000000020561257724672200243600ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Page as describe by the method getAllPage */ public class Page { private final String _id; /** * id of the page, that is namespace + name */ public String id(){ return _id; } private final Integer _perms; /** * Integer denoting the permissions on the page */ public Integer perms(){ return _perms; } private final Date _lastModified; /** * Last modification date */ public Date lastModified(){ return _lastModified; } private final Integer _size; /** * Size of the page */ public Integer size(){ return _size; } public Page(String id, Integer perms, Date lastModified, Integer size){ if ( id == null ){ throw new IllegalArgumentException("Can't build a Page with a null id"); } _id = id; _perms = perms; _lastModified = lastModified; _size = size; } @Override public String toString(){ return "id:" + _id + ", perms:" + _perms + ", lastModified:" + (_lastModified == null ? "null" : _lastModified.toString()) + ", size:" + _size; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/PageChange.java000066400000000000000000000031721257724672200254660ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Describe a page change, as returned by the getRecentChanges xmlrpc method * */ public class PageChange { private final String _pageId; /** * Id of the page changed */ public String pageId(){ return _pageId; } /** * Alias for {@link #pageId()} * * This alias is provided because it is the way it is called by the xmlrpc method */ public String name(){ return _pageId; } private final Integer _perms; /** * Integer representing the permissions on the file */ public Integer perms(){ return _perms; } private final Date _lastModified; /** * Date of the modification */ public Date lastModified(){ return _lastModified; } private final Integer _size; public Integer size(){ return _size; } private final String _author; /** * Author of the page */ public String author(){ return _author; } private final Integer _version; /** * Version of the page */ public Integer version(){ return _version; } public PageChange(String pageId, Integer perms, Date lastModified, Integer size, String author, Integer version){ if ( pageId == null ){ throw new IllegalArgumentException("Can't build a PageChange with a null pageId"); } _pageId = pageId; _perms = perms; _lastModified = lastModified; _size = size; _author = author; _version = version; } @Override public String toString(){ return "pageId:" + _pageId + ", perms:" + _perms + ", lastModified:" + (_lastModified == null ? "null" : _lastModified.toString()) + ", size: " + _size + ", author: " + _author + ", version: " + _version; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/PageDW.java000066400000000000000000000016411257724672200246120ustar00rootroot00000000000000package dw.xmlrpc; /** * Page as describe by DokuWiki's xmlrpc method getPageList */ public class PageDW { private final String _id; public String id(){ return _id; } private final Integer _size; public Integer size(){ return _size; } private final Integer _version; public Integer version(){ return _version; } private final Integer _mtime; public Integer mtime(){ return _mtime; } private final String _hash; public String hash(){ return _hash; } public PageDW(String id, Integer size, Integer version, Integer mtime, String hash){ if ( id == null ){ throw new IllegalArgumentException("Can't build a PageDW with a null id"); } _id = id; _size = size; _version = version; _mtime = mtime; _hash = hash; } @Override public String toString(){ return "id=" + _id + ", size=" + _size + ", version=" + _version + ", mtime=" + _mtime + ", hash=" + _hash; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/PageInfo.java000066400000000000000000000021231257724672200251670ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Information about a wiki page */ public class PageInfo { private final String _id; /** * Id of the page (namespace + name) */ public String id(){ return _id; } private final Date _modified; /** * Date of the modification of this version */ public Date modified(){ return _modified; } private final String _author; /** * Author of this version */ public String author(){ return _author; } private final Integer _version; /** * Version as a timestamp * * Should correspond to {@link #modified()} */ public Integer version(){ return _version; } public PageInfo(String id, Date modified, String author, Integer version){ if ( id == null ){ throw new IllegalArgumentException("Can't build a PageInfo with a null id"); } _id = id; _modified = modified; _author = author; _version = version; } @Override public String toString(){ return "id:" + _id + ", modified:" + (_modified == null ? "null" : _modified.toString()) + ", author:" + _author + ", version:" + _version; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/PageVersion.java000066400000000000000000000043051257724672200257250ustar00rootroot00000000000000package dw.xmlrpc; import java.util.Date; /** * Describe a version of a page. * * Dokuwiki may not always return every field (because the information is already * missing on Dokuwiki's side or because it isn't meant to give such field for a * given query). * Hence it's better to always check if a given field isn't null before using it. */ public class PageVersion { private final String _pageId; /** * Page id (namespace + name) */ public String pageId(){ return _pageId; } private final String _author; /** * Author of the revision */ public String author(){ return _author; } /** * Alias of {@link #author()} * * Provided because this is how this fields is named by the xmlrpc query */ public String user(){ return _author; } private final String _ip; /** * Ip who made this revision */ public String ip(){ return _ip; } private final String _type; /** * Type of revision (creation, edition, ...) */ public String type(){ return _type; } private final String _summary; /** * Summary of the revision */ public String summary(){ return _summary; } private final Date _modified; /** * Date of the revision */ public Date lastModified(){ return _modified; } /** * Alias of lastModifie * * Provided because it's called this way by the xmlrpc query */ public Date modified(){ return _modified; } private final Integer _version; /** * Version of the revision, as a timestamp * * Should correspond to {@link #modified()} */ public Integer version(){ return _version; } public PageVersion(String pageId, String author, String ip, String type, String summary, Date modified, Integer version){ if ( pageId == null ){ throw new IllegalArgumentException("Can't build a PageVersion with a null id"); } _pageId = pageId; _author = author; _ip = ip; _type = type; _summary = summary; _modified = modified; _version = version; } @Override public String toString(){ return "pageId=" + _pageId + ", author=" + _author + ", ip=" + _ip + ", type=" + _type + ", summary=" + _summary + ", modified=" + (_modified == null ? "null" : _modified.toString()) + ", version=" + _version; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/SearchResult.java000066400000000000000000000024711257724672200261110ustar00rootroot00000000000000package dw.xmlrpc; /** * Result of a text search on the wiki */ public class SearchResult { private final String _id; public String id(){ return _id; } private final String _title; public String title(){ return _title; } private final Integer _size; public Integer size(){ return _size; } private final Integer _rev; public Integer rev(){ return _rev; } private final Integer _mtime; public Integer mtime(){ return _mtime; } private final Integer _score; /** * Score of the result. * * The higher, the more relevant this result is. */ public Integer score(){ return _score; } private final String _snippet; /** * Snippet of the page matching the search. */ public String snippet(){ return _snippet; } public SearchResult(String id, String title, Integer rev, Integer mtime, Integer score, String snippet, Integer size){ if ( id == null ){ throw new IllegalArgumentException("Can't build a SearchResult with a null id"); } _id = id; _title = title; _rev = rev; _mtime = mtime; _score = score; _snippet = snippet; _size = size; } @Override public String toString(){ return "id: " + _id + ", title:" + _title + ", rev:" + _rev + ", mtime:" + _mtime + ", score: " + _score + ", snippet: " + _snippet + ", size: " + _size; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/000077500000000000000000000000001257724672200246345ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuAttachmentStillReferenced.java000066400000000000000000000007521257724672200334110ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when one tries to delete a distant media still referenced. * * Dokuwiki won't let delete a media if a page still uses it. * If one tries to delete such a media, Dokuwiki won't allow it, and this exception * will be thrown */ public class DokuAttachmentStillReferenced extends DokuException { private static final long serialVersionUID = -1349452363587746526L; public DokuAttachmentStillReferenced(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuAttachmentUploadException.java000066400000000000000000000004161257724672200334370ustar00rootroot00000000000000package dw.xmlrpc.exception; public class DokuAttachmentUploadException extends DokuException { private static final long serialVersionUID = 3307739440250260529L; public DokuAttachmentUploadException(String message, Throwable cause) { super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuBadUrlException.java000066400000000000000000000004551257724672200313560ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when a bad url has been provided */ public class DokuBadUrlException extends DokuException { private static final long serialVersionUID = 7969663858357866492L; public DokuBadUrlException(String message, Throwable cause) { super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuDeleteAttachmentException.java000066400000000000000000000004741257724672200334210ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when an attempt to delete a file on the wiki failed */ public class DokuDeleteAttachmentException extends DokuException { private static final long serialVersionUID = -5093967783205014204L; public DokuDeleteAttachmentException(Throwable cause) { super(cause); } } DokuDistantFileDoesntExistException.java000066400000000000000000000005271257724672200345260ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exceptionpackage dw.xmlrpc.exception; /** * Thrown when one attemps to work on a file which doesn't exist on the wiki */ public class DokuDistantFileDoesntExistException extends DokuException { private static final long serialVersionUID = -5014826815320361555L; public DokuDistantFileDoesntExistException(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuEmptyNewPageException.java000066400000000000000000000006001257724672200325420ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown by Dokuwiki when one try to use putPage with an empty page content * if the page doesn't exist yet (or has alreay been deleted) */ public class DokuEmptyNewPageException extends DokuException { private static final long serialVersionUID = 3088375008770606694L; public DokuEmptyNewPageException(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuException.java000066400000000000000000000006011257724672200302550ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Generic exception */ public class DokuException extends Exception { private static final long serialVersionUID = 7882114034813429168L; public DokuException(Throwable cause) { super(cause); } public DokuException(String message, Throwable cause) { super(message, cause); } public DokuException(String message){ super(message); } } DokuIncompatibleVersionException.java000066400000000000000000000011141257724672200340730ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exceptionpackage dw.xmlrpc.exception; public class DokuIncompatibleVersionException extends DokuException { private static final long serialVersionUID = 7903625706488374779L; public DokuIncompatibleVersionException(String oldestCompatibleVersion){ super(getMessage(oldestCompatibleVersion)); } private static String getMessage(String oldestCompatibleVersion){ return "The version of Dokuwiki we're querying doesn't support the action we're trying to perform. " + "The older compatible version is " + oldestCompatibleVersion + ". " + "Try to update your Dokuwiki server."; } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuInvalidTimeStampException.java000066400000000000000000000005311257724672200334120ustar00rootroot00000000000000package dw.xmlrpc.exception; import dw.xmlrpc.exception.DokuException; /** * Thrown when an invalid timestamp is provided */ public class DokuInvalidTimeStampException extends DokuException { private static final long serialVersionUID = -2041584428271122864L; public DokuInvalidTimeStampException(Throwable cause) { super(cause); } } DokuMethodDoesNotExistsException.java000066400000000000000000000004241257724672200340360ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exceptionpackage dw.xmlrpc.exception; public class DokuMethodDoesNotExistsException extends DokuException { private static final long serialVersionUID = 2005563951980285304L; public DokuMethodDoesNotExistsException(String message, Throwable cause){ super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuMisConfiguredWikiException.java000066400000000000000000000004201257724672200335570ustar00rootroot00000000000000package dw.xmlrpc.exception; public class DokuMisConfiguredWikiException extends DokuException { private static final long serialVersionUID = 7988621871633643736L; public DokuMisConfiguredWikiException(String message, Throwable cause) { super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuNoChangesException.java000066400000000000000000000004541257724672200320510ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when one looked out for changes when there are none */ public class DokuNoChangesException extends DokuException { private static final long serialVersionUID = 6200266566237242596L; public DokuNoChangesException(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuPageDoesNotExistException.java000066400000000000000000000003641257724672200333710ustar00rootroot00000000000000package dw.xmlrpc.exception; public class DokuPageDoesNotExistException extends DokuException { private static final long serialVersionUID = 8579585910287045131L; public DokuPageDoesNotExistException(Throwable cause) { super(cause); } }dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuPageLockedException.java000066400000000000000000000004611257724672200322000ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when one tries to edit a page locked by someone else */ public class DokuPageLockedException extends DokuException { private static final long serialVersionUID = -6402957075601882399L; public DokuPageLockedException(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuTimeoutException.java000066400000000000000000000004121257724672200316240ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when a call timeout */ public class DokuTimeoutException extends DokuException { private static final long serialVersionUID = -1156444596841763628L; public DokuTimeoutException(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuUnauthorizedException.java000066400000000000000000000011721257724672200326630ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when a user attempts to make a query he isn't allowed to. * * If this exception is unexpected you may want to check: * * The credentials given to the #dw.xmlrpc.DokuJClient * * The wiki configuration (xmlrpc interface must be enabled, and this user must be allowed to use it) */ public class DokuUnauthorizedException extends DokuException { private static final long serialVersionUID = -1970601945755526735L; public DokuUnauthorizedException(Throwable cause) { super(cause); } public DokuUnauthorizedException(String message, Throwable cause) { super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuUnknownException.java000066400000000000000000000007571257724672200316510ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown when an xmlrpc query failed for an unknown reason. * * To have more information on the failure you may access the original exception * using getCause() */ public class DokuUnknownException extends DokuException { private static final long serialVersionUID = -4230515595018490484L; public DokuUnknownException(Throwable cause) { super(cause); } public DokuUnknownException(String message, Throwable cause) { super(message, cause); } } dokuJClient-dokujclient-3.5.2/src/main/java/dw/xmlrpc/exception/DokuWordblockException.java000066400000000000000000000010061257724672200321240ustar00rootroot00000000000000package dw.xmlrpc.exception; /** * Thrown if a page can't be edited because of a wordblock. * * The list of forbidden words for a given wiki are defined in its wordblock.conf file. * If one try to edit a page addind one of this words, DokuWiki won't allow the edition, * and this exception will be thrown. */ public class DokuWordblockException extends DokuException { private static final long serialVersionUID = -3281103378061961240L; public DokuWordblockException(Throwable cause) { super(cause); } } dokuJClient-dokujclient-3.5.2/src/main/resources/000077500000000000000000000000001257724672200220105ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/main/resources/application.properties000066400000000000000000000000471257724672200264320ustar00rootroot00000000000000application.version=${project.version} dokuJClient-dokujclient-3.5.2/src/main/resources/dokujclient000077500000000000000000000002761257724672200242560ustar00rootroot00000000000000#!/bin/bash if [ -L "$0" ] && [ -x $(which readlink) ]; then thisFile="$(readlink -mn "$0")" else thisFile="$0" fi cpBase="$(dirname "$thisFile")" java -cp "$cpBase/*" dw.cli.Program $@ dokuJClient-dokujclient-3.5.2/src/test/000077500000000000000000000000001257724672200200315ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/000077500000000000000000000000001257724672200207525ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/000077500000000000000000000000001257724672200213645ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/000077500000000000000000000000001257724672200221335ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/000077500000000000000000000000001257724672200237345ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/000077500000000000000000000000001257724672200250645ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_AclChanger.java000066400000000000000000000017131257724672200307170ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_AclChanger extends TestHelper { @org.junit.Before public void clean() throws Exception { //It stings a bit since the setup rely on the tested code. However: // * without it, we can't launch two mutation runs in a row // * if there's a bug in the tested code, it will be caught anyway runWithArguments("addAcl", "--scope", "*", "--username", "@user", "--permission", "8"); } @org.junit.Test public void canAddAndRemoveAcl() throws Exception { assertSuccess("8", runWithArgumentAsWriterUser("aclCheck", "ns1:start")); assertSuccess("", runWithArguments("delAcl", "--scope", "*", "--username", "@user")); assertSuccess("0", runWithArgumentAsWriterUser("aclCheck", "ns1:start")); assertSuccess("", runWithArguments("addAcl", "--scope", "*", "--username", "@user", "--permission", "8")); assertSuccess("8", runWithArgumentAsWriterUser("aclCheck", "ns1:start")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_AclChecker.java000066400000000000000000000005031257724672200307100ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_AclChecker extends TestHelper { @org.junit.Test public void aclCheck() throws Exception { assertSuccess("255", runWithArguments("aclCheck", "ns1:start")); assertSuccess("8", runWithArgumentAsWriterUser("aclCheck", "ns1:start")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_AllPagesGetter.java000066400000000000000000000023661257724672200316000ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_AllPagesGetter extends TestHelper { @org.junit.Test public void getAllPages() throws Exception { Output output = runWithArguments("getAllPages"); assertGenericSuccess(output); String[] pages = output.out.split("\n"); assertTrue(pages.length >= 11); //Don't assertEquals because other tests may create new pages assertHasExactlyOnceThisLine("nssearch:page3", pages); } @org.junit.Test public void getAllPagesWithLongFlag() throws Exception { Output output = runWithArguments("getAllPages", "-l"); assertGenericSuccess(output); String[] pages = output.out.split("\n"); assertTrue(pages.length >= 11); //Don't assertEquals because other tests may create new pages assertHasExactlyOnceThisLine("nssearch:page3 255 197", pages); } private void assertHasExactlyOnceThisLine(String expected, String[] actual){ boolean found = false; for(String line : actual){ if ( line.equals(expected) ){ if ( found ){ fail("line found twice: " + expected); } found = true; } } if ( ! found ){ fail("line not found: " + expected); } } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_AttachmentInfoGetter.java000066400000000000000000000006611257724672200330100ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_AttachmentInfoGetter extends TestHelper { @org.junit.Test public void getAttachmentInfo() throws Exception { Output output = runWithArguments("getAttachmentInfo", "ro_for_tests:img1.gif"); assertGenericSuccess(output); assertTrue(output.out.contains("ro_for_tests:img1.gif 67")); } } Test_AttachmentPutterAndDeleter.java000066400000000000000000000074621257724672200341040ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itestpackage dw.cli.commands.itest; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static junitx.framework.FileAssert.assertBinaryEquals; import java.io.File; import dw.cli.Output; import dw.cli.itest.TestHelper; import dw.xmlrpc.itest.TestParams; public class Test_AttachmentPutterAndDeleter extends TestHelper { private static String ns = "putAndDelete_ns"; private static String localFileName = "localToto.gif"; private final File localFile = new File(localFileName); @org.junit.Before @org.junit.After public void clean() throws Exception { localFile.delete(); runWithArguments("deleteAttachment", ns + ":toto.gif"); } @org.junit.Test public void putAndDeleteAttachment() throws Exception { assertFalse(runWithArguments("getAttachments", ns).out.contains("toto.gif")); Output outputPut = runWithArguments("putAttachment", ns + ":toto.gif", TestParams.localFileToUpload); assertSuccess("", outputPut); assertTrue(runWithArguments("getAttachments", ns).out.contains("toto.gif")); Output outputDelete = runWithArguments("deleteAttachment", ns + ":toto.gif"); assertSuccess("", outputDelete); assertFalse(runWithArguments("getAttachments", ns).out.contains("toto.gif")); } @org.junit.Test public void putAttachmentWontOverwriteWithoutTheForceOption() throws Exception{ //Ensure we start in a clean state runWithArguments("putAttachment", ns + ":toto.gif", TestParams.localFileToUpload); runWithArguments("getAttachment", ns + ":toto.gif", localFileName); assertBinaryEquals(new File(TestParams.localFileToUpload), localFile); //Try to override the distant file without providing the flag Output output = runWithArguments("putAttachment", ns + ":toto.gif", TestParams.localFile2ToUpload); assertGenericError(output); //Assert the attachment hasn't been overrided runWithArguments("getAttachment", ns + ":toto.gif", localFileName); assertBinaryEquals(new File(TestParams.localFileToUpload), localFile); } @org.junit.Test public void putAttachmentWillOverwriteWithTheForceOption() throws Exception{ //Ensure we start in a clean state runWithArguments("putAttachment", ns + ":toto.gif", TestParams.localFileToUpload); runWithArguments("getAttachment", ns + ":toto.gif", localFileName); assertBinaryEquals(new File(TestParams.localFileToUpload), localFile); //Try to override the distant file without providing the flag Output output = runWithArguments("putAttachment", ns + ":toto.gif", "-f", TestParams.localFile2ToUpload); assertSuccess("", output); //Assert the attachment hasn't been overrided runWithArguments("getAttachment", ns + ":toto.gif", localFileName); assertBinaryEquals(new File(TestParams.localFile2ToUpload), localFile); } @org.junit.Test public void deletingAnUnexistingFileYieldsAnErrorOnlyIfNoForceFlagHasBeenProvided() throws Exception { Output outputForceLess = runWithArguments("deleteAttachment", ns + ":unknown_file.gif"); assertGenericError(outputForceLess); Output outputForced = runWithArguments("deleteAttachment", "-f", ns + ":unknown_file.gif"); assertSuccess("", outputForced); } @org.junit.Test public void getAFileToANonWritablePlaceDoesntCrash() throws Exception{ //Ensure we start in a clean state runWithArguments("putAttachment", ns + ":toto.gif", TestParams.localFileToUpload); runWithArguments("getAttachment", ns + ":toto.gif", localFileName); assertTrue(runWithArguments("getAttachments", ns).out.contains("toto.gif")); //Actually test Output output = runWithArguments("getAttachment", ns + ":toto.gif", "/home/whatever/icantwrite/here.jpg"); assertGenericError(output); } @org.junit.Test public void putAFileWhichDoesntExistDoesntCrash() throws Exception { Output output = runWithArguments("putAttachment", ns + ":toto.gif", "unexistingFile.jpg"); assertGenericError(output); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_AttachmentReader.java000066400000000000000000000013731257724672200321450ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_AttachmentReader extends TestHelper { @org.junit.Test public void getAttachments() throws Exception { Output output = runWithArguments("getAttachments", "ro_for_tests"); assertSuccess("ro_for_tests:img1.gif", output); } @org.junit.Test public void getAttachmentsLongListingFormat() throws Exception { Output output = runWithArguments("getAttachments", "-l", "ro_for_tests"); assertSuccessRegex("255 67 " + dateRegex + " ro_for_tests:img1.gif", output); } @org.junit.Test public void getAttachmentsMissingNamespaceShouldPrintError() throws Exception { Output output = runWithArguments("getAttachments"); assertGenericError(output); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_BackLinksGetter.java000066400000000000000000000004151257724672200317420ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_BackLinksGetter extends TestHelper { @org.junit.Test public void getBackLinks() throws Exception { assertSuccess("links:start", runWithArguments("getBackLinks", "ns1:dummy")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_Exception.java000066400000000000000000000014151257724672200306650ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import dw.cli.itest.TestHelper; public class Test_Exception extends TestHelper { @org.junit.Test public void knownBadUrlYieldErrorWithUsefulHint() throws Exception { try { runWithUrl("http://localhost/badUrl", "getVersion"); } catch(Exception e){ assertTrue(e.getMessage().contains("lib/exe/xmlrpc.php")); return; } fail("Should have thrown"); } @org.junit.Test public void badUrlYieldErrorWithUsefulHint() throws Exception { try { runWithUrl("http://localhost/badUrl/lib/exe/xmlrpc.php", "getVersion"); } catch(Exception e){ assertTrue(e.getMessage().contains("lib/exe/xmlrpc.php")); return; } fail("Should have thrown"); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_HelpPrinter.java000066400000000000000000000050531257724672200311650ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import dw.cli.Output; import dw.cli.Program; import dw.cli.itest.TestHelper; public class Test_HelpPrinter extends TestHelper { @org.junit.Test public void commandHelpPrintsGenericHelp() throws Exception { Output output = runWithoutGenericArguments("help"); assertGenericSuccess(output); assertIsGenericHelpMessage(output.out); } @org.junit.Test public void commandHelpCanPrintHelpForAGivenCommand() throws Exception { Output output = runWithoutGenericArguments("help", "getPagelist"); assertGenericSuccess(output); assertTrue(output.out.contains("[-l] [--depth ]")); } @org.junit.Test public void commandHelpPrintsGenericHelpIfQueriedWithInvalidCommand() throws Exception { Output output = runWithoutGenericArguments("help", "doesntExist"); assertGenericSuccess(output); assertIsGenericHelpMessage(output.out); } @org.junit.Test public void optionHelpPrintsHelp() throws Exception { Output output = runWithoutGenericArguments("--help"); assertGenericSuccess(output); assertIsGenericHelpMessage(output.out); } @org.junit.Test public void unexistingCommandPrintsHelp() throws Exception { Output output = runWithArguments("doesntExist"); assertGenericError(output); assertIsGenericHelpMessage(output.err); } @org.junit.Test public void incorrectOptionsPrintsHelp() throws Exception { List args = new ArrayList(); args.add("--urll"); args.add("http://localhost/myWiki/lib/exe/xmlrpc.php"); Output output = Program.run(args.toArray(new String[]{})); assertGenericError(output); assertIsGenericHelpMessage(output.err); } private void assertIsGenericHelpMessage(String message) { assertMessageContainsGenericOptions(message); assertMessageContainsListOfCommands(message); assertMessageTellHowToGetHelpForAGivenCommand(message); } private void assertMessageContainsGenericOptions(String message){ assertTrue(message.contains("--user")); assertTrue(message.contains("--url")); assertTrue(message.contains("--help")); assertTrue(message.contains("--password")); } private void assertMessageContainsListOfCommands(String message){ assertTrue(message.contains("getTitle")); assertTrue(message.contains("getAttachments")); assertTrue(message.contains("deleteAttachment")); assertTrue(message.contains("getPagelist")); } private void assertMessageTellHowToGetHelpForAGivenCommand(String message) { assertTrue(message.contains("help ")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_LinksLister.java000066400000000000000000000013531257724672200311730ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_LinksLister extends TestHelper{ @org.junit.Test public void listLinks() throws Exception { String expected = "http://dokuwiki.org" + "\nhttp://github.com/gturri" + "\nns1:dummy"; assertSuccess(expected, runWithArguments("listLinks", "links:start")); } @org.junit.Test public void listLinksWithLongFormat() throws Exception { String expected = "extern http://dokuwiki.org http://dokuwiki.org" + "\nextern http://github.com/gturri http://github.com/gturri" + "\nlocal ns1:dummy /dokuwikiITestsForXmlRpcClient_dokuwiki-2013-12-08/doku.php?id=ns1:dummy"; assertSuccess(expected, runWithArguments("listLinks", "-l", "links:start")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_LocksSetter.java000066400000000000000000000046531257724672200312000ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_LocksSetter extends TestHelper { @org.junit.Before @org.junit.After public void unlockAll() throws Exception { runWithArguments("unlock", "ns2:p1", "ns2:p2", "ns2:p3"); runWithArgumentAsWriterUser("unlock", "ns2:p1", "ns2:p2", "ns2:p3"); } @org.junit.Test public void canLockAPage() throws Exception { //Check initial state assertIsntLocked("ns2:p1"); assertIsntLocked("ns2:p3"); //Act assertSuccess("", runWithArguments("lock", "ns2:p1")); //Check final state assertIsLocked("ns2:p1"); assertIsntLocked("ns2:p3"); } private void assertIsntLocked(String pageId) throws Exception { assertGenericSuccess(runWithArgumentAsWriterUser("putPage", pageId, "some text")); } private void assertIsLocked(String pageId) throws Exception { assertGenericError(runWithArgumentAsWriterUser("putPage", pageId, "some text")); } @org.junit.Test public void canLockSeveralPages() throws Exception { //Check initial state assertIsntLocked("ns2:p1"); assertIsntLocked("ns2:p2"); assertIsntLocked("ns2:p3"); //Act assertSuccess("", runWithArguments("lock", "ns2:p1", "ns2:p2")); //Check final state assertIsLocked("ns2:p1"); assertIsLocked("ns2:p2"); assertIsntLocked("ns2:p3"); } @org.junit.Test public void canUnlockAPage() throws Exception { //Prepare and check initial state runWithArguments("lock", "ns2:p1"); assertIsLocked("ns2:p1"); //Act assertSuccess("", runWithArguments("unlock", "ns2:p1")); //Check final state assertIsntLocked("ns2:p1"); } @org.junit.Test public void canUnlockSeveralPage() throws Exception { //Prepare and check initial state runWithArguments("lock", "ns2:p1", "ns2:p2"); assertIsLocked("ns2:p1"); assertIsLocked("ns2:p2"); //Act assertSuccess("", runWithArguments("unlock", "ns2:p1", "ns2:p2")); //Check final state assertIsntLocked("ns2:p1"); assertIsntLocked("ns2:p2"); } @org.junit.Test public void reportsAnErrorIfAtLeastOneLockFailed() throws Exception { //Prepare initial state runWithArgumentAsWriterUser("lock", "ns2:p1"); //Act assertGenericError(runWithArguments("lock", "ns2:p1", "ns2:p2")); } @org.junit.Test public void reportsAnErrorIfAtLeastOneUnlockFailed() throws Exception { //Prepare initial state runWithArgumentAsWriterUser("lock", "ns2:p1"); //Act assertGenericError(runWithArguments("unlock", "ns2:p1", "ns2:p2")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageAppender.java000066400000000000000000000036551257724672200312720ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_PageAppender extends TestHelper { private final String pageId = "ns1:dummy"; private final String initialContent = "put page in a clean state."; @org.junit.Before public void setUp() throws Exception{ runWithArguments("putPage", pageId, initialContent); } @org.junit.Test public void appendPage() throws Exception { String append1 = "text appened"; assertSuccess("", runWithArguments("appendPage", pageId, append1)); assertSuccess(initialContent + append1, runWithArguments("getPage", pageId)); String append2 = "final text"; assertSuccess("", runWithArguments("appendPage", pageId, append2)); assertSuccess(initialContent + append1 + append2, runWithArguments("getPage", pageId)); } @org.junit.Test public void appendPageWithSeveralParts() throws Exception { String part1 = "toto"; String part2 = "tata"; assertSuccess("", runWithArguments("appendPage", pageId, part1, part2)); assertSuccess(initialContent + part1 + " " + part2, runWithArguments("getPage", pageId)); String part3 = "tutu"; assertSuccess("", runWithArguments("appendPage", pageId, part3)); assertSuccess(initialContent + part1 + " " + part2 + part3, runWithArguments("getPage", pageId)); } @org.junit.Test public void appendPageWithSummary() throws Exception{ //Sleep because DW behaves badly wrt revisions,when there are more than 1 version per second Thread.sleep(1000, 0); String summary1 = "I needed this change"; assertSuccess("", runWithArguments("appendPage", "--summary", summary1, pageId, "some text")); assertLastModificationSummary(summary1, runWithArguments("getPageVersions", pageId)); Thread.sleep(1000, 0); String summary2 = "fixed a typo"; assertSuccess("", runWithArguments("appendPage", "--summary", summary2, pageId, "some other text")); assertLastModificationSummary(summary2, runWithArguments("getPageVersions", pageId)); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageGetterAndPutter.java000066400000000000000000000040561257724672200326110ustar00rootroot00000000000000package dw.cli.commands.itest; import java.io.ByteArrayInputStream; import java.io.InputStream; import dw.cli.itest.TestHelper; public class Test_PageGetterAndPutter extends TestHelper { private final String pageId = "ns1:dummy"; @org.junit.Before public void setUp() throws Exception{ runWithArguments("putPage", pageId, ""); } @org.junit.Test public void putPageAndgetPage() throws Exception{ final String content1 = "content1"; final String content2 = "content2"; assertSuccess("", runWithArguments("putPage", pageId, content1)); assertSuccess(content1, runWithArguments("getPage", pageId)); assertSuccess("", runWithArguments("putPage", pageId, content2)); assertSuccess(content2, runWithArguments("getPage", pageId)); } @org.junit.Test public void putPageWithSeveralParts() throws Exception { runWithArguments("putPage", pageId, "toto", "tata"); assertSuccess("toto tata", runWithArguments("getPage", pageId)); } @org.junit.Test public void canPutAPageWithASummary() throws Exception { //Sleep because DW behaves badly wrt revisions,when there are more than 1 version per second Thread.sleep(1000, 0); assertSuccess("", runWithArguments("putPage", pageId, "--summary", "my summary 1", "some content 2")); assertLastModificationSummary("my summary 1", runWithArguments("getPageVersions", pageId)); //Sleep because DW behaves badly wrt revisions,when there are more than 1 version per second Thread.sleep(1000, 0); assertSuccess("", runWithArguments("putPage", pageId, "--summary", "my other summary", "some other content")); assertLastModificationSummary("my other summary", runWithArguments("getPageVersions", pageId)); } @org.junit.Test public void shouldReadFromStdinIfThereIsNoTextOnTheCommandLine() throws Exception { String data = "Some text on stdin"; InputStream stdin = System.in; try { System.setIn(new ByteArrayInputStream(data.getBytes())); runWithArguments("putPage", pageId); assertSuccess("Some text on stdin", runWithArguments("getPage", pageId)); } finally { System.setIn(stdin); } } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageHtmlGetter.java000066400000000000000000000007561257724672200316120ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_PageHtmlGetter extends TestHelper { private final String pageId = "rev:start"; @org.junit.Test public void getPageHTML() throws Exception { assertSuccess("\n

\n3rd version\n

\n", runWithArguments("getPageHTML", pageId)); } @org.junit.Test public void getPageHTMLVersion() throws Exception { assertSuccess("\n

\nv2\n

\n", runWithArguments("getPageHTMLVersion", pageId, "1356218411")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageInfoGetter.java000066400000000000000000000004271257724672200315740ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_PageInfoGetter extends TestHelper { @org.junit.Test public void getPageInfo() throws Exception { assertSuccess("rev:start 1356218419 lulu", runWithArguments("getPageInfo", "rev:start")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageInfoVersionGetter.java000066400000000000000000000005311257724672200331360ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_PageInfoVersionGetter extends TestHelper { @org.junit.Test public void getPageInfoVersion() throws Exception { String expected = "rev:start 1356218411 fifi"; assertSuccess(expected, runWithArguments("getPageInfoVersion", "rev:start", "1356218411")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageListGetter.java000066400000000000000000000017171257724672200316170ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_PageListGetter extends TestHelper { @org.junit.Test public void getPagelist() throws Exception { Output output = runWithArguments("getPagelist", "ns1"); assertSuccess("ns1:dummy\nns1:start", output); } @org.junit.Test public void getPageListLongFormat() throws Exception { Output output = runWithArguments("getPagelist", "-l", "nswithanotherns:otherns"); assertSuccess("4 1375372800 1375372800 nswithanotherns:otherns:page", output); } @org.junit.Test public void getPageListWithDepth() throws Exception { Output output = runWithArguments("getPagelist", "--depth", "3", "nswithanotherns"); assertGenericSuccess(output); assertTrue(output.out.contains("nswithanotherns:start")); assertTrue(output.out.contains("nswithanotherns:dummy")); assertTrue(output.out.contains("nswithanotherns:otherns:page")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageVersionGetter.java000066400000000000000000000007451257724672200323310ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_PageVersionGetter extends TestHelper { private final String pageId = "rev:start"; @org.junit.Test public void getPageVersion() throws Exception{ assertSuccess("version 1", runWithArguments("getPageVersion", pageId, "1356218400")); assertSuccess("", runWithArguments("getPageVersion", pageId, "1356218401")); assertSuccess("v2", runWithArguments("getPageVersion", pageId, "1356218411")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_PageVersionsGetter.java000066400000000000000000000021131257724672200325030ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_PageVersionsGetter extends TestHelper { @org.junit.Test public void getPageVersionsWithExplicitOffset() throws Exception{ //Might seems counter-intuitive since we could expect the same output as the other test //with just one line removed // //In fact: // * since provide "--offset 1", we skip the "last non current" revision (ie: "fifi - edit 1") // * since we provide a non zero offset, the current revision isn't added (ie: "lulu - edit 2") //hence, only one line remains String expected = "rev:start 1356218400 127.0.0.1 C riri - created"; assertSuccess(expected, runWithArguments("getPageVersions", "rev:start", "--offset", "1")); } @org.junit.Test public void getPageVersionsWithoutExplicitOffset() throws Exception{ String expected = "rev:start 1356218419 127.0.0.1 E lulu - edit 2" + "\nrev:start 1356218411 127.0.0.1 E fifi - edit 1" + "\nrev:start 1356218400 127.0.0.1 C riri - created"; assertSuccess(expected, runWithArguments("getPageVersions", "rev:start")); } } Test_RPCVersionSupportedGetter.java000066400000000000000000000004651257724672200337270ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itestpackage dw.cli.commands.itest; import dw.cli.itest.TestHelper; public class Test_RPCVersionSupportedGetter extends TestHelper { @org.junit.Test public void getRPCVersionSupported() throws Exception { assertSuccess(params.rpcVersionSupported.toString(), runWithArguments("getRPCVersionSupported")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_RecentChangesGetter.java000066400000000000000000000006561257724672200326210ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_RecentChangesGetter extends TestHelper { @org.junit.Test public void getRecentChanges() throws Exception { Output output = runWithArguments("getRecentChanges", "1356218401"); assertGenericSuccess(output); assertTrue(output.out.contains("rev:start 1356218419 someuser 255 11")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_RecentMediaChangesGetter.java000066400000000000000000000006731257724672200335600ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_RecentMediaChangesGetter extends TestHelper { @org.junit.Test public void getRecentMediaChanges() throws Exception { Output output = runWithArguments("getRecentMediaChanges", "1356383400"); assertGenericSuccess(output); assertTrue(output.out.contains("ro_for_tests:img1.gif fifi 255 67")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_Searcher.java000066400000000000000000000015431257724672200304650ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_Searcher extends TestHelper { @org.junit.Test public void search() throws Exception{ Output output = runWithArguments("search", "amet"); assertSuccess("nssearch:page3\nnssearch:start", output); } @org.junit.Test public void searchWithLongSwitch() throws Exception { Output output = runWithArguments("search", "-l", "amet"); assertSuccess("2 1375376400 1375376400 Page 3 title 197 nssearch:page3\n1 1383544045 1383544045 56 nssearch:start", output); } @org.junit.Test public void searchWithSnippetSwitch() throws Exception { Output output = runWithArguments("search", "--snippet", "amet"); assertGenericSuccess(output); assertTrue(output.out.contains("nssearch:page3\n> ======Page 3 title======")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_TimeGetter.java000066400000000000000000000006651257724672200310060ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_TimeGetter extends TestHelper { @org.junit.Test public void getTime() throws Exception{ Output output = runWithArguments("getTime"); assertGenericSuccess(output); assertIsTimestamp(output.out); } private void assertIsTimestamp(String string) { assertEquals(10, string.length()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_TitleGetter.java000066400000000000000000000004431257724672200311630ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_TitleGetter extends TestHelper { @org.junit.Test public void getTitle() throws Exception{ Output output = runWithArguments("getTitle"); assertSuccess("test xmlrpc", output); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_Version.java000066400000000000000000000005011257724672200303470ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_Version extends TestHelper { @org.junit.Test public void optionVersion() throws Exception{ Output output = runWithArguments("--version"); assertGenericSuccess(output); assertNotNullOrEmpty(output.out); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_VersionGetter.java000066400000000000000000000004561257724672200315330ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_VersionGetter extends TestHelper { @org.junit.Test public void getVersion() throws Exception { Output output = runWithArguments("getVersion"); assertSuccess(params.wikiVersion, output); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_XMLRPCAPIVersionGetter.java000066400000000000000000000005231257724672200330060ustar00rootroot00000000000000package dw.cli.commands.itest; import dw.cli.Output; import dw.cli.itest.TestHelper; public class Test_XMLRPCAPIVersionGetter extends TestHelper { @org.junit.Test public void getXMLRPCAPIVersion() throws Exception{ Output output = runWithArguments("getXMLRPCAPIVersion"); assertSuccess(params.apiVersion.toString(), output); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/commands/itest/Test_getAttachment.java000066400000000000000000000020111257724672200315100ustar00rootroot00000000000000package dw.cli.commands.itest; import static org.junit.Assert.*; import static junitx.framework.FileAssert.assertBinaryEquals; import java.io.File; import dw.cli.Output; import dw.cli.itest.TestHelper; import dw.xmlrpc.itest.TestParams; public class Test_getAttachment extends TestHelper { private final File localFile = new File("myFile.gif"); @org.junit.Before @org.junit.After public void clean(){ localFile.delete(); } @org.junit.Test public void canGetAttachment() throws Exception { //Make sure we're in a clean state assertFalse(localFile.exists()); Output output = runWithArguments("getAttachment", "ro_for_tests:img1.gif", "myFile.gif"); assertSuccess("", output); assertTrue(localFile.exists()); assertBinaryEquals(new File(TestParams.localFileToUpload), new File("myFile.gif")); } @org.junit.Test public void attachmentDoesntExist() throws Exception { Output output = runWithArguments("getAttachment", "ro_for_tests:unexisting_file.gif", "myFile.gif"); assertGenericError(output); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/itest/000077500000000000000000000000001257724672200232635ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/itest/TestHelper.java000066400000000000000000000067731257724672200262220ustar00rootroot00000000000000package dw.cli.itest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import dw.cli.Output; import dw.cli.Program; import dw.xmlrpc.itest.TestParams; public class TestHelper { protected final TestParams params = new TestParams("dokuwiki-2013-12-08", "Release 2013-12-08 \"Binky\"", 8, 2); protected final String dateRegex = "[A-Za-z]{3} [A-Za-z]{3} [0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3}? [0-9]{4}"; protected void assertNotNullOrEmpty(String str){ assertNotNull(str); assertFalse(str.equals("")); } protected void assertNotZero(int number){ assertFalse(number == 0); } protected Output runWithArguments(String command, String... extraArguments) throws Exception{ String[] arguments = buildArguments(TestParams.user, TestParams.password, command, extraArguments); return Program.run(arguments); } protected Output runWithUrl(String url, String command, String... extraArguments) throws Exception { String[] arguments = buildArguments(TestParams.user, TestParams.password, command, url, extraArguments); return Program.run(arguments); } protected Output runWithoutGenericArguments(String command, String... extraArguments) throws Exception { List args = new ArrayList(); args.add(command); for(String extraArg : extraArguments){ args.add(extraArg); } return Program.run(args.toArray(new String[]{})); } protected Output runWithArgumentAsWriterUser(String command, String... extraArguments) throws Exception { String[] arguments = buildArguments(TestParams.writerLogin, TestParams.writerPwd, command, extraArguments); return Program.run(arguments); } protected Output runWithArgumentAsPermissionLessUser(String command, String...extraArguments) throws Exception { String[] arguments = buildArguments("badUser", "badPassword", command, extraArguments); return Program.run(arguments); } private String[] buildArguments(String user, String password, String command, String... extraArguments){ return buildArguments(user, password, command, params.url, extraArguments); } private String[] buildArguments(String user, String password, String command, String url, String... extraArguments){ List args = new ArrayList(); args.add("-u"); args.add(user); args.add("-p"); args.add(password); args.add("--url"); args.add(url); args.add(command); for(String extraArg : extraArguments){ args.add(extraArg); } return args.toArray(new String[]{}); } protected void assertSuccess(String expectedOutput, Output actualOutput){ assertEquals(expectedOutput, actualOutput.out); assertGenericSuccess(actualOutput); } protected void assertSuccessRegex(String expectedOutput, Output actualOutput){ assertTrue(actualOutput.out.matches(expectedOutput)); assertGenericSuccess(actualOutput); } protected void assertGenericSuccess(Output actualOutput){ assertEquals("", actualOutput.err); assertEquals(0, actualOutput.exitCode); } protected void assertGenericError(Output actualOutput){ assertNotNullOrEmpty(actualOutput.err); assertEquals("", actualOutput.out); assertNotZero(actualOutput.exitCode); } protected void assertLastModificationSummary(String expectedSummary, Output actualOutput) { String lastModification = actualOutput.out.split("\n")[0]; String actualSummary = lastModification.split(" - ")[1]; assertEquals(expectedSummary, actualSummary); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/itest/Test_PermissionLessUser.java000066400000000000000000000004241257724672200307430ustar00rootroot00000000000000package dw.cli.itest; public class Test_PermissionLessUser extends TestHelper { @org.junit.Test public void shouldntCrashIfUserDoesntHaveEnoughPermissions() throws Exception { assertGenericError(runWithArgumentAsPermissionLessUser("putPage", "start", "some text")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/utest/000077500000000000000000000000001257724672200232775ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/utest/MockPasswordReader.java000066400000000000000000000004231257724672200277000ustar00rootroot00000000000000package dw.cli.utest; import dw.cli.PasswordReader; public class MockPasswordReader extends PasswordReader { private final String _string; public MockPasswordReader(String string){ _string = string; } @Override public String readPassword(){ return _string; } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/utest/Test_CliOptions.java000066400000000000000000000004451257724672200272270ustar00rootroot00000000000000package dw.cli.utest; import static org.junit.Assert.*; import dw.cli.CliOptions; public class Test_CliOptions { @org.junit.Test public void toStringDoesntThrowNullPointerException(){ CliOptions cliWithNullMembers = new CliOptions(); assertNotNull(cliWithNullMembers.toString()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/utest/Test_OptionParser.java000066400000000000000000000052771257724672200276010ustar00rootroot00000000000000package dw.cli.utest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.net.URL; import dw.cli.CliOptions; import dw.cli.OptionParser; public class Test_OptionParser { @org.junit.Test public void canParseGenericOptions() throws Exception{ String[] args = new String[]{"-u", "toto", "-p", "123456", "--url", "http://myUrl", "getTitle", "arg0"}; OptionParser parser = new OptionParser(args); parser.parse(); System.out.println(parser.getHelpMessage()); assertTrue(parser.success()); assertNotNull(parser.getHelpMessage()); CliOptions options = parser.getCliOptions(); assertEquals("toto", options.user); assertEquals("123456", options.password); assertEquals(new URL("http://myUrl"), options.url); assertEquals("getTitle", options.command); assertEquals(1, options.commandArguments.length); assertEquals("arg0", options.commandArguments[0]); } @org.junit.Test public void canParseCommandFlags() throws Exception { String[] args = new String[]{"--url", "http://myUrl", "someCommand", "arg0", "-l", "3"}; OptionParser parser = new OptionParser(args); parser.parse(); assertTrue(parser.success()); CliOptions options = parser.getCliOptions(); assertEquals("someCommand", options.command); assertEquals(3, options.commandArguments.length); assertEquals("arg0", options.commandArguments[0]); assertEquals("-l", options.commandArguments[1]); assertEquals("3", options.commandArguments[2]); } @org.junit.Test public void failsIfAnArgumentIsMissingItsValue() throws Exception{ String[] args = new String[]{"-u", "toto", "-p", "123456", "--url"}; OptionParser parser = new OptionParser(args); parser.parse(); assertFalse(parser.success()); } @org.junit.Test public void canReadPasswordInteractively() throws Exception { String[] args = new String[]{"-u", "toto", "--password-interactive", "--url", "http://myUrl", "getTitle", "arg0"}; OptionParser parser = new OptionParser(args, new MockPasswordReader("abcdef")); parser.parse(); assertEquals(true, parser.success()); CliOptions options = parser.getCliOptions(); assertEquals("abcdef", options.password); assertEquals("toto", options.user); assertEquals(new URL("http://myUrl"), options.url); assertEquals("getTitle", options.command); } @org.junit.Test public void failsIfBothFlagsPasswordAndInteractivePassword() throws Exception { String[] args = new String[]{"-u", "toto", "-p", "123456", "--password-interactive", "--url", "http://myUrl", "getTitle", "arg0"}; OptionParser parser = new OptionParser(args); parser.parse(); assertFalse(parser.success()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/cli/utest/Test_PagePutter.java000066400000000000000000000031001257724672200272130ustar00rootroot00000000000000package dw.cli.utest; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.IOException; import dw.cli.StdinReader; import dw.cli.commands.PagePutter; import dw.xmlrpc.DokuJClient; public class Test_PagePutter { private StdinReader _mockStdinReader; private DokuJClient _mockDokuJClient; private PagePutter _sut; private static final String PAGE_ID = "somePageId"; private static final String TEXT_ON_CMD_LINE = "some text on cmd line"; private static final String TEXT_ON_STDIN = "some text on stdin"; @org.junit.Before public void before() throws IOException{ _mockStdinReader = mock(StdinReader.class); _mockDokuJClient = mock(DokuJClient.class); when(_mockStdinReader.readStdin()).thenReturn(TEXT_ON_STDIN); _sut = new PagePutter(false, _mockStdinReader); } @org.junit.Test public void shouldReadFromStdinIfThereIsTextOnTheCommandLine() throws Exception{ String[] args = new String[]{ PAGE_ID, TEXT_ON_CMD_LINE }; _sut.run(_mockDokuJClient, args); verify(_mockDokuJClient).putPage(eq(PAGE_ID), eq(TEXT_ON_CMD_LINE), anyString(), anyBoolean()); } @org.junit.Test public void shouldReadFromStdinIfThereIsNoTextOnTheCommandLine() throws Exception { String[] args = new String[]{ PAGE_ID }; _sut.run(_mockDokuJClient, args); verify(_mockDokuJClient).putPage(eq(PAGE_ID), eq(TEXT_ON_STDIN), anyString(), anyBoolean()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/000077500000000000000000000000001257724672200226715ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/000077500000000000000000000000001257724672200240215ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/TestHelper.java000066400000000000000000000040351257724672200267450ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuPageLockedException; public class TestHelper { /** * Assert that the actual Date is equal to the expected one. * Since we don't want to bother with timezones, we add a margin */ static void assertDatesNear(int year, int month, int day, int hour, int minute, int second, Date actual){ Date date = buildDate(year, month, day, hour, minute, second); int marginInMs = 24 * 3600 * 1000 + 1; assertTrue(Math.abs(date.getTime() - actual.getTime()) < marginInMs); } static Date buildDate(int year, int month, int day, int hour, int minute, int second){ TimeZone.setDefault(TimeZone.getTimeZone("GMT")); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(year, month, day, hour, minute, second); return cal.getTime(); } public static void assertPagesAreLockForMe(Iterable pageIds, DokuJClient client) throws DokuException { for(String pageId : pageIds){ assertPageIsLockForMe(pageId, client); } } public static void assertPageIsLockForMe(String pageId, DokuJClient client) throws DokuException{ boolean lockExceptionCaught = false; try { client.appendPage(pageId, "something"); } catch ( DokuPageLockedException e){ lockExceptionCaught = true; } assertTrue(lockExceptionCaught); } public static void assertPagesAreUnlockForMe(Iterable pageIds, DokuJClient client) throws DokuException { for(String pageId : pageIds){ assertPageIsUnlockForMe(pageId, client); } } public static void assertPageIsUnlockForMe(String pageId, DokuJClient client) throws DokuException{ String initialContent = client.getPage(pageId); try { client.appendPage(pageId, "something"); } catch (DokuPageLockedException e){ fail(); } //Clean page content client.putPage(pageId, initialContent); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/TestParams.java000066400000000000000000000046561257724672200267620ustar00rootroot00000000000000package dw.xmlrpc.itest; import java.util.ArrayList; import java.util.Collection; import java.util.List; public class TestParams { public final String localPath; public final String url; public final String urlToWikiNotConfiguredToAcceptRpcQueries; public final String wikiVersion; public final Integer apiVersion; public final Integer rpcVersionSupported; public final String name; public static final String urlPrefix = "http://localhost/"; public static final String urlSuffix = "/lib/exe/xmlrpc.php"; public TestParams(String name, String wikiVersion, Integer apiVersion, Integer rpcVersionSupported){ this.name = name; this.localPath = "dokuwikiITestsForXmlRpcClient_" + name; this.url = urlPrefix + localPath + urlSuffix; this.urlToWikiNotConfiguredToAcceptRpcQueries = urlPrefix + localPath + "_noRpc" + urlSuffix; this.wikiVersion = wikiVersion; this.apiVersion = apiVersion; this.rpcVersionSupported = rpcVersionSupported; } public static final String user = "xmlrpcuser"; public static final String password = "xmlrpc"; public static final String writerLogin = "writeruser"; public static final String writerPwd = "writer"; public static final String unauthorizedLogin = "norightsuser"; public static final String unauthorizedPwd = "norights"; public static final String wikiTitle = "test xmlrpc"; private static final String localRoot = "src/test/resources/testEnvironment"; public static final String localFileToUpload = localRoot + "/list-plus.gif"; public static final String localFile2ToUpload = localRoot + "/at.gif"; public static Collection data() { List result = new ArrayList(); result.add(new Object[]{new TestParams("dokuwiki-2012-01-25b", "Release 2012-01-25b \"Angua\"", 6, 2)}); result.add(new Object[]{new TestParams("dokuwiki-2012-10-13", "Release 2012-10-13 \"Adora Belle\"", 7, 2)}); result.add(new Object[]{new TestParams("dokuwiki-2013-05-10", "Release 2013-05-10 \"Weatherwax\"", 8, 2)}); result.add(new Object[]{new TestParams("dokuwiki-2013-12-08", "Release 2013-12-08 \"Binky\"", 8, 2)}); result.add(new Object[]{new TestParams("dokuwiki-2014-05-05", "Release 2014-05-05 \"Ponder Stibbons\"", 9, 2)}); result.add(new Object[]{new TestParams("dokuwiki-2014-09-29a", "Release 2014-09-29a \"Hrun\"", 9, 2)}); result.add(new Object[]{new TestParams("dokuwiki-2015-08-10a", "Release 2015-08-10a \"Detritus\"", 9, 2)}); return result; } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_AclChanger.java000066400000000000000000000046141257724672200276570ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.net.MalformedURLException; import java.util.Collection; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuIncompatibleVersionException; import dw.xmlrpc.exception.DokuUnauthorizedException; @RunWith(value = Parameterized.class) public class Test_AclChanger extends TestHelper { private final DokuJClient _client; private final String _pageId = "ns1:start"; TestParams _params; public Test_AclChanger(TestParams params) throws MalformedURLException, DokuException { _client = new DokuJClient(params.url, TestParams.user, TestParams.password); _params = params; } @Parameters public static Collection data() { return TestParams.data(); } @org.junit.Test public void canAddAndRemoveAcl() throws MalformedURLException, DokuException{ if ( dwIsTooOldAndDoesntSupportAclChanges()){ assertExpectedExceptionIsThrown(); } else { assertCanAddAndRemoveAcl(); } } private void assertExpectedExceptionIsThrown() throws DokuException{ try { _client.addAcl(_pageId, TestParams.unauthorizedLogin, 1); } catch(DokuIncompatibleVersionException e){ assertNotNull(e.getMessage()); return; } fail("Didn't receive the expected exception"); } private void assertCanAddAndRemoveAcl() throws MalformedURLException, DokuException{ assertCanRead(false); assertTrue(_client.addAcl(_pageId, TestParams.unauthorizedLogin, 1)); assertCanRead(true); assertTrue(_client.delAcl(_pageId, TestParams.unauthorizedLogin)); assertCanRead(false); } private boolean dwIsTooOldAndDoesntSupportAclChanges() { return _params.apiVersion < 8 || _params.name.equals("dokuwiki-2013-05-10"); } private void assertCanRead(boolean shouldBeAbleToRead) throws MalformedURLException, DokuException{ DokuJClient unauthorizedClient = new DokuJClient(_params.url, TestParams.unauthorizedLogin, TestParams.unauthorizedPwd); boolean couldRead = true; try { unauthorizedClient.getPage(_pageId); } catch(DokuUnauthorizedException e){ couldRead = false; } assertEquals(shouldBeAbleToRead, couldRead); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_Attacher.java000066400000000000000000000171611257724672200274240ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.*; import static junitx.framework.FileAssert.assertBinaryEquals; import java.io.File; import java.net.MalformedURLException; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TimeZone; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import dw.xmlrpc.AttachmentDetails; import dw.xmlrpc.AttachmentInfo; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.MediaChange; import dw.xmlrpc.exception.DokuAttachmentUploadException; import dw.xmlrpc.exception.DokuException; @RunWith(value = Parameterized.class) public class Test_Attacher extends TestHelper { private DokuJClient _client; private String _localDownloadedFile = "tempFileForTests.gif"; Set _uploadedFiles; public Test_Attacher(TestParams params) throws MalformedURLException, DokuException { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); _client = new DokuJClient(params.url, TestParams.user, TestParams.password); _uploadedFiles = new HashSet(); clean(); } @Parameters public static Collection data() { return TestParams.data(); } @org.junit.After public void clean(){ File f = new File(_localDownloadedFile); f.delete(); for ( String fileId : _uploadedFiles ){ tryToDeleteDistantFile(fileId); } } private void tryToDeleteDistantFile(String fileId){ try { _client.deleteAttachment(fileId); } catch ( Exception e ){ //Too bad we missed one... We'll live with it System.out.println("Failed to delete distant attachment " + fileId + " during tear down"); } } @org.junit.Test public void getAttachmentsUseParameters() throws Exception{ //Set up environment _uploadedFiles.add("nswithanotherns:img1.gif"); _uploadedFiles.add("ns2:img2.gif"); _uploadedFiles.add("nswithanotherns:img3.gif"); _uploadedFiles.add("nswithanotherns:img33.gif"); _uploadedFiles.add("nswithanotherns:otherns:img4.gif"); for ( String fileId : _uploadedFiles ){ _client.putAttachment(fileId, TestParams.localFileToUpload, true); } //actually test //Filtering on a PREG Map params = new HashMap(); params.put("pattern", "/3.gif/"); testGetAttachmentWithParams(params, 2); //without special parameters params = new HashMap(); testGetAttachmentWithParams(params, 4); //Limiting max depth params = new HashMap(); params.put("depth", 1); testGetAttachmentWithParams(params, 3); } private void testGetAttachmentWithParams(Map params, int nbExpectedAttachments) throws DokuException{ List res = _client.getAttachments("nswithanotherns", params); assertEquals(nbExpectedAttachments, res.size()); } @org.junit.Test public void getAttachmentsReturnsCorrectStructure() throws Exception { List res = _client.getAttachments("ro_for_tests"); assertEquals(1, res.size()); AttachmentDetails details = res.get(0); assertEquals("ro_for_tests:img1.gif", details.id()); assertEquals((Integer) 67, details.size()); //TODO: study timezones more in depth to strengthen this assertion assertNotNull(details.lastModified()); assertEquals(true, details.isImg()); assertEquals(true, details.writable()); assertEquals((Integer) 255, details.perms()); } @org.junit.Test public void getRecentMediaChanges() throws Exception{ List changes = _client.getRecentMediaChanges(1356383400); String mediaId = "ro_for_tests:img1.gif"; MediaChange change = findOneMediaChange(changes, mediaId); assertEquals(mediaId, change.id()); assertDatesNear(2012, 11, 24, 21, 11, 0, change.lastModified()); assertEquals("fifi", change.author()); assertEquals((Integer) 1356383460, change.version()); assertEquals((Integer) 255, change.perms()); assertEquals((Integer) 67, change.size()); } @org.junit.Test public void getRecentMediaChangesRespectMaxTimestamp() throws Exception { String oldMediaChange = "ro_for_tests:img1.gif"; String recentMediaChange = "ro_for_tests:img2.gif"; List changes = _client.getRecentMediaChanges(1356383400); assertNotNull(findOneMediaChange(changes,oldMediaChange)); assertNotNull(findOneMediaChange(changes, recentMediaChange)); changes = _client.getRecentMediaChanges(1356383461); assertNull(findOneMediaChange(changes,oldMediaChange)); assertNotNull(findOneMediaChange(changes, recentMediaChange)); } @org.junit.Test public void getRecentMediaChangesRespectMaxDate() throws Exception { String oldMediaChange = "ro_for_tests:img1.gif"; String recentMediaChange = "ro_for_tests:img2.gif"; List changes = _client.getRecentMediaChanges(buildDate(2012, 11, 24, 21, 10, 59)); assertNotNull(findOneMediaChange(changes,oldMediaChange)); assertNotNull(findOneMediaChange(changes, recentMediaChange)); changes = _client.getRecentMediaChanges(buildDate(2012, 11, 24, 21, 11, 1)); assertNull(findOneMediaChange(changes,oldMediaChange)); assertNotNull(findOneMediaChange(changes, recentMediaChange)); } private MediaChange findOneMediaChange(List changes, String mediaId){ MediaChange res = null; boolean foundOne = false; for(MediaChange change : changes){ if ( change.id().equals(mediaId) ){ if ( foundOne ){ fail("Found two media changes for the same mediaId " + mediaId); } foundOne = true; res = change; } } return res; } @org.junit.Test public void putGetAndDeleteAttachment() throws Exception{ String fileId = "ns1:img2.gif"; File file = new File(TestParams.localFileToUpload); _client.putAttachment(fileId, file, true); AttachmentInfo info = _client.getAttachmentInfo(fileId); assertEquals((Integer)(int) file.length(), info.size()); File fileRetrieved = _client.getAttachment(fileId, _localDownloadedFile); assertTrue(fileRetrieved.exists()); assertEquals(file.length(), fileRetrieved.length()); _client.deleteAttachment(fileId); info = _client.getAttachmentInfo(fileId); assertEquals((Integer)0, info.size()); } @org.junit.Test public void putWithoutOverwritingShouldPutOnlyIfTheresNoFileYet() throws Exception { String fileId = "ns1:img2.gif"; File file1 = new File(TestParams.localFileToUpload); File file2 = new File(TestParams.localFile2ToUpload); _client.putAttachment(fileId, file1, true); assertEquals(file1.length(), _client.getAttachment(fileId, _localDownloadedFile).length()); boolean expectedExceptionCaught = false; try { _client.putAttachment(fileId, file2, false); } catch (DokuAttachmentUploadException e){ expectedExceptionCaught = true; } assertTrue(expectedExceptionCaught); assertBinaryEquals(file1, _client.getAttachment(fileId, _localDownloadedFile)); } @org.junit.Test public void putWithOverwritingShouldAlwaysSucceed() throws Exception { String fileId = "ns1:img2.gif"; File file1 = new File(TestParams.localFileToUpload); File file2 = new File(TestParams.localFile2ToUpload); _client.putAttachment(fileId, file1, true); assertBinaryEquals(file1, _client.getAttachment(fileId, _localDownloadedFile)); _client.putAttachment(fileId, file2, true); assertBinaryEquals(file2, _client.getAttachment(fileId, _localDownloadedFile)); } @org.junit.Test public void getAttachmentInfo() throws Exception { String id = "ro_for_tests:img1.gif"; AttachmentInfo info = _client.getAttachmentInfo(id); assertEquals(id, info.id()); assertEquals((Integer) 67, info.size()); //TODO: enforce this test once we've clarify how to deal with timezone assertNotNull(info.lastModified()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_BadQueries.java000066400000000000000000000045521257724672200277150ustar00rootroot00000000000000package dw.xmlrpc.itest; import java.net.MalformedURLException; import static com.github.tomakehurst.wiremock.client.WireMock.*; import org.junit.Rule; import com.github.tomakehurst.wiremock.http.Fault; import com.github.tomakehurst.wiremock.junit.WireMockRule; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.DokuJClientConfig; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuTimeoutException; import dw.xmlrpc.exception.DokuUnknownException; public class Test_BadQueries { private final int port = 8080; @Rule public WireMockRule wireMockRule = new WireMockRule(port); @org.junit.Test(expected=DokuTimeoutException.class) public void iCanStopIfItTakesTooLongToRespond() throws MalformedURLException, DokuException{ setTimeout(); DokuJClient client = buildClientWithTimeOut(1); makeADummyCall(client); } @org.junit.Test public void iCanWaitEvenIfResponseTakesLong() throws MalformedURLException, DokuException{ setTimeout(); DokuJClient client = buildClientWithTimeOut(60); makeADummyCall(client); } @org.junit.Test public void timeoutOfZeroMeansWaitAsLongAsYouNeed() throws MalformedURLException, DokuException{ setTimeout(); DokuJClient client = buildClientWithTimeOut(0); makeADummyCall(client); } private void setTimeout(){ addRequestProcessingDelay(5*1000); stubFor(post(urlEqualTo("/lib/exe/xmlrpc.php")) .willReturn(aResponse() .withStatus(200) .withBody("") )); } @org.junit.Test(expected=DokuUnknownException.class) public void corruptedReply() throws Exception { stubFor(post(urlEqualTo("/lib/exe/xmlrpc.php")) .willReturn(aResponse() .withStatus(200) .withFault(Fault.MALFORMED_RESPONSE_CHUNK))); makeADummyCall(buildClient()); } private DokuJClient buildClient() throws MalformedURLException, DokuException { return buildClientWithTimeOut(0); } private DokuJClient buildClientWithTimeOut(int timeoutInSeconds) throws MalformedURLException, DokuException{ DokuJClientConfig config = new DokuJClientConfig("http://localhost:" + port + "/lib/exe/xmlrpc.php"); config.setTimeOutInSeconds(timeoutInSeconds); return new DokuJClient(config); } private void makeADummyCall(DokuJClient client) throws DokuException{ client.genericQuery("wiki.getAllPages"); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_Cookies.java000066400000000000000000000025211257724672200272570ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.*; import java.net.MalformedURLException; import java.util.Collection; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuException; @RunWith(value = Parameterized.class) public class Test_Cookies { private TestParams _params; public Test_Cookies(TestParams params) throws MalformedURLException, DokuException{ _params = params; } @Parameters public static Collection data() { return TestParams.data(); } @org.junit.Test public void cookies() throws Exception { DokuJClient client = new DokuJClient(_params.url); assertEquals(0, client.cookies().size()); assertFalse(client.hasDokuwikiCookies()); client.login(TestParams.writerLogin, TestParams.writerPwd); assertTrue(client.cookies().size() > 0); assertTrue(client.hasDokuwikiCookies()); } @org.junit.Test public void loginSuccess() throws Exception { DokuJClient client = new DokuJClient(_params.url); assertTrue(client.login(TestParams.writerLogin, TestParams.writerPwd)); } @org.junit.Test public void loginFail() throws Exception { DokuJClient client = new DokuJClient(_params.url); assertFalse(client.login(TestParams.writerLogin, "badPassword")); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_Exception.java000066400000000000000000000201341257724672200276210ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; import java.net.MalformedURLException; import java.util.Collection; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.exception.DokuAttachmentStillReferenced; import dw.xmlrpc.exception.DokuAttachmentUploadException; import dw.xmlrpc.exception.DokuBadUrlException; import dw.xmlrpc.exception.DokuDeleteAttachmentException; import dw.xmlrpc.exception.DokuDistantFileDoesntExistException; import dw.xmlrpc.exception.DokuEmptyNewPageException; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuInvalidTimeStampException; import dw.xmlrpc.exception.DokuMethodDoesNotExistsException; import dw.xmlrpc.exception.DokuMisConfiguredWikiException; import dw.xmlrpc.exception.DokuPageDoesNotExistException; import dw.xmlrpc.exception.DokuPageLockedException; import dw.xmlrpc.exception.DokuUnauthorizedException; import dw.xmlrpc.exception.DokuWordblockException; @RunWith(value = Parameterized.class) public class Test_Exception { private final DokuJClient _client; private final DokuJClient _unauthorizedClient; private final TestParams _params; private final File _file = new File(TestParams.localFileToUpload); public Test_Exception(TestParams params) throws MalformedURLException, DokuException { _params = params; _client = new DokuJClient(params.url, TestParams.user, TestParams.password); _unauthorizedClient = new DokuJClient(params.url, TestParams.unauthorizedLogin, TestParams.unauthorizedPwd); } @Parameters public static Collection data() { return TestParams.data(); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void unauthorizedToUseXmlRpc() throws Exception { DokuJClient unauthorizedClient = new DokuJClient(_params.url, "wrongUser","wrongPwd"); unauthorizedClient.getTime(); } @org.junit.Test(expected=DokuMisConfiguredWikiException.class) public void wikiNotConfiguredToAcceptIncomingRpcQueries() throws Exception { DokuJClient clientForUnconfiguredWiki = new DokuJClient(_params.urlToWikiNotConfiguredToAcceptRpcQueries, TestParams.user, TestParams.password); clientForUnconfiguredWiki.getTitle(); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void unauthorizedToRead() throws Exception { _unauthorizedClient.getPage("ns1:start"); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void unauthorizedToWrite() throws Exception { _unauthorizedClient.putPage("ns1:start", "text"); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void unauthorizedToListMedia() throws Exception { _unauthorizedClient.getAttachments(""); } @org.junit.Test(expected=DokuPageDoesNotExistException.class) public void getUnexistingPage() throws Exception { _client.getPageInfo("doesNotExist"); } @org.junit.Test(expected=DokuMisConfiguredWikiException.class) public void getPageInfoOnNotConfiguredWiki() throws Exception { DokuJClient clientForUnconfiguredWiki = new DokuJClient(_params.urlToWikiNotConfiguredToAcceptRpcQueries); clientForUnconfiguredWiki.getPageInfo("ns1:start"); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void getPageInfoWithUnauthorizedUser() throws Exception { _unauthorizedClient.getPageInfo("ns1:start"); } @org.junit.Test public void unauthorizedToDeleteMedia() throws Exception { String attachmentId = "forTestUnauthorizedWithMedia.gif"; _client.putAttachment(attachmentId, TestParams.localFileToUpload, true); boolean getRelevantException = false; try { _unauthorizedClient.deleteAttachment(attachmentId); } catch (DokuUnauthorizedException e){ getRelevantException = true; } _client.deleteAttachment(attachmentId); assertTrue(getRelevantException); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void unauthorizedToUploadMedia() throws Exception { _unauthorizedClient.putAttachment("shouldntHavePermissionToBeHere.gif", TestParams.localFileToUpload, true); } @org.junit.Test(expected=DokuDeleteAttachmentException.class) public void mediaToDeleteDoesntExist() throws Exception { String attachmentId = "unexistingFile.gif"; _client.deleteAttachment(attachmentId); } @org.junit.Test(expected=DokuDistantFileDoesntExistException.class) public void mediaToGetDoesntExist() throws Exception { _client.getAttachment("unexistingFile.gif", "file.gif"); } @org.junit.Test(expected=DokuUnauthorizedException.class) public void unauthorizedToGetMedia() throws Exception { String attachmentId = "forTestUnauthorizedWithMedia.gif"; _client.putAttachment(attachmentId, TestParams.localFileToUpload, true); _unauthorizedClient.getAttachment(attachmentId, "file.gif"); } @org.junit.Test(expected=DokuAttachmentStillReferenced.class) public void stillReferencedMedia() throws Exception { String distantFile = "referencedMedia.gif"; _client.putAttachment(distantFile, TestParams.localFileToUpload, true); _client.putPage("referencing", "here is a {{" + distantFile + "}}|file"); _client.deleteAttachment(distantFile); } @org.junit.Test(expected=DokuInvalidTimeStampException.class) public void invalidTimestamp() throws Exception { _client.getRecentChanges(123456); } @org.junit.Test(expected=DokuPageLockedException.class) public void pageLockedException() throws Exception { String pageId = "ns1:start"; _client.lock(pageId); DokuJClient otherClient = new DokuJClient(_params.url, TestParams.writerLogin, TestParams.writerPwd); otherClient.appendPage(pageId, "something"); } @org.junit.Test(expected=DokuBadUrlException.class) public void badUrlExceptionWhenPathIsWrong() throws Exception { DokuJClient client = new DokuJClient(_params.url + "azerty", TestParams.user, TestParams.password); client.getTitle(); } @org.junit.Test(expected=DokuBadUrlException.class) public void badUrlExceptionWhenHostIsUnknown() throws Exception { DokuJClient client = new DokuJClient("http://unknownHost/dokuwiki/lib/exe/xmlrpc.php", TestParams.user, TestParams.password); client.getTitle(); } @org.junit.Test(expected=DokuWordblockException.class) public void wordblockException() throws Exception { String pageId = "ns1:start"; _client.appendPage(pageId, "try to write a forbiddenword"); } @org.junit.Test(expected=DokuAttachmentUploadException.class) public void uploadForbiddenBecauseOfForbiddenExtension() throws Exception { _client.putAttachment("file.sh", _file, true); } @org.junit.Test(expected=DokuAttachmentUploadException.class) public void uploadForbiddenBecauseOfBadExtension() throws Exception { //jpg is authorized, but the file is in fact a gif _client.putAttachment("file.jpg", _file, true); } @org.junit.Test(expected=DokuAttachmentUploadException.class) public void uploadBecauseFileAlreadyExists() throws Exception { String attachmentId = "file.gif"; uploadWithoutThrowing(attachmentId); _client.putAttachment(attachmentId, _file, false); } private void uploadWithoutThrowing(String attachmentId){ try { _client.putAttachment(attachmentId, _file, true); } catch (Exception e){ fail(); } } @org.junit.Test(expected=DokuEmptyNewPageException.class) public void emptyNewPageException() throws Exception { String pageId = "toDelete"; //We try to delete it twice because to be sure we try it at least once //when the page is actually already deleted _client.putPage(pageId, ""); _client.putPage(pageId, ""); } @org.junit.Test(expected=DokuBadUrlException.class) public void status3xxYieldsBadUrlException() throws Exception { String tweakedUrl = _params.url.replaceAll(TestParams.urlSuffix, ""); new DokuJClient(tweakedUrl, TestParams.user, TestParams.password); } @org.junit.Test public void recognizeIfAMethodDoesNotExistAndContainsTheNameOfTheCalledMethod() throws Exception{ try { _client.genericQuery("some.dummy.action"); } catch(DokuMethodDoesNotExistsException e){ assertTrue(e.getMessage().contains("some.dummy.action")); return; } fail("We should have caught a DokuMethodDoesNotExistsException"); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_Lock.java000066400000000000000000000124411257724672200265550ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.*; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.LockResult; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuPageLockedException; @RunWith(value = Parameterized.class) public class Test_Lock extends TestHelper { private DokuJClient _client; private DokuJClient _otherClient; public Test_Lock(TestParams params) throws Exception{ _client = new DokuJClient(params.url, TestParams.user, TestParams.password); _otherClient = new DokuJClient(params.url, TestParams.writerLogin, TestParams.writerPwd); clean(); } @Parameters public static Collection data() { return TestParams.data(); } @org.junit.After public void clean() throws Exception { tryUnlock(_client, "ns2:p1"); tryUnlock(_client, "ns2:p2"); tryUnlock(_client, "ns2:p3"); tryUnlock(_client, "ns2:p4"); tryUnlock(_otherClient, "ns2:p1"); tryUnlock(_otherClient, "ns2:p2"); } private void tryUnlock(DokuJClient client, String pageId) throws DokuException{ try { client.unlock(pageId); } catch (DokuPageLockedException e){ } } @org.junit.Test public void iCanPlayWihLockToAllowYouToWriteOrNot() throws Exception{ String pageId = "ns1:start"; _client.lock(pageId); assertPageIsLockForMe(pageId, _otherClient); assertTrue(_client.unlock("ns1:start")); assertPageIsUnlockForMe(pageId, _otherClient); } @org.junit.Test public void iCanLockOrUnlockSeveralPagesAtOnce() throws Exception{ //1st round: lock some pages and unlock some already unlock pages List pagesToLock = new ArrayList(); pagesToLock.add("ns2:p1"); pagesToLock.add("ns2:p2"); List pagesToUnlock = new ArrayList(); pagesToUnlock.add("ns2:p3"); pagesToUnlock.add("ns2:p4"); _client.setLocks(pagesToLock, pagesToUnlock); assertPagesAreLockForMe(pagesToLock, _otherClient); assertPagesAreUnlockForMe(pagesToUnlock, _otherClient); //2nd round: lock some pages, some of which are already locked. Play with unlock too pagesToLock = new ArrayList(); pagesToLock.add("ns2:p1"); pagesToLock.add("ns2:p3"); pagesToUnlock = new ArrayList(); pagesToUnlock.add("ns2:p2"); pagesToUnlock.add("ns2:p4"); _client.setLocks(pagesToLock, pagesToUnlock); assertPagesAreLockForMe(pagesToLock, _otherClient); assertPagesAreUnlockForMe(pagesToUnlock, _otherClient); } //This doesn't really test the client, but it documents Dokuwiki's behavior, //hence it documents a non-intuitive behavior of the client @org.junit.Test public void iUnlockAutomaticallyWhenIWrite() throws Exception { String pageId = "ns1:start"; String initialContent = "init"; String addedContent1 = "added1"; String addedContent2 = "added2"; //Get a known state _client.putPage(pageId, initialContent); assertTrue(_client.lock(pageId)); //Now I write to let Dokuwiki unlock the page _client.appendPage(pageId, addedContent1); //And I make sure everyone may now write _otherClient.appendPage(pageId, addedContent2); String currentContent = _client.getPage(pageId); assertEquals(initialContent + addedContent1 + addedContent2, currentContent); } @org.junit.Test public void lockResult() throws Exception { Set emptySet = new HashSet(); //1st round: lock some pages and unlock some already unlocked pages List pagesToLock = new ArrayList(); pagesToLock.add("ns2:p1"); pagesToLock.add("ns2:p2"); List pagesToUnlock = new ArrayList(); pagesToUnlock.add("ns2:p3"); pagesToUnlock.add("ns2:p4"); LockResult expected = new LockResult(new HashSet(pagesToLock), emptySet, emptySet, new HashSet(pagesToUnlock)); LockResult actual = _client.setLocks(pagesToLock, pagesToUnlock); assertEquals(expected, actual); //2nd round: lock some pages, some of which are already locked. Play with unlock too pagesToLock = new ArrayList(); pagesToLock.add("ns2:p1"); pagesToLock.add("ns2:p3"); pagesToUnlock = new ArrayList(); pagesToUnlock.add("ns2:p2"); pagesToUnlock.add("ns2:p4"); Set locked = new HashSet(); locked.add("ns2:p1"); locked.add("ns2:p3"); Set unlocked = new HashSet(); unlocked.add("ns2:p2"); Set failedUnlock = new HashSet(); failedUnlock.add("ns2:p4"); expected = new LockResult(locked, emptySet, unlocked, failedUnlock); actual = _client.setLocks(pagesToLock, pagesToUnlock); assertEquals(expected, actual); } @org.junit.Test public void getFailedLockedAndUnlockedPages() throws Exception { Set emptySet = new HashSet(); _otherClient.lock("ns2:p1"); _otherClient.lock("ns2:p2"); List pagesToLock = new ArrayList(); pagesToLock.add("ns2:p1"); List pagesToUnlock = new ArrayList(); pagesToUnlock.add("ns2:p2"); LockResult expected = new LockResult(emptySet, new HashSet(pagesToLock), emptySet, new HashSet(pagesToUnlock)); LockResult actual = _client.setLocks(pagesToLock, pagesToUnlock); assertEquals(expected, actual); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/itest/Test_XmlRpcQueries.java000066400000000000000000000336461257724672200304420ustar00rootroot00000000000000package dw.xmlrpc.itest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TimeZone; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import dw.xmlrpc.DokuJClient; import dw.xmlrpc.DokuJClientConfig; import dw.xmlrpc.LinkInfo; import dw.xmlrpc.Page; import dw.xmlrpc.PageChange; import dw.xmlrpc.PageDW; import dw.xmlrpc.PageInfo; import dw.xmlrpc.PageVersion; import dw.xmlrpc.SearchResult; import dw.xmlrpc.exception.DokuException; import dw.xmlrpc.exception.DokuUnauthorizedException; @RunWith(value = Parameterized.class) public class Test_XmlRpcQueries extends TestHelper { private DokuJClient _client; private DokuJClient _clientWriter; private TestParams _params; public Test_XmlRpcQueries(TestParams params) throws MalformedURLException, DokuException{ _params = params; _client = new DokuJClient(params.url, TestParams.user, TestParams.password); _clientWriter = new DokuJClient(params.url, TestParams.writerLogin, TestParams.writerPwd); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); } @Parameters public static Collection data() { return TestParams.data(); } @org.junit.Test public void builtWithAConfig() throws Exception { DokuJClientConfig config = new DokuJClientConfig(_params.url); config.setUser(TestParams.user, TestParams.password); DokuJClient client = new DokuJClient(config); assertEquals(_params.wikiVersion, client.getVersion()); } @org.junit.Test public void getVersion() throws Exception { assertEquals(_params.wikiVersion, _client.getVersion()); } @org.junit.Test public void getPageInfo() throws Exception { String pageId = "rev:start"; PageInfo pageInfo = _client.getPageInfo(pageId); assertEquals(pageId, pageInfo.id()); assertEquals("lulu", pageInfo.author()); assertEquals((Integer) 1356218419, pageInfo.version()); assertDatesNear(2012, 11, 22, 23, 20, 19, pageInfo.modified()); } @org.junit.Test public void getPageInfoVersion() throws Exception { String pageId = "rev:start"; Integer version = 1356218411; PageInfo pageInfo = _client.getPageInfoVersion(pageId, version); assertEquals(pageId, pageInfo.id()); assertEquals("fifi", pageInfo.author()); assertEquals(version, pageInfo.version()); assertDatesNear(2012, 11, 22, 23, 20, 11, pageInfo.modified()); } @org.junit.Test public void getPageVersions() throws Exception{ String pageId = "rev:start"; List versions = _client.getPageVersions(pageId, 0); PageVersion version = versions.get(0); assertEquals((Integer) 1356218419, version.version()); assertEquals(pageId, version.pageId()); assertEquals("127.0.0.1", version.ip()); assertEquals("E", version.type()); assertEquals("lulu", version.author()); assertEquals("edit 2", version.summary()); assertDatesNear(2012, 11, 22, 23, 20, 19, version.modified()); } @org.junit.Test public void getPageVersion() throws Exception { String pageId = "rev:start"; assertEquals("version 1", _client.getPageVersion(pageId, 1356218400)); assertEquals("", _client.getPageVersion(pageId, 1356218401)); assertEquals("v2", _client.getPageVersion(pageId, 1356218411)); assertEquals("3rd version", _client.getPageVersion(pageId, 1356218419)); } @org.junit.Test public void getRecentChanges() throws Exception { List changes = _client.getRecentChanges(1356218401); assertTrue(changes.size() > 0); PageChange change = changes.get(0); assertEquals("someuser", change.author()); assertEquals((Integer) 1356218419, change.version()); assertEquals("rev:start", change.pageId()); assertEquals((Integer) 255, change.perms()); assertEquals((Integer) 11, change.size()); assertDatesNear(2012, 11, 22, 23, 20, 19, change.lastModified()); } @org.junit.Test public void getRecentChangesRespectMaxTimestamp() throws Exception { List changes = _client.getRecentChanges(1356218401); String pageId = "rev:start"; assertTrue(hasPageChangeOnce(changes, pageId)); changes = _client.getRecentChanges(1356218500); assertFalse(hasPageChangeOnce(changes, pageId)); } @org.junit.Test public void handlesTimestampsWithoutChange() throws Exception { assertEquals(0, _client.getRecentChanges(2000000000).size()); } @org.junit.Test public void getRecentChangesRespectMaxDate() throws Exception { List changes = _client.getRecentChanges(buildDate(2012, 11, 20, 0, 0, 0)); String pageId = "rev:start"; assertTrue(hasPageChangeOnce(changes, pageId)); changes = _client.getRecentChanges(buildDate(2013, 0, 1, 0, 0, 0)); assertFalse(hasPageChangeOnce(changes, pageId)); } private boolean hasPageChangeOnce(List changes, String pageId){ boolean foundChange = false; for(PageChange change : changes){ if ( change.pageId().equals(pageId) ){ if ( foundChange ){ fail("Had several PageChange for page " + pageId); } foundChange = true; } } return foundChange; } @org.junit.Test public void aclCheck() throws Exception { assertEquals((Integer) 255, _client.aclCheck("ns1:start")); assertEquals((Integer) 8, _clientWriter.aclCheck("ns1:start")); } @org.junit.Test public void getRPCVersionSupported() throws Exception { assertEquals(_params.rpcVersionSupported, _client.getRPCVersionSupported()); } @org.junit.Test public void getXMLRPCAPIVersion() throws Exception { assertEquals(_params.apiVersion, _client.getXMLRPCAPIVersion()); } @org.junit.Test public void time() throws Exception { //We proceed as follow to avoid having to use Sleep: // * edit a page to update its modification time and retrieve it // * retrieve server time // * edit the page again and retrieve // * make sure times are consistent PageDW page = _client.getPagelist("singlePage").get(0); _client.putPage(page.id(), "text before (time test)"); page = _client.getPagelist("singlePage").get(0); Integer timeBefore = page.mtime(); Integer serverTime = _client.getTime(); _client.putPage(page.id(), "text after (time test)"); page = _client.getPagelist("singlePage").get(0); Integer timeAfter = page.mtime(); assertTrue(0 < timeBefore); assertTrue(timeBefore <= serverTime); assertTrue(serverTime <= timeAfter); } @org.junit.Test public void getPagelistInAFlatNamespace() throws Exception { List expectedPages = new ArrayList(); expectedPages.add("ns1:start"); expectedPages.add("ns1:dummy"); List actualPages = _client.getPagelist("ns1"); assertEquals(expectedPages.size(), actualPages.size()); for (PageDW page : actualPages) { assertTrue(expectedPages.contains(page.id())); } } @org.junit.Test public void getPagelistCorrectlyBuildsPages() throws Exception{ String namespace = "nswithanotherns:otherns"; List pages = _client.getPagelist(namespace); assertEquals(1, pages.size()); PageDW page = pages.get(0); assertEquals(namespace + ":page", page.id()); assertEquals((Integer) 4, page.size()); assertEquals((Integer) 1375372800, page.version()); assertEquals((Integer) 1375372800, page.mtime()); assertEquals("71860c77c6745379b0d44304d66b6a13", page.hash()); } @org.junit.Test public void getPagelistInANamespaceWithAnotherNamespace() throws Exception { // Check we get every pages with no max recursion level Set expectedPages = new HashSet(); expectedPages.add("nswithanotherns:start"); expectedPages.add("nswithanotherns:dummy"); expectedPages.add("nswithanotherns:otherns:page"); HashMap options = new HashMap(); List actualPages = _client.getPagelist("nswithanotherns", options); assertEquals(expectedPages.size(), actualPages.size()); for (PageDW page : actualPages) { assertTrue(expectedPages.contains(page.id())); } // And now makes sure we can limit this recursion level expectedPages = new HashSet(); expectedPages.add("nswithanotherns:start"); expectedPages.add("nswithanotherns:dummy"); options.put("depth", "2"); actualPages = _client.getPagelist("nswithanotherns", options); assertEquals(expectedPages.size(), actualPages.size()); for (PageDW page : actualPages) { assertTrue(expectedPages.contains(page.id())); } } @org.junit.Test public void genericQueryWithParameters() throws Exception { Object[] params = new Object[] { "ns1:start" }; //255 because we make the query as an admin assertEquals(255, _client.genericQuery("wiki.aclCheck", params)); } @org.junit.Test public void genericQueryWithoutParameters() throws Exception { assertEquals(_params.wikiVersion, _client.genericQuery("dokuwiki.getVersion")); } @org.junit.Test public void getTitle() throws Exception { assertEquals(TestParams.wikiTitle, _client.getTitle()); } @org.junit.Test public void putAndGetPage() throws Exception { String pageId = "ns1:dummy"; String content1 = "content1"; String content2 = "content2"; _client.putPage(pageId, content1); assertEquals(content1, _client.getPage(pageId)); _client.putPage(pageId, content2); assertEquals(content2, _client.getPage(pageId)); } @org.junit.Test public void appendPage() throws Exception { String pageId = "ns1:dummy"; String initialContent = "put page in a clean state."; String append1 = "text appended."; String append2 = "final text"; _client.putPage(pageId, initialContent); _client.appendPage(pageId, append1); assertEquals(initialContent + append1, _client.getPage(pageId)); _client.appendPage(pageId, append2); assertEquals(initialContent + append1 + append2, _client.getPage(pageId)); } @org.junit.Test public void editWithSummary() throws Exception { String pageId = "ns1:dummy"; String initialContent = _client.getPage(pageId); String addedContent = "def"; String addedSummary = "sum append"; String finalContent = "abc"; String finalSummary = "sum put"; //Start with appendPage, to make sure we change the content of the page //hence, that the modification is taken into account _client.appendPage(pageId, addedContent, addedSummary, false); assertEquals(initialContent + addedContent, _client.getPage(pageId)); //Because DW creates at most one revision per second //If we don't sleep here the next modification will override the previous one Thread.sleep(1000, 0); _client.putPage(pageId, finalContent, finalSummary, false); assertEquals(finalContent, _client.getPage(pageId)); List versions = _client.getPageVersions(pageId); assertEquals(finalSummary, versions.get(0).summary()); assertEquals(addedSummary, versions.get(1).summary()); } @org.junit.Test public void getPageHTML() throws Exception { String pageId = "rev:start"; assertEquals("\n

\n3rd version\n

\n", _client.getPageHTML(pageId)); } @org.junit.Test public void getPageHTMLVersion() throws Exception{ String pageId = "rev:start"; Integer version = 1356218411; assertEquals("\n

\nv2\n

\n", _client.getPageHTMLVersion(pageId, version)); } @org.junit.Test public void listLinks() throws Exception{ List links = _client.listLinks("links:start"); LinkInfo link0 = new LinkInfo(LinkInfo.Type.extern, "http://dokuwiki.org", "http://dokuwiki.org"); LinkInfo link1 = new LinkInfo(LinkInfo.Type.extern, "http://github.com/gturri", "http://github.com/gturri"); LinkInfo link2 = new LinkInfo(LinkInfo.Type.local, "ns1:dummy","/" + _params.localPath + "/doku.php?id=ns1:dummy" ); assertEquals(link0, links.get(0)); assertEquals(link1, links.get(1)); assertEquals(link2, links.get(2)); } @org.junit.Test public void getBackLinks() throws Exception{ List links = _client.getBackLinks("ns1:dummy"); assertEquals("links:start", links.get(0)); } @org.junit.Test public void getAllPages() throws Exception{ List pages = _client.getAllPages(); //Not an Equals assertion because other tests may create new pages assertTrue(pages.size() >= 11); //We check thoroughly an arbitrary page String pageId = "nssearch:page3"; Page page = null; for(Page p : pages){ if ( p.id().equals(pageId) ){ if ( page != null ){ fail("page " + pageId + " returned twice"); } page = p; } } assertNotNull(page); assertEquals(pageId, page.id()); assertEquals((Integer) 255, page.perms()); assertDatesNear(2013, 7, 1, 17, 0, 0, page.lastModified()); assertEquals((Integer) 197, page.size()); } @org.junit.Test public void readPermsWithoutBeingAnAdmin() throws Exception { try { //Test to make sure we deal correctly with the fact that Dokuwiki may //either return an Integer or a String for the perms _clientWriter.getAllPages(); _clientWriter.getRecentChanges(1356218401); } catch (ClassCastException e){ fail(); } } @org.junit.Test public void search() throws Exception { List results = _client.search("amet"); SearchResult sr = results.get(0); assertEquals("nssearch:page3", sr.id()); if ( _client.getXMLRPCAPIVersion() >= 7 ){ //Previous version of the API doesn't return a title for this query assertEquals("Page 3 title", sr.title()); } else { assertEquals("nssearch:page3", sr.title()); } assertEquals((Integer) 1375376400, sr.rev()); assertEquals((Integer) 1375376400, sr.mtime()); assertEquals((Integer) 2, sr.score()); assertEquals((Integer) 197, sr.size()); assertTrue(sr.snippet().contains("Amet")); assertEquals("nssearch:start", results.get(1).id()); assertEquals((Integer) 1, results.get(1).score()); } @org.junit.Test public void logoff() throws Exception { _client.search("amet"); boolean actuallyLogoff = false; _client.logoff(); try { _client.search("amet"); } catch(DokuUnauthorizedException e){ actuallyLogoff = true; } assertTrue(actuallyLogoff); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/000077500000000000000000000000001257724672200240355ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_AttachmentDetails.java000066400000000000000000000005101257724672200312710ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.AttachmentDetails; public class Test_AttachmentDetails { @org.junit.Test public void toStringShouldntThrowNullRef(){ AttachmentDetails details = new AttachmentDetails(null, null, null, null, null, null); assertNotNull(details.toString()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_AttachmentInfo.java000066400000000000000000000004441257724672200306050ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.AttachmentInfo; public class Test_AttachmentInfo { @org.junit.Test public void toStringShouldntThrowNullRef(){ AttachmentInfo info = new AttachmentInfo(null, null, null); assertNotNull(info.toString()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_LinkInfo.java000066400000000000000000000023261257724672200274130ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.AttachmentDetails; import dw.xmlrpc.LinkInfo; public class Test_LinkInfo { @org.junit.Test public void equals(){ String link = "http://dokuwiki.org"; LinkInfo link1 = new LinkInfo("extern", link, link); LinkInfo link1bis = new LinkInfo(LinkInfo.Type.extern, link, link); LinkInfo link2 = new LinkInfo("local", "start", "http://mywiki?id=start"); assertTrue(link1.equals(link1bis)); assertFalse(link1.equals(link2)); assertFalse(link1bis.equals(link2)); assertTrue(link1bis.equals(link1)); assertFalse(link2.equals(link1)); assertFalse(link2.equals(link1bis)); assertFalse(link1.equals(null)); //case null assertFalse(link1.equals(new AttachmentDetails(null, null, null, null, null, null))); //Other kind of object } @org.junit.Test public void toStringShouldntThrowNullRef(){ LinkInfo link = new LinkInfo(LinkInfo.Type.local, null, null); link.toString(); } @org.junit.Test public void equalsLinkInfoHaveSameHashCode(){ LinkInfo link1 = new LinkInfo("local", "start", "http://something"); LinkInfo link2 = new LinkInfo("local", "start", "http://something"); assertEquals(link1.hashCode(), link2.hashCode()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_LockResult.java000066400000000000000000000026761257724672200300010ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import java.util.HashSet; import java.util.Set; import java.util.TreeSet; import dw.xmlrpc.LockResult; public class Test_LockResult { @org.junit.Test public void LockResultEquality(){ Set locked1 = new HashSet(); locked1.add("myPage"); Set locked2 = new TreeSet(); locked2.add("myPage"); Set locked3 = new HashSet(); locked3.add("yourPage"); LockResult res1 = BuildLockResult(locked1); LockResult res2 = BuildLockResult(locked2); LockResult res3 = BuildLockResult(locked3); assertTrue(res1.equals(res2)); assertFalse(res1.equals(res3)); assertFalse(res2.equals(res3)); assertFalse(res3.equals(res2)); assertFalse(res3.equals(res1)); assertTrue(res2.equals(res1)); assertTrue(res1.equals(res1)); assertFalse(res1.equals(null)); assertFalse(res1.equals(new Integer(1))); } @org.junit.Test public void equalsLockResultHaveSameHashCode(){ Set locked1 = new HashSet(); locked1.add("myPage"); Set locked2 = new TreeSet(); locked2.add("myPage"); LockResult result1 = BuildLockResult(locked1); LockResult result2 = BuildLockResult(locked2); assertEquals(result1.hashCode(), result2.hashCode()); } private LockResult BuildLockResult(Set locked){ Set emptySet = new HashSet(); return new LockResult(locked, emptySet, emptySet, emptySet); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_MediaChange.java000066400000000000000000000004721257724672200300270ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.assertNotNull; import dw.xmlrpc.MediaChange; public class Test_MediaChange { @org.junit.Test public void toStringShouldntThrowNullRef(){ MediaChange change = new MediaChange(null, null, null, null, null, null); assertNotNull(change.toString()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_Page.java000066400000000000000000000006561257724672200265620ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.Page; import java.util.Date; public class Test_Page { @org.junit.Test(expected=IllegalArgumentException.class) public void ShouldntAcceptToBuildWithNullId(){ new Page(null, 255, new Date(), 0); } @org.junit.Test public void toStringShouldntThrowNullRef(){ Page page = new Page("id", null, null, null); assertNotNull(page.toString()); } } dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_PageChange.java000066400000000000000000000007531257724672200276660ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.PageChange; import java.util.Date; public class Test_PageChange { @org.junit.Test(expected=IllegalArgumentException.class) public void ShouldntAcceptToBuildWithNullId(){ new PageChange(null, 255, new Date(), 0,"author", 123456789); } @org.junit.Test public void toStringShouldntThrowNullRef(){ PageChange page = new PageChange("id", null, null, null, null, null); assertNotNull(page.toString()); } }dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_PageDW.java000066400000000000000000000006631257724672200270130ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.PageDW; public class Test_PageDW { @org.junit.Test(expected=IllegalArgumentException.class) public void ShouldntAcceptToBuildWithNullId(){ new PageDW(null, 255, 123456789, 123456789, "123"); } @org.junit.Test public void toStringShouldntThrowNullRef(){ PageDW page = new PageDW("id", null, null, null, null); assertNotNull(page.toString()); } }dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_PageInfo.java000066400000000000000000000007171257724672200273740ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import java.util.Date; import dw.xmlrpc.PageInfo; public class Test_PageInfo { @org.junit.Test(expected=IllegalArgumentException.class) public void ShouldntAcceptToBuildWithNullId(){ new PageInfo(null, new Date(), "author", 123456789); } @org.junit.Test public void toStringShouldntThrowNullRef(){ PageInfo page = new PageInfo("id", null, null, null); assertNotNull(page.toString()); } }dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_PageVersion.java000066400000000000000000000016721257724672200301270ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import java.util.Date; import dw.xmlrpc.PageVersion; public class Test_PageVersion { @org.junit.Test(expected=IllegalArgumentException.class) public void ShouldntAcceptToBuildWithNullId(){ new PageVersion(null, "author", "127.0.0.1", "E", "summary", new Date(), 123456789); } @org.junit.Test public void toStringShouldntThrowNullRef(){ PageVersion page = new PageVersion("id", null, null, null, null, null, null); assertNotNull(page.toString()); } @org.junit.Test public void userAndAuthorReturnTheSameValue(){ PageVersion page = new PageVersion("id", "toto", null, null, null, null, null); assertEquals(page.user(), page.author()); } @org.junit.Test public void returnTheExpectedDate(){ Date date = new Date(); PageVersion page = new PageVersion("id", "author", "127.0.0.1", "E", "summary", new Date(), 123456789); assertEquals(date, page.lastModified()); } }dokuJClient-dokujclient-3.5.2/src/test/java/dw/xmlrpc/utest/Test_SearchResult.java000066400000000000000000000007531257724672200303100ustar00rootroot00000000000000package dw.xmlrpc.utest; import static org.junit.Assert.*; import dw.xmlrpc.SearchResult; public class Test_SearchResult { @org.junit.Test(expected=IllegalArgumentException.class) public void ShouldntAcceptToBuildWithNullId(){ new SearchResult(null, "title", 123456789, 123456789, 3, "snippet", 1); } @org.junit.Test public void toStringShouldntThrowNullRef(){ SearchResult page = new SearchResult("id", null, null, null, null, null, null); assertNotNull(page.toString()); } }dokuJClient-dokujclient-3.5.2/src/test/resources/000077500000000000000000000000001257724672200220435ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/README.md000066400000000000000000000006331257724672200233240ustar00rootroot00000000000000Running integration tests ========================= Tests will try to connect to an instance of Dokuwiki. To set up such an instance you should run the installTestEnvironment.sh script. This script is meant to be run from src/test/resources (otherwise it may not find some file it needs) You may need to run it as root since it will try to write files in your server filesystem and give ownership to its user. dokuJClient-dokujclient-3.5.2/src/test/resources/installTestEnvironment.sh000077500000000000000000000060601257724672200271370ustar00rootroot00000000000000#!/bin/bash #directory where Dokuwiki should be installed in order to be reachable at http://localhost serverFileSystemRoot=/var/www/html #Owner of the files (to make sure the instance of dokuwiki can ediable its pages) serverFileSystemOwner=www-data #Shouldn't be changed since itests try to connect to this url baseUrl=http://localhost dirNamePrefix=dokuwikiITestsForXmlRpcClient_ dwVersions="dokuwiki-2013-05-10 dokuwiki-2012-10-13 dokuwiki-2012-01-25b dokuwiki-2013-12-08 dokuwiki-2014-05-05 dokuwiki-2014-09-29a dokuwiki-2015-08-10a" installDir=tmpForInstallation relativeTestFileDir=testEnvironment mkdir -p $installDir cd $installDir function installFakeWiki { #Argument 1 is the name of the version of Dokuwiki to install #Argument 2 is optional. It can be "norpc". It asks for the setup of a particular wiki #Argument 3 is required if arg2 is provided. It overrides the destination name dwVersion=$1 if [ $# -eq 3 ]; then typeOfWiki=$2 customDestDir=$3 else unset typeOfWiki unset customDestDir fi echo "Going to install $dwVersion" pushd . >/dev/null #Avoid downloading the tarball again if we already have it if [ ! -e $dwVersion.tgz ]; then echo " Starting to download $dwVersion.tgz" wget http://download.dokuwiki.org/src/dokuwiki/$dwVersion.tgz else echo " $dwVersion.tgz found. No need to download it again." fi rm -rf $dwVersion tar -xzf $dwVersion.tgz echo " Copying files to the server" dirName=${dirNamePrefix}${dwVersion} if [ $# -eq 3 ]; then destDir=$serverFileSystemRoot/$customDestDir echo " Installing in $destDir" else destDir=$serverFileSystemRoot/$dirName fi rm -rf $destDir cp -r $dwVersion $destDir echo " Configuring the wiki" cp ../$relativeTestFileDir/conf/* $destDir/conf rm -rf $destDir/data/pages cp -r ../$relativeTestFileDir/data/* $destDir/data chown -R $serverFileSystemOwner $destDir if [ x$typeOfWiki = xnorpc ]; then echo " Using conf to not accept rpc queries" cp ../$relativeTestFileDir/conf/local.disabled_rpc.php $destDir/conf/local.php fi echo " Reseting some mtimes" touch -t201212230020.00 $destDir/data/attic/rev/start.1356218400.txt.gz touch -t201212230020.11 $destDir/data/attic/rev/start.1356218411.txt.gz touch -t201212230020.19 $destDir/data/attic/rev/start.1356218419.txt.gz touch -t201212230020.19 $destDir/data/pages/rev/start.txt touch -t201308011800.00 $destDir/data/pages/nswithanotherns/otherns/page.txt touch -t201311040647.25 $destDir/data/pages/nssearch/start.txt touch -t201308011900.00 $destDir/data/pages/nssearch/page3.txt touch -t201212242111.00 $destDir/data/media/ro_for_tests/img1.gif echo " Running the indexer" cd ../$relativeTestFileDir/data/pages for f in $(find . -name "*txt"); do f=$(echo $f | cut -d '.' -f 2 | tr / :) wget -O /dev/null -q $baseUrl/$dirName/lib/exe/indexer.php?id=$f done echo " Installed $dwVersion" popd >/dev/null } for dwVersion in $dwVersions; do installFakeWiki $dwVersion installFakeWiki $dwVersion norpc ${dirNamePrefix}${dwVersion}_noRpc done echo Done. dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/000077500000000000000000000000001257724672200252475ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/at.gif000066400000000000000000000000711257724672200263400ustar00rootroot00000000000000GIF89a !, vk%;dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/conf/000077500000000000000000000000001257724672200261745ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/conf/acl.auth.php000066400000000000000000000003111257724672200303770ustar00rootroot00000000000000# acl.auth.php # # Don't modify the lines above # # Access Control Lists # # Auto-generated by install script # Date: Sun, 16 Dec 2012 10:55:52 +0000 * @ALL 0 * norightsuser 0 * @user 8 dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/conf/local.disabled_rpc.php000066400000000000000000000010271257724672200324110ustar00rootroot00000000000000 # Don't modify the lines above # # Userfile # # Format: # # login:passwordhash:Real Name:email:groups,comma,seperated xmlrpcuser:$1$0TQWcl7p$fsl5QHQMcJ1hN4pKpQkrB0:xmlrpcuser:xml@rpc:admin,user writeruser:$1$U7Eovyk4$JO.B.1x9SWUFhklKh7516.:writeruser:wri@ter:user norightsuser:$1$2fTAmWKY$zuoiU7ibDsUpbXFEP7l130:norightsuser:no@rights:untouchables dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/conf/wordblock.conf000066400000000000000000000000161257724672200310260ustar00rootroot00000000000000forbiddenword dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/000077500000000000000000000000001257724672200261605ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/attic/000077500000000000000000000000001257724672200272645ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/attic/rev/000077500000000000000000000000001257724672200300605ustar00rootroot00000000000000start.1356218400.txt.gz000066400000000000000000000000431257724672200333670ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/attic/rev*K-*S0z start.1356218411.txt.gz000066400000000000000000000000341257724672200333710ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/attic/rev*3kstart.1356218419.txt.gz000066400000000000000000000000451257724672200334030ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/attic/rev2.JQ(K-*w: dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/media/000077500000000000000000000000001257724672200272375ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/media/ro_for_tests/000077500000000000000000000000001257724672200317475ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/media/ro_for_tests/img1.gif000066400000000000000000000001031257724672200332650ustar00rootroot00000000000000GIF89a {!, +ʁ{[xqtR;dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/000077500000000000000000000000001257724672200271065ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/_dokuwiki.changes000066400000000000000000000002131257724672200324210ustar00rootroot000000000000001356218400 127.0.0.1 C rev:start someuser created 1356218411 127.0.0.1 E rev:start someuser 1356218419 127.0.0.1 E rev:start someuser dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/_media.changes000066400000000000000000000002031257724672200316510ustar00rootroot000000000000001356383460 127.0.0.1 C ro_for_tests:img1.gif fifi updated my file 1356383462 127.0.0.1 D ro_for_tests:img2.gif riri some comment dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/rev/000077500000000000000000000000001257724672200277025ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/rev/start.changes000066400000000000000000000002131257724672200323650ustar00rootroot000000000000001356218400 127.0.0.1 C rev:start riri created 1356218411 127.0.0.1 E rev:start fifi edit 1 1356218419 127.0.0.1 E rev:start lulu edit 2 dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/rev/start.indexed000066400000000000000000000000011257724672200323700ustar00rootroot000000000000005dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/meta/rev/start.meta000066400000000000000000000013721257724672200317120ustar00rootroot00000000000000a:2:{s:7:"current";a:7:{s:4:"date";a:2:{s:7:"created";i:1356218400;s:8:"modified";i:1356218419;}s:11:"last_change";a:7:{s:4:"date";i:1356218419;s:2:"ip";s:9:"127.0.0.1";s:4:"type";s:1:"E";s:2:"id";s:9:"rev:start";s:4:"user";N;s:3:"sum";s:0:"";s:5:"extra";s:0:"";}s:4:"user";s:0:"";s:7:"creator";s:0:"";s:8:"internal";a:2:{s:5:"cache";b:1;s:3:"toc";b:1;}s:11:"description";a:1:{s:8:"abstract";s:11:"3rd version";}s:8:"relation";a:1:{s:10:"firstimage";s:0:"";}}s:10:"persistent";a:4:{s:4:"date";a:2:{s:7:"created";i:1356218400;s:8:"modified";i:1356218419;}s:11:"last_change";a:7:{s:4:"date";i:1356218419;s:2:"ip";s:9:"127.0.0.1";s:4:"type";s:1:"E";s:2:"id";s:9:"rev:start";s:4:"user";N;s:3:"sum";s:0:"";s:5:"extra";s:0:"";}s:4:"user";s:0:"";s:7:"creator";s:0:"";}}dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/000077500000000000000000000000001257724672200272575ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/links/000077500000000000000000000000001257724672200303775ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/links/start.txt000066400000000000000000000001411257724672200322710ustar00rootroot00000000000000 * first link: [[http://dokuwiki.org]] * other one: http://github.com/gturri * [[ns1:dummy]]dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/ns1/000077500000000000000000000000001257724672200277605ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/ns1/dummy.txt000077500000000000000000000000251257724672200316540ustar00rootroot00000000000000dummy page inside ns1dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/ns1/start.txt000077500000000000000000000000141257724672200316540ustar00rootroot00000000000000Index of ns1dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nssearch/000077500000000000000000000000001257724672200310655ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nssearch/page1.txt000066400000000000000000000001601257724672200326200ustar00rootroot00000000000000Pellentesque fringilla, lectus in faucibus venenatis, ante purus imperdiet elit, at ornare augue lectus nec dui.dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nssearch/page2.txt000066400000000000000000000001771257724672200326310ustar00rootroot00000000000000Sed dui urna, posuere non tempor ac, condimentum nec ante. Vivamus risus justo, euismod eu ultricies dictum, accumsan ac liberodokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nssearch/page3.txt000066400000000000000000000003051257724672200326230ustar00rootroot00000000000000======Page 3 title====== Amet in hac habitasse platea dictumst. Phasellus eros purus, consectetur a pretium id, venenatis a est. Aenean magna ipsum, condimentum at pretium ut, porta sit amet sem. dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nssearch/start.txt000066400000000000000000000000701257724672200327600ustar00rootroot00000000000000Lorem ipsum dolor sit amet, consectetur adipiscing elit.dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nswithanotherns/000077500000000000000000000000001257724672200325155ustar00rootroot00000000000000dummy.txt000077500000000000000000000000051257724672200343300ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nswithanothernsdummydokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nswithanotherns/otherns/000077500000000000000000000000001257724672200341775ustar00rootroot00000000000000page.txt000077500000000000000000000000041257724672200355720ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nswithanotherns/othernspagestart.txt000077500000000000000000000000051257724672200343320ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/nswithanothernsstartdokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/rev/000077500000000000000000000000001257724672200300535ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/rev/start.txt000066400000000000000000000000131257724672200317430ustar00rootroot000000000000003rd versiondokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/singlepage/000077500000000000000000000000001257724672200313755ustar00rootroot00000000000000dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/data/pages/singlepage/start.txt000066400000000000000000000000261257724672200332710ustar00rootroot00000000000000text after (time test)dokuJClient-dokujclient-3.5.2/src/test/resources/testEnvironment/list-plus.gif000066400000000000000000000001031257724672200276640ustar00rootroot00000000000000GIF89a {!, +ʁ{[xqtR;