This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
The following commit(s) were added to refs/heads/main by this push: new 3191408 Introduce params for Jira example (#63) 3191408 is described below commit 31914088c4b55deb9d7de943b61b920e1f2235e8 Author: Marco Carletti <79271996+mcarl...@users.noreply.github.com> AuthorDate: Wed May 25 13:06:15 2022 +0200 Introduce params for Jira example (#63) --- .../java/org/apache/camel/example/jira/AddIssueRoute.java | 14 +++++++++++--- .../org/apache/camel/example/jira/AttachFileRoute.java | 10 +++++++--- .../org/apache/camel/example/jira/NewCommentsRoute.java | 2 +- jira/src/main/resources/application.properties | 7 +++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/jira/src/main/java/org/apache/camel/example/jira/AddIssueRoute.java b/jira/src/main/java/org/apache/camel/example/jira/AddIssueRoute.java index b39a857..d4eba78 100644 --- a/jira/src/main/java/org/apache/camel/example/jira/AddIssueRoute.java +++ b/jira/src/main/java/org/apache/camel/example/jira/AddIssueRoute.java @@ -21,6 +21,7 @@ import java.util.Date; import org.apache.camel.builder.RouteBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import static org.apache.camel.component.jira.JiraConstants.ISSUE_PRIORITY_NAME; @@ -33,14 +34,20 @@ public class AddIssueRoute extends RouteBuilder { private static final Logger LOG = LoggerFactory.getLogger(AddIssueRoute.class); + @Value("${example.jira.project-key}") + private String project; + + @Value("${example.jira.issue-type}") + private String issueType; + @Override public void configure() { LOG.info(" >>>>>>>>>>>>>>>>>>>>> jira example - add new issue"); // change the fields accordingly to your target jira server from("timer://foo?fixedRate=true&period=50000") - .setHeader(ISSUE_PROJECT_KEY, () -> "COM") - .setHeader(ISSUE_TYPE_NAME, () -> "Bug") + .setHeader(ISSUE_PROJECT_KEY, () -> project) + .setHeader(ISSUE_TYPE_NAME, () -> issueType) .setHeader(ISSUE_SUMMARY, () -> "Example Demo Bug jira " + (new Date())) .setHeader(ISSUE_PRIORITY_NAME, () -> "Low") @@ -52,7 +59,8 @@ public class AddIssueRoute extends RouteBuilder { // }) .setBody(constant("A small description for a test issue. ")) .log(" JIRA new issue: ${body}") - .to("jira://addIssue"); + .to("jira://addIssue") + .log("Issue created: ${body.key}"); } } diff --git a/jira/src/main/java/org/apache/camel/example/jira/AttachFileRoute.java b/jira/src/main/java/org/apache/camel/example/jira/AttachFileRoute.java index 2b0ad52..1bfe7b8 100644 --- a/jira/src/main/java/org/apache/camel/example/jira/AttachFileRoute.java +++ b/jira/src/main/java/org/apache/camel/example/jira/AttachFileRoute.java @@ -19,6 +19,7 @@ package org.apache.camel.example.jira; import org.apache.camel.builder.RouteBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import static org.apache.camel.component.jira.JiraConstants.ISSUE_KEY; @@ -28,13 +29,16 @@ public class AttachFileRoute extends RouteBuilder { private static final Logger LOG = LoggerFactory.getLogger(AttachFileRoute.class); + @Value("${example.jira.issue-attach}") + private String issue; + @Override public void configure() { LOG.info(" >>>>>>>>>>>>>>>>>>>>> jira example - add attachment"); // change the fields accordinly to your target jira server - from("file:///A_valid_directory?fileName=my_file.png&noop=true&delay=50000") - .setHeader(ISSUE_KEY, () -> "MYP-13") - .log(" JIRA attach: ${header.camelFileName} to MYP-13") + from("file://{{example.jira.upload-directory}}?fileName={{example.jira.upload-file-name}}&noop=true&delay=50000") + .setHeader(ISSUE_KEY, () -> issue) + .log(" JIRA attach: ${header.camelFileName} to ${headers.IssueKey}") .to("jira://attach"); diff --git a/jira/src/main/java/org/apache/camel/example/jira/NewCommentsRoute.java b/jira/src/main/java/org/apache/camel/example/jira/NewCommentsRoute.java index 0965764..aea74a4 100644 --- a/jira/src/main/java/org/apache/camel/example/jira/NewCommentsRoute.java +++ b/jira/src/main/java/org/apache/camel/example/jira/NewCommentsRoute.java @@ -32,7 +32,7 @@ public class NewCommentsRoute extends RouteBuilder { LOG.info(" >>>>>>>>>>>>>>>>>>>>> jira example - retrieve only new comments"); // change the fields accordinly to your target jira server - from("jira://newComments?jql=RAW(project=COM AND resolution = Unresolved)&delay=4000") + from("jira://newComments?jql=RAW(project={{example.jira.project-key}} AND resolution = Unresolved)&delay=4000") .process(exchange -> { Comment comment = (Comment) exchange.getIn().getBody(); LOG.info("new jira comment id: {} - by: {}: {}", comment.getId(), comment.getAuthor().getDisplayName(), diff --git a/jira/src/main/resources/application.properties b/jira/src/main/resources/application.properties index ed269f7..4a39f2d 100644 --- a/jira/src/main/resources/application.properties +++ b/jira/src/main/resources/application.properties @@ -22,3 +22,10 @@ camel.component.jira.consumer-key=test camel.component.jira.access-token=test camel.component.jira.private-key=test camel.component.jira.jira-url=https\://test.com + +# example specific properties +example.jira.project-key=COM +example.jira.issue-type=Bug +example.jira.upload-directory=/tmp +example.jira.upload-file-name=my_file.png +example.jira.issue-attach=COM-79