Changes for page XML-RPC Java Examples
Last modified by Thomas Mortagne on 2023/10/10 14:31
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Tags
-
... ... @@ -1,1 +1,1 @@ 1 -xmlrpc|java|example|page|space|authentication|create|delete |update1 +xmlrpc|java|example|page|space|authentication|create|delete - Content
-
... ... @@ -88,7 +88,47 @@ 88 88 } 89 89 {{/code}} 90 90 91 += Search documents = 91 91 93 +{{code language="java"}} 94 +import java.net.MalformedURLException; 95 +import java.util.List; 96 +import org.apache.xmlrpc.XmlRpcException; 97 +import org.codehaus.swizzle.confluence.SearchResult; 98 +import org.xwiki.xmlrpc.XWikiXmlRpcClient; 99 + 100 +public class XWikiXMLRPCSearch { 101 + 102 + public static void main(String[] args) throws MalformedURLException, XmlRpcException { 103 + //Replace the url with your xwiki server address 104 + String url = "http://localhost:8080/xwiki/xmlrpc/confluence"; 105 + 106 + //Replace user & pass with desired xwiki username & password 107 + String user = "Admin"; 108 + String pass = "admin"; 109 + 110 + //Perform Login & Authentication using above url address 111 + XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(url); 112 + rpc.login(user, pass); 113 + 114 + //Replace string to search in the rpc.search() method below 115 + //Specify the number of results to be returned in rpc.search() as 5 116 + List<SearchResult> result = rpc.search("text I want to search", 5); 117 + 118 + 119 + //Print obtained results to console if result is not empty 120 + if (result.size() != 0) { 121 + for (int i = 0; i < result.size(); i++) { 122 + System.out.println(result.get(i).getTitle()); 123 + } 124 + } //Print standard message if result is empty 125 + else { 126 + System.out.println("No Results To Display"); 127 + } 128 + } 129 +} 130 +{{/code}} 131 + 92 92 = Space: Get A List Of Spaces = 93 93 94 94 Now, that we can log in and log out, let's move to finding out what's inside your wiki. How about a list of all the spaces inside the wiki. Compare the above two examples and you will see the new import that we added viz. the SpaceSummary class.