Class JiraIssueUtils
- java.lang.Object
-
- com.atlassian.bamboo.jira.jiraissues.JiraIssueUtils
-
- All Implemented Interfaces:
JiraIssueHelper
public class JiraIssueUtils extends Object implements JiraIssueHelper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JiraIssueUtils.JiraPanel
-
Field Summary
Fields Modifier and Type Field Description static Pattern
LENIENT_ISSUE_KEY_BOUNDARY_REGEX
static String
PROJECT_ISSUE_NUMBER_SEPARATOR
static String
RENDERED_JIRA_KEY
static String
RENDERED_JIRA_KEY_NO_SERVER
static Pattern
RESTRICTIVE_ISSUE_KEY_BOUNDARY_REGEX
-
Constructor Summary
Constructors Constructor Description JiraIssueUtils(JiraApplinksService jiraApplinksService, ResultsSummaryManager resultsSummaryManager, com.atlassian.event.api.EventPublisher eventPublisher, AdministrationConfigurationAccessor administrationConfigurationAccessor, LinkedJiraIssueDao linkedJiraIssueDao)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Function<JiraXmlSearchResultItemEntity,JiraIssueDetails>
buildJiraIssueDetailsFromSearchResultFunction(@NotNull com.atlassian.applinks.api.ApplicationLink applicationLink, JiraIssueDetailsBuilderFactory jiraIssueDetailsBuilderFactory)
Returns function which buildsJiraIssueDetails
from JIRA XML search resultvoid
findAndSaveJiraIssueKeys(@NotNull String string, @NotNull ResultsSummary buildResultsSummary)
Finds any jira issue keys in the given input string, and saves them against the given build result summary.@NotNull LinkedHashSet<String>
findIssueKeys(String string, boolean ignoreIfInUrl, Pattern issueKeyBoundaryRegex)
Deprecated.since 6.5 usefindPotentialIssueKeys(String, boolean, Pattern, Pattern)
instead@NotNull Set<String>
findIssueKeysInText(@NotNull String string)
Find the JIRA issue keys within the given string.@NotNull Set<String>
findIssueKeysInText(@NotNull String string, boolean ignoreIfInUrl)
Find the JIRA issue keys within the given string.@NotNull List<String>
findIssueKeysInTextAsList(@NotNull String string, boolean ignoreIfInUrl)
Find the JIRA issue keys within the given string.@NotNull List<String>
findIssueKeysInTextAsList(@NotNull String string, boolean ignoreIfInUrl, @NotNull Pattern issueKeyBoundaryRegex)
Find the JIRA issue keys within the given string.@NotNull LinkedHashSet<String>
findPotentialIssueKeys(String string, boolean ignoreIfInUrl, Pattern issueKeyLeftBoundaryRegex, Pattern issueKeyRightBoundaryRegex)
Find the JIRA issue keys within the given string.@NotNull List<LinkedJiraIssue>
getFilteredFixedJiraIssues(@Nullable Collection<LinkedJiraIssue> possibleIssues, int numberNeeded)
@NotNull List<LinkedJiraIssue>
getFilteredJiraIssues(@Nullable Collection<LinkedJiraIssue> possibleIssues, int numberNeeded)
Returns a required length list of jira issues and controls logic behind which are shown * Fixed issues are given preference@NotNull List<LinkedJiraIssue>
getFilteredRelatedJiraIssues(@Nullable Collection<LinkedJiraIssue> possibleIssues, int numberNeeded)
@NotNull Set<LinkedJiraIssue>
getFixedJiraIssues(@NotNull Iterable<LinkedJiraIssue> allIssues)
returns a set of all jira issues with link type 'fixed'static JiraIssueUtils
getFreemarkerInstance()
static @Nullable String
getJiraDisplayUrl(@NotNull com.atlassian.applinks.api.ApplicationLink applicationLink, @NotNull String issueKey)
protected String
getJiraIssueTitleText()
static @NotNull String
getJiraIssueUrl(@NotNull String host, @NotNull JiraIssueKey issueKey, @Nullable JiraIssueUtils.JiraPanel panel)
static @Nullable String
getJiraUrl(@NotNull com.atlassian.applinks.api.ApplicationLink applicationLink, @NotNull String issueKey)
@NotNull Set<LinkedJiraIssue>
getRelatedJiraIssues(@NotNull Iterable<LinkedJiraIssue> allIssues)
returns a set of all jira issues with link type 'related'@Nullable String
getRenderedString(@Nullable String inputString)
Renders any jira links within the input string@Nullable String
getRenderedString(@Nullable String inputString, @NotNull DeploymentVersion deploymentVersion)
Renders valid jira issues in the input string, valid issues are determined by what is stored in the DeploymentVersion@Nullable String
getRenderedString(@Nullable String inputString, @NotNull ImmutableResultsSummary resultsSummary)
Renders valid jira issues in the input string, valid issues are determined by what is stored in the BuildResultSummary@Nullable String
getRenderedString(@Nullable String inputString, @NotNull String buildKey, @NotNull Integer buildNumber)
Renders valid jira issues in the input string, valid issues are determined by what is stored in the BuildResultSummaryboolean
isJiraServerSetup()
Whether any JIRA server is linked with this instance of Bamboo.boolean
isValidIssueKey(@NotNull String string)
Checks whether a given string could be a valid issue key.void
setAdministrationConfigurationAccessor(AdministrationConfigurationAccessor administrationConfigurationAccessor)
static Function<InternalLinkedJiraIssue,String>
transformJiraIssueToJiraIssueKey()
-
-
-
Field Detail
-
RESTRICTIVE_ISSUE_KEY_BOUNDARY_REGEX
public static final Pattern RESTRICTIVE_ISSUE_KEY_BOUNDARY_REGEX
-
LENIENT_ISSUE_KEY_BOUNDARY_REGEX
public static final Pattern LENIENT_ISSUE_KEY_BOUNDARY_REGEX
-
PROJECT_ISSUE_NUMBER_SEPARATOR
public static final String PROJECT_ISSUE_NUMBER_SEPARATOR
- See Also:
- Constant Field Values
-
RENDERED_JIRA_KEY
public static final String RENDERED_JIRA_KEY
- See Also:
- Constant Field Values
-
RENDERED_JIRA_KEY_NO_SERVER
public static final String RENDERED_JIRA_KEY_NO_SERVER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JiraIssueUtils
public JiraIssueUtils(JiraApplinksService jiraApplinksService, ResultsSummaryManager resultsSummaryManager, com.atlassian.event.api.EventPublisher eventPublisher, AdministrationConfigurationAccessor administrationConfigurationAccessor, LinkedJiraIssueDao linkedJiraIssueDao)
-
-
Method Detail
-
getFreemarkerInstance
public static JiraIssueUtils getFreemarkerInstance()
-
findAndSaveJiraIssueKeys
public void findAndSaveJiraIssueKeys(@NotNull @NotNull String string, @NotNull @NotNull ResultsSummary buildResultsSummary)
Finds any jira issue keys in the given input string, and saves them against the given build result summary.- Parameters:
string
-buildResultsSummary
-
-
isValidIssueKey
public boolean isValidIssueKey(@NotNull @NotNull String string)
Description copied from interface:JiraIssueHelper
Checks whether a given string could be a valid issue key.- Specified by:
isValidIssueKey
in interfaceJiraIssueHelper
-
getFixedJiraIssues
@NotNull public @NotNull Set<LinkedJiraIssue> getFixedJiraIssues(@NotNull @NotNull Iterable<LinkedJiraIssue> allIssues)
returns a set of all jira issues with link type 'fixed'- Parameters:
allIssues
-- Returns:
-
getRelatedJiraIssues
@NotNull public @NotNull Set<LinkedJiraIssue> getRelatedJiraIssues(@NotNull @NotNull Iterable<LinkedJiraIssue> allIssues)
returns a set of all jira issues with link type 'related'- Parameters:
allIssues
-- Returns:
-
findIssueKeysInText
@NotNull public @NotNull Set<String> findIssueKeysInText(@NotNull @NotNull String string)
Description copied from interface:JiraIssueHelper
Find the JIRA issue keys within the given string.- Specified by:
findIssueKeysInText
in interfaceJiraIssueHelper
- Parameters:
string
- text to search- Returns:
- JIRA issue keys in order of appearance in the string
-
findIssueKeysInText
@NotNull public @NotNull Set<String> findIssueKeysInText(@NotNull @NotNull String string, boolean ignoreIfInUrl)
Description copied from interface:JiraIssueHelper
Find the JIRA issue keys within the given string.- Specified by:
findIssueKeysInText
in interfaceJiraIssueHelper
- Parameters:
string
- text to searchignoreIfInUrl
- whether to ignore found keys if they're part of URLs- Returns:
- JIRA issue keys in order of appearance in the string
-
findIssueKeys
@NotNull @Deprecated public @NotNull LinkedHashSet<String> findIssueKeys(String string, boolean ignoreIfInUrl, Pattern issueKeyBoundaryRegex)
Deprecated.since 6.5 usefindPotentialIssueKeys(String, boolean, Pattern, Pattern)
insteadFind the JIRA issue keys within the given string. Preserves the order they were found in.- Parameters:
string
-ignoreIfInUrl
-- Returns:
- An ordered set of JIRA Issue Keys
-
findPotentialIssueKeys
@NotNull public @NotNull LinkedHashSet<String> findPotentialIssueKeys(String string, boolean ignoreIfInUrl, Pattern issueKeyLeftBoundaryRegex, Pattern issueKeyRightBoundaryRegex)
Description copied from interface:JiraIssueHelper
Find the JIRA issue keys within the given string. Preserves the order they were found in.- Specified by:
findPotentialIssueKeys
in interfaceJiraIssueHelper
-
findIssueKeysInTextAsList
@NotNull public @NotNull List<String> findIssueKeysInTextAsList(@NotNull @NotNull String string, boolean ignoreIfInUrl)
Description copied from interface:JiraIssueHelper
Find the JIRA issue keys within the given string. Maintains the order they were found in. Does not contain duplicates.- Specified by:
findIssueKeysInTextAsList
in interfaceJiraIssueHelper
- Parameters:
string
- text to searchignoreIfInUrl
- whether to ignore found keys if they're part of URLs- Returns:
- A list of JIRA issue keys
-
findIssueKeysInTextAsList
@NotNull public @NotNull List<String> findIssueKeysInTextAsList(@NotNull @NotNull String string, boolean ignoreIfInUrl, @NotNull @NotNull Pattern issueKeyBoundaryRegex)
Description copied from interface:JiraIssueHelper
Find the JIRA issue keys within the given string. Maintains the order they were found in. Does not contain duplicates.This method accepts a
Pattern
as a parameter to test characters before and after discovered issue key, in order to adjust sensitivity of the search. As an example, for text "CR-BAM-1534", if the character "-" is disallowed by the boundary regex, the key "BAM-1534" will not be returned (as the "-" character is present in the text just before the key).- Specified by:
findIssueKeysInTextAsList
in interfaceJiraIssueHelper
- Parameters:
string
- text to searchignoreIfInUrl
- whether to ignore found keys if they're part of URLsissueKeyBoundaryRegex
- regular expression which has to match characters before and after discovered issue key, for example "[^a-zA-Z0-9-]"- Returns:
- A list of JIRA issue keys
-
getRenderedString
@Nullable public @Nullable String getRenderedString(@Nullable @Nullable String inputString, @NotNull @NotNull String buildKey, @NotNull @NotNull Integer buildNumber)
Renders valid jira issues in the input string, valid issues are determined by what is stored in the BuildResultSummary- Parameters:
inputString
-buildKey
-buildNumber
-- Returns:
-
getRenderedString
@Nullable public @Nullable String getRenderedString(@Nullable @Nullable String inputString, @NotNull @NotNull ImmutableResultsSummary resultsSummary)
Renders valid jira issues in the input string, valid issues are determined by what is stored in the BuildResultSummary- Parameters:
inputString
-resultsSummary
-- Returns:
-
getRenderedString
@Nullable public @Nullable String getRenderedString(@Nullable @Nullable String inputString, @NotNull @NotNull DeploymentVersion deploymentVersion)
Renders valid jira issues in the input string, valid issues are determined by what is stored in the DeploymentVersion- Parameters:
inputString
-- Returns:
-
getRenderedString
@Nullable public @Nullable String getRenderedString(@Nullable @Nullable String inputString)
Renders any jira links within the input string- Parameters:
inputString
-- Returns:
-
getJiraUrl
@Nullable public static @Nullable String getJiraUrl(@NotNull @NotNull com.atlassian.applinks.api.ApplicationLink applicationLink, @NotNull @NotNull String issueKey)
-
getJiraDisplayUrl
@Nullable public static @Nullable String getJiraDisplayUrl(@NotNull @NotNull com.atlassian.applinks.api.ApplicationLink applicationLink, @NotNull @NotNull String issueKey)
-
getJiraIssueUrl
@NotNull public static @NotNull String getJiraIssueUrl(@NotNull @NotNull String host, @NotNull @NotNull JiraIssueKey issueKey, @Nullable @Nullable JiraIssueUtils.JiraPanel panel)
-
getJiraIssueTitleText
protected String getJiraIssueTitleText()
-
getFilteredJiraIssues
@NotNull public @NotNull List<LinkedJiraIssue> getFilteredJiraIssues(@Nullable @Nullable Collection<LinkedJiraIssue> possibleIssues, int numberNeeded)
Returns a required length list of jira issues and controls logic behind which are shown * Fixed issues are given preferenceThis is needed so that only the required number of JIRA Issues will be retrieved from the jira server
- Parameters:
possibleIssues
-numberNeeded
-- Returns:
-
getFilteredFixedJiraIssues
@NotNull public @NotNull List<LinkedJiraIssue> getFilteredFixedJiraIssues(@Nullable @Nullable Collection<LinkedJiraIssue> possibleIssues, int numberNeeded)
-
getFilteredRelatedJiraIssues
@NotNull public @NotNull List<LinkedJiraIssue> getFilteredRelatedJiraIssues(@Nullable @Nullable Collection<LinkedJiraIssue> possibleIssues, int numberNeeded)
-
isJiraServerSetup
public boolean isJiraServerSetup()
Description copied from interface:JiraIssueHelper
Whether any JIRA server is linked with this instance of Bamboo.- Specified by:
isJiraServerSetup
in interfaceJiraIssueHelper
-
buildJiraIssueDetailsFromSearchResultFunction
public static Function<JiraXmlSearchResultItemEntity,JiraIssueDetails> buildJiraIssueDetailsFromSearchResultFunction(@NotNull @NotNull com.atlassian.applinks.api.ApplicationLink applicationLink, JiraIssueDetailsBuilderFactory jiraIssueDetailsBuilderFactory)
Returns function which buildsJiraIssueDetails
from JIRA XML search result- Returns:
Function
-
transformJiraIssueToJiraIssueKey
public static Function<InternalLinkedJiraIssue,String> transformJiraIssueToJiraIssueKey()
-
setAdministrationConfigurationAccessor
public void setAdministrationConfigurationAccessor(AdministrationConfigurationAccessor administrationConfigurationAccessor)
-
-