Class IssueProviderWrapper
- java.lang.Object
-
- jetbrains.buildServer.issueTracker.impl.IssueProviderWrapper
-
- All Implemented Interfaces:
IssueBatchProviderSupport
,IssueProvider
,IssueProviderEx
,SIssueProvider
public class IssueProviderWrapper extends Object implements IssueProviderEx
- Author:
- Maxim Podkolzine (maxim.podkolzine@jetbrains.com)
-
-
Field Summary
-
Fields inherited from interface jetbrains.buildServer.issueTracker.IssueProvider
SECURE_PROPERTY_PREFIX
-
-
Constructor Summary
Constructors Constructor Description IssueProviderWrapper(SIssueProvider delegate, String id, SProject project)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
describeError(RetrieveIssueException e)
Returns a human-readable description of theRetrieveIssueException
error.void
dispose()
Disposes the provider (releases all necessary resources, dumps caches on disk, etc).boolean
equals(Object o)
IssueData
findIssueById(String id)
Returns the issue by the specified id.Map<String,IssueData>
findIssuesByIds(Collection<String> ids)
Finds and returns the specified collection of issue ids.IssueData
findPossiblyExpiredIssue(String id)
Returns the issue data corresponding to theid
.SIssueProvider
getActualProvider()
Unwraps this provider and returns actual provider instance.Set<String>
getAssociatedProjects()
Returns the list of project internal ids associated with this provider.CommentTransformationHelper
getCommentTransformationHelper()
Returns the instance of helper class to support comment transformation (i.e.String
getConfigurationSummary()
Returns the basic summary of current configuration, for instance, "Jira" provider might return:"Projects: P1, P2"
.String
getId()
Returns a short id of the provider, e.g.String
getName()
Returns the name of the issue tracking system corresponding to this provider.SProject
getProject()
Returns project to which current issue provider belongsMap<String,String>
getProperties()
Returns the map of provider properties.PropertiesProcessor
getPropertiesProcessor()
Returns the properties processor instance (validator).Collection<IssueMention>
getRelatedIssues(String comment)
Returns the collection of issues related, or mentioned in the comment.Collection<IssueMention>
getRelatedIssues(VcsModification modification)
Returns the collection of issues related to a modification.IssueTestConnectionSupport
getTestConnectionSupport()
Returns the test connection support.String
getType()
Returns the type of this provider (the type of the corresponding factory).String
getUrl()
Returns the provider's URL, e.g.String
getUsername()
Returns the username configured for the provider, or empty string if not set.int
hashCode()
boolean
isApplicableInProjectFreeContext()
Returns whether the provider can be applied in the context without any project.boolean
isBatchFetchSupported()
Returns whether the issue provider supports fetching in batch.boolean
isFailedToFetch(String id)
Returns whether the issue could not be fetched due to error.boolean
isFetched(String id)
Returns whether the issue is fetched and can be efficiently returned usingIssueProvider.findIssueById(String)
method.boolean
isHasRelatedIssues(String comment)
Returns whether there are related issues in the specifiedcomment
.boolean
isHasRelatedIssues(VcsModification modification)
Returns whether there are related issues in the specifiedmodification
.void
setProperties(Map<String,String> map)
Sets the provider properties (seeIssueProvider.getProperties()
method for the details).String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.issueTracker.SIssueProvider
getAdditionalTestData
-
-
-
-
Constructor Detail
-
IssueProviderWrapper
public IssueProviderWrapper(@NotNull SIssueProvider delegate, @NotNull String id, @NotNull SProject project)
-
-
Method Detail
-
getActualProvider
@NotNull public SIssueProvider getActualProvider()
Description copied from interface:IssueProviderEx
Unwraps this provider and returns actual provider instance.- Specified by:
getActualProvider
in interfaceIssueProviderEx
- Returns:
- actual
SIssueProvider
instance
-
getId
@NotNull public String getId()
Description copied from interface:IssueProviderEx
Returns a short id of the provider, e.g. "jira", "bugzilla", "youtrack", etc. The id is unique, immutable and consists of alpha-numeric characters.- Specified by:
getId
in interfaceIssueProviderEx
- Returns:
- provider id
-
getName
@NotNull public String getName()
Description copied from interface:IssueProviderEx
Returns the name of the issue tracking system corresponding to this provider.- Specified by:
getName
in interfaceIssueProviderEx
- Returns:
- provider name
-
getUrl
@NotNull public String getUrl()
Description copied from interface:IssueProviderEx
Returns the provider's URL, e.g. "http://www.jetbrains.net/tracker/".- Specified by:
getUrl
in interfaceIssueProviderEx
- Returns:
- provider's url
-
getProject
@NotNull public SProject getProject()
Description copied from interface:IssueProviderEx
Returns project to which current issue provider belongs- Specified by:
getProject
in interfaceIssueProviderEx
- Returns:
- id of the project
-
getUsername
@NotNull public String getUsername()
Description copied from interface:IssueProviderEx
Returns the username configured for the provider, or empty string if not set.- Specified by:
getUsername
in interfaceIssueProviderEx
- Returns:
- provider's username
-
describeError
@NotNull public String describeError(@NotNull RetrieveIssueException e)
Description copied from interface:IssueProviderEx
Returns a human-readable description of theRetrieveIssueException
error.- Specified by:
describeError
in interfaceIssueProviderEx
- Parameters:
e
- exception to describe- Returns:
- a string description
-
getType
@NotNull public String getType()
Description copied from interface:IssueProvider
Returns the type of this provider (the type of the corresponding factory). The type is immutable and consists of alpha-numeric characters.- Specified by:
getType
in interfaceIssueProvider
- Returns:
- provider type
-
getRelatedIssues
@NotNull public Collection<IssueMention> getRelatedIssues(@NotNull String comment)
Description copied from interface:IssueProvider
Returns the collection of issues related, or mentioned in the comment. The relation can be defined by a mention in the text (a mention means thatcomment
contains the substring that matches a certain pattern), or by any way the plugin chooses.- Specified by:
getRelatedIssues
in interfaceIssueProvider
- Parameters:
comment
- the comment- Returns:
- collection of related issues
- See Also:
IssueProvider.isHasRelatedIssues(String)
-
isHasRelatedIssues
public boolean isHasRelatedIssues(@NotNull String comment)
Description copied from interface:IssueProvider
Returns whether there are related issues in the specifiedcomment
. The relation can be defined by a mention in the text (a mention means thatcomment
contains the substring that matches a certain pattern), or by any way the plugin chooses.- Specified by:
isHasRelatedIssues
in interfaceIssueProvider
- Parameters:
comment
- the comment- Returns:
- true if the comment has related issues
- See Also:
IssueProvider.getRelatedIssues(String)
-
getRelatedIssues
@NotNull public Collection<IssueMention> getRelatedIssues(@NotNull VcsModification modification)
Description copied from interface:IssueProvider
Returns the collection of issues related to a modification. In most cases the relation is defined via mentioning the issue id in the modification comment, but could also be some extra field in VCS commit.- Specified by:
getRelatedIssues
in interfaceIssueProvider
- Parameters:
modification
- VCS modification- Returns:
- collection of related issues
- See Also:
IssueProvider.isHasRelatedIssues(jetbrains.buildServer.vcs.VcsModification)
-
isHasRelatedIssues
public boolean isHasRelatedIssues(@NotNull VcsModification modification)
Description copied from interface:IssueProvider
Returns whether there are related issues in the specifiedmodification
. In most cases the relation is defined via mentioning the issue id in the modification comment, but could also be some extra field in VCS commit.- Specified by:
isHasRelatedIssues
in interfaceIssueProvider
- Parameters:
modification
- a VCS modification- Returns:
- true if the modification has related issues
- See Also:
IssueProvider.getRelatedIssues(jetbrains.buildServer.vcs.VcsModification)
-
findIssueById
public IssueData findIssueById(@NotNull String id)
Description copied from interface:IssueProvider
Returns the issue by the specified id. Returned data isn't expected to be up-to-date, i.e. fetched from the ITS at the moment of call.The implementors are encouraged to report retrieving errors by throwing
RetrieveIssueException
, rather than simply returnnull
:NotFoundException
when the issue cannot be found,UnsupportedException
when the issue tracker protocol is not supported, etc.- Specified by:
findIssueById
in interfaceIssueProvider
- Parameters:
id
- issue id- Returns:
- the corresponding issue, or
null
if the issue cannot be retrieved
-
isBatchFetchSupported
public boolean isBatchFetchSupported()
Description copied from interface:IssueBatchProviderSupport
Returns whether the issue provider supports fetching in batch.Note: the method is always fast.
- Specified by:
isBatchFetchSupported
in interfaceIssueBatchProviderSupport
- Returns:
- true if the issue provider supports fetching in batch
-
findIssuesByIds
public Map<String,IssueData> findIssuesByIds(@NotNull Collection<String> ids)
Description copied from interface:IssueBatchProviderSupport
Finds and returns the specified collection of issue ids. If current provider does not support batch fetching,null
is returned.Note: the method is not necessarily fast, and should be called in a separate issue.
- Specified by:
findIssuesByIds
in interfaceIssueBatchProviderSupport
- Parameters:
ids
- the collection of issue ids to fetch- Returns:
- the map
issue id -> issue data
, ornull
-
getProperties
@NotNull public Map<String,String> getProperties()
Description copied from interface:IssueProvider
Returns the map of provider properties. This map includes all fields that are configured in admin UI and stored in TeamCity config file (e.g. credentials used in all communications with remote server, server url, etc, but not the id or type).The keys should consist of alphanumeric characters and start with a letter.
- Specified by:
getProperties
in interfaceIssueProvider
- Returns:
- the properties map
-
isFetched
public boolean isFetched(@NotNull String id)
Description copied from interface:SIssueProvider
Returns whether the issue is fetched and can be efficiently returned usingIssueProvider.findIssueById(String)
method.- Specified by:
isFetched
in interfaceSIssueProvider
- Parameters:
id
- the issue id- Returns:
- true if the issue is fetched
- See Also:
SIssueProvider.isFailedToFetch(String)
-
findPossiblyExpiredIssue
public IssueData findPossiblyExpiredIssue(@NotNull String id)
Description copied from interface:SIssueProvider
Returns the issue data corresponding to theid
.The main difference from
IssueProvider.findIssueById(String)
method is that method must be always fast (should use only cached data) and the result data isn't expected to be up-to-date. So this method should return the issue data if by chance it can be retrieved fast, even if a provider considers it out-dated andIssueProvider.findIssueById(String)
method would make an extra call to the issue-tracking system.The simplest (100% legal) implementation of this method:
public IssueData findPossiblyExpiredIssue(@NotNull String id) { return null; }
This way TeamCity will always show 'Retrieving...' message, when the issue isn't fetched (seeSIssueProvider.isFetched(String)
).- Specified by:
findPossiblyExpiredIssue
in interfaceSIssueProvider
- Parameters:
id
- the issue id- Returns:
- issue data, or
null
if the it cannot be returned efficiently
-
isFailedToFetch
public boolean isFailedToFetch(@NotNull String id)
Description copied from interface:SIssueProvider
Returns whether the issue could not be fetched due to error.In case of
true
, the issue data isn't in a cache (i.e.isFetched(id) == false
), but the error is.- Specified by:
isFailedToFetch
in interfaceSIssueProvider
- Parameters:
id
- the issue id- Returns:
- true if issue could not be fetched
- See Also:
SIssueProvider.isFetched(String)
-
getPropertiesProcessor
@NotNull public PropertiesProcessor getPropertiesProcessor()
Description copied from interface:SIssueProvider
Returns the properties processor instance (validator).It is guaranteed that
IssueProvider.setProperties(java.util.Map)
method is called only if the processor finds no errors.- Specified by:
getPropertiesProcessor
in interfaceSIssueProvider
- Returns:
- properties processor
-
getTestConnectionSupport
@NotNull public IssueTestConnectionSupport getTestConnectionSupport()
Description copied from interface:SIssueProvider
Returns the test connection support.- Specified by:
getTestConnectionSupport
in interfaceSIssueProvider
- Returns:
- test connection support
-
getConfigurationSummary
public String getConfigurationSummary()
Description copied from interface:SIssueProvider
Returns the basic summary of current configuration, for instance, "Jira" provider might return:"Projects: P1, P2"
.- Specified by:
getConfigurationSummary
in interfaceSIssueProvider
- Returns:
- provider configuration summary, or null
-
setProperties
public void setProperties(@NotNull Map<String,String> map)
Description copied from interface:IssueProvider
Sets the provider properties (seeIssueProvider.getProperties()
method for the details).Few words about thread-safety: properties can be changed from the admin UI, or in config file. By any of these events this method is called (synchronously). Hence this method should lock any other API method.
- Specified by:
setProperties
in interfaceIssueProvider
- Parameters:
map
- a properties map- See Also:
IssueProvider.getProperties()
-
dispose
public void dispose()
Description copied from interface:IssueProvider
Disposes the provider (releases all necessary resources, dumps caches on disk, etc). This method is called when the provider is deleted from the system, and on server shutdown.- Specified by:
dispose
in interfaceIssueProvider
-
getCommentTransformationHelper
public CommentTransformationHelper getCommentTransformationHelper()
Description copied from interface:IssueProvider
Returns the instance of helper class to support comment transformation (i.e. automatic replacement of issues, mentioned in a comment, with a link and a popup).- Specified by:
getCommentTransformationHelper
in interfaceIssueProvider
- Returns:
- a helper, or null
-
getAssociatedProjects
@Nullable public Set<String> getAssociatedProjects()
Description copied from interface:IssueProviderEx
Returns the list of project internal ids associated with this provider. If the value is notnull
, the provider will only be applied to returned projects. If the value isnull
, all projects are applied.Compatibility: in earlier TeamCity versions the effective value used in
null
.- Specified by:
getAssociatedProjects
in interfaceIssueProviderEx
- Returns:
- list of associated project internal ids, or
null
-
isApplicableInProjectFreeContext
public boolean isApplicableInProjectFreeContext()
Description copied from interface:IssueProviderEx
Returns whether the provider can be applied in the context without any project.Compatibility: in earlier TeamCity versions the effective value used is
true
.- Specified by:
isApplicableInProjectFreeContext
in interfaceIssueProviderEx
- Returns:
- true iff the provider is applicable in the project-free context
-
-