Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to find property using ContentPropertyService inside an Extractor2 module?

takilara
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 8, 2021

I have a macro module that use the following code to access a content-property with key "quest" (the value for quest is a json)

Option<JsonContentPropertyfoundPropertyOpt = this.contentPropertyService.find().withContentId(thisContentId).withPropertyKey("quest").fetchOne();

This works fine in the macro code. 

I would also like to use the Extractor2 module to extract elements from the json, and add to the search text using the extractText method.

However, using the same code as above, does not seem to work in the Extractor2 module.

From Googling (Specifically https://community.developer.atlassian.com/t/how-to-use-expansions-on-contentpropertyservice/46866), it seems i may have to use Expansion to allow the Extractor2 to detect the json property.

Note that REST towards http://localhost:1990/confluence/rest/api/content/753670?expand=metadata.properties.quest works fine.

I have tried to use various permutations of Expansion without succes, including

Expansion exp = ExpansionsParser.parseSingle("metadata.properties.quest");
Expansion exp = Expansion("metadata.properties.quest");        
Expansion exp = Expansion.combine("metadata","properties","quest");

Based on the above linked topic, i have also tried find(new Expansion('content'), new Expansion('version')) and find(new Expansion(JsonContentProperty.Expansions.CONTENT), new Expansion('property'))

 

Is expansion my problem here? or is there something else? 

 

Extra info:

I am getting thisContentId as follows:

Extractor2:

Page page = getPage(searchable);        
StringBuilder builder = new StringBuilder();        
if (page == null) {            
return builder;        
}
        
ContentId thisContentId = page.getContentId();

 

Macro:

ContentId thisContentId = conversionContext.getEntity().getContentId(); 

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.11.2
TAGS
AUG Leaders

Atlassian Community Events