So I'm trying to follow this tutorial https://developer.atlassian.com/server/confluence/search-decorator-module-tutorial/ in which you create a search decorator but I keep getting the following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project search-decorator: Compilation failure: Compilation failure:
[ERROR] /C:/Users/dbianco/search-decorator/src/main/java/com/example/plugins/tutorial/confluence/PromoteContentCreatorSearchDecorator.java:[6,42] cannot find symbol
[ERROR] symbol: class SearchDecorator
[ERROR] location: package com.atlassian.confluence.search.v2
[ERROR] /C:/Users/dbianco/search-decorator/src/main/java/com/example/plugins/tutorial/confluence/PromoteContentCreatorSearchDecorator.java:[23,62] cannot find symbol
[ERROR] symbol: class SearchDecorator
[ERROR] /C:/Users/dbianco/search-decorator/src/main/java/com/example/plugins/tutorial/confluence/PromoteContentCreatorSearchDecorator.java:[31,5] method does not override or implement a method from a supertype
[ERROR] /C:/Users/dbianco/search-decorator/src/main/java/com/example/plugins/tutorial/confluence/PromoteContentCreatorSearchDecorator.java:[39,24] com.atlassian.confluence.plugins.v2.search.tutorial.PromoteContentCreatorSearchDecorator.PromoteContentCreatorSearch is not abstract and does not override abstract method getLimit() in com.atlassian.confluence.search.v2.ISearch
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
PromoteContentCreatorSearchDecorator.java
package com.atlassian.confluence.plugins.v2.search.tutorial;
import com.atlassian.confluence.search.v2.HightlightParams;
import com.atlassian.confluence.search.v2.ISearch;
import com.atlassian.confluence.search.v2.ResultFilter;
import com.atlassian.confluence.search.v2.SearchDecorator;
import com.atlassian.confluence.search.v2.SearchFilter;
import com.atlassian.confluence.search.v2.SearchQuery;
import com.atlassian.confluence.search.v2.SearchSort;
import com.atlassian.confluence.search.v2.query.BooleanQuery;
import com.atlassian.confluence.search.v2.query.ConstantScoreQuery;
import com.atlassian.confluence.search.v2.query.CreatorQuery;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.sal.api.user.UserKey;
import com.atlassian.sal.api.user.UserManager;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Optional;
import static java.util.Objects.requireNonNull;
public class PromoteContentCreatorSearchDecorator implements SearchDecorator {
private final UserManager userManager;
@Autowired
public PromoteContentCreatorSearchDecorator(@ComponentImport UserManager userManager) {
this.userManager = requireNonNull(userManager);
}
@Override
public ISearch decorate(ISearch search) {
UserKey loginUserKey = userManager.getRemoteUserKey();
if (loginUserKey != null) {
return new PromoteContentCreatorSearch(search, loginUserKey);
}
return search;
}
private static class PromoteContentCreatorSearch implements ISearch {
private final ISearch delegate;
private final UserKey creator;
private PromoteContentCreatorSearch(ISearch delegate, UserKey creator) {
this.delegate = delegate;
this.creator = creator;
}
@Override
public SearchQuery getQuery() {
// a content matching should clause adds an overwhelming contribution to the overall score so it
// is ranked before any unmatched content
return BooleanQuery.builder()
.addMust(delegate.getQuery())
.addShould(new ConstantScoreQuery(new CreatorQuery(creator), 50.0f))
.build();
}
}
}