Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@throws(classOf[JIRAException])
def getJIRARESTClient(): Option[JiraRestClient] = {
try {
val asyncClientFactory: AsynchronousJiraRestClientFactory = new AsynchronousJiraRestClientFactory()
result = Some(asyncClientFactory.createWithBasicHttpAuthentication(
new URI(baseUrl),
jiraUser,
jiraPwd
))
}catch{
case(e: Exception) => {
logger.error(s"The atlassian jira erest client could not be created. Reason: ${e}")
throw new JIRAException()
}
}
result
}
@throws(classOf[JIRAException])
def createNewJIRAItemAndWriteFeatureInto(rf: RequirementFeature): Unit ={
val defaultIssueType = configuration.envOrElseConfig("data.destination.jira.defaultIssueType")
try{
val issueTypes = client.getMetadataClient.getIssueTypes.claim().asScala
for(it <- issueTypes) yield {
if(it.getName.equals(defaultIssueType)){
val projectId: Long = client.getProjectClient.getProject(rf.projectKey).claim().getId
val newIssueInput: IssueInput = new IssueInputBuilder(rf.projectKey,it.getId, rf.jiraIssue.get.summary).build()
val newIssue: BasicIssue = client.getIssueClient.createIssue(newIssueInput).claim()
updateDescriptionIntoExistingJIRAIssue(updateJIRAItemInRF(newIssue, rf))
}
}
}catch{
case e: Exception => {
logger.error(s"Error trying to create a new JIRA issue. feature: '${rf.name}'. Reason: ${e}")
throw new JIRAException(s"Error trying to create a new JIRA issue. feature: '${rf.name}'. Reason: ${e}")
}
}
}
private def updateJIRAItemInRF(newIssue: BasicIssue, rf: RequirementFeature): RequirementFeature ={
val newJIRAItem: JIRAIssue = new JIRAIssue(newIssue.getId, newIssue.getKey, rf.name)
new RequirementFeature(rf.feature_id, rf.name, rf.projectKey, rf.component, rf.scenarios, Some(newJIRAItem), rf.lastUpdateTime)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.