I would like to setup a script job that scans a page for web inks and marks in red those that are not valid any more.
The reason why I do not want to use a macro for this is that I want watchers to be notified of this change.
I have installed Confluence script runner, I had a look at the confluence API especially regarding ContentEntityObject but I could not figure out a way to read the page content and update it.
Hi Roberto,
My name is Rafael Franco and I'm the Tech Lead of the Product Team here at Adaptavist. Thanks for using ScriptRunner for Confluence.
May I ask how do you define that a link is not valid any more?
Regards,
Rafael
Hi Rafael,
I would just use HttpUrlConnection to send a "HEAD" command and then verify whether its return code is 200
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roberto,
Ok, clear now. What you need essentially is understand that each page is composed of a sort of meta language called storage format https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html
In essence what you need to do is look for all pages, iterate over them, get the page content and update it, so something like:
ContentEntityObject contentEntityObject = page.getContentEntityObject() String body = contentEntityObject.getBodyAsString() //Do a regex to replace the "a" links and add a style="background-color:red" to it after the replace do contentEntityObject.setBodyAsString() with the updated body and then finally: this.pageManager.saveContentEntity(contentEntityObject, SILENT_SAVE_CONTEXT);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Roberto, link checking could add quite a load to the Confluence server, so I'd recommend you have some way to restrict how often connections are made
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Matt, I guess this is a one time operation, so should be fine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I was trying to get a list of all the users in Confluence through a groovy script. Could you help me with it?
Thanks in advance.
Akhil
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.