I want to use a ScriptRunner event to only process certain pages. I know how to narrow the page down to the space within the ScriptRunner event code, but I only want to process certain pages within the space. Is there a way when creating pages to designate what I'll call a PageType? So when I create a page, I'd like to give the page a PageType I define and then read that value from Groovy.
To help clarify this a little more, I have a space lets call Projects. Under this I have what I call a "Project" page type and under Project page I have a Request page. I want the ability to define each of these page type and be able to use Groovey to determine what each page type is.
(space) Projects
- Project 1
- Request 1
- Project 2
- Request 2
Maybe you could define a label that refers to a specific page type and filter based on that?
I was able to add a Content Property to my pages. My one issue now is how to retrive the Content Property via REST. This is what I have so far but it's not working. I've add log entries to see how far it gets and I get to "eWeb Request Form Event: 2" and then it throws an error on http.get with a Not Found error.
import com.atlassian.confluence.event.events.content.page.PageEvent
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.pages.Page
def event = event as PageEvent
Page page = event.getPage()
Space space = page.getSpace()
if (space.key != 'eWebProjects') {
log.warn("eWebRequest Form Save Event - this is not the eWebProjects space")
return
}
import groovyx.net.http.HTTPBuilder
//import static groovyx.net.http.ContentType.*
//import groovyx.net.http.ContentType
//import static groovyx.net.http.Method.*
//import groovy.json.JsonSlurper
//import net.sf.json.groovy.JsonSlurper
log.warn("eWeb Request Form Event: 1")
def http = new HTTPBuilder('http://confluence/rest/api/')
log.warn("eWeb Request Form Event: 2")
def pageType
def url = 'content/' + page.id + '/property/page-type/'
http.get(path: url,
contentType : 'application/json'
) { resp, reader ->
println reader
log.warn("eWeb Request Form Event: 3")
//pageType = json
}
log.warn("eWeb Request Form Event: page-type = " + pageType)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.