{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/comments/75598653","id":75598653,"diff_hunk":"@@ -0,0 +1,156 @@\n+package org.jenkinsci.plugins.edithelp;\n+\n+import java.io.File;\n+import java.io.FileNotFoundException;\n+import java.io.IOException;\n+import java.io.BufferedWriter;\n+import java.io.OutputStreamWriter;\n+import java.io.FileOutputStream;\n+import hudson.Extension;\n+import hudson.cli.PrivateKeyProvider;\n+import hudson.model.RootAction;\n+import jenkins.model.Jenkins;\n+import org.apache.commons.lang.StringUtils;\n+import org.kohsuke.accmod.Restricted;\n+import org.kohsuke.accmod.restrictions.NoExternalUse;\n+import org.kohsuke.stapler.HttpResponse;\n+import org.kohsuke.stapler.QueryParameter;\n+import java.nio.charset.StandardCharsets;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.logging.Logger;\n+import hudson.util.HttpResponses;\n+\n+import static java.nio.file.Files.readAllLines;\n+import static java.util.logging.Level.WARNING;\n+\n+\n+\n+\n+\n+@Extension\n+public class EditHelpRootAction implements RootAction {\n+\n+    private static final Logger LOGGER = Logger.getLogger(PrivateKeyProvider.class.getName());\n+\n+    //hashMap for cache storage\n+    private transient Map<String, String> hashMapOfHelp = new HashMap<String, String>();\n+\n+    //reading files into cache\n+    public EditHelpRootAction() throws IOException, FileNotFoundException {\n+        File dirfile = Jenkins.getActiveInstance().getRootDir();\n+        if(dirfile != null) {\n+\n+            //check if the directory exists\n+            File helpManagerFile = new File(dirfile, \"helpmanager\");\n+\n+            if (!helpManagerFile.exists()) {\n+                if (!helpManagerFile.mkdirs()) {\n+                    LOGGER.log(WARNING,\"Unable create directory: \"+helpManagerFile.getAbsolutePath());\n+                }\n+            }\n+\n+            //reading files from the directory\n+            if (helpManagerFile.getAbsolutePath() != null) {\n+                File dir = new File(helpManagerFile.getAbsolutePath());\n+                File[] files = dir.listFiles();\n+                if (files != null) {\n+                    for (File file : files){\n+                        if (file.isFile()){\n+                            hashMapOfHelp.put(file.getName(),readFromFile(file));\n+                        }\n+                    }\n+                }\n+            }\n+        }\n+    }\n+\n+    @Override\n+    public String getIconFileName() {\n+        return null;\n+    }\n+\n+    @Override\n+    public String getDisplayName() {\n+        return null;\n+    }\n+\n+    @Override\n+    public String getUrlName() {\n+        return \"helpmanager\";\n+    }\n+\n+    //copying from HashMap\n+    @Restricted(NoExternalUse.class)\n+    public HttpResponse doHelpInfo(@QueryParameter(\"class\") String className) {\n+\n+        Jenkins.getActiveInstance().checkPermission(Jenkins.READ);","path":"src/main/java/org/jenkinsci/plugins/edithelp/EditHelpRootAction.java","position":88,"original_position":88,"commit_id":"a9abd6ce6e4e5ba6ec1eadda7ff443a4cc74fced","original_commit_id":"a9abd6ce6e4e5ba6ec1eadda7ff443a4cc74fced","user":{"login":"samatdav","id":9495022,"avatar_url":"https://avatars.githubusercontent.com/u/9495022?v=3","gravatar_id":"","url":"https://api.github.com/users/samatdav","html_url":"https://github.com/samatdav","followers_url":"https://api.github.com/users/samatdav/followers","following_url":"https://api.github.com/users/samatdav/following{/other_user}","gists_url":"https://api.github.com/users/samatdav/gists{/gist_id}","starred_url":"https://api.github.com/users/samatdav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samatdav/subscriptions","organizations_url":"https://api.github.com/users/samatdav/orgs","repos_url":"https://api.github.com/users/samatdav/repos","events_url":"https://api.github.com/users/samatdav/events{/privacy}","received_events_url":"https://api.github.com/users/samatdav/received_events","type":"User","site_admin":false},"body":"@oleg-nenashev Could you please provide an example of such code in Jenkins? I could not find how this is used and I am not sure how to implement it.","created_at":"2016-08-21T16:58:51Z","updated_at":"2016-08-21T16:58:51Z","html_url":"https://github.com/jenkinsci/help-editor-plugin/pull/1#discussion_r75598653","pull_request_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/comments/75598653"},"html":{"href":"https://github.com/jenkinsci/help-editor-plugin/pull/1#discussion_r75598653"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1","id":80553192,"html_url":"https://github.com/jenkinsci/help-editor-plugin/pull/1","diff_url":"https://github.com/jenkinsci/help-editor-plugin/pull/1.diff","patch_url":"https://github.com/jenkinsci/help-editor-plugin/pull/1.patch","issue_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues/1","number":1,"state":"open","locked":false,"title":"Help editor plugin","user":{"login":"samatdav","id":9495022,"avatar_url":"https://avatars.githubusercontent.com/u/9495022?v=3","gravatar_id":"","url":"https://api.github.com/users/samatdav","html_url":"https://github.com/samatdav","followers_url":"https://api.github.com/users/samatdav/followers","following_url":"https://api.github.com/users/samatdav/following{/other_user}","gists_url":"https://api.github.com/users/samatdav/gists{/gist_id}","starred_url":"https://api.github.com/users/samatdav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samatdav/subscriptions","organizations_url":"https://api.github.com/users/samatdav/orgs","repos_url":"https://api.github.com/users/samatdav/repos","events_url":"https://api.github.com/users/samatdav/events{/privacy}","received_events_url":"https://api.github.com/users/samatdav/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-09T02:41:29Z","updated_at":"2016-08-21T16:58:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47c387774acb753fccb9e7c9ccd72ecb664c4cf2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues/1/comments","statuses_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/statuses/a9abd6ce6e4e5ba6ec1eadda7ff443a4cc74fced","head":{"label":"samatdav:master","ref":"master","sha":"a9abd6ce6e4e5ba6ec1eadda7ff443a4cc74fced","user":{"login":"samatdav","id":9495022,"avatar_url":"https://avatars.githubusercontent.com/u/9495022?v=3","gravatar_id":"","url":"https://api.github.com/users/samatdav","html_url":"https://github.com/samatdav","followers_url":"https://api.github.com/users/samatdav/followers","following_url":"https://api.github.com/users/samatdav/following{/other_user}","gists_url":"https://api.github.com/users/samatdav/gists{/gist_id}","starred_url":"https://api.github.com/users/samatdav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samatdav/subscriptions","organizations_url":"https://api.github.com/users/samatdav/orgs","repos_url":"https://api.github.com/users/samatdav/repos","events_url":"https://api.github.com/users/samatdav/events{/privacy}","received_events_url":"https://api.github.com/users/samatdav/received_events","type":"User","site_admin":false},"repo":{"id":65094463,"name":"help-editor-plugin","full_name":"samatdav/help-editor-plugin","owner":{"login":"samatdav","id":9495022,"avatar_url":"https://avatars.githubusercontent.com/u/9495022?v=3","gravatar_id":"","url":"https://api.github.com/users/samatdav","html_url":"https://github.com/samatdav","followers_url":"https://api.github.com/users/samatdav/followers","following_url":"https://api.github.com/users/samatdav/following{/other_user}","gists_url":"https://api.github.com/users/samatdav/gists{/gist_id}","starred_url":"https://api.github.com/users/samatdav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samatdav/subscriptions","organizations_url":"https://api.github.com/users/samatdav/orgs","repos_url":"https://api.github.com/users/samatdav/repos","events_url":"https://api.github.com/users/samatdav/events{/privacy}","received_events_url":"https://api.github.com/users/samatdav/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samatdav/help-editor-plugin","description":null,"fork":false,"url":"https://api.github.com/repos/samatdav/help-editor-plugin","forks_url":"https://api.github.com/repos/samatdav/help-editor-plugin/forks","keys_url":"https://api.github.com/repos/samatdav/help-editor-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samatdav/help-editor-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samatdav/help-editor-plugin/teams","hooks_url":"https://api.github.com/repos/samatdav/help-editor-plugin/hooks","issue_events_url":"https://api.github.com/repos/samatdav/help-editor-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/samatdav/help-editor-plugin/events","assignees_url":"https://api.github.com/repos/samatdav/help-editor-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/samatdav/help-editor-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/samatdav/help-editor-plugin/tags","blobs_url":"https://api.github.com/repos/samatdav/help-editor-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samatdav/help-editor-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samatdav/help-editor-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/samatdav/help-editor-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samatdav/help-editor-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/samatdav/help-editor-plugin/languages","stargazers_url":"https://api.github.com/repos/samatdav/help-editor-plugin/stargazers","contributors_url":"https://api.github.com/repos/samatdav/help-editor-plugin/contributors","subscribers_url":"https://api.github.com/repos/samatdav/help-editor-plugin/subscribers","subscription_url":"https://api.github.com/repos/samatdav/help-editor-plugin/subscription","commits_url":"https://api.github.com/repos/samatdav/help-editor-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/samatdav/help-editor-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/samatdav/help-editor-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/samatdav/help-editor-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/samatdav/help-editor-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/samatdav/help-editor-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samatdav/help-editor-plugin/merges","archive_url":"https://api.github.com/repos/samatdav/help-editor-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samatdav/help-editor-plugin/downloads","issues_url":"https://api.github.com/repos/samatdav/help-editor-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/samatdav/help-editor-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/samatdav/help-editor-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/samatdav/help-editor-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samatdav/help-editor-plugin/labels{/name}","releases_url":"https://api.github.com/repos/samatdav/help-editor-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/samatdav/help-editor-plugin/deployments","created_at":"2016-08-06T17:41:58Z","updated_at":"2016-08-08T11:42:47Z","pushed_at":"2016-08-20T23:09:55Z","git_url":"git://github.com/samatdav/help-editor-plugin.git","ssh_url":"git@github.com:samatdav/help-editor-plugin.git","clone_url":"https://github.com/samatdav/help-editor-plugin.git","svn_url":"https://github.com/samatdav/help-editor-plugin","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":0,"forks":5,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jenkinsci:pull","ref":"pull","sha":"9ac9554c3edd799db773e91ddf2edae838149b36","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":65211724,"name":"help-editor-plugin","full_name":"jenkinsci/help-editor-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/help-editor-plugin","description":null,"fork":true,"url":"https://api.github.com/repos/jenkinsci/help-editor-plugin","forks_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/jenkinsci/help-editor-plugin/deployments","created_at":"2016-08-08T14:36:35Z","updated_at":"2016-08-19T22:23:54Z","pushed_at":"2016-08-20T23:09:55Z","git_url":"git://github.com/jenkinsci/help-editor-plugin.git","ssh_url":"git@github.com:jenkinsci/help-editor-plugin.git","clone_url":"https://github.com/jenkinsci/help-editor-plugin.git","svn_url":"https://github.com/jenkinsci/help-editor-plugin","homepage":null,"size":22,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1"},"html":{"href":"https://github.com/jenkinsci/help-editor-plugin/pull/1"},"issue":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues/1"},"comments":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/help-editor-plugin/statuses/a9abd6ce6e4e5ba6ec1eadda7ff443a4cc74fced"}}}}
{"actor":{"display_login":"samatdav"}}