Hi,
I'm hoping someone can suggest how to achieve this. I want to use the ContentProperty to store some values for a Confluence page, but can't get a handle on either the ContentService or the ContentPropertyService.
I'm using Confluence 7.10.2 and ScriptRunner 6.21.0.
I can get an instance of both services via
@Field ContentService contentService = ComponentLocator.getComponent(ContentService, 'apiContentService');
@Field ContentPropertyService contentPropertyService = ComponentLocator.getComponent ContentPropertyService;
using this, I can successfully create and add a new property via contentPropertyService.create( myNewProperty )
however I'm unable to use .find to access the ContentPropertyFinder as
ContentId contentId = ContentId.of(pageId)
def found = contentPropertyService.find().withContentId(contentId).fetchOne();
groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy260.withContentId() is applicable for argument types: (com.atlassian.confluence.api.model.content.id.ContentId) values: [ContentId[id=19071593}]
And I have a similar issue with ContentService
def page = contentService.find().withId(ContentId.valueOf(pageId as String)).fetchOneOrNull();
which crashes out in a similar manner
groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy217.withId() is applicable for argument types: (com.atlassian.confluence.api.model.content.id.ContentId) values: [ContentId{id=19071593}].
Possible solutions: with(groovy.lang.Closure), with(boolean, groovy.lang.Closure), wait(), find(), wait(long), find([Lcom.atlassian.confluence.api.model.Expansion;)
If I try and call .find with null or an Expansion, I get
java.lang.IllegalArgumentException: interface com.atlassian.confluence.api.service.content.ContentService$ContentFinder is not visible from class loader
I believe my issue is due to Spring/autowire and Groovy's proxy getting in the way of each other but I'm at a loss as to how to resolve this.
For anyone else who has this issue, the answer appears to be to explicitly set the Expansions, which where trial-and-error.
def found = contentPropertyService.find(new Expansion('content'), new Expansion('version'))
.withPropertyKey('my-key')
.withContentId(pageId)
.fetch()
found.get().value
does the trick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.