{"action":"created","comment":{"url":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments/44443882","id":44443882,"diff_hunk":"@@ -0,0 +1,229 @@\n+/**\n+ * Copyright (c) 2015 Apereo Foundation\n+ *\n+ * Licensed under the Educational Community 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://opensource.org/licenses/ecl2\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.sakaiproject.component.app.scheduler.jobs.coursepublish;\n+\n+import org.apache.commons.logging.Log;\n+import org.apache.commons.logging.LogFactory;\n+import org.quartz.JobExecutionContext;\n+import org.quartz.JobExecutionException;\n+import org.quartz.StatefulJob;\n+import org.sakaiproject.component.api.ServerConfigurationService;\n+import org.sakaiproject.coursemanagement.api.CourseSitePublishService;\n+import org.sakaiproject.tool.api.Session;\n+import org.sakaiproject.tool.api.SessionManager;\n+import org.sakaiproject.user.api.User;\n+import org.sakaiproject.user.api.UserDirectoryService;\n+import org.sakaiproject.user.api.UserNotDefinedException;\n+\n+\n+/**\n+ * quartz job to remove course sites after a specified period of time.\n+ */\n+public class CourseSitePublishJob implements StatefulJob {\n+\n+   // logger\n+   private final transient Log logger = LogFactory.getLog(getClass());\n+\n+   // sakai.properties\n+   public final static String PROPERTY_COURSE_SITE_PUBLISH_USER                             = \"course_site_publish_service.user\";\n+   public final static String PROPERTY_COURSE_SITE_PUBLISH_NUM_DAYS_BEFORE_TERM_STARTS      = \"course_site_publish_service.num_days_before_term_starts\";\n+\n+   // default values for the sakai.properties\n+   public final static String DEFAULT_VALUE_COURSE_SITE_PUBLISH_USER                        = \"admin\";\n+   public final static int DEFAULT_VALUE_COURSE_SITE_PUBLISH_NUM_DAYS_BEFORE_TERM_STARTS = 14;\n+\n+   // sakai services\n+   private CourseSitePublishService   courseSitePublishService;\n+   private ServerConfigurationService serverConfigurationService;\n+   private SessionManager sessionManager;\n+   private UserDirectoryService userDirectoryService;\n+\n+   // data members\n+   private User user;                      // sakai user who will be used when running this job\n+   private int numDaysBeforeTermStarts;    // number of days before a term starts when course sites will be published and made available to students enrolled in the course.\n+\n+\n+\n+   /**\n+    * default constructor.\n+    */\n+   public CourseSitePublishJob() {\n+      // no code necessary\n+\t}\n+\n+   /**\n+    * called by the spring framework.\n+    */\n+   public void destroy() {\n+      logger.info(\"destroy()\");\n+\n+      // no code necessary\n+   }\n+\n+   /**\n+    * called by the spring framework after this class has been instantiated, this method reads in the following values from sakai.properties:\n+    * <ol>\n+    *    <li>course_site_publish_service.user                    </li>\n+    *    <li>course_site_publish_service.num_days_before_term_starts</li>\n+    * </ol>\n+    */\n+   public void init() {\n+\n+      logger.debug(\"init()\");\n+\n+      // get the number of days after a term ends after which course sites that have expired will be removed\n+      String numDaysBeforeTermStartsString = serverConfigurationService.getString(PROPERTY_COURSE_SITE_PUBLISH_NUM_DAYS_BEFORE_TERM_STARTS);","path":"jobscheduler/scheduler-component-shared/src/java/org/sakaiproject/component/app/scheduler/jobs/coursepublish/CourseSitePublishJob.java","position":88,"original_position":88,"commit_id":"660d94c2688d664c873c54f7817e2ec29aa62f06","original_commit_id":"660d94c2688d664c873c54f7817e2ec29aa62f06","user":{"login":"bbailla2","id":10620229,"avatar_url":"https://avatars.githubusercontent.com/u/10620229?v=3","gravatar_id":"","url":"https://api.github.com/users/bbailla2","html_url":"https://github.com/bbailla2","followers_url":"https://api.github.com/users/bbailla2/followers","following_url":"https://api.github.com/users/bbailla2/following{/other_user}","gists_url":"https://api.github.com/users/bbailla2/gists{/gist_id}","starred_url":"https://api.github.com/users/bbailla2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbailla2/subscriptions","organizations_url":"https://api.github.com/users/bbailla2/orgs","repos_url":"https://api.github.com/users/bbailla2/repos","events_url":"https://api.github.com/users/bbailla2/events{/privacy}","received_events_url":"https://api.github.com/users/bbailla2/received_events","type":"User","site_admin":false},"body":"Should this all be condensed to:\r\nserverConfigurationService.getInt(PROPERTY_COURSE_SITE_PUBLISH_NUM_DAYS_BEFORE_TERM_STARTS, DEFAULT_VALUE_COURSE_SITE_PUBLISH_NUM_DAYS_BEFORE_TERM_STARTS);?","created_at":"2015-11-10T18:24:55Z","updated_at":"2015-11-10T18:24:55Z","html_url":"https://github.com/sakaiproject/sakai/pull/1165#discussion_r44443882","pull_request_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165","_links":{"self":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments/44443882"},"html":{"href":"https://github.com/sakaiproject/sakai/pull/1165#discussion_r44443882"},"pull_request":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165"}}},"pull_request":{"url":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165","id":47097363,"html_url":"https://github.com/sakaiproject/sakai/pull/1165","diff_url":"https://github.com/sakaiproject/sakai/pull/1165.diff","patch_url":"https://github.com/sakaiproject/sakai/pull/1165.patch","issue_url":"https://api.github.com/repos/sakaiproject/sakai/issues/1165","number":1165,"state":"open","locked":false,"title":"SAK-29952 Publish and unpublish sites automatically based in the terms","user":{"login":"ddelblanco","id":5720144,"avatar_url":"https://avatars.githubusercontent.com/u/5720144?v=3","gravatar_id":"","url":"https://api.github.com/users/ddelblanco","html_url":"https://github.com/ddelblanco","followers_url":"https://api.github.com/users/ddelblanco/followers","following_url":"https://api.github.com/users/ddelblanco/following{/other_user}","gists_url":"https://api.github.com/users/ddelblanco/gists{/gist_id}","starred_url":"https://api.github.com/users/ddelblanco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddelblanco/subscriptions","organizations_url":"https://api.github.com/users/ddelblanco/orgs","repos_url":"https://api.github.com/users/ddelblanco/repos","events_url":"https://api.github.com/users/ddelblanco/events{/privacy}","received_events_url":"https://api.github.com/users/ddelblanco/received_events","type":"User","site_admin":false},"body":"Publish and unpublish sites automatically based in the term's dates. \r\n\r\nBased in the rsmart code.","created_at":"2015-10-07T23:55:48Z","updated_at":"2015-11-10T18:24:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7c10a5a35c418423e147eaff0f5f6ec896ff475","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165/commits","review_comments_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165/comments","review_comment_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sakaiproject/sakai/issues/1165/comments","statuses_url":"https://api.github.com/repos/sakaiproject/sakai/statuses/660d94c2688d664c873c54f7817e2ec29aa62f06","head":{"label":"ddelblanco:SAK-29952","ref":"SAK-29952","sha":"660d94c2688d664c873c54f7817e2ec29aa62f06","user":{"login":"ddelblanco","id":5720144,"avatar_url":"https://avatars.githubusercontent.com/u/5720144?v=3","gravatar_id":"","url":"https://api.github.com/users/ddelblanco","html_url":"https://github.com/ddelblanco","followers_url":"https://api.github.com/users/ddelblanco/followers","following_url":"https://api.github.com/users/ddelblanco/following{/other_user}","gists_url":"https://api.github.com/users/ddelblanco/gists{/gist_id}","starred_url":"https://api.github.com/users/ddelblanco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddelblanco/subscriptions","organizations_url":"https://api.github.com/users/ddelblanco/orgs","repos_url":"https://api.github.com/users/ddelblanco/repos","events_url":"https://api.github.com/users/ddelblanco/events{/privacy}","received_events_url":"https://api.github.com/users/ddelblanco/received_events","type":"User","site_admin":false},"repo":{"id":40727809,"name":"sakai","full_name":"ddelblanco/sakai","owner":{"login":"ddelblanco","id":5720144,"avatar_url":"https://avatars.githubusercontent.com/u/5720144?v=3","gravatar_id":"","url":"https://api.github.com/users/ddelblanco","html_url":"https://github.com/ddelblanco","followers_url":"https://api.github.com/users/ddelblanco/followers","following_url":"https://api.github.com/users/ddelblanco/following{/other_user}","gists_url":"https://api.github.com/users/ddelblanco/gists{/gist_id}","starred_url":"https://api.github.com/users/ddelblanco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddelblanco/subscriptions","organizations_url":"https://api.github.com/users/ddelblanco/orgs","repos_url":"https://api.github.com/users/ddelblanco/repos","events_url":"https://api.github.com/users/ddelblanco/events{/privacy}","received_events_url":"https://api.github.com/users/ddelblanco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ddelblanco/sakai","description":"Sakai is a freely available, feature-rich technology solution for learning, teaching, research and collaboration. Sakai is an open source software suite developed by a diverse and global adopter community.","fork":true,"url":"https://api.github.com/repos/ddelblanco/sakai","forks_url":"https://api.github.com/repos/ddelblanco/sakai/forks","keys_url":"https://api.github.com/repos/ddelblanco/sakai/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ddelblanco/sakai/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ddelblanco/sakai/teams","hooks_url":"https://api.github.com/repos/ddelblanco/sakai/hooks","issue_events_url":"https://api.github.com/repos/ddelblanco/sakai/issues/events{/number}","events_url":"https://api.github.com/repos/ddelblanco/sakai/events","assignees_url":"https://api.github.com/repos/ddelblanco/sakai/assignees{/user}","branches_url":"https://api.github.com/repos/ddelblanco/sakai/branches{/branch}","tags_url":"https://api.github.com/repos/ddelblanco/sakai/tags","blobs_url":"https://api.github.com/repos/ddelblanco/sakai/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ddelblanco/sakai/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ddelblanco/sakai/git/refs{/sha}","trees_url":"https://api.github.com/repos/ddelblanco/sakai/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ddelblanco/sakai/statuses/{sha}","languages_url":"https://api.github.com/repos/ddelblanco/sakai/languages","stargazers_url":"https://api.github.com/repos/ddelblanco/sakai/stargazers","contributors_url":"https://api.github.com/repos/ddelblanco/sakai/contributors","subscribers_url":"https://api.github.com/repos/ddelblanco/sakai/subscribers","subscription_url":"https://api.github.com/repos/ddelblanco/sakai/subscription","commits_url":"https://api.github.com/repos/ddelblanco/sakai/commits{/sha}","git_commits_url":"https://api.github.com/repos/ddelblanco/sakai/git/commits{/sha}","comments_url":"https://api.github.com/repos/ddelblanco/sakai/comments{/number}","issue_comment_url":"https://api.github.com/repos/ddelblanco/sakai/issues/comments{/number}","contents_url":"https://api.github.com/repos/ddelblanco/sakai/contents/{+path}","compare_url":"https://api.github.com/repos/ddelblanco/sakai/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ddelblanco/sakai/merges","archive_url":"https://api.github.com/repos/ddelblanco/sakai/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ddelblanco/sakai/downloads","issues_url":"https://api.github.com/repos/ddelblanco/sakai/issues{/number}","pulls_url":"https://api.github.com/repos/ddelblanco/sakai/pulls{/number}","milestones_url":"https://api.github.com/repos/ddelblanco/sakai/milestones{/number}","notifications_url":"https://api.github.com/repos/ddelblanco/sakai/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ddelblanco/sakai/labels{/name}","releases_url":"https://api.github.com/repos/ddelblanco/sakai/releases{/id}","created_at":"2015-08-14T17:34:58Z","updated_at":"2015-08-14T17:35:45Z","pushed_at":"2015-11-09T22:40:31Z","git_url":"git://github.com/ddelblanco/sakai.git","ssh_url":"git@github.com:ddelblanco/sakai.git","clone_url":"https://github.com/ddelblanco/sakai.git","svn_url":"https://github.com/ddelblanco/sakai","homepage":"https://www.sakaiproject.org","size":210541,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"sakaiproject:master","ref":"master","sha":"6b02a162ca42d779a41298be47f24a58478ed226","user":{"login":"sakaiproject","id":314726,"avatar_url":"https://avatars.githubusercontent.com/u/314726?v=3","gravatar_id":"","url":"https://api.github.com/users/sakaiproject","html_url":"https://github.com/sakaiproject","followers_url":"https://api.github.com/users/sakaiproject/followers","following_url":"https://api.github.com/users/sakaiproject/following{/other_user}","gists_url":"https://api.github.com/users/sakaiproject/gists{/gist_id}","starred_url":"https://api.github.com/users/sakaiproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sakaiproject/subscriptions","organizations_url":"https://api.github.com/users/sakaiproject/orgs","repos_url":"https://api.github.com/users/sakaiproject/repos","events_url":"https://api.github.com/users/sakaiproject/events{/privacy}","received_events_url":"https://api.github.com/users/sakaiproject/received_events","type":"Organization","site_admin":false},"repo":{"id":28589709,"name":"sakai","full_name":"sakaiproject/sakai","owner":{"login":"sakaiproject","id":314726,"avatar_url":"https://avatars.githubusercontent.com/u/314726?v=3","gravatar_id":"","url":"https://api.github.com/users/sakaiproject","html_url":"https://github.com/sakaiproject","followers_url":"https://api.github.com/users/sakaiproject/followers","following_url":"https://api.github.com/users/sakaiproject/following{/other_user}","gists_url":"https://api.github.com/users/sakaiproject/gists{/gist_id}","starred_url":"https://api.github.com/users/sakaiproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sakaiproject/subscriptions","organizations_url":"https://api.github.com/users/sakaiproject/orgs","repos_url":"https://api.github.com/users/sakaiproject/repos","events_url":"https://api.github.com/users/sakaiproject/events{/privacy}","received_events_url":"https://api.github.com/users/sakaiproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sakaiproject/sakai","description":"Sakai is a freely available, feature-rich technology solution for learning, teaching, research and collaboration. Sakai is an open source software suite developed by a diverse and global adopter community.","fork":false,"url":"https://api.github.com/repos/sakaiproject/sakai","forks_url":"https://api.github.com/repos/sakaiproject/sakai/forks","keys_url":"https://api.github.com/repos/sakaiproject/sakai/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sakaiproject/sakai/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sakaiproject/sakai/teams","hooks_url":"https://api.github.com/repos/sakaiproject/sakai/hooks","issue_events_url":"https://api.github.com/repos/sakaiproject/sakai/issues/events{/number}","events_url":"https://api.github.com/repos/sakaiproject/sakai/events","assignees_url":"https://api.github.com/repos/sakaiproject/sakai/assignees{/user}","branches_url":"https://api.github.com/repos/sakaiproject/sakai/branches{/branch}","tags_url":"https://api.github.com/repos/sakaiproject/sakai/tags","blobs_url":"https://api.github.com/repos/sakaiproject/sakai/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sakaiproject/sakai/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sakaiproject/sakai/git/refs{/sha}","trees_url":"https://api.github.com/repos/sakaiproject/sakai/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sakaiproject/sakai/statuses/{sha}","languages_url":"https://api.github.com/repos/sakaiproject/sakai/languages","stargazers_url":"https://api.github.com/repos/sakaiproject/sakai/stargazers","contributors_url":"https://api.github.com/repos/sakaiproject/sakai/contributors","subscribers_url":"https://api.github.com/repos/sakaiproject/sakai/subscribers","subscription_url":"https://api.github.com/repos/sakaiproject/sakai/subscription","commits_url":"https://api.github.com/repos/sakaiproject/sakai/commits{/sha}","git_commits_url":"https://api.github.com/repos/sakaiproject/sakai/git/commits{/sha}","comments_url":"https://api.github.com/repos/sakaiproject/sakai/comments{/number}","issue_comment_url":"https://api.github.com/repos/sakaiproject/sakai/issues/comments{/number}","contents_url":"https://api.github.com/repos/sakaiproject/sakai/contents/{+path}","compare_url":"https://api.github.com/repos/sakaiproject/sakai/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sakaiproject/sakai/merges","archive_url":"https://api.github.com/repos/sakaiproject/sakai/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sakaiproject/sakai/downloads","issues_url":"https://api.github.com/repos/sakaiproject/sakai/issues{/number}","pulls_url":"https://api.github.com/repos/sakaiproject/sakai/pulls{/number}","milestones_url":"https://api.github.com/repos/sakaiproject/sakai/milestones{/number}","notifications_url":"https://api.github.com/repos/sakaiproject/sakai/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sakaiproject/sakai/labels{/name}","releases_url":"https://api.github.com/repos/sakaiproject/sakai/releases{/id}","created_at":"2014-12-29T11:14:17Z","updated_at":"2015-11-10T09:42:14Z","pushed_at":"2015-11-10T16:55:42Z","git_url":"git://github.com/sakaiproject/sakai.git","ssh_url":"git@github.com:sakaiproject/sakai.git","clone_url":"https://github.com/sakaiproject/sakai.git","svn_url":"https://github.com/sakaiproject/sakai","homepage":"https://www.sakaiproject.org","size":276752,"stargazers_count":93,"watchers_count":93,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":157,"mirror_url":null,"open_issues_count":32,"forks":157,"open_issues":32,"watchers":93,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165"},"html":{"href":"https://github.com/sakaiproject/sakai/pull/1165"},"issue":{"href":"https://api.github.com/repos/sakaiproject/sakai/issues/1165"},"comments":{"href":"https://api.github.com/repos/sakaiproject/sakai/issues/1165/comments"},"review_comments":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165/comments"},"review_comment":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/1165/commits"},"statuses":{"href":"https://api.github.com/repos/sakaiproject/sakai/statuses/660d94c2688d664c873c54f7817e2ec29aa62f06"}}}}