Changes for page XML-RPC Java Examples
Last modified by Thomas Mortagne on 2023/10/10 14:31
From version 2.2
edited by dilipkumarj
on 2010/01/30 16:38
on 2010/01/30 16:38
Change comment:
Moved Search Documents to Features>>XMLRPCJavaExamples2
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -431,5 +431,61 @@ 431 431 } 432 432 } 433 433 } 434 +{{/code}} 434 434 436 + 437 + 438 += Page: Remove A Page = 439 + 440 +Removal of Pages is straight forward. You are required to know the fully qualified name of the Page i.e. SpaceName.PageName (in our example, this would be "demo code.New Page"). We test the safe deletion of the Page using a boolean variable. The rpc.removePage() method returns true if the Page was successfully removed from the wiki. 441 + 442 +{{warning}} 443 +You would need to have the deletion rights assigned to the user credentials you are passing to the rpc.login() method 444 +{{/warning}} 445 +{{warning}} 446 +rpc.removePage() method does not completely delete a Page in ordinary circumstances. If you have a recycle bin option enabled (by default, it is enabled for XWiki), then the "removed/deleted Page" is stored in the recycle bin from where it will cleaned out as per the settings for recycle bin in the xwiki.cfg file of your XWiki instance. 447 +{{/warning}} 448 + 449 +{{code language="java"}} 450 + 451 + 452 +import java.net.MalformedURLException; 453 +import org.apache.xmlrpc.XmlRpcException; 454 +import org.xwiki.xmlrpc.XWikiXmlRpcClient; 455 + 456 + 457 +public class DeletePage { 458 + public static void main(String[] args) throws MalformedURLException, XmlRpcException { 459 + 460 + //URL of the xwiki instance 461 + String url = "http://localhost:8080/xwiki/xmlrpc/confluence"; 462 + 463 + //Replace user & pass with desired xwiki username & password 464 + String user = "Admin"; 465 + String pass = "admin"; 466 + 467 + 468 + XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(url); 469 + try { 470 + 471 + //Perform Login & Authentication 472 + rpc.login(user, pass); 473 + 474 + //Delete Page called "New Page" from Space called "demo code" 475 + //Test deletion using a Boolean variable 476 + Boolean b=rpc.removePage("demo code.New Page"); 477 + 478 + //Should print "true" if deletion of page was successful 479 + System.out.println(b); 480 + 481 + 482 + } catch (XmlRpcException e) { 483 + System.out.println("invalid username/password was specified or communication problem or "); 484 + System.out.println(e); 485 + } finally { 486 + rpc.logout(); 487 + } 488 + } 489 +} 490 + 435 435 {{/code}}