Confluence custom search plugin

Hi guys,

I’m trying to create a custom search plugin for Confluence.

Long story short:

How do I define search plugin in atlassian-plugin.xml? This doesn’t work:

<search-decorator key="promoteContentCreatorSearchDecorator"
                  class="com.confluence.plugins.PromoteContentCreatorSearchDecorator"
                  weight="100"/>

I get my module always disabled:

Long story long:

I found this guide and I like it quite a lot but it is only applicable for Confluence 7. While we still on Confluence 6.12

So I found this one as well and everything seems fine except my module does not start after installing addon. I assume that is because of the way it is described in module description (see above). What is the right way to do that?

Instead of search Web Resources I declare now my own class and it gets enabled:

    <web-resource key="promoteContentCreatorSearchDecorator" name="Search Content Decorator" class="com.confluence.plugins.PromoteContentCreatorSearchDecorator" weight="100">
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        
        <resource type="download" name="search.css" location="/css/search.css"/>
        <resource type="download" name="search.js" location="/js/search.js"/>
        <resource type="download" name="images/" location="/images"/>

        <context>confluence-search</context>
    </web-resource>

Looks better but I don’t get any response from it in the log. Seems like it’s not being triggered from search

My JAVA class looks like this now:

@Scanned
public class PromoteContentCreatorSearchDecorator extends AbstractSearch{
    private static final Logger log = Logger.getLogger(PromoteContentCreatorSearchDecorator.class);
    private static final String logPref = "PromoteContentCreatorSearchDecorator: ";
    @ConfluenceImport
    private SearchManager searchManager;

    public PromoteContentCreatorSearchDecorator(
            @ComponentImport  SearchQuery query,
            @ComponentImport SearchSort sort,
            @ComponentImport SearchFilter searchFilter,
            int startOffset, int limit,
            @ComponentImport SearchManager searchManager) {
        super(query, sort, SearchResultTypeSearchFilter.CONTENT.and(searchFilter), startOffset, limit);
        this.searchManager = searchManager;
    }

    @Inject
    public void search(){
        log.debug(logPref + "Getting started!");
        ...
        log.debug(logPref + "END");
    }
}