{"action":"created","comment":{"url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/25943697","id":25943697,"diff_hunk":"@@ -0,0 +1,197 @@\n+/*\n+ * Copyright 2002-2015 the original author or authors.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except 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, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.springframework.integration.mongodb.metadata;\n+\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.springframework.dao.DuplicateKeyException;\n+import org.springframework.data.mongodb.MongoDbFactory;\n+import org.springframework.data.mongodb.core.MongoTemplate;\n+import org.springframework.data.mongodb.core.query.Criteria;\n+import org.springframework.data.mongodb.core.query.Query;\n+import org.springframework.data.mongodb.core.query.Update;\n+import org.springframework.integration.metadata.ConcurrentMetadataStore;\n+import org.springframework.util.Assert;\n+import org.springframework.util.StringUtils;\n+\n+import com.mongodb.WriteResult;\n+\n+/**\n+ * MongoDbMetadataStore implementation of {@link ConcurrentMetadataStore}.\n+ * Use this {@link org.springframework.integration.metadata.MetadataStore} to\n+ * achieve meta-data persistence shared across application instances and\n+ * restarts.\n+ *\n+ * @author Senthil Arumugam, Samiraj Panneer Selvam\n+ * @since 4.2\n+ *\n+ */\n+public class MongoDbMetadataStore implements ConcurrentMetadataStore {\n+\n+\tprotected final Log logger = LogFactory.getLog(getClass());\n+\tprivate final MongoTemplate template;\n+\tprivate final String DEFAULT_COLLECTION_NAME = \"metadatastore\";\n+\tprivate final String collectionName;\n+\tprivate final String ID_FIELD = \"_id\";\n+\tprivate final String VALUE = \"value\";\n+\t\n+\t/**\n+\t * \n+\t * Configures the MongoDbMetadataStore by provided {@link MongoTemplate} and\n+\t * default collection name - {@link #DEFAULT_COLLECTION_NAME}.\n+\t * \n+\t * @param template The mongodb template\n+\t * @param collectionName the collection name where it persists the data\n+\t */\n+\tpublic MongoDbMetadataStore(MongoTemplate template, String collectionName) {\n+\t\tthis.template = template;\n+\t\tthis.collectionName = (StringUtils.hasText(collectionName)) ? collectionName\n+\t\t\t\t: DEFAULT_COLLECTION_NAME;\n+\t}\n+\n+\t/**\n+\t * Configures the MongoDbMetadataStore by provided {@link MongoTemplate} and\n+\t * default collection name - {@link #DEFAULT_COLLECTION_NAME}.\n+\t * \n+\t * @param template The mongodb template\n+\t */\n+\tpublic MongoDbMetadataStore(MongoTemplate template) {\n+\t\tthis(template, null);\n+\t}\n+\n+\t/**\n+\t * Configures the MongoDbMetadataStore by provided {@link MongoDbFactory} and\n+\t * default collection name - {@link #DEFAULT_COLLECTION_NAME}.\n+\t * \n+\t * @param factory The mongodb factory\n+\t */\n+\tpublic MongoDbMetadataStore(MongoDbFactory factory) {\n+\t\tthis(factory, null);\n+\t}\n+\t\n+\t/**\n+\t * Configures the MongoDbMetadataStore by provided {@link MongoDbFactory} and\n+\t * collection name\n+\t * \n+\t * @param collectionName the collection name where it persists the data\n+\t * @param factory MongoDbFactory\n+\t */\n+\tpublic MongoDbMetadataStore(MongoDbFactory factory, String collectionName) {\n+\t\ttemplate = new MongoTemplate(factory);\n+\t\tthis.collectionName = (StringUtils.hasText(collectionName)) ? collectionName\n+\t\t\t\t: DEFAULT_COLLECTION_NAME;\n+\t}\n+\t\n+\t\n+\t/**\n+\t * Method put.\n+\t * @param key String\n+\t * @param value String\n+\t * @see org.springframework.integration.metadata.MetadataStore#put(String, String)\n+\t */\n+\t@Override\n+\tpublic void put(String key, String value) {\n+\t\tAssert.notNull(key, \"'key' must not be null.\");\n+\t\tAssert.notNull(value, \"'value' must not be null.\");\n+\t\tMap<String,String> fileInfo = new HashMap();\n+\t\tfileInfo.put(ID_FIELD, key);\n+\t\tfileInfo.put(VALUE, value);\n+\t\ttemplate.save(fileInfo, collectionName);\n+\t}\n+\n+\t/**\n+\t * Method get.\n+\t * @param key String\n+\t * @return String\n+\t * @see org.springframework.integration.metadata.MetadataStore#get(String)\n+\t */\n+\t@Override\n+\tpublic String get(String key) {\n+\t\tAssert.notNull(key, \"'key' must not be null.\");\n+\t\tQuery query = new Query(Criteria.where(ID_FIELD).is(key));\n+\t\t@SuppressWarnings(\"unchecked\")\n+\t\tMap<String,String> result = template.findOne(query, Map.class, collectionName);\n+\t\treturn result==null?null:result.get(VALUE);","path":"spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/metadata/MongoDbMetadataStore.java","position":130,"original_position":130,"commit_id":"93326250a9405257f7b754145bc9892eb0bae919","original_commit_id":"93326250a9405257f7b754145bc9892eb0bae919","user":{"login":"artembilan","id":1071590,"avatar_url":"https://avatars.githubusercontent.com/u/1071590?v=3","gravatar_id":"","url":"https://api.github.com/users/artembilan","html_url":"https://github.com/artembilan","followers_url":"https://api.github.com/users/artembilan/followers","following_url":"https://api.github.com/users/artembilan/following{/other_user}","gists_url":"https://api.github.com/users/artembilan/gists{/gist_id}","starred_url":"https://api.github.com/users/artembilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artembilan/subscriptions","organizations_url":"https://api.github.com/users/artembilan/orgs","repos_url":"https://api.github.com/users/artembilan/repos","events_url":"https://api.github.com/users/artembilan/events{/privacy}","received_events_url":"https://api.github.com/users/artembilan/received_events","type":"User","site_admin":false},"body":"It isn't so easy to provide such a tool, hence we just follow with code style rules: https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-Code-Style.\r\nSome of them you can import to your IDE: \r\nhttps://github.com/spring-projects/spring-framework/tree/master/src/idea\r\nhttps://github.com/spring-projects/spring-framework/tree/master/src/eclipse\r\nBut of course, there is no such an option to format your whitespaces vulnerabilities :smile: ","created_at":"2015-03-06T13:22:30Z","updated_at":"2015-03-06T13:22:30Z","html_url":"https://github.com/spring-projects/spring-integration/pull/1397#discussion_r25943697","pull_request_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397","_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments/25943697"},"html":{"href":"https://github.com/spring-projects/spring-integration/pull/1397#discussion_r25943697"},"pull_request":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397"}}},"pull_request":{"url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397","id":30287167,"html_url":"https://github.com/spring-projects/spring-integration/pull/1397","diff_url":"https://github.com/spring-projects/spring-integration/pull/1397.diff","patch_url":"https://github.com/spring-projects/spring-integration/pull/1397.patch","issue_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/1397","number":1397,"state":"open","locked":false,"title":"[INT-3666] - Implementation of Metadastore for MongoDB","user":{"login":"senthilaru","id":3784051,"avatar_url":"https://avatars.githubusercontent.com/u/3784051?v=3","gravatar_id":"","url":"https://api.github.com/users/senthilaru","html_url":"https://github.com/senthilaru","followers_url":"https://api.github.com/users/senthilaru/followers","following_url":"https://api.github.com/users/senthilaru/following{/other_user}","gists_url":"https://api.github.com/users/senthilaru/gists{/gist_id}","starred_url":"https://api.github.com/users/senthilaru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senthilaru/subscriptions","organizations_url":"https://api.github.com/users/senthilaru/orgs","repos_url":"https://api.github.com/users/senthilaru/repos","events_url":"https://api.github.com/users/senthilaru/events{/privacy}","received_events_url":"https://api.github.com/users/senthilaru/received_events","type":"User","site_admin":false},"body":"[INT-3666] - Implementation of Metadastore for MongoDB","created_at":"2015-03-02T14:31:10Z","updated_at":"2015-03-06T13:22:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4329e051dbb92c35fc9616ce40fa2859f721444c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397/commits","review_comments_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397/comments","review_comment_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/1397/comments","statuses_url":"https://api.github.com/repos/spring-projects/spring-integration/statuses/93326250a9405257f7b754145bc9892eb0bae919","head":{"label":"senthilaru:INT-3666","ref":"INT-3666","sha":"93326250a9405257f7b754145bc9892eb0bae919","user":{"login":"senthilaru","id":3784051,"avatar_url":"https://avatars.githubusercontent.com/u/3784051?v=3","gravatar_id":"","url":"https://api.github.com/users/senthilaru","html_url":"https://github.com/senthilaru","followers_url":"https://api.github.com/users/senthilaru/followers","following_url":"https://api.github.com/users/senthilaru/following{/other_user}","gists_url":"https://api.github.com/users/senthilaru/gists{/gist_id}","starred_url":"https://api.github.com/users/senthilaru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senthilaru/subscriptions","organizations_url":"https://api.github.com/users/senthilaru/orgs","repos_url":"https://api.github.com/users/senthilaru/repos","events_url":"https://api.github.com/users/senthilaru/events{/privacy}","received_events_url":"https://api.github.com/users/senthilaru/received_events","type":"User","site_admin":false},"repo":{"id":30573070,"name":"spring-integration","full_name":"senthilaru/spring-integration","owner":{"login":"senthilaru","id":3784051,"avatar_url":"https://avatars.githubusercontent.com/u/3784051?v=3","gravatar_id":"","url":"https://api.github.com/users/senthilaru","html_url":"https://github.com/senthilaru","followers_url":"https://api.github.com/users/senthilaru/followers","following_url":"https://api.github.com/users/senthilaru/following{/other_user}","gists_url":"https://api.github.com/users/senthilaru/gists{/gist_id}","starred_url":"https://api.github.com/users/senthilaru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/senthilaru/subscriptions","organizations_url":"https://api.github.com/users/senthilaru/orgs","repos_url":"https://api.github.com/users/senthilaru/repos","events_url":"https://api.github.com/users/senthilaru/events{/privacy}","received_events_url":"https://api.github.com/users/senthilaru/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/senthilaru/spring-integration","description":"Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)","fork":true,"url":"https://api.github.com/repos/senthilaru/spring-integration","forks_url":"https://api.github.com/repos/senthilaru/spring-integration/forks","keys_url":"https://api.github.com/repos/senthilaru/spring-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/senthilaru/spring-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/senthilaru/spring-integration/teams","hooks_url":"https://api.github.com/repos/senthilaru/spring-integration/hooks","issue_events_url":"https://api.github.com/repos/senthilaru/spring-integration/issues/events{/number}","events_url":"https://api.github.com/repos/senthilaru/spring-integration/events","assignees_url":"https://api.github.com/repos/senthilaru/spring-integration/assignees{/user}","branches_url":"https://api.github.com/repos/senthilaru/spring-integration/branches{/branch}","tags_url":"https://api.github.com/repos/senthilaru/spring-integration/tags","blobs_url":"https://api.github.com/repos/senthilaru/spring-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/senthilaru/spring-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/senthilaru/spring-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/senthilaru/spring-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/senthilaru/spring-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/senthilaru/spring-integration/languages","stargazers_url":"https://api.github.com/repos/senthilaru/spring-integration/stargazers","contributors_url":"https://api.github.com/repos/senthilaru/spring-integration/contributors","subscribers_url":"https://api.github.com/repos/senthilaru/spring-integration/subscribers","subscription_url":"https://api.github.com/repos/senthilaru/spring-integration/subscription","commits_url":"https://api.github.com/repos/senthilaru/spring-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/senthilaru/spring-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/senthilaru/spring-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/senthilaru/spring-integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/senthilaru/spring-integration/contents/{+path}","compare_url":"https://api.github.com/repos/senthilaru/spring-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/senthilaru/spring-integration/merges","archive_url":"https://api.github.com/repos/senthilaru/spring-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/senthilaru/spring-integration/downloads","issues_url":"https://api.github.com/repos/senthilaru/spring-integration/issues{/number}","pulls_url":"https://api.github.com/repos/senthilaru/spring-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/senthilaru/spring-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/senthilaru/spring-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/senthilaru/spring-integration/labels{/name}","releases_url":"https://api.github.com/repos/senthilaru/spring-integration/releases{/id}","created_at":"2015-02-10T03:32:25Z","updated_at":"2015-03-02T04:37:50Z","pushed_at":"2015-03-06T06:45:16Z","git_url":"git://github.com/senthilaru/spring-integration.git","ssh_url":"git@github.com:senthilaru/spring-integration.git","clone_url":"https://github.com/senthilaru/spring-integration.git","svn_url":"https://github.com/senthilaru/spring-integration","homepage":"http://projects.spring.io/spring-integration/","size":30326,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"spring-projects:master","ref":"master","sha":"134c7c870b35f15b97b37bf13eeeaf060d671527","user":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars.githubusercontent.com/u/317776?v=3","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"repo":{"id":2090979,"name":"spring-integration","full_name":"spring-projects/spring-integration","owner":{"login":"spring-projects","id":317776,"avatar_url":"https://avatars.githubusercontent.com/u/317776?v=3","gravatar_id":"","url":"https://api.github.com/users/spring-projects","html_url":"https://github.com/spring-projects","followers_url":"https://api.github.com/users/spring-projects/followers","following_url":"https://api.github.com/users/spring-projects/following{/other_user}","gists_url":"https://api.github.com/users/spring-projects/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-projects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-projects/subscriptions","organizations_url":"https://api.github.com/users/spring-projects/orgs","repos_url":"https://api.github.com/users/spring-projects/repos","events_url":"https://api.github.com/users/spring-projects/events{/privacy}","received_events_url":"https://api.github.com/users/spring-projects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spring-projects/spring-integration","description":"Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns (EIP)","fork":false,"url":"https://api.github.com/repos/spring-projects/spring-integration","forks_url":"https://api.github.com/repos/spring-projects/spring-integration/forks","keys_url":"https://api.github.com/repos/spring-projects/spring-integration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spring-projects/spring-integration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spring-projects/spring-integration/teams","hooks_url":"https://api.github.com/repos/spring-projects/spring-integration/hooks","issue_events_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/events{/number}","events_url":"https://api.github.com/repos/spring-projects/spring-integration/events","assignees_url":"https://api.github.com/repos/spring-projects/spring-integration/assignees{/user}","branches_url":"https://api.github.com/repos/spring-projects/spring-integration/branches{/branch}","tags_url":"https://api.github.com/repos/spring-projects/spring-integration/tags","blobs_url":"https://api.github.com/repos/spring-projects/spring-integration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spring-projects/spring-integration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spring-projects/spring-integration/git/refs{/sha}","trees_url":"https://api.github.com/repos/spring-projects/spring-integration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spring-projects/spring-integration/statuses/{sha}","languages_url":"https://api.github.com/repos/spring-projects/spring-integration/languages","stargazers_url":"https://api.github.com/repos/spring-projects/spring-integration/stargazers","contributors_url":"https://api.github.com/repos/spring-projects/spring-integration/contributors","subscribers_url":"https://api.github.com/repos/spring-projects/spring-integration/subscribers","subscription_url":"https://api.github.com/repos/spring-projects/spring-integration/subscription","commits_url":"https://api.github.com/repos/spring-projects/spring-integration/commits{/sha}","git_commits_url":"https://api.github.com/repos/spring-projects/spring-integration/git/commits{/sha}","comments_url":"https://api.github.com/repos/spring-projects/spring-integration/comments{/number}","issue_comment_url":"https://api.github.com/repos/spring-projects/spring-integration/issues/comments{/number}","contents_url":"https://api.github.com/repos/spring-projects/spring-integration/contents/{+path}","compare_url":"https://api.github.com/repos/spring-projects/spring-integration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spring-projects/spring-integration/merges","archive_url":"https://api.github.com/repos/spring-projects/spring-integration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spring-projects/spring-integration/downloads","issues_url":"https://api.github.com/repos/spring-projects/spring-integration/issues{/number}","pulls_url":"https://api.github.com/repos/spring-projects/spring-integration/pulls{/number}","milestones_url":"https://api.github.com/repos/spring-projects/spring-integration/milestones{/number}","notifications_url":"https://api.github.com/repos/spring-projects/spring-integration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spring-projects/spring-integration/labels{/name}","releases_url":"https://api.github.com/repos/spring-projects/spring-integration/releases{/id}","created_at":"2011-07-22T21:47:27Z","updated_at":"2015-03-05T18:46:16Z","pushed_at":"2015-03-06T09:09:35Z","git_url":"git://github.com/spring-projects/spring-integration.git","ssh_url":"git@github.com:spring-projects/spring-integration.git","clone_url":"https://github.com/spring-projects/spring-integration.git","svn_url":"https://github.com/spring-projects/spring-integration","homepage":"http://projects.spring.io/spring-integration/","size":82490,"stargazers_count":320,"watchers_count":320,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":301,"mirror_url":null,"open_issues_count":6,"forks":301,"open_issues":6,"watchers":320,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397"},"html":{"href":"https://github.com/spring-projects/spring-integration/pull/1397"},"issue":{"href":"https://api.github.com/repos/spring-projects/spring-integration/issues/1397"},"comments":{"href":"https://api.github.com/repos/spring-projects/spring-integration/issues/1397/comments"},"review_comments":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397/comments"},"review_comment":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spring-projects/spring-integration/pulls/1397/commits"},"statuses":{"href":"https://api.github.com/repos/spring-projects/spring-integration/statuses/93326250a9405257f7b754145bc9892eb0bae919"}}}}