All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.randombits.supplier.confluence.general.ConfluenceValueSupplier Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy