Thinking about it, I'm not sure why I felt XML-RPC
was necessary. :)
Here's a simpler example that does it all over straight http get/post.
Requires the apache commons httpclient lib, which requires commons
logging and commons codec.
public class XWikiPoster {
//----( Configuration [change me!] )----
static final String SERVER = "http://my.xwiki.com";
static final String USERNAME = "myName"; // exactly how you'd
enter
static final String PASSWORD = "myPass"; // them in the web login
form
static final String SPACE = "Sandbox";
static final String DYNAMIC = "Dynamic";
static final String STATIC = "Static";
//--------------------------------------
On 12/10/06, Robin Fernandes <rewbs.soal@gmail.com> wrote:
> Hi,
>
> There's probably several ways to do this... the first one that comes
> to my mind is to write an XML-RPC client to grab the rendered content
> from one page and save it back into another. Then set up a cron job
to
> kick off your XML-RPC client periodically. A simple implementation
of
> the XML-RPC client is below.
>
> Alternatively you could write the code to do the copy in a groovy
> script in another XWiki document and hit it periodically.
>
> ---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
>
> package com.ibm.robinf.xwikixmlrpcclient;
>
> import java.io.IOException;
> import java.net.MalformedURLException;
> import java.util.Hashtable;
> import java.util.Vector;
>
> import org.apache.xmlrpc.XmlRpcClient;
> import org.apache.xmlrpc.XmlRpcException;
>
> /**
> * @author Robin
> */
> public class XWikiRPCTest {
> //----( Configuration [change me!] )----
> protected final static String XMLRPC_SERVER_URL
=
> "http://mywiki.blah.com/xwiki/bin/xmlrpc/confluence";
> protected final static String DYNAMIC
= "Play.Dynamic";
> protected final static String STATIC =
"Play.Static";
> protected final static String WIKI_NAME
= "robin_fernandesatukibmcom";
> protected final static String PASSWORD
= "WXYZ";
> //--------------------------------------
>
> protected XmlRpcClient client;
>
> public XWikiRPCTest() throws MalformedURLException
{
> client = new
XmlRpcClient(XMLRPC_SERVER_URL);
> }
>
> public static void main(String[] args)
throws XmlRpcException, IOException {
> XWikiRPCTest
myRPCTest = new XWikiRPCTest();
> String token
= myRPCTest.login();
> String renderedContent
= myRPCTest.getRenderedContent(DYNAMIC, token);
> Hashtable<String,
String> staticPage = myRPCTest.getPage(STATIC, token);
> staticPage.put("content",
renderedContent);
> myRPCTest.putPage(staticPage,
token);
> myRPCTest.logout(token);
> }
>
> private String getRenderedContent(String
pageName, String token)
> throws XmlRpcException, IOException {
> Hashtable<String,
String> dynamicPage = getPage(DYNAMIC, token);
> String rawContent
= dynamicPage.get("content");
>
> Vector<String>
params = new Vector<String>(4);
> params.add(token);
> params.add("Play");
> params.add(pageName);
> params.add(rawContent);
>
> String renderedContent
= (String)
> client.execute("confluence1.renderContent", params);
> return renderedContent;
> }
>
> protected String login() throws XmlRpcException,
IOException {
> String loginToken;
> Vector<String>
loginParams = new Vector<String>(2);
> loginParams.add(WIKI_NAME);
> loginParams.add(PASSWORD);
> loginToken
= (String) client.execute ("confluence1.login", loginParams);
> System.out.println("Login:
" + loginToken);
> return loginToken;
> }
>
> protected void logout(String loginToken)
throws XmlRpcException, IOException {
> Vector<String>
logoutParams = new Vector<String>(1);
> logoutParams.add(loginToken);
> System.out.println("Logout:
" + client.execute
> ("confluence1.logout", logoutParams));
> }
>
> private Hashtable<String, String>
getPage(String pageName, String
> token) throws XmlRpcException, IOException {
> Vector<String> params = new Vector<String>();
> params.add(token);
> params.add(pageName);
> Hashtable<String, String> page =
(Hashtable<String, String>)
> client.execute("confluence1.getPage", params);
> return page;
> }
>
> private void putPage(Hashtable page, String
token) throws
> XmlRpcException, IOException {
> Vector<Object> params = new Vector<Object>();
> params.add(token);
> params.add(page);
> client.execute ("confluence1.storePage",
params);
> }
>
> }
> ---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
>
> Cheers,
> Robin
>
>
> On 12/10/06, fanuzzi@us.ibm.com <fanuzzi@us.ibm.com> wrote:
> > All,
> > Here is what I am wanting to do. I have a page that
generates some dynamic data via a plug-in and every so often I was to "snap-shot"
it to a static page. Mean, take the dynamic page data and create
a static xwiki page from it.
> >
> > 1) Is it possible to do?
> > 2) If so, how do I do it.
> >
> > Thanks,
> >
> > Tony Nuzzi
> >
> >
> >
> >
> > --
> > You receive this message as a subscriber of the xwiki-dev@objectweb.org
mailing list.
> > To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
> > For general help: mailto:sympa@objectweb.org?subject=help
> > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
> >
> >
> >
>
--
You receive this message as a subscriber of the xwiki-dev@objectweb.org
mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws