Giter VIP home page Giter VIP logo

dokujclient's Introduction

This repo is not maintained anymore. (You can get in touch with me if you would like to take ownership of it).

Since the 2022 release of Dokuwiki (perhaps even the 2020 release, I don't remember exactly) the handling of xml-rpc by dokuwiki seems a bit flaky. Subsequently testing dokujclient became pretty tedious (and it's also not clear how many people are still using this xml-rpc interface). That's why I'm reallocating my time to other projects.


Dokujclient is both a command line tool to interact with instances of Dokwiki, and a Java library for Dokuwiki xmlrpc interface which is also compatible with Android.

Currently tested with:

  • Hogfather (dokuwiki-2020-07-29)
  • Greebo (dokuwiki-2018-04-22)
  • Frusterick Manners (dokuwiki-2017-02-19)
  • Elenor of Tsort (dokuwiki-2016-06-26)
  • Detritus (dokuwiki-2015-08-10)
  • Hrun (dokuwiki-2014-09-29)
  • Ponder Stibbons (dokuwiki-2014-05-05)
  • Binky (dokuwiki-2013-12-08)

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) <user>] --url <url> [(-p|--password) <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] <attachmentId> <localFile>

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

It may be installed from the packages on several Linux distributions:

sudo apt-get install dokujclient

If it isn't available in the packages of your plateform you may:

  • Download the binaries.

  • 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 requests 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:

<dependency>
    <groupId>fr.turri</groupId>
    <artifactId>dokujclient</artifactId>
    <version>3.9.1</version>
</dependency>

Binaries may alse be downloaded 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 you should:

# Install Maven
sudo apt-get install maven

# Set the M2_REPO classpath variable
mvn -Declipse.workspace=<path-to-eclipse-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 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 [email protected]

Charityware

Dokujclient is a personal open source project started in 2012. I have put hundreds of hours to maintain and enhance it.

It is provided as a charityware. It can be downloaded and installed at no charge. If you found it useful and would like to support its development, you may make a donation to a non-profit charitable organization.

To who

Any association acting for the environment

How

Forwarding me (address available e.g. in the git log) the confirmation email you send or receive will ensure your kind gesture will motivate me to continue developing this software.

I can't give money

Making sure you have a positive impact would already be awesome:

  • Volunteer to an NGO near you. Give some of your time
  • Ride you bike instead of taking your car
  • Buy local organic food
  • Use a reusable bag and stop using plastic straws
  • Plant trees
  • Take only what you need, not what you can

dokujclient's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar eduardomozart avatar gturri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dokujclient's Issues

[Request] Login with result

I would like to see a funtion to determine if a client is actually logged in after callin login. I've managed to do that with a raw query already, but I don't understand why the client doesn't support this.

Getting de.timroes.axmlrpc.XMLRPCServerException: parse error. not well formed exception.

I getting following exception when I am trying to upload page to DokuWiki.
at java.lang.Thread.run(Thread.java:745) Caused by: dw.xmlrpc.exception.DokuUnknownException: de.timroes.axmlrpc.XMLRPCServerException: parse error. not well formed [-32700] at dw.xmlrpc.ExceptionConverter.Convert(ExceptionConverter.java:105) at dw.xmlrpc.CoreClient.genericQuery(CoreClient.java:49) at dw.xmlrpc.DokuJClient.genericQuery(DokuJClient.java:702) at dw.xmlrpc.DokuJClient.putPage(DokuJClient.java:500) at dw.xmlrpc.DokuJClient.putPage(DokuJClient.java:472) at com.paramatrix.wikimigration.apis.doku.DokuService.addPage(DokuService.java:34) ... 6 more Caused by: de.timroes.axmlrpc.XMLRPCServerException: parse error. not well formed [-32700] at de.timroes.axmlrpc.ResponseParser.parse(ResponseParser.java:78) at de.timroes.axmlrpc.XMLRPCClient$Caller.call(XMLRPCClient.java:744) at de.timroes.axmlrpc.XMLRPCClient.call(XMLRPCClient.java:461) at dw.xmlrpc.CoreClient.genericQuery(CoreClient.java:43) ... 10 more

Content of page I uploading is in below mentioned file.
2.dw.zip

test with Hrun

  • Ensure it works with the new DW version: Hrun
  • Fix if it doesn't
  • Adapt the compatibility informations

ExceptionConverter: Missing "message.contains(..)" checks lead to NullPointerException

There's (at least) one missing block if(message.contains(...)) for The requested page does not exist.

atm this results in a nasty NullPointerException a few lines further down, where e.getCause().getClass() is checked, because e.getCause() is null. Please add e.getClause() != null &&.

I'm using your latest code (from master) and DokuWiki Hrun.

List of other "missing" exception messages I found when I searched DokuWiki for RemoteExceptions:
"Empty page ID"
"You are not allowed to edit this page"
"Filename not given"
"You don't have permissions to upload files"
plus: a bunch of localized error messages from dokuwiki's media.php->media_save(..)

let use 'minor' and 'sum' while editing a page

With methods putPage and appendPage it should be possible to use the 'sum' and 'minor' options.

From the public interface point of view we could either accept a map of generic options, or add two booleans.

putPage issue when data plugin involved

Hi,
I'm using docujclient Version 3.8.0 in conjunction with my dokuwiki Release 2014-09-29d Hrun instance.
I've written a Windows script that uses dokujclient commandline putPage to insert new pages into the wiki.

There are 2 cases of content. With and without following sections containig blocks like this:

---- datatemplateentry beleg ----
template : xx:tpl:beleg
nummer : b16232
objekt : ob:xx
beleg-typ : DTYP:RE
beleg-dt : 2016-12-27
beleg-jahr : 2016
kategorie :
partner : PA:HW:diverse
betrag : 27.25
zahlbetrag : 27.25
lohnanteil :
zahl-dt : 2016-12-27
steuer : X

When I put pages without such blocks everything works. When I put pages containing such blocks I get an error from the DokuJClient commandline.

But when I copy the same text into the dokuwiki editor and save the page all works as expected.

So my question is, what is wrong doing this the dokuJClient xmlrpc way and how can I get this working.

Help is apreciated

Regards Joachim

Add a hint to configuration in javadoc of DokuJClient

It would be nice to have a hint in DokuJClient how to configure (a link to DokuJClientConfig would be good and then adding to documentation). I couldn't find out how to pass options to de.timroes.axmlrpc.XMLRPCClient (e.g. FLAGS_FORWARD). Maybe it's impossible, anyway - a short statement is needed.

client.getAllPages() fails with XMLRPCException but CLI works

When I try to getAllPages or getRecentChanges from my wiki I get the error de.timroes.axmlrpc.XMLRPCException: Error getting result from server. However client.getTitle() and client.getPageHTML("start") work fine and so does the CLI-command:

./dokujclient --user ... --password ... --url http://127.0.0.1/~michael/dokuwiki/lib/exe/xmlrpc.php getAllPages

Here is my java-code:

private static final int SECONDS_IN_DAY = 24 * 60 * 60;

public Map getWikiData() {
        Map contextMap = new HashMap();

        // Set access data, will later be done via config
        String url = "http://127.0.0.1/~michael/dokuwiki/lib/exe/xmlrpc.php";
        String api_user = "...";
        String api_pwd = "...";

        Date currentDate  = new Date();
        Integer recentDatePeriod = (int)(currentDate.getTime() / 1000 - 30 * SECONDS_IN_DAY);


        // initialise relevant variables
        String wikiTitle = "request failed!";
        List<PageChange> recentChanges = Collections.emptyList();
        List<Page> allPages = Collections.emptyList();

        // try to get data from the server
        try {
            DokuJClient client = new DokuJClient(url, api_user, api_pwd);
            wikiTitle = client.getTitle();

            try {
                allPages = client.getAllPages();
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }

            try {
                recentChanges = client.getRecentChanges(recentDatePeriod);
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

        // store data
        contextMap.put("wikiTitle", wikiTitle);
        contextMap.put("recentChanges", recentChanges.toString());
        contextMap.put("allPages", allPages.toString());

        return contextMap;
    }

I'm using the current DokuWiki master-Branch (i.e. Detritus) and your maven repo for the java sources and the link from the README for the CLI-binaries.

Any ideas?

Truncated response in aXMLRPC's ResponseParser

When I try to connect to a dokuwiki for which I have a working account when I reproduce the example on https://www.dokuwiki.org/devel:xmlrpc I get a XMLRPCException due to truncated response. This happens not in dokuJClient, but aXMLRPC's ResponseParser, but it might be related to wrong usage. The response is just cut at some point. Example exception stack:

[Fatal Error] :1:1: Content ist nicht zulässig in Prolog.
Mär 26, 2014 12:05:33 AM dw.xmlrpc.CoreClient genericQuery
INFORMATION: Caught exception when executing action dokuwiki.login: de.timroes.axmlrpc.XMLRPCException: Error getting result from server.
Exception in thread "main" dw.xmlrpc.exception.DokuUnknownException: de.timroes.axmlrpc.XMLRPCException: Error getting result from server.
at dw.xmlrpc.ExceptionConverter.Convert(ExceptionConverter.java:74)
at dw.xmlrpc.CoreClient.genericQuery(CoreClient.java:45)
at dw.xmlrpc.DokuJClient.genericQuery(DokuJClient.java:625)
at dw.xmlrpc.DokuJClient.login(DokuJClient.java:108)
at dw.xmlrpc.DokuJClient.loginWithRetry(DokuJClient.java:100)
at dw.xmlrpc.DokuJClient.(DokuJClient.java:54)
at sciberlin.dokuwikixmlrpc.SCIBerlinDokuwikiXMLRPC.main(SCIBerlinDokuwikiXMLRPC.java:28)
Caused by: de.timroes.axmlrpc.XMLRPCException: Error getting result from server.
at de.timroes.axmlrpc.ResponseParser.parse(ResponseParser.java:73)
at de.timroes.axmlrpc.XMLRPCClient$Caller.call(XMLRPCClient.java:707)
at de.timroes.axmlrpc.XMLRPCClient.call(XMLRPCClient.java:424)
at dw.xmlrpc.CoreClient.genericQuery(CoreClient.java:39)
... 5 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content ist nicht zulässig in Prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:348)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at de.timroes.axmlrpc.ResponseParser.parse(ResponseParser.java:37)
... 8 more

I reproduced this with git tag 3.0.0, git commit 8f3d91b (current HEAD) and git tag 2.0.0

getPageInfo returns an incorrect modification date

Hi Guillaume,

I had an issue regarding timestamp comparison between the modification timestamp from getPageInfo and another timestamp. The one to blame is not really the DokuJClient.. but here's what I found out:

In its RemoteAPICore.php->pageInfo function DokuWiki uses a date to string conversion which finally calls gmdate to extract year, month, day, hour, minute and second; thus, the result is in GMT.

The XMLRPC library you're using (de.timroes aXMLRPC) seems to parse the timestamp with the pattern yyyyMMdd'T'HH:mm:ss (see DateTimeSerializer), without a timezone.
That's fine, as there's no timezone information in the answer from DokuWiki. But without a timezone the resulting date is considered to be in the client's timezone.

So it's likely more an issue for the XMLRPC library... e.g. to set a custom DateTimeSerializer, a default timezone for the DateTimeSerializer, and/or a flag to include timezone parsing.

I don't know if you want to try to do anything about that issue.. at least it is documented now ;)

My workaround looks like this: new SimpleDateFormat("yyyyMMddHHmmssz").parse(new SimpleDateFormat("yyyyMMddHHmmss").format(modified) + "GMT").

  1. date -> string without timezone
  2. add timezone information (we know DokuWiki's output is in GMT)
  3. parse again, this time including timezone information

Another workaround might be to tweak DokuWiki to output the modification date in the desired timezone.

In an ideal world, DokuWiki's date transformation would include timezone information which in turn would be parsed by the XMLRPC library's DateTimeSerializer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.