com.atlassian.jira.vcs
Class DefaultRepositoryManager

java.lang.Object
  extended by com.atlassian.jira.vcs.DefaultRepositoryManager
All Implemented Interfaces:
Startable, RepositoryManager
Direct Known Subclasses:
EnterpriseRepositoryManager

public class DefaultRepositoryManager
extends java.lang.Object
implements RepositoryManager, Startable


Field Summary
 
Fields inherited from interface com.atlassian.jira.vcs.RepositoryManager
CVS_TYPE, VCS_SERVICE_DELAY, VCS_SERVICE_NAME, VCS_TYPES
 
Constructor Summary
DefaultRepositoryManager()
           
DefaultRepositoryManager(com.atlassian.core.ofbiz.association.AssociationManager associationManager, org.ofbiz.core.entity.GenericDelegator genericDelegator, ServiceManager serviceManager, PermissionManager permissionManager, ChangeHistoryManager changeHistoryManager, ProjectManager projectManager, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 Repository createRepository(java.lang.String type, java.lang.String name, java.lang.String description, java.util.Properties properties)
          Creates a new Repository with the provided attributes and properties and creates a VcsService if one does not yet exist.
protected static boolean equals(java.lang.String propertyName, com.opensymphony.module.propertyset.PropertySet oldPropertySet, java.util.Properties newProperties)
          Gets and compares the values of given propety between old and new properties
protected  com.atlassian.core.ofbiz.association.AssociationManager getAssociationManager()
           
 java.util.Map<java.lang.Long,java.util.Set<CVSCommit>> getCommits(Issue issue, com.opensymphony.user.User remoteUser)
          Retrieves all of the commits for this Issue from ALL of the repositories associated with the issue's project.
protected  org.ofbiz.core.entity.GenericDelegator getGenericDelegator()
           
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsForRepository(Repository repository)
          This method allows you to find the projects that have been associated with a given Repository.
 com.opensymphony.module.propertyset.PropertySet getPropertySet(org.ofbiz.core.entity.GenericValue versionControlGV)
          Retrieves a PropertySet for a repository provided the repositories GenericValue.
 java.util.Collection<Repository> getRepositories()
          This method will return all Repository's that exist within JIRA.
 java.util.Collection<Repository> getRepositoriesForProject(org.ofbiz.core.entity.GenericValue project)
          This method will return a list of Repositorys that are associated with the provided project.
 Repository getRepository(java.lang.Long id)
          Retrieves the Repository by its Repository.getId().
 Repository getRepository(java.lang.String name)
          Retrieves the repository by name
protected  ServiceManager getServiceManager()
           
protected  boolean isDifferentRepository(com.opensymphony.module.propertyset.PropertySet oldPropertySet, java.util.Properties newProperties)
          Checks if any of the new properties values will require a new repository to be created.
 boolean isValidType(java.lang.String type)
          Validates if a Repository.getType() is valid for this RepositoryManager.
protected  void markVcsServiceToRun()
          Adds VCS service to the schedule skipper of the service manager.
 void onClearCache(ClearCacheEvent event)
           
 void refresh()
          This will clear the repository cache and load all Repository's from the datastore.
 void removeRepository(java.lang.Long id)
          This method will remove the Repository specified by id from the datastore and it will remove all associations that may exist from the repository to projects.
 void setProjectRepositories(org.ofbiz.core.entity.GenericValue project, java.util.Collection<java.lang.Long> repositoryIds)
          Given a project and a collection of repository ids, associates the project with the repositories that have the given ids NOTE: the old associations are removed
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 boolean updateRepositories()
          Tries to update (e.g.
 void updateRepository(java.lang.Long id, java.lang.String type, java.lang.String name, java.lang.String description, java.util.Properties properties)
          Updates the repository with the given id.
protected  boolean updateRepository(Repository repository)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRepositoryManager

public DefaultRepositoryManager(com.atlassian.core.ofbiz.association.AssociationManager associationManager,
                                org.ofbiz.core.entity.GenericDelegator genericDelegator,
                                ServiceManager serviceManager,
                                PermissionManager permissionManager,
                                ChangeHistoryManager changeHistoryManager,
                                ProjectManager projectManager,
                                com.atlassian.event.api.EventPublisher eventPublisher)
                         throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

DefaultRepositoryManager

public DefaultRepositoryManager()
                         throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException
Method Detail

start

public void start()
           throws java.lang.Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
java.lang.Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

getRepositoriesForProject

public java.util.Collection<Repository> getRepositoriesForProject(org.ofbiz.core.entity.GenericValue project)
                                                           throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: RepositoryManager
This method will return a list of Repositorys that are associated with the provided project.

NOTE: In standard and professional editions the returned list will only ever contain a single repository. If you have associated more than one repository with the project the list will contain the first repository it encounters as stored in the database. JIRA enterprise edition allows you to associate multiple repositories with a project.

Specified by:
getRepositoriesForProject in interface RepositoryManager
Parameters:
project - a GenericValue representing the project associated with the repositories you would like to retrieve.
Returns:
collection of Repository's.
Throws:
org.ofbiz.core.entity.GenericEntityException - if there is a problem accessing the data store.

getProjectsForRepository

public java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjectsForRepository(Repository repository)
                                                                                  throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: RepositoryManager
This method allows you to find the projects that have been associated with a given Repository.

Specified by:
getProjectsForRepository in interface RepositoryManager
Parameters:
repository - represents the repository associated with the collection of projects returned.
Returns:
a collection of GenericValues that represent the projects the provided repository are associated with.
Throws:
org.ofbiz.core.entity.GenericEntityException - thrown if there is trouble accessing the datastore.

getRepository

public Repository getRepository(java.lang.String name)
Retrieves the repository by name

Specified by:
getRepository in interface RepositoryManager
Parameters:
name - name of the repository
Returns:
the repository with the given name if one is found, null otherwise

getRepository

public Repository getRepository(java.lang.Long id)
                         throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: RepositoryManager
Retrieves the Repository by its Repository.getId(). If the repository is not found in the datastore a RuntimeException will be generated.

Specified by:
getRepository in interface RepositoryManager
Parameters:
id - represents the repositories id.
Returns:
a Repository object as found by id.
Throws:
org.ofbiz.core.entity.GenericEntityException - thrown if there is trouble accessing the datastore.

getPropertySet

public com.opensymphony.module.propertyset.PropertySet getPropertySet(org.ofbiz.core.entity.GenericValue versionControlGV)
Description copied from interface: RepositoryManager
Retrieves a PropertySet for a repository provided the repositories GenericValue. The property set stores values such as ViewCvsBrowser.ROOT_PARAMETER and ViewCvsBrowser.KEY_BASE_URL.

Specified by:
getPropertySet in interface RepositoryManager
Parameters:
versionControlGV - the generic value representation of the repository.
Returns:
the PropertySet for the specified repository.

isValidType

public boolean isValidType(java.lang.String type)
Description copied from interface: RepositoryManager
Validates if a Repository.getType() is valid for this RepositoryManager.

Specified by:
isValidType in interface RepositoryManager
Parameters:
type - is a repository type (e.g. RepositoryManager.CVS_TYPE)
Returns:
true if the passed type is in the RepositoryManager.VCS_TYPES, false otherwise.

getCommits

public java.util.Map<java.lang.Long,java.util.Set<CVSCommit>> getCommits(Issue issue,
                                                                         com.opensymphony.user.User remoteUser)
Description copied from interface: RepositoryManager
Retrieves all of the commits for this Issue from ALL of the repositories associated with the issue's project. It will only show commits if the user has the Permissions.VIEW_VERSION_CONTROL permission.

Returns a map of (repository id -> Set of CVSCommit):

If the map is empty, there are no associated repositories for the issue and user. If the List of CVSCommit is null, then the vcs log has not yet been parsed for that repository.

Specified by:
getCommits in interface RepositoryManager
Parameters:
issue - is the issue which identifies the project which should be used to find Repository's.
remoteUser - is the user who's permissions will determine which commits are visible. This is the user who is making the browse request.
Returns:
map of (repository id -> List of CVSCommit)

createRepository

public Repository createRepository(java.lang.String type,
                                   java.lang.String name,
                                   java.lang.String description,
                                   java.util.Properties properties)
                            throws java.lang.Exception
Description copied from interface: RepositoryManager
Creates a new Repository with the provided attributes and properties and creates a VcsService if one does not yet exist.

Specified by:
createRepository in interface RepositoryManager
Parameters:
type - the type of the Repository, this should be RepositoryManager.CVS_TYPE.
name - the name of the Repository.
description - the description of the Repository.
properties - are properties that are essential for the repository to work, such as ViewCvsBrowser.ROOT_PARAMETER and ViewCvsBrowser.KEY_BASE_URL.
Returns:
the Repository object representation of the newly created repository.
Throws:
java.lang.Exception - thrown if there is a problem creating the repository, this could be caused by trouble accessing the datastore, or trouble creating the VcsService.

updateRepository

public void updateRepository(java.lang.Long id,
                             java.lang.String type,
                             java.lang.String name,
                             java.lang.String description,
                             java.util.Properties properties)
                      throws org.ofbiz.core.entity.GenericEntityException
Updates the repository with the given id. The values are updated based on the properties

Specified by:
updateRepository in interface RepositoryManager
Parameters:
id - repository id
type - VCS type, this method only supports RepositoryManager.CVS_TYPE
name - VCS name
description - VCS description
properties - new properties to store
Throws:
org.ofbiz.core.entity.GenericEntityException - thrown if the Repository can not be found by id or if there is trouble accessing the datastore.

isDifferentRepository

protected boolean isDifferentRepository(com.opensymphony.module.propertyset.PropertySet oldPropertySet,
                                        java.util.Properties newProperties)
Checks if any of the new properties values will require a new repository to be created. Returns true if the values differ in CvsRepository.KEY_MODULE_NAME, CvsRepository.KEY_PASSWORD, CvsRepository.KEY_CVS_ROOT or CvsRepository.KEY_FETCH_LOG values.

Parameters:
oldPropertySet - old properties
newProperties - new properties
Returns:
true if requires new repository based on the difference in property values, false otherwise

equals

protected static boolean equals(java.lang.String propertyName,
                                com.opensymphony.module.propertyset.PropertySet oldPropertySet,
                                java.util.Properties newProperties)
Gets and compares the values of given propety between old and new properties

Parameters:
propertyName - property name
oldPropertySet - old properties
newProperties - new properties
Returns:
true if they are equal or both null

markVcsServiceToRun

protected void markVcsServiceToRun()
Adds VCS service to the schedule skipper of the service manager. The service is only added if is usable.


removeRepository

public void removeRepository(java.lang.Long id)
                      throws java.lang.Exception
Description copied from interface: RepositoryManager
This method will remove the Repository specified by id from the datastore and it will remove all associations that may exist from the repository to projects.

Specified by:
removeRepository in interface RepositoryManager
Parameters:
id - represents the repositories id.
Throws:
java.lang.Exception - thrown if there is trouble removing the values from the datastore.

setProjectRepositories

public void setProjectRepositories(org.ofbiz.core.entity.GenericValue project,
                                   java.util.Collection<java.lang.Long> repositoryIds)
                            throws org.ofbiz.core.entity.GenericEntityException
Given a project and a collection of repository ids, associates the project with the repositories that have the given ids NOTE: the old associations are removed

Specified by:
setProjectRepositories in interface RepositoryManager
Parameters:
project - project generic value
repositoryIds - collection of repository ids <Long>
Throws:
org.ofbiz.core.entity.GenericEntityException - if at least one repository with the given id does not exist

getRepositories

public java.util.Collection<Repository> getRepositories()
Description copied from interface: RepositoryManager
This method will return all Repository's that exist within JIRA.

Specified by:
getRepositories in interface RepositoryManager
Returns:
A List of all Repository objects in the system.

updateRepositories

public boolean updateRepositories()
                           throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: RepositoryManager
Tries to update (e.g. cvs up) all the repositories in the system.

Specified by:
updateRepositories in interface RepositoryManager
Returns:
true if ALL repositories were updated without a problem, false if an exception occurred.
Throws:
org.ofbiz.core.entity.GenericEntityException - throw if there is trouble accessing the datastore.

updateRepository

protected boolean updateRepository(Repository repository)
                            throws org.netbeans.lib.cvsclient.command.CommandException,
                                   org.netbeans.lib.cvsclient.connection.AuthenticationException,
                                   java.io.IOException,
                                   net.sf.statcvs.input.LogSyntaxException,
                                   LockException
Throws:
org.netbeans.lib.cvsclient.command.CommandException
org.netbeans.lib.cvsclient.connection.AuthenticationException
java.io.IOException
net.sf.statcvs.input.LogSyntaxException
LockException

refresh

public void refresh()
             throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: RepositoryManager
This will clear the repository cache and load all Repository's from the datastore.

Specified by:
refresh in interface RepositoryManager
Throws:
org.ofbiz.core.entity.GenericEntityException - thrown if there is trouble accessing the datastore.

getGenericDelegator

protected org.ofbiz.core.entity.GenericDelegator getGenericDelegator()

getAssociationManager

protected com.atlassian.core.ofbiz.association.AssociationManager getAssociationManager()

getServiceManager

protected ServiceManager getServiceManager()


Copyright © 2002-2010 Atlassian. All Rights Reserved.