我使用以下代码在Confluence 4.3上创建页面:
public void publish() throws IOException {
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date today = Calendar.getInstance().getTime();
XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(CONFLUENCE_URI);
try {
rpc.login(USER_NAME, PASSWORD);
Page page = new Page();
page.setSpace(owrConf.getString(ConfigKeys.CONFLUENCE_SPACE));
page.setTitle(owrConf.getString(ConfigKeys.CONFLUENCE_PAGE_TITLE) + "_" + df.format(today));
List<String> lines = Files.readAllLines(Paths.get("summary.markup"), Charset.defaultCharset());
StringBuilder b = new StringBuilder();
for(int i=0; i < lines.size(); i++) {
b.append(String.format("%s%s", lines.get(i), "\r\n"));
}
page.setContent(b.toString());
page.setParentId(owrConf.getString(ConfigKeys.CONFLUENCE_PAGE_ID));
rpc.storePage(page);
} catch (XmlRpcException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
这很好用,但我只是想知道我是否可以更新现有页面而不是总是创建一个新页面。我无法找到Confluence 4.3的API信息来执行此操作。
答案 0 :(得分:1)
看看这篇用Python和XMLRPC更新页面的帖子。
How can I create a new page to confluence with Python
您也可以查看此页面 https://answers.atlassian.com/questions/316106/how-to-update-a-page-in-confluence-by-java
但实际上在2015年你应该使用Confluence REST API来做这种事情。使用一些JSON数据对此网址发布简单的帖子并更新您的网页
https://docs.atlassian.com/atlassian-confluence/REST/latest/#d3e941
更新
@Configuration
@EnableAutoConfiguration
public class TestSpringBootApplication
{
public static void main(String... args)
{
(new SpringApplication("META-INF/spring/propertiesContext.xml",
"META-INF/spring/concurrent-route-context.xml")).run(args);
}
}
从此页面获取此信息:http://extensions.xwiki.org/xwiki/bin/view/Extension/XML-RPC+Integration+Java+Examples