It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I get the object of a comment by an add-on (Talk-Advanced Inline Comments) in ScriptRunner ?

Nadav Dahan Jul 27, 2017

I'm trying to get the object of an in-line comment by Talk. but after several tries I still cannot. This only gets me the ID of the comment. 

def xhtmlContent = ComponentLocator.getComponent(XhtmlContent)
final List<String> ids = new ArrayList<>();

xhtmlContent.handleMacroDefinitions(page.getBodyAsString(), new DefaultConversionContext(page.toPageContext()), new MacroDefinitionHandler() {
    @Override
    public void handle(MacroDefinition macroDefinition) {
        if ("talk".equals(macroDefinition.getName())) {
            ids.add(macroDefinition.getParameters().get("id"));
        }
    }
});

 But I am trying to get the whole object so I can get all the parameters for a report I am making.(Comment Text, Created On, Created By, Status, Color .....)

So I tried other imports such as:

import com.stiltsoft.confluence.talk.manager.TalkManager

and getting the object like this:

def talkManager = ComponentLocator.getComponent(TalkManager)
def talkComment = talkManager.getCommentById(page, "talk-1")

 

or:

@WithPlugin(com.stiltsoft.confluence.talk.confluence-talk-plugin)
@PluginModule(TalkManager)

using this link:

https://scriptrunner.adaptavist.com/latest/jira/scripting-other-plugins.html

Does anyone know how to do this? 

2 answers

0 votes
Andrey Khaneev Jul 27, 2017

Try this one

@WithPlugin(com.stiltsoft.confluence.talk.confluence-talk-plugin)
@PluginModule

TalkManger talkManager

 

Nadav Dahan Jul 29, 2017

I've tried this and it still is unable to resolve the TalkManager classs.

Andrey Khaneev Jul 30, 2017

What error messages do you get?

Nadav Dahan Jul 30, 2017

error_3.png

0 votes

Hello,

Following code loads as expected.

import com.onresolve.scriptrunner.runner.ScriptRunnerImpl
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import org.apache.log4j.Level
import org.apache.log4j.Logger

def log = Logger.getLogger("com.test.talk")
log.setLevel(Level.DEBUG)

@WithPlugin("com.stiltsoft.confluence.talk.confluence-talk-plugin")

def talkManager = ScriptRunnerImpl.getPluginComponent(com.stiltsoft.confluence.talk.manager.TalkManager)
talkManager ? log.info("Found: " + talkManager.toString()) : log.info("Not Found")

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

947 views 0 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you