This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.21.x by this push:
new f3eb56c817d Fix camel-jira to add assignee using the id (#10602)
(#10613)
f3eb56c817d is described below
commit f3eb56c817d4b0f1e52c0870725bd88c73160845
Author: Claudio Miranda <[email protected]>
AuthorDate: Fri Jul 7 02:47:09 2023 -0300
Fix camel-jira to add assignee using the id (#10602) (#10613)
- Jira cloud service requires the user id instead of the user name for the
assignee
field
- Adds more context about the authentication using personal token
(cherry picked from commit c3f69b44287eea53471b87b49b5a01d61d33449c)
---
.../org/apache/camel/catalog/components/jira.json | 1 +
.../apache/camel/catalog/schemas/camel-spring.xsd | 2 +-
.../org/apache/camel/component/jira/jira.json | 1 +
.../camel-jira/src/main/docs/jira-component.adoc | 21 +++++++++++++--------
.../apache/camel/component/jira/JiraConstants.java | 2 ++
.../component/jira/producer/AddIssueProducer.java | 7 +++++++
.../jira/producer/UpdateIssueProducer.java | 8 ++++++++
7 files changed, 33 insertions(+), 9 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jira.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jira.json
index 13fe6a3a1e6..504a3275a4a 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jira.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/jira.json
@@ -36,6 +36,7 @@
"verificationCode": { "kind": "property", "displayName": "Verification
Code", "group": "security", "label": "security", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": true, "configurationClass":
"org.apache.camel.component.jira.JiraConfiguration", "configurationField":
"configuration", "description": "(OAuth only) The verification code from Jira
generated in the first step of the authorization proccess." }
},
"headers": {
+ "IssueAssigneeId": { "kind": "header", "displayName": "", "group":
"producer", "label": "producer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The assignee's id of the issue", "constantName":
"org.apache.camel.component.jira.JiraConstants#ISSUE_ASSIGNEE_ID" },
"IssueAssignee": { "kind": "header", "displayName": "", "group":
"producer", "label": "producer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The assignee's name of the issue", "constantName":
"org.apache.camel.component.jira.JiraConstants#ISSUE_ASSIGNEE" },
"IssueComponents": { "kind": "header", "displayName": "", "group":
"producer", "label": "producer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The comma separated list of the issue's components",
"constantName":
"org.apache.camel.component.jira.JiraConstants#ISSUE_COMPONENTS" },
"IssueChanged": { "kind": "header", "displayName": "", "group":
"consumer", "label": "consumer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of the updated field (i.e Status)",
"constantName": "org.apache.camel.component.jira.JiraConstants#ISSUE_CHANGED" },
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index eef5f6cdb6f..78bd105bf59 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -489,7 +489,7 @@ Enriches a message with data from a secondary resource
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[
-Camel error handling.
+Error handler settings
]]>
</xs:documentation>
</xs:annotation>
diff --git
a/components/camel-jira/src/generated/resources/org/apache/camel/component/jira/jira.json
b/components/camel-jira/src/generated/resources/org/apache/camel/component/jira/jira.json
index 13fe6a3a1e6..504a3275a4a 100644
---
a/components/camel-jira/src/generated/resources/org/apache/camel/component/jira/jira.json
+++
b/components/camel-jira/src/generated/resources/org/apache/camel/component/jira/jira.json
@@ -36,6 +36,7 @@
"verificationCode": { "kind": "property", "displayName": "Verification
Code", "group": "security", "label": "security", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": true, "configurationClass":
"org.apache.camel.component.jira.JiraConfiguration", "configurationField":
"configuration", "description": "(OAuth only) The verification code from Jira
generated in the first step of the authorization proccess." }
},
"headers": {
+ "IssueAssigneeId": { "kind": "header", "displayName": "", "group":
"producer", "label": "producer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The assignee's id of the issue", "constantName":
"org.apache.camel.component.jira.JiraConstants#ISSUE_ASSIGNEE_ID" },
"IssueAssignee": { "kind": "header", "displayName": "", "group":
"producer", "label": "producer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The assignee's name of the issue", "constantName":
"org.apache.camel.component.jira.JiraConstants#ISSUE_ASSIGNEE" },
"IssueComponents": { "kind": "header", "displayName": "", "group":
"producer", "label": "producer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The comma separated list of the issue's components",
"constantName":
"org.apache.camel.component.jira.JiraConstants#ISSUE_COMPONENTS" },
"IssueChanged": { "kind": "header", "displayName": "", "group":
"consumer", "label": "consumer", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of the updated field (i.e Status)",
"constantName": "org.apache.camel.component.jira.JiraConstants#ISSUE_CHANGED" },
diff --git a/components/camel-jira/src/main/docs/jira-component.adoc
b/components/camel-jira/src/main/docs/jira-component.adoc
index 67f5e473827..15effcdbeb5 100644
--- a/components/camel-jira/src/main/docs/jira-component.adoc
+++ b/components/camel-jira/src/main/docs/jira-component.adoc
@@ -90,13 +90,17 @@ You can bind the `JiraRestClientFactory` with name
*JiraRestClientFactory* in th
== Authentication
-Camel-jira supports
*https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/[Basic
Authentication]*,
*https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/[OAuth
3 legged authentication]* and
*https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html*.
+Camel-jira supports the following forms of authentication:
-We recommend to use OAuth whenever possible, as it provides the best security
for your users and system.
+*
https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/[Basic
Authentication]
+*
https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-oauth-authentication/[OAuth
3 legged authentication]
+*
https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html[Personal
Token]*
+
+We recommend to use OAuth or Personal token whenever possible, as it provides
the best security for your users and system.
=== Basic authentication requirements:
-* An username and a password or the API Token. Verify if the Jira server
installation supports the use of
https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/[API
Tokens] instead of the user's password. This way the user's password is not
exposed.
+* An username and a password.
=== OAuth authentication requirements:
@@ -110,10 +114,9 @@ to generate the client private key, consumer key,
verification code and access t
=== Personal access token authentication requirements:
-Follow the tutorial in
https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html
-to generate an access token bearer.
+Follow the tutorial to generate the
https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html[Personal
Token].
-* An access token
+* You have to set only the personal token in the `access-token` parameter.
== JQL:
@@ -168,9 +171,10 @@ Required:
Optional:
* `IssueAssignee`: the assignee user
+* `IssueAssigneeId`: the assignee user id
* `IssuePriorityId` or `IssuePriorityName`: The priority of the issue, you can
see the valid list in `\http://jira_server/rest/api/2/priority`.
* `IssueComponents`: A list of string with the valid component names.
-* `IssueWatchersAdd`: A list of strings with the usernames to add to the
watcher list.
+* `IssueWatchersAdd`: A list of strings with the usernames (or id) to add to
the watcher list.
* `IssueDescription`: The description of the issue.
== AddComment
@@ -209,6 +213,7 @@ Required:
* `IssueTypeId` or `IssueTypeName`: The `id` of the issue type or the name of
the issue type, you can see the valid list in
`\http://jira_server/rest/api/2/issue/createmeta?projectKeys=SAMPLE_KEY`.
* `IssueSummary`: The summary of the issue.
* `IssueAssignee`: the assignee user
+* `IssueAssigneeId`: the assignee user id
* `IssuePriorityId` or `IssuePriorityName`: The priority of the issue, you can
see the valid list in `\http://jira_server/rest/api/2/priority`.
* `IssueComponents`: A list of string with the valid component names.
* `IssueDescription`: The description of the issue.
@@ -216,7 +221,7 @@ Required:
== Watcher
* `IssueKey`: The issue key identifier.
-* `IssueWatchersAdd`: A list of strings with the usernames to add to the
watcher list.
+* `IssueWatchersAdd`: A list of strings with the usernames (or id) to add to
the watcher list.
* `IssueWatchersRemove`: A list of strings with the usernames to remove from
the watcher list.
== WatchUpdates (consumer)
diff --git
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConstants.java
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConstants.java
index e7413958b3d..bf45041aade 100644
---
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConstants.java
+++
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/JiraConstants.java
@@ -26,6 +26,8 @@ public interface JiraConstants {
String JIRA_URL = "jiraUrl";
String PRIVATE_KEY = "privateKey";
String CONSUMER_KEY = "consumerKey";
+ @Metadata(label = "producer", description = "The assignee's id of the
issue", javaType = "String")
+ String ISSUE_ASSIGNEE_ID = "IssueAssigneeId";
@Metadata(label = "producer", description = "The assignee's name of the
issue", javaType = "String")
String ISSUE_ASSIGNEE = "IssueAssignee";
@Metadata(label = "producer", description = "The comma separated list of
the issue's components", javaType = "String")
diff --git
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AddIssueProducer.java
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AddIssueProducer.java
index 3c21bc365c2..82d3f29654e 100644
---
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AddIssueProducer.java
+++
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/AddIssueProducer.java
@@ -23,8 +23,11 @@ import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.domain.BasicIssue;
import com.atlassian.jira.rest.client.api.domain.Issue;
+import com.atlassian.jira.rest.client.api.domain.IssueFieldId;
import com.atlassian.jira.rest.client.api.domain.IssueType;
import com.atlassian.jira.rest.client.api.domain.Priority;
+import
com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue;
+import com.atlassian.jira.rest.client.api.domain.input.FieldInput;
import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder;
import org.apache.camel.Exchange;
import org.apache.camel.component.jira.JiraEndpoint;
@@ -50,6 +53,7 @@ public class AddIssueProducer extends DefaultProducer {
String summary = exchange.getIn().getHeader(ISSUE_SUMMARY,
String.class);
// optional fields
String assigneeName = exchange.getIn().getHeader(ISSUE_ASSIGNEE,
String.class);
+ String assigneeId = exchange.getIn().getHeader(ISSUE_ASSIGNEE_ID,
String.class);
String priorityName = exchange.getIn().getHeader(ISSUE_PRIORITY_NAME,
String.class);
Long priorityId = exchange.getIn().getHeader(ISSUE_PRIORITY_ID,
Long.class);
String components = exchange.getIn().getHeader(ISSUE_COMPONENTS,
String.class);
@@ -105,6 +109,9 @@ public class AddIssueProducer extends DefaultProducer {
}
if (assigneeName != null) {
builder.setAssigneeName(assigneeName);
+ } else if (assigneeId != null) {
+ builder.setFieldInput(
+ new FieldInput(IssueFieldId.ASSIGNEE_FIELD,
ComplexIssueInputFieldValue.with("id", assigneeId)));
}
IssueRestClient issueClient = client.getIssueClient();
diff --git
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
index e0d8fd04542..f54a15647a7 100644
---
a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
+++
b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
@@ -21,8 +21,11 @@ import java.util.List;
import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClient;
+import com.atlassian.jira.rest.client.api.domain.IssueFieldId;
import com.atlassian.jira.rest.client.api.domain.IssueType;
import com.atlassian.jira.rest.client.api.domain.Priority;
+import
com.atlassian.jira.rest.client.api.domain.input.ComplexIssueInputFieldValue;
+import com.atlassian.jira.rest.client.api.domain.input.FieldInput;
import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder;
import org.apache.camel.Exchange;
import org.apache.camel.component.jira.JiraEndpoint;
@@ -30,6 +33,7 @@ import org.apache.camel.support.DefaultProducer;
import org.apache.camel.util.ObjectHelper;
import static org.apache.camel.component.jira.JiraConstants.ISSUE_ASSIGNEE;
+import static org.apache.camel.component.jira.JiraConstants.ISSUE_ASSIGNEE_ID;
import static org.apache.camel.component.jira.JiraConstants.ISSUE_COMPONENTS;
import static org.apache.camel.component.jira.JiraConstants.ISSUE_KEY;
import static org.apache.camel.component.jira.JiraConstants.ISSUE_PRIORITY_ID;
@@ -56,6 +60,7 @@ public class UpdateIssueProducer extends DefaultProducer {
String issueTypeName = exchange.getIn().getHeader(ISSUE_TYPE_NAME,
String.class);
String summary = exchange.getIn().getHeader(ISSUE_SUMMARY,
String.class);
String assigneeName = exchange.getIn().getHeader(ISSUE_ASSIGNEE,
String.class);
+ String assigneeId = exchange.getIn().getHeader(ISSUE_ASSIGNEE_ID,
String.class);
String priorityName = exchange.getIn().getHeader(ISSUE_PRIORITY_NAME,
String.class);
Long priorityId = exchange.getIn().getHeader(ISSUE_PRIORITY_ID,
Long.class);
String components = exchange.getIn().getHeader(ISSUE_COMPONENTS,
String.class);
@@ -101,6 +106,9 @@ public class UpdateIssueProducer extends DefaultProducer {
}
if (assigneeName != null) {
builder.setAssigneeName(assigneeName);
+ } else if (assigneeId != null) {
+ builder.setFieldInput(
+ new FieldInput(IssueFieldId.ASSIGNEE_FIELD,
ComplexIssueInputFieldValue.with("id", assigneeId)));
}
IssueRestClient issueClient = client.getIssueClient();
issueClient.updateIssue(issueKey, builder.build()).claim();