String spaceKey,
PageForXmlRpc page) throws IOException, XmlRpcException {
// get a handle to the XMLRPC client obj, this method should be called
// to manage the connection and make sure it's live even though there
// is a class var. This is actually called here for coding clarity.
XmlRpcClient client = getXMLRPCClient(confSettings);
// make sure loginToken is up to date
String loginToken = getLoginToken(confSettings);
Vector paramsVector = new Vector();
// add the login token
paramsVector.add(loginToken);
// add the page ---------------------
page.setSpace(spaceKey);
paramsVector.add(page.getPageParams());
PageForXmlRpc resultPage = new PageForXmlRpc();
// write the page ---------------------
try {
resultPage.setPageParams(client.execute(CONFLUENCE_REMOTE_API_VERSION + ".storePage", paramsVector));
return resultPage;
} catch (XmlRpcException e) {
// page may already exist - have to get more info on page
log.debug("page added may already exist");
}
// page may already exist, get more info on page ---------------------
try {
resultPage = populatePageXmlRpcData(confSettings, spaceKey, page.getTitle());
} catch (XmlRpcException e) {
if (isConfluence4OrMore(confSettings)) {
resultPage = getPageSummary(confSettings, spaceKey, page.getTitle());
}
}
// write the page ---------------------
loginToken = getLoginToken(confSettings);
paramsVector = new Vector();
// add the login token
paramsVector.add(loginToken);
page.setSpace(spaceKey);
resultPage.setContent(page.getContent());
paramsVector.add(resultPage.getPageParams());
// write the page
resultPage.setPageParams(client.execute(CONFLUENCE_REMOTE_API_VERSION + ".storePage", paramsVector));
return resultPage;
}