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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,501,486
Community Members
 
Community Events
180
Community Groups

Iterate over all Spaces

Florian Rising Star Sep 02, 2020

Hi,

I want to write a user macro to get a public list of all spaces, not only the spaces the current user has access to. The official documentation mentions the $spaceManager (https://developer.atlassian.com/server/confluence/confluence-objects-accessible-from-velocity/) but the requried method getAllSpaces() is marked as deprecated (https://docs.atlassian.com/ConfluenceServer/javadoc/7.4.0/com/atlassian/confluence/spaces/SpaceManager.html).

Is there another way to get a list of all spaces without running into trouble in near future? There is a hint in the documentation saying "since 7.3.0, use SpaceService.find(Expansion...) in plugins and SpaceManagerInternal in core where applicable". I tried but I can't get it up and running.

 

 

1 answer

Hi there, did you manage to find a way to work with the SpaceService.find() method in a user macro? I am running into the same problem...

Florian Rising Star Jan 14, 2022

Hi @Liza, unfortunately no. 

int start = 0;
PageResponse<Space> pageResponse;
do {
pageResponse = spaceService.find().fetchMany(new SimplePageRequest(start, start + MAX_RESULTS));
for (Space space : pageResponse.getResults()) {
// do stuff
}
start += MAX_RESULTS;
} while (pageResponse.hasMore());

MAX_RESULTS HAS TO be 500 because that's the limit for fetchMany. Where did I read that? Nowhere, it isn't documented and you have to guess it (fortunately I did it before production).

This method sucks, getAllSpaces() is much better, and to make it even worse, one method returns 1433 and the other 1423 for which should give the same results.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.4.0
TAGS
AUG Leaders

Atlassian Community Events