gpt4 book ai didi

ruby - 如何使用远程 API 将 Confluence "Space"导出为 PDF

转载 作者:数据小太阳 更新时间:2023-10-29 07:08:11 24 4
gpt4 key购买 nike

如何将 Confluence 的“空间”导出为 pdf 文件?看起来 Confluence 5.0 可能仍然支持使用 XML-RPC API。不过,我找不到调用什么的示例。

https://developer.atlassian.com/display/CONFDEV/Remote+API+Specification+for+PDF+Export#RemoteAPISpecificationforPDFExport-XML-RPCInformation

该链接表示调用应以 pdfexport 为前缀,但没有列出任何调用或给出示例。

最佳答案

这可以使用 Bob Swift 的 SOAP 库('org.swift.common:confluence-soap:5.4.1')。我在 gradle 插件中使用它,因此您需要更改一些内容

void exportSpaceAsPdf(spaceKey, File outputFile) {
// Setup Pdf Export Service
PdfExportRpcServiceLocator serviceLocator = new PdfExportRpcServiceLocator()
serviceLocator.setpdfexportEndpointAddress("${url}/rpc/soap-axis/pdfexport")
serviceLocator.setMaintainSession(true)
def pdfService = serviceLocator.getpdfexport()

// Login
def token = pdfService.login(user, password)

// Perform Export
def pdfUrl = pdfService.exportSpace(token, spaceKey)

// Download Pdf
HttpClient client = new DefaultHttpClient();
HttpGet httpget = new HttpGet(pdfUrl)
httpget.addHeader(
BasicScheme.authenticate(
new UsernamePasswordCredentials(user,password),"UTF-8", false))
HttpResponse response = client.execute(httpget)
HttpEntity entity = response.getEntity()

if (entity != null) {
InputStream inputStream = entity.getContent()
FileOutputStream fos = new FileOutputStream(outputFile)
int inByte
while ((inByte = inputStream.read()) != -1)
fos.write(inByte)
inputStream.close()
fos.close()
} else {
throw new GradleException("""Cannot Export Space to PDF:
Space: ${spaceKey}
Dest: ${outputFile.absolutePath}
URL: ${pdfUrl}
Status: ${response.getStatusLine()}
""")
}

}

关于ruby - 如何使用远程 API 将 Confluence "Space"导出为 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21487525/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com