org.randombits.supplier.confluence.general.ConfluenceValueSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of supplier-confluence Show documentation
Show all versions of supplier-confluence Show documentation
This plugin provides Confluence-specific Suppliers.
package org.randombits.supplier.confluence.general;
import org.randombits.supplier.core.SupplierContext;
import org.randombits.supplier.core.annotate.AnnotatedSupplier;
import org.randombits.supplier.core.annotate.KeyContext;
import org.randombits.supplier.core.annotate.KeyParam;
import org.randombits.supplier.core.annotate.SupplierKey;
import org.randombits.supplier.core.annotate.SupplierPrefix;
import org.randombits.support.confluence.LinkAssistant;
import org.randombits.utils.lang.API;
import org.springframework.beans.factory.annotation.Autowired;
import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.content.render.xhtml.DefaultConversionContext;
import com.atlassian.confluence.core.ConfluenceEntityObject;
import com.atlassian.confluence.core.ContentEntityObject;
import com.atlassian.confluence.renderer.PageContext;
/**
* Provides Confluence-specific 'value' creation.
*/
@SupplierPrefix(value = "value", required = true)
@API("1.0.0")
public class ConfluenceValueSupplier extends AnnotatedSupplier {
private LinkAssistant linkAssistant;
@Autowired
public void setLinkAssistant(LinkAssistant linkAssistant){
this.linkAssistant = linkAssistant;
}
@SupplierKey("content {id}")
@API("1.0.0")
public ConfluenceEntityObject getContent(@KeyContext SupplierContext context, @KeyParam("id") String id) {
ContentEntityObject currentContent = context.getEnvironmentValue(ContentEntityObject.class);
PageContext pageContext = currentContent != null ? currentContent.toPageContext() : new PageContext();
ConversionContext conversionContext = new DefaultConversionContext(pageContext);
return linkAssistant.getEntityForWikiLink(conversionContext, id);
}
}