{"action":"created","comment":{"url":"https://api.github.com/repos/codenvy/codenvy/pulls/comments/65687840","id":65687840,"diff_hunk":"@@ -0,0 +1,104 @@\n+/*\n+ *  [2012] - [2016] Codenvy, S.A.\n+ *  All Rights Reserved.\n+ *\n+ * NOTICE:  All information contained herein is, and remains\n+ * the property of Codenvy S.A. and its suppliers,\n+ * if any.  The intellectual and technical concepts contained\n+ * herein are proprietary to Codenvy S.A.\n+ * and its suppliers and may be covered by U.S. and Foreign Patents,\n+ * patents in process, and are protected by trade secret or copyright law.\n+ * Dissemination of this information or reproduction of this material\n+ * is strictly forbidden unless prior written permission is obtained\n+ * from Codenvy S.A..\n+ */\n+package com.codenvy.plugin.urlfactory;\n+\n+import org.apache.commons.compress.utils.BoundedInputStream;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import javax.inject.Singleton;\n+import javax.validation.constraints.NotNull;\n+import java.io.BufferedReader;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.io.InputStreamReader;\n+import java.net.URL;\n+import java.net.URLConnection;\n+import java.util.stream.Collectors;\n+\n+import static java.nio.charset.StandardCharsets.UTF_8;\n+import static java.util.Objects.requireNonNull;\n+\n+/**\n+ * Allow to grab content from URL\n+ *\n+ * @author Florent Benoit\n+ */\n+@Singleton\n+public class URLFetcher {\n+\n+    /**\n+     * Logger.\n+     */\n+    private static final Logger LOG = LoggerFactory.getLogger(URLFetcher.class);\n+\n+    /**\n+     * Maximum size of allowed data. (30KB)\n+     */\n+    protected static final long MAXIMUM_READ_BYTES = 30 * 1000;\n+\n+    /**\n+     * Fetch the url provided and return its content\n+     * To avoid DDOS, limit the amount of the collected data\n+     *\n+     * @param url\n+     *         the URL to fetch\n+     * @return the content of the file\n+     */\n+    public String fetch(@NotNull final String url) {\n+        requireNonNull(url, \"url parameter can't be null\");\n+        try {\n+            return fetch(new URL(url).openConnection());\n+        } catch (IOException e) {\n+            // we shouldn't fetch if check is done before\n+            LOG.debug(\"Invalid URL\", e);\n+            return null;\n+        }\n+    }\n+\n+\n+    /**\n+     * Fetch the url provided and return its content\n+     * To avoid DDOS, limit the amount of the collected data\n+     *\n+     * @param urlConnection\n+     *         the URL connection to fetch\n+     * @return the content of the file\n+     */\n+    protected String fetch(URLConnection urlConnection) {","path":"plugins/plugin-urlfactory/src/main/java/com/codenvy/plugin/urlfactory/URLFetcher.java","position":80,"original_position":80,"commit_id":"45fca5a912451684457fcedbf1c3803134fafedc","original_commit_id":"45fca5a912451684457fcedbf1c3803134fafedc","user":{"login":"garagatyi","id":1851863,"avatar_url":"https://avatars.githubusercontent.com/u/1851863?v=3","gravatar_id":"","url":"https://api.github.com/users/garagatyi","html_url":"https://github.com/garagatyi","followers_url":"https://api.github.com/users/garagatyi/followers","following_url":"https://api.github.com/users/garagatyi/following{/other_user}","gists_url":"https://api.github.com/users/garagatyi/gists{/gist_id}","starred_url":"https://api.github.com/users/garagatyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garagatyi/subscriptions","organizations_url":"https://api.github.com/users/garagatyi/orgs","repos_url":"https://api.github.com/users/garagatyi/repos","events_url":"https://api.github.com/users/garagatyi/events{/privacy}","received_events_url":"https://api.github.com/users/garagatyi/received_events","type":"User","site_admin":false},"body":"@NotNull?","created_at":"2016-06-03T10:32:02Z","updated_at":"2016-06-03T10:32:02Z","html_url":"https://github.com/codenvy/codenvy/pull/255#discussion_r65687840","pull_request_url":"https://api.github.com/repos/codenvy/codenvy/pulls/255","_links":{"self":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/comments/65687840"},"html":{"href":"https://github.com/codenvy/codenvy/pull/255#discussion_r65687840"},"pull_request":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/255"}}},"pull_request":{"url":"https://api.github.com/repos/codenvy/codenvy/pulls/255","id":72316643,"html_url":"https://github.com/codenvy/codenvy/pull/255","diff_url":"https://github.com/codenvy/codenvy/pull/255.diff","patch_url":"https://github.com/codenvy/codenvy/pull/255.patch","issue_url":"https://api.github.com/repos/codenvy/codenvy/issues/255","number":255,"state":"open","locked":false,"title":"CODENVY-603 CODENVY-604 allow to use .codenvy.json inside a repository","user":{"login":"benoitf","id":436777,"avatar_url":"https://avatars.githubusercontent.com/u/436777?v=3","gravatar_id":"","url":"https://api.github.com/users/benoitf","html_url":"https://github.com/benoitf","followers_url":"https://api.github.com/users/benoitf/followers","following_url":"https://api.github.com/users/benoitf/following{/other_user}","gists_url":"https://api.github.com/users/benoitf/gists{/gist_id}","starred_url":"https://api.github.com/users/benoitf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benoitf/subscriptions","organizations_url":"https://api.github.com/users/benoitf/orgs","repos_url":"https://api.github.com/users/benoitf/repos","events_url":"https://api.github.com/users/benoitf/events{/privacy}","received_events_url":"https://api.github.com/users/benoitf/received_events","type":"User","site_admin":false},"body":"## .codenvy.json inside repositories\r\n\r\nNow URL factories can work with an existing .codenvy.json inside the repository\r\n\r\nexample: https://aio.codenvy-dev.com/factory/?url=https://github.com/benoitf/test-repository\r\n\r\n## gitlab support for urls\r\n\r\nexample:\r\nhttps://aio.codenvy-dev.com/factory/?url=https://gitlab.com/benoitf/simple-project\r\n\r\n## code refactoring\r\nIntroduce plugin-urlfactory with code shared between github and gitlab factory resolvers\r\n\r\n\r\nChange-Id: I6579a19149028e5b6197cb214848fefcfc476fb5\r\nSigned-off-by: Florent BENOIT <fbenoit@codenvy.com>","created_at":"2016-06-02T09:42:17Z","updated_at":"2016-06-03T10:32:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1501ec17d206ff7aa7cf2958aad571a1ac9414ba","assignee":null,"milestone":{"url":"https://api.github.com/repos/codenvy/codenvy/milestones/2","html_url":"https://github.com/codenvy/codenvy/milestones/4.4.0","labels_url":"https://api.github.com/repos/codenvy/codenvy/milestones/2/labels","id":1802559,"number":2,"title":"4.4.0","description":null,"creator":{"login":"benoitf","id":436777,"avatar_url":"https://avatars.githubusercontent.com/u/436777?v=3","gravatar_id":"","url":"https://api.github.com/users/benoitf","html_url":"https://github.com/benoitf","followers_url":"https://api.github.com/users/benoitf/followers","following_url":"https://api.github.com/users/benoitf/following{/other_user}","gists_url":"https://api.github.com/users/benoitf/gists{/gist_id}","starred_url":"https://api.github.com/users/benoitf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benoitf/subscriptions","organizations_url":"https://api.github.com/users/benoitf/orgs","repos_url":"https://api.github.com/users/benoitf/repos","events_url":"https://api.github.com/users/benoitf/events{/privacy}","received_events_url":"https://api.github.com/users/benoitf/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2016-06-01T14:53:22Z","updated_at":"2016-06-02T11:59:29Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/codenvy/codenvy/pulls/255/commits","review_comments_url":"https://api.github.com/repos/codenvy/codenvy/pulls/255/comments","review_comment_url":"https://api.github.com/repos/codenvy/codenvy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codenvy/codenvy/issues/255/comments","statuses_url":"https://api.github.com/repos/codenvy/codenvy/statuses/45fca5a912451684457fcedbf1c3803134fafedc","head":{"label":"codenvy:CODENVY-603","ref":"CODENVY-603","sha":"45fca5a912451684457fcedbf1c3803134fafedc","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":54102761,"name":"codenvy","full_name":"codenvy/codenvy","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/codenvy","description":"Codenvy","fork":false,"url":"https://api.github.com/repos/codenvy/codenvy","forks_url":"https://api.github.com/repos/codenvy/codenvy/forks","keys_url":"https://api.github.com/repos/codenvy/codenvy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/codenvy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/codenvy/teams","hooks_url":"https://api.github.com/repos/codenvy/codenvy/hooks","issue_events_url":"https://api.github.com/repos/codenvy/codenvy/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/codenvy/events","assignees_url":"https://api.github.com/repos/codenvy/codenvy/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/codenvy/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/codenvy/tags","blobs_url":"https://api.github.com/repos/codenvy/codenvy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/codenvy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/codenvy/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/codenvy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/codenvy/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/codenvy/languages","stargazers_url":"https://api.github.com/repos/codenvy/codenvy/stargazers","contributors_url":"https://api.github.com/repos/codenvy/codenvy/contributors","subscribers_url":"https://api.github.com/repos/codenvy/codenvy/subscribers","subscription_url":"https://api.github.com/repos/codenvy/codenvy/subscription","commits_url":"https://api.github.com/repos/codenvy/codenvy/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/codenvy/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/codenvy/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/codenvy/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/codenvy/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/codenvy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/codenvy/merges","archive_url":"https://api.github.com/repos/codenvy/codenvy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/codenvy/downloads","issues_url":"https://api.github.com/repos/codenvy/codenvy/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/codenvy/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/codenvy/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/codenvy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/codenvy/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/codenvy/releases{/id}","deployments_url":"https://api.github.com/repos/codenvy/codenvy/deployments","created_at":"2016-03-17T08:51:27Z","updated_at":"2016-05-25T21:30:28Z","pushed_at":"2016-06-03T10:11:25Z","git_url":"git://github.com/codenvy/codenvy.git","ssh_url":"git@github.com:codenvy/codenvy.git","clone_url":"https://github.com/codenvy/codenvy.git","svn_url":"https://github.com/codenvy/codenvy","homepage":null,"size":69020,"stargazers_count":9,"watchers_count":9,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":4,"forks":13,"open_issues":4,"watchers":9,"default_branch":"master"}},"base":{"label":"codenvy:master","ref":"master","sha":"3009002f368fbc27423570078bddc8fafd1e2f02","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":54102761,"name":"codenvy","full_name":"codenvy/codenvy","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/codenvy","description":"Codenvy","fork":false,"url":"https://api.github.com/repos/codenvy/codenvy","forks_url":"https://api.github.com/repos/codenvy/codenvy/forks","keys_url":"https://api.github.com/repos/codenvy/codenvy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/codenvy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/codenvy/teams","hooks_url":"https://api.github.com/repos/codenvy/codenvy/hooks","issue_events_url":"https://api.github.com/repos/codenvy/codenvy/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/codenvy/events","assignees_url":"https://api.github.com/repos/codenvy/codenvy/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/codenvy/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/codenvy/tags","blobs_url":"https://api.github.com/repos/codenvy/codenvy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/codenvy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/codenvy/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/codenvy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/codenvy/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/codenvy/languages","stargazers_url":"https://api.github.com/repos/codenvy/codenvy/stargazers","contributors_url":"https://api.github.com/repos/codenvy/codenvy/contributors","subscribers_url":"https://api.github.com/repos/codenvy/codenvy/subscribers","subscription_url":"https://api.github.com/repos/codenvy/codenvy/subscription","commits_url":"https://api.github.com/repos/codenvy/codenvy/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/codenvy/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/codenvy/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/codenvy/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/codenvy/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/codenvy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/codenvy/merges","archive_url":"https://api.github.com/repos/codenvy/codenvy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/codenvy/downloads","issues_url":"https://api.github.com/repos/codenvy/codenvy/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/codenvy/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/codenvy/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/codenvy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/codenvy/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/codenvy/releases{/id}","deployments_url":"https://api.github.com/repos/codenvy/codenvy/deployments","created_at":"2016-03-17T08:51:27Z","updated_at":"2016-05-25T21:30:28Z","pushed_at":"2016-06-03T10:11:25Z","git_url":"git://github.com/codenvy/codenvy.git","ssh_url":"git@github.com:codenvy/codenvy.git","clone_url":"https://github.com/codenvy/codenvy.git","svn_url":"https://github.com/codenvy/codenvy","homepage":null,"size":69020,"stargazers_count":9,"watchers_count":9,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":4,"forks":13,"open_issues":4,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/255"},"html":{"href":"https://github.com/codenvy/codenvy/pull/255"},"issue":{"href":"https://api.github.com/repos/codenvy/codenvy/issues/255"},"comments":{"href":"https://api.github.com/repos/codenvy/codenvy/issues/255/comments"},"review_comments":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/255/comments"},"review_comment":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/255/commits"},"statuses":{"href":"https://api.github.com/repos/codenvy/codenvy/statuses/45fca5a912451684457fcedbf1c3803134fafedc"}}}}
{"actor":{"display_login":"garagatyi"}}