How to access PageProperty

My Page has a PageProperty with a table containing key value pairs.
The page was created by a confluence user.
Im writing an eventlistener and I want to get those key value pairs.
I tried this java-code:

ContentProperties properties = page.getProperties();
List<ContentProperty> cpList = properties.asList();
for(ContentProperty cp : cpList) { 
	if(cp.getContentEntity() != null){
		System.out.println("CEBodyAsString: " + cp.getContentEntity().getBodyAsString());
	}
}

But it returns nothing. So it seems to me that all the ContentProperties have empty ContentEntityObjects.

Dear flowyoe,

are you sure you are trying to access it the right way? I would have assumed that your key/value pair are e.g. strings. So you might succeed with cp.getStringValue() for the value and cp.getName() for the key. getContentEntity() does not seem to make sense here.

I hope that helps.

Andreas

Thanks for the reply.
I also tryed this in the for-loop:

 System.out.println("cp.getName: " + cp.getName());
 System.out.println("cp.getStringValue: " + cp.getStringValue());
 System.out.println("cp.toString: " + cp.toString());

it returns:

[INFO] [talledLocalContainer] cp.getName: macro-count.code
[INFO] [talledLocalContainer] cp.getStringValue: 15-3
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@6d19f3c3
[INFO] [talledLocalContainer] cp.getName: macro-count.attachments
[INFO] [talledLocalContainer] cp.getStringValue: 15-1
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@4e2bde3b
[INFO] [talledLocalContainer] cp.getName: macro-count.toc
[INFO] [talledLocalContainer] cp.getStringValue: 15-1
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@3f71c272
[INFO] [talledLocalContainer] cp.getName: macro-count.jira.jqlQuery
[INFO] [talledLocalContainer] cp.getStringValue: 15-2
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@e5bc385
[INFO] [talledLocalContainer] cp.getName: macro-count.roadmap
[INFO] [talledLocalContainer] cp.getStringValue: 15-1
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@2cfebe66
[INFO] [talledLocalContainer] cp.getName: macro-count.unknown
[INFO] [talledLocalContainer] cp.getStringValue: 15-2
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@3cb477c4
[INFO] [talledLocalContainer] cp.getName: macro-count.jira.key
[INFO] [talledLocalContainer] cp.getStringValue: 15-1
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@d674072
[INFO] [talledLocalContainer] cp.getName: macro-count.info
[INFO] [talledLocalContainer] cp.getStringValue: 15-2
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@5d70fdb0
[INFO] [talledLocalContainer] cp.getName: macro-count.status
[INFO] [talledLocalContainer] cp.getStringValue: 15-3
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@42465f6
[INFO] [talledLocalContainer] cp.getName: macro-count.details
[INFO] [talledLocalContainer] cp.getStringValue: 18-1
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@5527e0ac
[INFO] [talledLocalContainer] cp.getName: macro-create-events-published-for-version
[INFO] [talledLocalContainer] cp.getStringValue: null
[INFO] [talledLocalContainer] cp.toString: com.atlassian.confluence.content.ContentProperty@5f33968d

those are not my key/value pairs

Can you post the code used to store the values?

The page is created normally with the browser. But it has a pageProperty(-macro) containing a table with key-value-pairs.

Dear flowyoe,

now I see where you are coming from. Although the name is similar a page property macro does not store content properties. It is just a table with data.

What you have to do is parse the content of the page in storage format and extract your properties out of it. Atlassian’s Page Property Report does this here.

Kind regards

Andreas

Actually, there is a REST API (at least) for the Page Properties:

rest/masterdetail/1.0/detailssummary/lines?cql=type=page&spaceKey=TEST