You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.
Join groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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
Calling all Confluence Cloud Admins! We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.