Add "text:as content" key

The text supplier includes some keys to cast text to other types. I'd like to include an additional "as content" key that would work just like "value:content X" except the parameter is passed as the context instead. The idea is to be able to pass a page name in a keychain and resolve it to a page object:

value:text "SPACE:Page Name" > text:as content > page:...

or

data:pageName > text:as content > ...

I've implemented this locally with the following code:

@SupplierKey("as content")
public ConfluenceEntityObject getContent(@KeyContext SupplierContext context) {
String id = ( String ) context.getValue();
PageContext pageContext = new PageContext();
ConversionContext conversionContext = new DefaultConversionContext(pageContext);
return linkAssistant.getEntityForWikiLink( conversionContext, id );
}

The main issue, though, is that without the page context being passed in, I don't know if there is a way to use the current page's page context by default. This means you always need to include the space key prefix before the page name.

  • Mike Kalnicki
  • Apr 11 2016
  • Needs review
  • Attach files