com.atlassian.studio.repository
Class DelegatingRepositoryPermissionsManagerImpl

java.lang.Object
  extended by com.atlassian.studio.repository.DelegatingRepositoryPermissionsManagerImpl
All Implemented Interfaces:
RepositoryPermissionsManager

public class DelegatingRepositoryPermissionsManagerImpl
extends Object
implements RepositoryPermissionsManager

A permissions manager which delegates to the other permissions managers so that things can be called "once". The manager is designed to be thread-safe. Because operations on the manager may take a while (communicating with other servers), it has an "overload" mode whereby if more than QUEUE_SIZE threads are already waiting on acquiring a lock, any more will be shut out quickly with an exception.

Since:
v1.0

Field Summary
 
Fields inherited from interface com.atlassian.studio.repository.RepositoryPermissionsManager
IGNORE_SYSADMIN_GROUP
 
Constructor Summary
DelegatingRepositoryPermissionsManagerImpl(com.atlassian.applinks.core.AppLinksManager applinksManager, com.atlassian.sal.api.net.RequestFactory<?> requestFactory, JiraAuthenticationContext authenticationContext, com.atlassian.studio.host.common.ThemeProperties themeProperties, FisheyeRepositoryPermissionsManager fisheyeRepositoryPermissionsManager, SvnRepositoryPermissionsManager svnRepositoryPermissionsManager, CruciblePermissionsManager cruciblePermissionsManager)
           
DelegatingRepositoryPermissionsManagerImpl(int queueSize, int queueSafetyWaitInMillis, com.atlassian.applinks.core.AppLinksManager applinksManager, com.atlassian.sal.api.net.RequestFactory<?> requestFactory, JiraAuthenticationContext authenticationContext, com.atlassian.studio.host.common.ThemeProperties themeProperties, FisheyeRepositoryPermissionsManager fisheyeRepositoryPermissionsManager, SvnRepositoryPermissionsManager svnRepositoryPermissionsManager, CruciblePermissionsManager cruciblePermissionsManager)
           
 
Method Summary
 void deletePathPermissions(String svnPath)
          Removes permissions applied to a path allowing higher-up permissions to be automatically applied.
 RepositoryPermissions getInitialPermissions()
           
 List<String> getNonProjectPaths()
          Returns map of svn paths that are not roots of any Fisheye Repository and permissions for each path.
 int getNumFreeSlotsInExecutionQueue()
           
 RepositoryPermissions getPathPermissions(String svnPath)
           
 RepositoryPermissions getPermissions(String repositoryKey)
           
 String getSvnPathForFisheyeRepository(String fisheyeRepository)
          The repository key in FishEye and the SVN path corresponding to that key may be different.
 void reset()
          Resets the cache of Fisheye to Svn mapping
 void setDefaultPermissions(RepositoryPermissions permissions)
          Sets the default permissions that will be applied to new repositories.
 void setFisheyeRepositoryPermissionsManager(FisheyeRepositoryPermissionsManager fisheyeRepositoryPermissionsManager)
           
 void setPermissions(String repositoryKey, RepositoryPermissions permissions)
          Applies new permissions to a repository.
 void setPermissions(String repositoryKey, String svnPath, RepositoryPermissions permissions)
          Applies new permissions to a repository and a specific SVN path.
 void setRawPermissions(String repositoryKey, String svnPath, RepositoryPermissions permissions)
          Sets the permissions for a path without performing any jiggery-pokery that would usually ensure consistency.
 void setSvnRepositoryPermissionsManager(SvnRepositoryPermissionsManager svnRepositoryPermissionsManager)
           
 PermissionsSynchronisationResult synchroniseAllRepositoryPermissions()
          Synchronises the permissions for all projects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingRepositoryPermissionsManagerImpl

public DelegatingRepositoryPermissionsManagerImpl(com.atlassian.applinks.core.AppLinksManager applinksManager,
                                                  com.atlassian.sal.api.net.RequestFactory<?> requestFactory,
                                                  JiraAuthenticationContext authenticationContext,
                                                  com.atlassian.studio.host.common.ThemeProperties themeProperties,
                                                  FisheyeRepositoryPermissionsManager fisheyeRepositoryPermissionsManager,
                                                  SvnRepositoryPermissionsManager svnRepositoryPermissionsManager,
                                                  CruciblePermissionsManager cruciblePermissionsManager)

DelegatingRepositoryPermissionsManagerImpl

public DelegatingRepositoryPermissionsManagerImpl(int queueSize,
                                                  int queueSafetyWaitInMillis,
                                                  com.atlassian.applinks.core.AppLinksManager applinksManager,
                                                  com.atlassian.sal.api.net.RequestFactory<?> requestFactory,
                                                  JiraAuthenticationContext authenticationContext,
                                                  com.atlassian.studio.host.common.ThemeProperties themeProperties,
                                                  FisheyeRepositoryPermissionsManager fisheyeRepositoryPermissionsManager,
                                                  SvnRepositoryPermissionsManager svnRepositoryPermissionsManager,
                                                  CruciblePermissionsManager cruciblePermissionsManager)
Method Detail

getPermissions

public RepositoryPermissions getPermissions(String repositoryKey)
                                     throws ApplicationNotFoundException,
                                            ApplicationCommunicationException,
                                            RepositoryNotFoundException
Specified by:
getPermissions in interface RepositoryPermissionsManager
Parameters:
repositoryKey - used to designate the target repository
Returns:
the permissions corresponding to the given repository as designated by repositoryKey
Throws:
ApplicationNotFoundException - if an application primary instance (such as FishEye or Subversion) is not configured properly
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords
RepositoryNotFoundException - if the repository of the given repository key is not found

getPathPermissions

public RepositoryPermissions getPathPermissions(String svnPath)
                                         throws ApplicationNotFoundException,
                                                ApplicationCommunicationException
Specified by:
getPathPermissions in interface RepositoryPermissionsManager
Parameters:
svnPath - used to designate the target path
Returns:
the permissions corresponding to the given path as designated by path
Throws:
ApplicationNotFoundException - if an application primary instance (such as FishEye or Subversion) is not configured properly
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords

setPermissions

public void setPermissions(String repositoryKey,
                           RepositoryPermissions permissions)
                    throws ApplicationNotFoundException,
                           RepositoryNotFoundException,
                           ApplicationCommunicationException
Description copied from interface: RepositoryPermissionsManager
Applies new permissions to a repository. The permissions manager figures out the relevant SVN path.

Specified by:
setPermissions in interface RepositoryPermissionsManager
Parameters:
repositoryKey - the target repository
permissions - the new permissions for the target repository
Throws:
ApplicationNotFoundException - if an application primary instance is not configured properly
RepositoryNotFoundException - if the repository of the given repository key is not found
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords

setPermissions

public void setPermissions(String repositoryKey,
                           String svnPath,
                           RepositoryPermissions permissions)
                    throws RepositoryNotFoundException,
                           ApplicationNotFoundException,
                           ApplicationCommunicationException
Description copied from interface: RepositoryPermissionsManager
Applies new permissions to a repository and a specific SVN path. Useful when creating a new repository or when the usual method of determining permissions is unavailable. In most cases it is best to let the permissions manager figure out the SVN path by calling the setPermissions method which lacks the svnPath parameter.

Specified by:
setPermissions in interface RepositoryPermissionsManager
Parameters:
repositoryKey - the target repository
svnPath - the target svn path corresponding to the repository.
permissions - the new permissions for the target repository
Throws:
RepositoryNotFoundException - if the repository of the given repository key is not found
ApplicationNotFoundException - if an application primary instance is not configured properly
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords

setRawPermissions

public void setRawPermissions(String repositoryKey,
                              String svnPath,
                              RepositoryPermissions permissions)
                       throws RepositoryNotFoundException,
                              ApplicationCommunicationException,
                              ApplicationNotFoundException
Description copied from interface: RepositoryPermissionsManager
Sets the permissions for a path without performing any jiggery-pokery that would usually ensure consistency. Useful when a piece of code needs to manage the permissions at a fine-grained level.

Specified by:
setRawPermissions in interface RepositoryPermissionsManager
Parameters:
repositoryKey - the project key of the repository, may be null
svnPath - the path whose permissions will be set
permissions - the new permissions
Throws:
RepositoryNotFoundException - if the repository of the given repository key is not found
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords
ApplicationNotFoundException - if an application primary instance is not configured properly

synchroniseAllRepositoryPermissions

public PermissionsSynchronisationResult synchroniseAllRepositoryPermissions()
                                                                     throws ApplicationCommunicationException,
                                                                            ApplicationNotFoundException
Synchronises the permissions for all projects.

Specified by:
synchroniseAllRepositoryPermissions in interface RepositoryPermissionsManager
Returns:
the synchronisation result
Throws:
ApplicationCommunicationException - if the manager is unable to retrieve the current repository mappings from FishEye
ApplicationNotFoundException - if FishEye is not currently linked in AppLinks

setDefaultPermissions

public void setDefaultPermissions(RepositoryPermissions permissions)
                           throws ApplicationCommunicationException,
                                  ApplicationNotFoundException
Description copied from interface: RepositoryPermissionsManager
Sets the default permissions that will be applied to new repositories. If a repository is created and the defaults are subsequently changed, the new defaults will not be automatically applied to the existing repository.

Specified by:
setDefaultPermissions in interface RepositoryPermissionsManager
Parameters:
permissions - the new defaults
Throws:
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords
ApplicationNotFoundException - if an application primary instance is not configured properly

getInitialPermissions

public RepositoryPermissions getInitialPermissions()
                                            throws IOException
Specified by:
getInitialPermissions in interface RepositoryPermissionsManager
Returns:
the current permissions that will be applied to new repositories, these permissions will continue to apply to the new repository even if the defaults are later changed; the repository's permissions must be managed manually. The initial permissions are affected by both the default and root permissions.
Throws:
IOException - if the permissions cannot be loaded

getSvnPathForFisheyeRepository

public String getSvnPathForFisheyeRepository(String fisheyeRepository)
Description copied from interface: RepositoryPermissionsManager
The repository key in FishEye and the SVN path corresponding to that key may be different. Use this method to discover the SVN path corresponding to a particular repository key.

Specified by:
getSvnPathForFisheyeRepository in interface RepositoryPermissionsManager
Parameters:
fisheyeRepository - as found in FishEye
Returns:
the corresponding SVN path

getNonProjectPaths

public List<String> getNonProjectPaths()
                                throws IOException,
                                       ApplicationNotFoundException,
                                       ApplicationCommunicationException
Description copied from interface: RepositoryPermissionsManager
Returns map of svn paths that are not roots of any Fisheye Repository and permissions for each path.

Specified by:
getNonProjectPaths in interface RepositoryPermissionsManager
Returns:
map of svn paths that are not roots of any Fisheye Repository and permissions for each path.
Throws:
IOException - if there is an error reading svn authz file
ApplicationNotFoundException - if an application primary instance is not configured properly
ApplicationCommunicationException - examples of communication errors are timeouts and incorrect passwords

setFisheyeRepositoryPermissionsManager

public void setFisheyeRepositoryPermissionsManager(FisheyeRepositoryPermissionsManager fisheyeRepositoryPermissionsManager)

setSvnRepositoryPermissionsManager

public void setSvnRepositoryPermissionsManager(SvnRepositoryPermissionsManager svnRepositoryPermissionsManager)

reset

public void reset()
Description copied from interface: RepositoryPermissionsManager
Resets the cache of Fisheye to Svn mapping

Specified by:
reset in interface RepositoryPermissionsManager

deletePathPermissions

public void deletePathPermissions(String svnPath)
Description copied from interface: RepositoryPermissionsManager
Removes permissions applied to a path allowing higher-up permissions to be automatically applied. In most cases synchroniseAllRepositoryPermissions should be called after this method is invoked.

Specified by:
deletePathPermissions in interface RepositoryPermissionsManager
Parameters:
svnPath - the path whose permissions will be dropped

getNumFreeSlotsInExecutionQueue

public int getNumFreeSlotsInExecutionQueue()


Copyright © 2002-2012 Atlassian. All Rights Reserved.