JAVA API to sync external directories


I've noticed a few people who want a REST method to trigger an external user directory sync.  The primary use case, and the one for my company, is we sometime know when a change has been made that we want JIRA or Confluence to pickup and don't want to set a very quick auto-sync interval and don't want to wait for a really long one.

I wrote a rest service for Confluence that performed the task, and I'm trying to port it to JIRA.   Here's the java portion I use for Confluence.


import java.util.Map;
import java.util.List;

import com.atlassian.crowd.embedded.api.Directory;

public class ADRestService
   private final DirectoryManager directoryManager;

   public ADRestService( DirectoryManager directoryManager)
       this.directoryManager      = directoryManager;

   public Response syncAllDirectories( ){
      String response = "<p>Syncing</p>";

      List directories = directoryManager.findAllDirectories();
      for( Directory directory : directoryManager.findAllDirectories() ){
            if( directoryManager.isSynchronisable( directory.getId() ) 
            && !directoryManager.isSynchronising( directory.getId() )){
               directoryManager.synchroniseCache( directory.getId(), SynchronisationMode.INCREMENTAL );
         } catch( Exception e ){
            // com.atlassian.crowd.exception.DirectoryInstantiationException
            // com.atlassian.crowd.exception.OperationFailedException

      return Response.ok( new RestResponse( response ) ).build();

In porting this to JIRA, I've discovered that I need to enable the jira-core artifact in the pom.xml otherwise it can't find the DirectoryManager.  The comment in the pom created by Atlassian indicates that I should be doing this using methods in the jira-api.  Does anybody know what those may be?

        <!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
        <!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->


1 answer

0 vote

Hi Scott!

This kind of questions will get a better and faster answer if you post them in our Developer Community. There you'll find developers, product experts and vendors that will be able to help you with your question :)



Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Service Desk

Wy are we still using email for Service Desk workflows?

...attest to the experience of an urgent approval that gets lost in the boss’s inbox and requires that special “Please Approve” email or text message. In an age where we have distributed teams...

91 views 0 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you