list all repositories on the server using the Java API?

Chris Evans October 28, 2015

I am trying to write a plugin that will act on all the repositories on a server when the plugin is enabled.  RepositoryService.findAll is returning an empty result.  Is there another call I can use to get a list of all of the repos on the server?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Chris Evans October 29, 2015

Answering my own question - the plugin wasn't running under any secutiory context, so it was only seeing public repositories, which none existed.  I had to run the findAll under with ADMIN privileges.

public void checkRepos() {
      securityService.withPermission(Permission.ADMIN," Enabling Hook").call(new UncheckedOperation<Boolean>() {
            @Override
            public Boolean perform() {
               PageRequest pageRequest = new PageRequestImpl(0,65536);
               Page<Repository> repoPages =    repoService.findAll(pageRequest);
               for (Repository repo : repoPages.getValues()){
                  //Do my repo work here
               }
               return true;
            }
      });
   }
TAGS
AUG Leaders

Atlassian Community Events