CAMEL-7777 Fixed the CS error of camel-github component
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b4d28ec5 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b4d28ec5 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b4d28ec5 Branch: refs/heads/master Commit: b4d28ec56fd2e3a23181e45d82073c0b072c4ee1 Parents: f0f341e Author: Willem Jiang <willem.ji...@gmail.com> Authored: Mon Sep 22 16:57:38 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Mon Sep 22 16:57:38 2014 +0800 ---------------------------------------------------------------------- .../camel/component/github/GitHubEndpoint.java | 10 ++--- .../github/consumer/AbstractGitHubConsumer.java | 20 ++++++++- .../github/consumer/CommitConsumer.java | 30 ++++++------- .../consumer/PullRequestCommentConsumer.java | 37 ++++++++-------- .../github/consumer/PullRequestConsumer.java | 46 ++++++++++---------- .../component/github/consumer/TagConsumer.java | 28 ++++++------ .../github/producer/AbstractGitHubProducer.java | 20 ++++++++- .../producer/PullRequestCommentProducer.java | 10 ++--- .../src/main/resources/log4j.properties | 16 ------- .../src/test/resources/log4j.properties | 36 +++++++++++++++ 10 files changed, 153 insertions(+), 100 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/GitHubEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/GitHubEndpoint.java b/components/camel-github/src/main/java/org/apache/camel/component/github/GitHubEndpoint.java index 8070d48..2763f92 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/GitHubEndpoint.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/GitHubEndpoint.java @@ -53,15 +53,15 @@ import org.apache.camel.impl.DefaultEndpoint; */ public class GitHubEndpoint extends DefaultEndpoint { - private String username = null; + private String username; - private String password = null; + private String password; - private String oauthToken = null; + private String oauthToken; - private String repoOwner = null; + private String repoOwner; - private String repoName = null; + private String repoName; public GitHubEndpoint(String uri, GitHubComponent component) { super(uri, component); http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java index a33852c..299f89d 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java @@ -1,3 +1,19 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.camel.component.github.consumer; import org.apache.camel.Processor; @@ -11,9 +27,9 @@ public abstract class AbstractGitHubConsumer extends ScheduledPollConsumer { private final GitHubEndpoint endpoint; - private RepositoryService repositoryService = null; + private RepositoryService repositoryService; - private Repository repository = null; + private Repository repository; public AbstractGitHubConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception { super(endpoint, processor); http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java index 71492d7..65366a9 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java @@ -29,9 +29,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class CommitConsumer extends AbstractGitHubConsumer { - private static final transient Logger LOG = LoggerFactory.getLogger(CommitConsumer.class); - - private CommitService commitService = null; + private static final transient Logger LOG = LoggerFactory.getLogger(CommitConsumer.class); + + private CommitService commitService; private List<String> commitHashes = new ArrayList<String>(); @@ -43,26 +43,26 @@ public class CommitConsumer extends AbstractGitHubConsumer { LOG.info("GitHub CommitConsumer: Indexing current commits..."); List<RepositoryCommit> commits = commitService.getCommits(getRepository(), branchName, null); - for (RepositoryCommit commit : commits) { - commitHashes.add(commit.getSha()); - } + for (RepositoryCommit commit : commits) { + commitHashes.add(commit.getSha()); + } } @Override protected int poll() throws Exception { List<RepositoryCommit> commits = commitService.getCommits(getRepository()); - // In the end, we want tags oldest to newest. - Stack<RepositoryCommit> newCommits = new Stack<RepositoryCommit>(); - for (RepositoryCommit commit : commits) { - if (!commitHashes.contains(commit.getSha())) { - newCommits.push(commit); - commitHashes.add(commit.getSha()); - } + // In the end, we want tags oldest to newest. + Stack<RepositoryCommit> newCommits = new Stack<RepositoryCommit>(); + for (RepositoryCommit commit : commits) { + if (!commitHashes.contains(commit.getSha())) { + newCommits.push(commit); + commitHashes.add(commit.getSha()); + } } - while(!newCommits.empty()) { + while (!newCommits.empty()) { RepositoryCommit newCommit = newCommits.pop(); - Exchange e = getEndpoint().createExchange(); + Exchange e = getEndpoint().createExchange(); e.getIn().setBody(newCommit); getProcessor().process(e); } http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java index 85e7a9a..8f297de 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java @@ -32,11 +32,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PullRequestCommentConsumer extends AbstractGitHubConsumer { - private static final transient Logger LOG = LoggerFactory.getLogger(PullRequestCommentConsumer.class); - - private PullRequestService pullRequestService = null; + private static final transient Logger LOG = LoggerFactory.getLogger(PullRequestCommentConsumer.class); - private IssueService issueService = null; + private PullRequestService pullRequestService; + + private IssueService issueService; private List<Long> commentIds = new ArrayList<Long>(); @@ -47,26 +47,27 @@ public class PullRequestCommentConsumer extends AbstractGitHubConsumer { initService(pullRequestService); issueService = new IssueService(); initService(issueService); - + LOG.info("GitHub PullRequestCommentConsumer: Indexing current pull request comments..."); List<PullRequest> pullRequests = pullRequestService.getPullRequests(getRepository(), "open"); - for (PullRequest pullRequest : pullRequests) { - List<CommitComment> commitComments = pullRequestService.getComments(getRepository(), pullRequest.getNumber()); - for (Comment comment : commitComments) { - commentIds.add(comment.getId()); - } - List<Comment> comments = issueService.getComments(getRepository(), pullRequest.getNumber()); - for (Comment comment : comments) { + for (PullRequest pullRequest : pullRequests) { + List<CommitComment> commitComments = pullRequestService.getComments(getRepository(), + pullRequest.getNumber()); + for (Comment comment : commitComments) { + commentIds.add(comment.getId()); + } + List<Comment> comments = issueService.getComments(getRepository(), pullRequest.getNumber()); + for (Comment comment : comments) { commentIds.add(comment.getId()); } - } + } } @Override protected int poll() throws Exception { - List<PullRequest> pullRequests = pullRequestService.getPullRequests(getRepository(), "open"); - // In the end, we want comments oldest to newest. - Stack<Comment> newComments = new Stack<Comment>(); + List<PullRequest> pullRequests = pullRequestService.getPullRequests(getRepository(), "open"); + // In the end, we want comments oldest to newest. + Stack<Comment> newComments = new Stack<Comment>(); for (PullRequest pullRequest : pullRequests) { List<CommitComment> commitComments = pullRequestService.getComments(getRepository(), pullRequest.getNumber()); for (Comment comment : commitComments) { @@ -84,9 +85,9 @@ public class PullRequestCommentConsumer extends AbstractGitHubConsumer { } } - while(!newComments.empty()) { + while (!newComments.empty()) { Comment newComment = newComments.pop(); - Exchange e = getEndpoint().createExchange(); + Exchange e = getEndpoint().createExchange(); e.getIn().setBody(newComment); getProcessor().process(e); } http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java index 97673c3..5b2d6ad 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java @@ -28,45 +28,45 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class PullRequestConsumer extends AbstractGitHubConsumer { - private static final transient Logger LOG = LoggerFactory.getLogger(PullRequestConsumer.class); - - private PullRequestService pullRequestService = null; + private static final transient Logger LOG = LoggerFactory.getLogger(PullRequestConsumer.class); + + private PullRequestService pullRequestService; - private int lastOpenPullRequest = 0; + private int lastOpenPullRequest; public PullRequestConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception { super(endpoint, processor); pullRequestService = new PullRequestService(); - initService(pullRequestService); - - LOG.info("GitHub PullRequestConsumer: Indexing current pull requests..."); + initService(pullRequestService); + + LOG.info("GitHub PullRequestConsumer: Indexing current pull requests..."); List<PullRequest> pullRequests = pullRequestService.getPullRequests(getRepository(), "open"); - if (pullRequests.size() > 0) { - lastOpenPullRequest = pullRequests.get(0).getNumber(); - } + if (pullRequests.size() > 0) { + lastOpenPullRequest = pullRequests.get(0).getNumber(); + } } @Override protected int poll() throws Exception { - List<PullRequest> openPullRequests = pullRequestService.getPullRequests(getRepository(), "open"); - // In the end, we want PRs oldest to newest. - Stack<PullRequest> newPullRequests = new Stack<PullRequest>(); + List<PullRequest> openPullRequests = pullRequestService.getPullRequests(getRepository(), "open"); + // In the end, we want PRs oldest to newest. + Stack<PullRequest> newPullRequests = new Stack<PullRequest>(); for (PullRequest pullRequest : openPullRequests) { - if (pullRequest.getNumber() > lastOpenPullRequest) { - newPullRequests.push(pullRequest); - } else { - break; - } + if (pullRequest.getNumber() > lastOpenPullRequest) { + newPullRequests.push(pullRequest); + } else { + break; + } } if (newPullRequests.size() > 0) { - lastOpenPullRequest = openPullRequests.get(0).getNumber(); + lastOpenPullRequest = openPullRequests.get(0).getNumber(); } - - while(!newPullRequests.empty()) { - PullRequest newPullRequest = newPullRequests.pop(); - Exchange e = getEndpoint().createExchange(); + + while (!newPullRequests.empty()) { + PullRequest newPullRequest = newPullRequests.pop(); + Exchange e = getEndpoint().createExchange(); e.getIn().setBody(newPullRequest); getProcessor().process(e); } http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/TagConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/TagConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/TagConsumer.java index 7f21604..e40bd74 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/TagConsumer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/TagConsumer.java @@ -28,8 +28,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class TagConsumer extends AbstractGitHubConsumer { - private static final transient Logger LOG = LoggerFactory.getLogger(TagConsumer.class); - + private static final transient Logger LOG = LoggerFactory.getLogger(TagConsumer.class); + private List<String> tagNames = new ArrayList<String>(); public TagConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception { @@ -37,26 +37,26 @@ public class TagConsumer extends AbstractGitHubConsumer { LOG.info("GitHub TagConsumer: Indexing current tags..."); List<RepositoryTag> tags = getRepositoryService().getTags(getRepository()); - for (RepositoryTag tag : tags) { - tagNames.add(tag.getName()); - } + for (RepositoryTag tag : tags) { + tagNames.add(tag.getName()); + } } @Override protected int poll() throws Exception { List<RepositoryTag> tags = getRepositoryService().getTags(getRepository()); - // In the end, we want tags oldest to newest. - Stack<RepositoryTag> newTags = new Stack<RepositoryTag>(); - for (RepositoryTag tag : tags) { - if (!tagNames.contains(tag.getName())) { - newTags.push(tag); - tagNames.add(tag.getName()); - } + // In the end, we want tags oldest to newest. + Stack<RepositoryTag> newTags = new Stack<RepositoryTag>(); + for (RepositoryTag tag : tags) { + if (!tagNames.contains(tag.getName())) { + newTags.push(tag); + tagNames.add(tag.getName()); + } } - while(!newTags.empty()) { + while (!newTags.empty()) { RepositoryTag newTag = newTags.pop(); - Exchange e = getEndpoint().createExchange(); + Exchange e = getEndpoint().createExchange(); e.getIn().setBody(newTag); getProcessor().process(e); } http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java index 3858849..31d29b3 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java @@ -1,3 +1,19 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.camel.component.github.producer; import org.apache.camel.Exchange; @@ -11,9 +27,9 @@ public abstract class AbstractGitHubProducer extends DefaultProducer { private final GitHubEndpoint endpoint; - private RepositoryService repositoryService = null; + private RepositoryService repositoryService; - private Repository repository = null; + private Repository repository; public AbstractGitHubProducer(GitHubEndpoint endpoint) throws Exception { super(endpoint); http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java index 1029b52..87aec0f 100644 --- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java +++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java @@ -23,7 +23,7 @@ import org.eclipse.egit.github.core.service.IssueService; import org.eclipse.egit.github.core.service.PullRequestService; /** - * Producer endpoint that adds one of two types of comments on a GitHub pullrequest: + * Producer endpoint that adds one of two types of comments on a GitHub pull request: * * 1.) Response to an in-line comment made on a pull request commit review. To use, include the * "GitHubInResponseTo" header, identifying the comment ID (integer) that you're responding to. @@ -32,9 +32,9 @@ import org.eclipse.egit.github.core.service.PullRequestService; * Both endpoints require the "GitHubPullRequest" header, identifying the pull request number (integer). */ public class PullRequestCommentProducer extends AbstractGitHubProducer { - private PullRequestService pullRequestService = null; + private PullRequestService pullRequestService; - private IssueService issueService = null; + private IssueService issueService; public PullRequestCommentProducer(GitHubEndpoint endpoint) throws Exception { super(endpoint); @@ -52,10 +52,10 @@ public class PullRequestCommentProducer extends AbstractGitHubProducer { Comment response; if (inResponseTo != null && inResponseTo > 0) { - response = pullRequestService.replyToComment(getRepository(), pullRequestNumber, inResponseTo, text); + response = pullRequestService.replyToComment(getRepository(), pullRequestNumber, inResponseTo, text); } else { // Otherwise, just comment on the pull request itself. - response = issueService.createComment(getRepository(), pullRequestNumber, text); + response = issueService.createComment(getRepository(), pullRequestNumber, text); } // support InOut http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/main/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/components/camel-github/src/main/resources/log4j.properties b/components/camel-github/src/main/resources/log4j.properties deleted file mode 100644 index 4621723..0000000 --- a/components/camel-github/src/main/resources/log4j.properties +++ /dev/null @@ -1,16 +0,0 @@ - -# -# The logging properties used -# -log4j.rootLogger=INFO, out - -# uncomment the following line to turn on Camel debugging -#log4j.logger.org.apache.camel=DEBUG - -# CONSOLE appender not used by default -log4j.appender.out=org.apache.log4j.ConsoleAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/b4d28ec5/components/camel-github/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/components/camel-github/src/test/resources/log4j.properties b/components/camel-github/src/test/resources/log4j.properties new file mode 100644 index 0000000..b34806a --- /dev/null +++ b/components/camel-github/src/test/resources/log4j.properties @@ -0,0 +1,36 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- + +# +# The logging properties used +# +log4j.rootLogger=INFO, file + +#log4j.logger.org.apache.camel=DEBUG + +# CONSOLE appender not used by default +log4j.appender.out=org.apache.log4j.ConsoleAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# File appender +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +log4j.appender.file.file=target/camel-github-test.log +log4j.appender.file.append=true +