public class WikiBot
extends java.lang.Object
Constructor and Description |
---|
WikiBot(java.lang.String urlApi,
java.lang.String userName,
java.lang.String userPassword)
Basic class constructor
|
WikiBot(java.lang.String urlApi,
java.lang.String userName,
java.lang.String userPassword,
int sleeper)
Class constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
convertToWikiTitle(java.lang.String title)
Convert a title in wiki title format
|
protected int |
createOrEditePage(java.util.List<WikiPage> pages)
Create or edit a
List of WikiPage |
protected org.json.JSONObject |
doPostMultiBoundary(java.lang.String url,
java.util.Map<java.lang.String,java.lang.Object> params,
java.lang.String ref)
Submit a POST request with different content types
|
protected org.json.JSONObject |
doPostMultipart(java.lang.String url,
java.util.Map<java.lang.String,java.lang.Object> params,
java.lang.String ref) |
boolean |
edit(java.lang.String title,
java.lang.String text,
java.lang.String summary)
Import a page (create or edit it)
|
int |
getSleeper()
Set the time between two requests
|
boolean |
importPage(WikiPage p)
Import a WikiPage in the MediaWiki
|
boolean |
importPages(java.lang.String title,
java.io.File xml,
java.lang.String summary) |
boolean |
isLog() |
protected boolean |
login()
Login the user as bot
|
protected boolean |
logout()
Logout the user
|
void |
setLog(boolean isLog) |
void |
setSignature(java.lang.String signature)
Set bot signature
|
void |
setSleeper(int sleeper) |
boolean |
uploadAFile(java.io.File file,
java.lang.String filename,
java.lang.String text,
java.lang.String comment)
Method use to upload a file on a mediawiki server
|
protected int |
uploadAFile(java.util.List<WikiFile> files)
Upload a
List of WikiFile |
boolean |
uploadAFile(WikiFile f)
Upload a wikifile in the MediaWiki
|
public WikiBot(java.lang.String urlApi, java.lang.String userName, java.lang.String userPassword)
urlApi
- the URL to the API of the target mediawikiuserName
- the login of the usernameuserPassword
- his passwordpublic WikiBot(java.lang.String urlApi, java.lang.String userName, java.lang.String userPassword, int sleeper)
urlApi
- the URL to the API of the target mediawikiuserName
- the login of the usernameuserPassword
- his passwordsleeper
- the time in ms between two requestsprotected boolean login() throws java.lang.Exception
java.lang.Exception
protected boolean logout()
protected int createOrEditePage(java.util.List<WikiPage> pages) throws java.lang.Exception
List
of WikiPage
pages
- the list of pagesjava.lang.Exception
protected int uploadAFile(java.util.List<WikiFile> files) throws javax.security.auth.login.FailedLoginException
List
of WikiFile
files
- the list of filesjavax.security.auth.login.FailedLoginException
public int getSleeper()
public void setSleeper(int sleeper)
sleeper
- the sleeper to setpublic boolean isLog()
public void setLog(boolean isLog)
isLog
- the isLog to setpublic java.lang.String convertToWikiTitle(java.lang.String title)
title
- the raw titlepublic boolean edit(java.lang.String title, java.lang.String text, java.lang.String summary) throws java.io.IOException, javax.security.auth.login.LoginException
title
- text
- summary
- java.io.IOException
javax.security.auth.login.LoginException
public boolean uploadAFile(java.io.File file, java.lang.String filename, java.lang.String text, java.lang.String comment) throws java.io.IOException, javax.security.auth.login.LoginException
file
- the filefilename
- his remote nametext
- the text to associatecomment
- the comment to associatejava.io.IOException
javax.security.auth.login.LoginException
protected org.json.JSONObject doPostMultiBoundary(java.lang.String url, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String ref) throws java.io.IOException, org.json.JSONException
url
- the tqrget URLparams
- the parameters (UTF-8 text or byte[], send in POST)ref
- the reforg.json.JSONException
java.io.IOException
protected org.json.JSONObject doPostMultipart(java.lang.String url, java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String ref) throws java.io.IOException, org.json.JSONException
java.io.IOException
org.json.JSONException
public void setSignature(java.lang.String signature)
signature
- public boolean uploadAFile(WikiFile f) throws javax.security.auth.login.LoginException, java.io.IOException
f
- the WikiFilejava.io.IOException
javax.security.auth.login.LoginException
public boolean importPage(WikiPage p) throws javax.security.auth.login.LoginException, java.io.IOException
p
- javax.security.auth.login.LoginException
java.io.IOException
public boolean importPages(java.lang.String title, java.io.File xml, java.lang.String summary) throws java.io.IOException, javax.security.auth.login.LoginException
java.io.IOException
javax.security.auth.login.LoginException
Copyright © 2007-2020 EDIT. All Rights Reserved.