{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/carbon-mediation/pulls/comments/35837495","id":35837495,"diff_hunk":"@@ -0,0 +1,145 @@\n+/*\n+ *  Copyright (c) 2005-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ *  WSO2 Inc. licenses this file to you under the Apache License,\n+ *  Version 2.0 (the \"License\"); you may not use this file except\n+ *  in compliance with the License.\n+ *  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package org.wso2.carbon.inbound.endpoint.protocol.kafka;\n+\n+import org.apache.axiom.om.OMElement;\n+import org.apache.axiom.om.util.UUIDGenerator;\n+import org.apache.axis2.AxisFault;\n+import org.apache.axis2.builder.Builder;\n+import org.apache.axis2.builder.BuilderUtil;\n+import org.apache.axis2.builder.SOAPBuilder;\n+import org.apache.axis2.context.MessageContext;\n+import org.apache.axis2.transport.TransportUtils;\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.apache.synapse.core.SynapseEnvironment;\n+import org.apache.synapse.mediators.base.SequenceMediator;\n+\n+import java.io.ByteArrayInputStream;\n+import java.io.InputStream;\n+\n+/**\n+ * KafkaInjectHandler uses to mediate the received Kafka message\n+ */\n+public class KAFKAInjectHandler implements InjectHandler {\n+    private static final Log log = LogFactory.getLog(KAFKAInjectHandler.class);\n+\n+    private String injectingSeq;\n+    private String onErrorSeq;\n+    private boolean sequential;\n+    private SynapseEnvironment synapseEnvironment;\n+    private String contentType;\n+\n+    public KAFKAInjectHandler(String injectingSeq, String onErrorSeq,boolean sequential,\n+                              SynapseEnvironment synapseEnvironment, String contentType) {\n+        this.injectingSeq = injectingSeq;\n+        this.onErrorSeq = onErrorSeq;\n+        this.sequential=sequential;\n+        this.synapseEnvironment = synapseEnvironment;\n+        this.contentType = contentType;\n+    }\n+\n+    /**\n+     * Determine the message builder to use, set the message payload to the message context and\n+     * inject the message to the sequence\n+     */\n+    public boolean invoke(Object object) {\n+        byte[] msg = (byte[]) object;\n+\n+        org.apache.synapse.MessageContext msgCtx = createMessageContext();\n+        log.debug(\"Processed Kafka Message \");\n+        MessageContext axis2MsgCtx = ((org.apache.synapse.core.axis2.Axis2MessageContext) msgCtx)\n+                .getAxis2MessageContext();\n+        // Determine the message builder to use\n+        Builder builder = null;\n+        if (contentType == null) {\n+            log.debug(\"No content type specified. Using SOAP builder.\");","path":"components/inbound-endpoints/org.wso2.carbon.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/kafka/KAFKAInjectHandler.java","position":71,"original_position":71,"commit_id":"311018d1e6c8af9d9e9059fc89a8c4e1b88e5cfa","original_commit_id":"311018d1e6c8af9d9e9059fc89a8c4e1b88e5cfa","user":{"login":"prabathabey","id":6664125,"avatar_url":"https://avatars.githubusercontent.com/u/6664125?v=3","gravatar_id":"","url":"https://api.github.com/users/prabathabey","html_url":"https://github.com/prabathabey","followers_url":"https://api.github.com/users/prabathabey/followers","following_url":"https://api.github.com/users/prabathabey/following{/other_user}","gists_url":"https://api.github.com/users/prabathabey/gists{/gist_id}","starred_url":"https://api.github.com/users/prabathabey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prabathabey/subscriptions","organizations_url":"https://api.github.com/users/prabathabey/orgs","repos_url":"https://api.github.com/users/prabathabey/repos","events_url":"https://api.github.com/users/prabathabey/events{/privacy}","received_events_url":"https://api.github.com/users/prabathabey/received_events","type":"User","site_admin":false},"body":"Same goes here as well.","created_at":"2015-07-30T04:33:37Z","updated_at":"2015-07-30T04:33:37Z","html_url":"https://github.com/wso2/carbon-mediation/pull/144#discussion_r35837495","pull_request_url":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144","_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-mediation/pulls/comments/35837495"},"html":{"href":"https://github.com/wso2/carbon-mediation/pull/144#discussion_r35837495"},"pull_request":{"href":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144","id":35245092,"html_url":"https://github.com/wso2/carbon-mediation/pull/144","diff_url":"https://github.com/wso2/carbon-mediation/pull/144.diff","patch_url":"https://github.com/wso2/carbon-mediation/pull/144.patch","issue_url":"https://api.github.com/repos/wso2/carbon-mediation/issues/144","number":144,"state":"closed","locked":false,"title":"Added kafka inbound","user":{"login":"katheesR","id":12377707,"avatar_url":"https://avatars.githubusercontent.com/u/12377707?v=3","gravatar_id":"","url":"https://api.github.com/users/katheesR","html_url":"https://github.com/katheesR","followers_url":"https://api.github.com/users/katheesR/followers","following_url":"https://api.github.com/users/katheesR/following{/other_user}","gists_url":"https://api.github.com/users/katheesR/gists{/gist_id}","starred_url":"https://api.github.com/users/katheesR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katheesR/subscriptions","organizations_url":"https://api.github.com/users/katheesR/orgs","repos_url":"https://api.github.com/users/katheesR/repos","events_url":"https://api.github.com/users/katheesR/events{/privacy}","received_events_url":"https://api.github.com/users/katheesR/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-12T16:30:53Z","updated_at":"2015-07-30T04:33:37Z","closed_at":"2015-05-12T16:33:14Z","merged_at":"2015-05-12T16:33:14Z","merge_commit_sha":"93f504c47fa799f1b52be23caa93b4316976601b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144/commits","review_comments_url":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144/comments","review_comment_url":"https://api.github.com/repos/wso2/carbon-mediation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/carbon-mediation/issues/144/comments","statuses_url":"https://api.github.com/repos/wso2/carbon-mediation/statuses/311018d1e6c8af9d9e9059fc89a8c4e1b88e5cfa","head":{"label":"katheesR:develop","ref":"develop","sha":"311018d1e6c8af9d9e9059fc89a8c4e1b88e5cfa","user":{"login":"katheesR","id":12377707,"avatar_url":"https://avatars.githubusercontent.com/u/12377707?v=3","gravatar_id":"","url":"https://api.github.com/users/katheesR","html_url":"https://github.com/katheesR","followers_url":"https://api.github.com/users/katheesR/followers","following_url":"https://api.github.com/users/katheesR/following{/other_user}","gists_url":"https://api.github.com/users/katheesR/gists{/gist_id}","starred_url":"https://api.github.com/users/katheesR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katheesR/subscriptions","organizations_url":"https://api.github.com/users/katheesR/orgs","repos_url":"https://api.github.com/users/katheesR/repos","events_url":"https://api.github.com/users/katheesR/events{/privacy}","received_events_url":"https://api.github.com/users/katheesR/received_events","type":"User","site_admin":false},"repo":{"id":35409094,"name":"carbon-mediation","full_name":"katheesR/carbon-mediation","owner":{"login":"katheesR","id":12377707,"avatar_url":"https://avatars.githubusercontent.com/u/12377707?v=3","gravatar_id":"","url":"https://api.github.com/users/katheesR","html_url":"https://github.com/katheesR","followers_url":"https://api.github.com/users/katheesR/followers","following_url":"https://api.github.com/users/katheesR/following{/other_user}","gists_url":"https://api.github.com/users/katheesR/gists{/gist_id}","starred_url":"https://api.github.com/users/katheesR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/katheesR/subscriptions","organizations_url":"https://api.github.com/users/katheesR/orgs","repos_url":"https://api.github.com/users/katheesR/repos","events_url":"https://api.github.com/users/katheesR/events{/privacy}","received_events_url":"https://api.github.com/users/katheesR/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/katheesR/carbon-mediation","description":"","fork":true,"url":"https://api.github.com/repos/katheesR/carbon-mediation","forks_url":"https://api.github.com/repos/katheesR/carbon-mediation/forks","keys_url":"https://api.github.com/repos/katheesR/carbon-mediation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/katheesR/carbon-mediation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/katheesR/carbon-mediation/teams","hooks_url":"https://api.github.com/repos/katheesR/carbon-mediation/hooks","issue_events_url":"https://api.github.com/repos/katheesR/carbon-mediation/issues/events{/number}","events_url":"https://api.github.com/repos/katheesR/carbon-mediation/events","assignees_url":"https://api.github.com/repos/katheesR/carbon-mediation/assignees{/user}","branches_url":"https://api.github.com/repos/katheesR/carbon-mediation/branches{/branch}","tags_url":"https://api.github.com/repos/katheesR/carbon-mediation/tags","blobs_url":"https://api.github.com/repos/katheesR/carbon-mediation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/katheesR/carbon-mediation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/katheesR/carbon-mediation/git/refs{/sha}","trees_url":"https://api.github.com/repos/katheesR/carbon-mediation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/katheesR/carbon-mediation/statuses/{sha}","languages_url":"https://api.github.com/repos/katheesR/carbon-mediation/languages","stargazers_url":"https://api.github.com/repos/katheesR/carbon-mediation/stargazers","contributors_url":"https://api.github.com/repos/katheesR/carbon-mediation/contributors","subscribers_url":"https://api.github.com/repos/katheesR/carbon-mediation/subscribers","subscription_url":"https://api.github.com/repos/katheesR/carbon-mediation/subscription","commits_url":"https://api.github.com/repos/katheesR/carbon-mediation/commits{/sha}","git_commits_url":"https://api.github.com/repos/katheesR/carbon-mediation/git/commits{/sha}","comments_url":"https://api.github.com/repos/katheesR/carbon-mediation/comments{/number}","issue_comment_url":"https://api.github.com/repos/katheesR/carbon-mediation/issues/comments{/number}","contents_url":"https://api.github.com/repos/katheesR/carbon-mediation/contents/{+path}","compare_url":"https://api.github.com/repos/katheesR/carbon-mediation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/katheesR/carbon-mediation/merges","archive_url":"https://api.github.com/repos/katheesR/carbon-mediation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/katheesR/carbon-mediation/downloads","issues_url":"https://api.github.com/repos/katheesR/carbon-mediation/issues{/number}","pulls_url":"https://api.github.com/repos/katheesR/carbon-mediation/pulls{/number}","milestones_url":"https://api.github.com/repos/katheesR/carbon-mediation/milestones{/number}","notifications_url":"https://api.github.com/repos/katheesR/carbon-mediation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/katheesR/carbon-mediation/labels{/name}","releases_url":"https://api.github.com/repos/katheesR/carbon-mediation/releases{/id}","created_at":"2015-05-11T07:34:09Z","updated_at":"2015-05-11T07:34:16Z","pushed_at":"2015-07-28T10:28:00Z","git_url":"git://github.com/katheesR/carbon-mediation.git","ssh_url":"git@github.com:katheesR/carbon-mediation.git","clone_url":"https://github.com/katheesR/carbon-mediation.git","svn_url":"https://github.com/katheesR/carbon-mediation","homepage":null,"size":12101,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"KafkaInbound"}},"base":{"label":"wso2:develop","ref":"develop","sha":"90643ccc32e80dca9414d2f344077f19bcbbb81f","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":16429916,"name":"carbon-mediation","full_name":"wso2/carbon-mediation","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/carbon-mediation","description":"","fork":false,"url":"https://api.github.com/repos/wso2/carbon-mediation","forks_url":"https://api.github.com/repos/wso2/carbon-mediation/forks","keys_url":"https://api.github.com/repos/wso2/carbon-mediation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/carbon-mediation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/carbon-mediation/teams","hooks_url":"https://api.github.com/repos/wso2/carbon-mediation/hooks","issue_events_url":"https://api.github.com/repos/wso2/carbon-mediation/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/carbon-mediation/events","assignees_url":"https://api.github.com/repos/wso2/carbon-mediation/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/carbon-mediation/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/carbon-mediation/tags","blobs_url":"https://api.github.com/repos/wso2/carbon-mediation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/carbon-mediation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/carbon-mediation/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/carbon-mediation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/carbon-mediation/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/carbon-mediation/languages","stargazers_url":"https://api.github.com/repos/wso2/carbon-mediation/stargazers","contributors_url":"https://api.github.com/repos/wso2/carbon-mediation/contributors","subscribers_url":"https://api.github.com/repos/wso2/carbon-mediation/subscribers","subscription_url":"https://api.github.com/repos/wso2/carbon-mediation/subscription","commits_url":"https://api.github.com/repos/wso2/carbon-mediation/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/carbon-mediation/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/carbon-mediation/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/carbon-mediation/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/carbon-mediation/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/carbon-mediation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/carbon-mediation/merges","archive_url":"https://api.github.com/repos/wso2/carbon-mediation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/carbon-mediation/downloads","issues_url":"https://api.github.com/repos/wso2/carbon-mediation/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/carbon-mediation/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/carbon-mediation/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/carbon-mediation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/carbon-mediation/labels{/name}","releases_url":"https://api.github.com/repos/wso2/carbon-mediation/releases{/id}","created_at":"2014-02-01T07:01:29Z","updated_at":"2015-04-27T07:04:16Z","pushed_at":"2015-07-29T16:03:32Z","git_url":"git://github.com/wso2/carbon-mediation.git","ssh_url":"git@github.com:wso2/carbon-mediation.git","clone_url":"https://github.com/wso2/carbon-mediation.git","svn_url":"https://github.com/wso2/carbon-mediation","homepage":null,"size":17277,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":80,"mirror_url":null,"open_issues_count":20,"forks":80,"open_issues":20,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144"},"html":{"href":"https://github.com/wso2/carbon-mediation/pull/144"},"issue":{"href":"https://api.github.com/repos/wso2/carbon-mediation/issues/144"},"comments":{"href":"https://api.github.com/repos/wso2/carbon-mediation/issues/144/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/carbon-mediation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/carbon-mediation/pulls/144/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/carbon-mediation/statuses/311018d1e6c8af9d9e9059fc89a8c4e1b88e5cfa"}}}}