問題を解決しました。 Confluence PageテンプレートはStorage Formatで記述され、クライアントに返される前に内部的にConfluenceでレンダリングされます。テンプレート内の変数を宣言し、JavaまたはJavascriptのテンプレートコンテキストにエントリを追加してデータをフィードする方法があります。例えば
は、JIRAチャートマクロは、以下のテンプレート単純template.xmlに挿入されている:
<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">Your Company JIRA</ac:parameter>
<ac:parameter ac:name="jqlQuery"><at:var at:name="vJql" /></ac:parameter<name />
<ac:parameter ac:name="count">true</ac:parameter>
<ac:parameter ac:name="serverId"><at:var at:name="vServerId" /></ac:parameter>
</ac:structured-macro>
つVARS vJql
とvServerId
構文<at:var at:name="varName"/>
を使用して宣言されます。これらの変数は、クラスcom.atlassian.confluence.plugins.createcontent.api.contextproviders.AbstractBlueprintContextProvider
を拡張するクラスによって提供されるテンプレートコンテキストでアクセスできます。以下のためのエントリを含むコンテキストを返すことによってVARSを送り、クラス内
<content-template key="simple-template"
template-title-key="delivery.blueprint.template.title" i18n-name-key="new.template.blueprint.name">
<resource name="template" type="download" location="/templates/simple-template.xml" />
<context-provider class="com.company.atlassian.plugins.confluence.SimpleTemplateContextProvider" />
</content-template>
:テンプレートとコンテキスト・プロバイダを結合するためには、素子context-provider
を添加することにより、アトラシアン-plugin.xmlのテンプレート宣言を設定への必要バール:
private final String VAR_PROJECT_KEY = "jira-project";
private final String VAR_VERSION = "jira-fix-version";
private final String VAR_JQL = "vJql";
private final String VAR_SERVER_ID = "vServerId";
@Override
protected BlueprintContext updateBlueprintContext(BlueprintContext context) {
try {
String projectKey = (String) context.get(VAR_PROJECT_KEY);
String version = (String) context.get(VAR_VERSION);
String jql = "project = \'" + projectKey + "\' AND fixVersion = " + version;
String serverId = ResourceBundle.getBundle("simple-template-example").getString("jira.serverid");
context.put(VAR_JQL, jql);
context.put(VAR_SERVER_ID, serverId);
return context;
} catch (Exception e) {
e.printStackTrace();
return context;
}
}
完了。