Hello everybody,
is there someone who can help me!
Two confluence spaces are done together.
We use the macro "Page Properties", to define process owners for pages.
In one space is using "Prozessverantwortlicher" as designation, in the second space "Prozessbevollmächtigte" is recorded in the "page properties" tables. So I currently have two names for "process owners". It would be very useful, if I can match this over script runner to one designation "Prozessverantwortlicher".
I got this script sample (App-Adaptavist ScriptRunner for Confluence) from Adaptavista Support. Many thanks to Lee.
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.search.v2.ContentSearch
import com.atlassian.confluence.search.v2.SearchManager
import com.atlassian.confluence.search.v2.query.MacroUsageQuery
import com.atlassian.sal.api.component.ComponentLocator
def pageManager = ComponentLocator.getComponent(PageManager)
def searchManager = ComponentLocator.getComponent(SearchManager)
def macroName = "details"
def result = []
def search = new ContentSearch(new MacroUsageQuery(macroName), null, null, 0, 500)
def searchResults = searchManager.search(search)
searchResults.getAll().each { searchResult ->
result << pageManager.getPage(searchResult.spaceKey, searchResult.displayTitle) }
result.each{ page -> log.warn"Page: " + page }
I don't want to show all pages, only those from the specific space "KPKQMBAR"
searchResults.getAll().each { searchResult ->
if ( searchResult.spaceKey == "KPKQMBAR"){
result << pageManager.getPage(searchResult.spaceKey, searchResult.displayTitle)
}
}When executing the code in the scriptrunner console, pages from different spaces are displayed anyway. So I'm doing something wrong.
What should I do differently?
As soon as the results are known and I have all the pages in which the "Prozebevollmächtigte" appears, I would now like to change this name to "Prozessverantwortlicher" via a script command.
Here I was suggested to proceed as follows:
Once you have grabbed the body content of the page, with the Page's getBodyAsString method, you can use Groovy's Replace All method to find all occurrences of a specific set of characters, in this case, the table heading "<th>Prozessbevollmächtigter</th>"
Unfortunately I can't get any further here. In general, are my programming ability not very good.
How can I do this in a script?
Thanks
Daniel