com.atlassian.crowd.manager.directory
Class DirectorySynchroniserHelperImpl

java.lang.Object
  extended by com.atlassian.crowd.manager.directory.DirectorySynchroniserHelperImpl
All Implemented Interfaces:
DirectorySynchroniserHelper

@Transactional
public class DirectorySynchroniserHelperImpl
extends Object
implements DirectorySynchroniserHelper

A DirectorySynchroniserHelper that requests a SynchronisableDirectory synchronises its cache, and stores synchronisation information in the Directory's attributes.


Constructor Summary
DirectorySynchroniserHelperImpl(DirectoryDao directoryDao, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 Directory findDirectoryById(long directoryId)
          Returns a Directory based on the passed in directoryId.
 void handleEvent(DirectoryUpdatedEvent event)
          Removes SynchronisableDirectoryProperties.IS_SYNCHRONISING attribute from the updated directory, so we can recognise when a directory requires initial synchronisation.
 boolean isSynchronising(long synchronisableDirectoryId)
          Returns true if the given directory is currently being synchronised.
 void updateSyncEndTime(SynchronisableDirectory synchronisableDirectory)
          Updates information relevant to a directory's current synchronisation end time.
 void updateSyncStartTime(SynchronisableDirectory synchronisableDirectory)
          Updates a SynchronisableDirectory's current synchronisation start time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectorySynchroniserHelperImpl

public DirectorySynchroniserHelperImpl(DirectoryDao directoryDao,
                                       com.atlassian.event.api.EventPublisher eventPublisher)
Method Detail

updateSyncStartTime

public void updateSyncStartTime(SynchronisableDirectory synchronisableDirectory)
                         throws DirectoryNotFoundException
Description copied from interface: DirectorySynchroniserHelper
Updates a SynchronisableDirectory's current synchronisation start time.

Specified by:
updateSyncStartTime in interface DirectorySynchroniserHelper
Parameters:
synchronisableDirectory - directory to update
Throws:
DirectoryNotFoundException - if the directory could not be found

updateSyncEndTime

public void updateSyncEndTime(SynchronisableDirectory synchronisableDirectory)
                       throws DirectoryNotFoundException
Description copied from interface: DirectorySynchroniserHelper
Updates information relevant to a directory's current synchronisation end time. The duration, last sync start time and current sync start time will be updated.

DirectorySynchroniserHelper.updateSyncStartTime(com.atlassian.crowd.directory.SynchronisableDirectory) must have been invoked before this method call.

Specified by:
updateSyncEndTime in interface DirectorySynchroniserHelper
Parameters:
synchronisableDirectory - directory to update
Throws:
DirectoryNotFoundException - If the directory could not be found

isSynchronising

public boolean isSynchronising(long synchronisableDirectoryId)
                        throws DirectoryNotFoundException
Description copied from interface: DirectorySynchroniserHelper
Returns true if the given directory is currently being synchronised.

Specified by:
isSynchronising in interface DirectorySynchroniserHelper
Parameters:
synchronisableDirectoryId - synchronisable directory id
Returns:
true if the given directory is currently being synchronised
Throws:
DirectoryNotFoundException - if the directory could not be found

findDirectoryById

public Directory findDirectoryById(long directoryId)
                            throws DirectoryNotFoundException
Description copied from interface: DirectorySynchroniserHelper
Returns a Directory based on the passed in directoryId. Essentially equivalent to DirectoryManager.findDirectoryById(long), it exists to obtain the directory configuration without introducing a dependency on the complex DirectoryManager.

Specified by:
findDirectoryById in interface DirectorySynchroniserHelper
Parameters:
directoryId - the id of the directory to find
Returns:
the directory
Throws:
DirectoryNotFoundException - is thrown if the Directory cannot be found.

handleEvent

@EventListener
public void handleEvent(DirectoryUpdatedEvent event)
Removes SynchronisableDirectoryProperties.IS_SYNCHRONISING attribute from the updated directory, so we can recognise when a directory requires initial synchronisation.

Parameters:
event - directory update event


Copyright © 2013 Atlassian. All Rights Reserved.