Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Accessing space key in macro code?

Deleted user June 26, 2011

I'm writing a macro to create a list of pages that don't have permissions set within spaces. I'd like to make the macro such that if it resides in a page in a specified space, it lists pages from all spaces that are unrestricted, but if in any other space, it will only show pages from that space.

What is the easiest way to find out what space the macro is being used in?

(This is all based on not being able to find an existing way to list unrestricted pages.)

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 27, 2011

This should start you off -- assumes that all your logic goes in the Macro's execute method

public String execute(Map params, String body, RenderContext renderContext) throws MacroException
{
ContentEntityObject contentEntityObject = ((PageContext) renderContext).getEntity();
Space space;

if (contentEntityObject instanceof BlogPost) {
BlogPost blogPost = (BlogPost) contentEntityObject;
space = blogPost.getSpace();
}
else if (contentEntityObject instanceof Page) {
Page page = (Page) contentEntityObject;
space = page.getSpace();
}

// Now do stuff with the space
// ...
}
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
September 28, 2011

@Derrick Bommarito: Does this answer your question?

TAGS
AUG Leaders

Atlassian Community Events