{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/comments/42380547","id":42380547,"diff_hunk":"@@ -0,0 +1,140 @@\n+/*\n+ * The MIT License\n+ *\n+ * Copyright 2015 CloudBees, Inc.\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+\n+package com.cloudbees.hudson.plugins.folder.computed;\n+\n+import hudson.Extension;\n+import hudson.model.Item;\n+import hudson.model.PeriodicWork;\n+import hudson.scheduler.CronTabList;\n+import hudson.triggers.Trigger;\n+import java.lang.reflect.Field;\n+import java.util.Calendar;\n+import java.util.Date;\n+import java.util.GregorianCalendar;\n+import java.util.logging.Level;\n+import java.util.logging.Logger;\n+import jenkins.model.Jenkins;\n+import org.kohsuke.accmod.Restricted;\n+import org.kohsuke.accmod.restrictions.NoExternalUse;\n+\n+/**\n+ * {@link hudson.triggers.Trigger.Cron} analogue for {@link ComputedFolder}.\n+ * TODO should introduce a core API defining an {@link Item} with a {@code public Map<TriggerDescriptor,Trigger<?>> getTriggers()} interface\n+ * (retrofit {@link jenkins.model.ParameterizedJobMixIn.ParameterizedJob} and {@link ComputedFolder} to extend it, and use it from {@link hudson.triggers.Trigger.Cron}).\n+ */\n+@SuppressWarnings(\"unused\") // instantiated by Jenkins\n+@Restricted(NoExternalUse.class)\n+@Extension\n+public class FolderCron extends PeriodicWork {\n+\n+    private static final Logger LOGGER = Logger.getLogger(FolderCron.class.getName());\n+\n+    /**\n+     * A calendar to use.\n+     */\n+    private final Calendar cal = new GregorianCalendar();\n+\n+    /**\n+     * The hack field we want to access.\n+     */\n+    private final Field tabsField;\n+\n+    /**\n+     * Constructor.\n+     *\n+     * @throws NoSuchFieldException\n+     */\n+    // instantiated by Jenkins\n+    @SuppressWarnings(\"unused\")\n+    public FolderCron() throws NoSuchFieldException {","path":"src/main/java/com/cloudbees/hudson/plugins/folder/computed/FolderCron.java","position":71,"original_position":71,"commit_id":"b14134f164a2898af97e54a1bde9563e7f82ee14","original_commit_id":"fe91b2c1048f2228051a414e815dc442ede23cd8","user":{"login":"jglick","id":154109,"avatar_url":"https://avatars.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"body":"If it were thrown, you would want things to break visibly because something is wrong, which rethrowing the exception from an `Extension` constructor accomplishes.","created_at":"2015-10-19T14:53:08Z","updated_at":"2015-10-19T14:53:08Z","html_url":"https://github.com/jenkinsci/cloudbees-folder-plugin/pull/20#discussion_r42380547","pull_request_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/comments/42380547"},"html":{"href":"https://github.com/jenkinsci/cloudbees-folder-plugin/pull/20#discussion_r42380547"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20","id":47086575,"html_url":"https://github.com/jenkinsci/cloudbees-folder-plugin/pull/20","diff_url":"https://github.com/jenkinsci/cloudbees-folder-plugin/pull/20.diff","patch_url":"https://github.com/jenkinsci/cloudbees-folder-plugin/pull/20.patch","issue_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues/20","number":20,"state":"open","locked":false,"title":"ComputedFolder","user":{"login":"jglick","id":154109,"avatar_url":"https://avatars.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"body":"A new API for folders whose contents are determined algorithmically rather than by direct user modification.\r\n\r\n- [X] baseline update\r\n- [x] add `ComputedFolder`\r\n- [x] make `ComputedFolder` extend `AbstractFolder`\r\n- [x] redesign API\r\n- [x] define `OrphanedItemStrategy`\r\n- [x] `PeriodicFolderTrigger`\r\n- [x] `Cron`\r\n- [x] `List<Trigger> triggers`\r\n- [x] `ThrottleComputationQueueTaskDispatcher`\r\n- [x] narrow type of `FolderComputation.getParent`\r\n\r\n@reviewbybees esp. @stephenc","created_at":"2015-10-07T21:46:28Z","updated_at":"2015-10-19T14:53:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ffae4d51cbe74a28bb95949051ac69a19aedde7d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues/20/comments","statuses_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/statuses/b14134f164a2898af97e54a1bde9563e7f82ee14","head":{"label":"jglick:ComputedFolder","ref":"ComputedFolder","sha":"b14134f164a2898af97e54a1bde9563e7f82ee14","user":{"login":"jglick","id":154109,"avatar_url":"https://avatars.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"repo":{"id":35119118,"name":"cloudbees-folder-plugin","full_name":"jglick/cloudbees-folder-plugin","owner":{"login":"jglick","id":154109,"avatar_url":"https://avatars.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jglick/cloudbees-folder-plugin","description":"","fork":true,"url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin","forks_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/forks","keys_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/teams","hooks_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/hooks","issue_events_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/events","assignees_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/tags","blobs_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/languages","stargazers_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/stargazers","contributors_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/contributors","subscribers_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/subscribers","subscription_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/subscription","commits_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/merges","archive_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/downloads","issues_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jglick/cloudbees-folder-plugin/releases{/id}","created_at":"2015-05-05T19:18:33Z","updated_at":"2015-05-05T19:18:34Z","pushed_at":"2015-10-19T14:40:47Z","git_url":"git://github.com/jglick/cloudbees-folder-plugin.git","ssh_url":"git@github.com:jglick/cloudbees-folder-plugin.git","clone_url":"https://github.com/jglick/cloudbees-folder-plugin.git","svn_url":"https://github.com/jglick/cloudbees-folder-plugin","homepage":"","size":304,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"43a9c5d3260828b2f6d13866c75d1662d77a4aa5","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":13481588,"name":"cloudbees-folder-plugin","full_name":"jenkinsci/cloudbees-folder-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/cloudbees-folder-plugin","description":"","fork":false,"url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin","forks_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/releases{/id}","created_at":"2013-10-10T20:02:26Z","updated_at":"2015-09-30T08:52:34Z","pushed_at":"2015-10-19T14:40:47Z","git_url":"git://github.com/jenkinsci/cloudbees-folder-plugin.git","ssh_url":"git@github.com:jenkinsci/cloudbees-folder-plugin.git","clone_url":"https://github.com/jenkinsci/cloudbees-folder-plugin.git","svn_url":"https://github.com/jenkinsci/cloudbees-folder-plugin","homepage":"","size":1024,"stargazers_count":10,"watchers_count":10,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":7,"forks":20,"open_issues":7,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20"},"html":{"href":"https://github.com/jenkinsci/cloudbees-folder-plugin/pull/20"},"issue":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues/20"},"comments":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/cloudbees-folder-plugin/statuses/b14134f164a2898af97e54a1bde9563e7f82ee14"}}}}