{"action":"created","comment":{"url":"https://api.github.com/repos/TWCable/grabbit/pulls/comments/59244095","id":59244095,"diff_hunk":"@@ -0,0 +1,95 @@\n+package com.twcable.grabbit.spring.batch.repository.services.impl\n+\n+import com.twcable.grabbit.jcr.JcrUtil\n+import com.twcable.grabbit.spring.batch.repository.JcrJobRepositoryFactoryBean\n+import com.twcable.grabbit.spring.batch.repository.services.CleanJobRepository\n+import groovy.transform.CompileStatic\n+import groovy.util.logging.Slf4j\n+import org.apache.felix.scr.annotations.Activate\n+import org.apache.felix.scr.annotations.Component\n+import org.apache.felix.scr.annotations.Reference\n+import org.apache.felix.scr.annotations.Service\n+import org.apache.sling.api.resource.PersistenceException\n+import org.apache.sling.api.resource.Resource\n+import org.apache.sling.api.resource.ResourceResolver\n+import org.apache.sling.api.resource.ResourceResolverFactory\n+import org.springframework.batch.core.BatchStatus\n+import org.springframework.context.ConfigurableApplicationContext\n+\n+@Slf4j\n+@CompileStatic\n+@Component(label = \"Grabbit Clean Job Repository Service\", description = \"Grabbit Clean Job Repository Service\", immediate = true, metatype = true, enabled = true)\n+@Service(CleanJobRepository)\n+@SuppressWarnings(['GroovyUnusedDeclaration', 'GrMethodMayBeStatic'])\n+class DefaultCleanJobRepository implements CleanJobRepository {\n+\n+    @Reference\n+    ResourceResolverFactory resourceResolverFactory\n+\n+    @Reference\n+    ConfigurableApplicationContext configurableApplicationContext\n+\n+    @Activate\n+    void activate() {\n+        log.info \"CleanJobRepository Service activated\"\n+    }\n+\n+    @Override\n+    void cleanJobRepository(int hours) {\n+        JcrJobRepositoryFactoryBean jobRepositoryFactoryBean = configurableApplicationContext.getBean(JcrJobRepositoryFactoryBean)\n+\n+        if(!jobRepositoryFactoryBean) {\n+            log.error \"Cannot get an instance of JcrJobRepositoryFactoryBean. Will not clean up Grabbit Jcr Job Repository\"\n+            return\n+        }","path":"grabbit/src/main/groovy/com/twcable/grabbit/spring/batch/repository/services/impl/DefaultCleanJobRepository.groovy","position":44,"original_position":44,"commit_id":"4c70dc259bd0aa5062915b33e21ba1fab4c9480e","original_commit_id":"4c70dc259bd0aa5062915b33e21ba1fab4c9480e","user":{"login":"sagarsane","id":667114,"avatar_url":"https://avatars.githubusercontent.com/u/667114?v=3","gravatar_id":"","url":"https://api.github.com/users/sagarsane","html_url":"https://github.com/sagarsane","followers_url":"https://api.github.com/users/sagarsane/followers","following_url":"https://api.github.com/users/sagarsane/following{/other_user}","gists_url":"https://api.github.com/users/sagarsane/gists{/gist_id}","starred_url":"https://api.github.com/users/sagarsane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagarsane/subscriptions","organizations_url":"https://api.github.com/users/sagarsane/orgs","repos_url":"https://api.github.com/users/sagarsane/repos","events_url":"https://api.github.com/users/sagarsane/events{/privacy}","received_events_url":"https://api.github.com/users/sagarsane/received_events","type":"User","site_admin":false},"body":"Also added a short-circuit here. If this is null, nothing below is going to work :-)","created_at":"2016-04-11T17:21:03Z","updated_at":"2016-04-11T17:21:03Z","html_url":"https://github.com/TWCable/grabbit/pull/107#discussion_r59244095","pull_request_url":"https://api.github.com/repos/TWCable/grabbit/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/TWCable/grabbit/pulls/comments/59244095"},"html":{"href":"https://github.com/TWCable/grabbit/pull/107#discussion_r59244095"},"pull_request":{"href":"https://api.github.com/repos/TWCable/grabbit/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/TWCable/grabbit/pulls/107","id":65383640,"html_url":"https://github.com/TWCable/grabbit/pull/107","diff_url":"https://github.com/TWCable/grabbit/pull/107.diff","patch_url":"https://github.com/TWCable/grabbit/pull/107.patch","issue_url":"https://api.github.com/repos/TWCable/grabbit/issues/107","number":107,"state":"open","locked":false,"title":"Work towards automated cleaning of JcrJobRepository","user":{"login":"sagarsane","id":667114,"avatar_url":"https://avatars.githubusercontent.com/u/667114?v=3","gravatar_id":"","url":"https://api.github.com/users/sagarsane","html_url":"https://github.com/sagarsane","followers_url":"https://api.github.com/users/sagarsane/followers","following_url":"https://api.github.com/users/sagarsane/following{/other_user}","gists_url":"https://api.github.com/users/sagarsane/gists{/gist_id}","starred_url":"https://api.github.com/users/sagarsane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sagarsane/subscriptions","organizations_url":"https://api.github.com/users/sagarsane/orgs","repos_url":"https://api.github.com/users/sagarsane/repos","events_url":"https://api.github.com/users/sagarsane/events{/privacy}","received_events_url":"https://api.github.com/users/sagarsane/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-05T22:40:59Z","updated_at":"2016-04-11T17:21:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c144cd0025a81f1fe2a2f4d19d9ba581118524c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TWCable/grabbit/pulls/107/commits","review_comments_url":"https://api.github.com/repos/TWCable/grabbit/pulls/107/comments","review_comment_url":"https://api.github.com/repos/TWCable/grabbit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TWCable/grabbit/issues/107/comments","statuses_url":"https://api.github.com/repos/TWCable/grabbit/statuses/4c70dc259bd0aa5062915b33e21ba1fab4c9480e","head":{"label":"TWCable:6-clean-jcr-job-repository","ref":"6-clean-jcr-job-repository","sha":"4c70dc259bd0aa5062915b33e21ba1fab4c9480e","user":{"login":"TWCable","id":10778149,"avatar_url":"https://avatars.githubusercontent.com/u/10778149?v=3","gravatar_id":"","url":"https://api.github.com/users/TWCable","html_url":"https://github.com/TWCable","followers_url":"https://api.github.com/users/TWCable/followers","following_url":"https://api.github.com/users/TWCable/following{/other_user}","gists_url":"https://api.github.com/users/TWCable/gists{/gist_id}","starred_url":"https://api.github.com/users/TWCable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWCable/subscriptions","organizations_url":"https://api.github.com/users/TWCable/orgs","repos_url":"https://api.github.com/users/TWCable/repos","events_url":"https://api.github.com/users/TWCable/events{/privacy}","received_events_url":"https://api.github.com/users/TWCable/received_events","type":"Organization","site_admin":false},"repo":{"id":31395930,"name":"grabbit","full_name":"TWCable/grabbit","owner":{"login":"TWCable","id":10778149,"avatar_url":"https://avatars.githubusercontent.com/u/10778149?v=3","gravatar_id":"","url":"https://api.github.com/users/TWCable","html_url":"https://github.com/TWCable","followers_url":"https://api.github.com/users/TWCable/followers","following_url":"https://api.github.com/users/TWCable/following{/other_user}","gists_url":"https://api.github.com/users/TWCable/gists{/gist_id}","starred_url":"https://api.github.com/users/TWCable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWCable/subscriptions","organizations_url":"https://api.github.com/users/TWCable/orgs","repos_url":"https://api.github.com/users/TWCable/repos","events_url":"https://api.github.com/users/TWCable/events{/privacy}","received_events_url":"https://api.github.com/users/TWCable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TWCable/grabbit","description":"Grabbit - Fast Content Sync tool for AEM/CQ","fork":false,"url":"https://api.github.com/repos/TWCable/grabbit","forks_url":"https://api.github.com/repos/TWCable/grabbit/forks","keys_url":"https://api.github.com/repos/TWCable/grabbit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TWCable/grabbit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TWCable/grabbit/teams","hooks_url":"https://api.github.com/repos/TWCable/grabbit/hooks","issue_events_url":"https://api.github.com/repos/TWCable/grabbit/issues/events{/number}","events_url":"https://api.github.com/repos/TWCable/grabbit/events","assignees_url":"https://api.github.com/repos/TWCable/grabbit/assignees{/user}","branches_url":"https://api.github.com/repos/TWCable/grabbit/branches{/branch}","tags_url":"https://api.github.com/repos/TWCable/grabbit/tags","blobs_url":"https://api.github.com/repos/TWCable/grabbit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TWCable/grabbit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TWCable/grabbit/git/refs{/sha}","trees_url":"https://api.github.com/repos/TWCable/grabbit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TWCable/grabbit/statuses/{sha}","languages_url":"https://api.github.com/repos/TWCable/grabbit/languages","stargazers_url":"https://api.github.com/repos/TWCable/grabbit/stargazers","contributors_url":"https://api.github.com/repos/TWCable/grabbit/contributors","subscribers_url":"https://api.github.com/repos/TWCable/grabbit/subscribers","subscription_url":"https://api.github.com/repos/TWCable/grabbit/subscription","commits_url":"https://api.github.com/repos/TWCable/grabbit/commits{/sha}","git_commits_url":"https://api.github.com/repos/TWCable/grabbit/git/commits{/sha}","comments_url":"https://api.github.com/repos/TWCable/grabbit/comments{/number}","issue_comment_url":"https://api.github.com/repos/TWCable/grabbit/issues/comments{/number}","contents_url":"https://api.github.com/repos/TWCable/grabbit/contents/{+path}","compare_url":"https://api.github.com/repos/TWCable/grabbit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TWCable/grabbit/merges","archive_url":"https://api.github.com/repos/TWCable/grabbit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TWCable/grabbit/downloads","issues_url":"https://api.github.com/repos/TWCable/grabbit/issues{/number}","pulls_url":"https://api.github.com/repos/TWCable/grabbit/pulls{/number}","milestones_url":"https://api.github.com/repos/TWCable/grabbit/milestones{/number}","notifications_url":"https://api.github.com/repos/TWCable/grabbit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TWCable/grabbit/labels{/name}","releases_url":"https://api.github.com/repos/TWCable/grabbit/releases{/id}","deployments_url":"https://api.github.com/repos/TWCable/grabbit/deployments","created_at":"2015-02-27T00:24:35Z","updated_at":"2016-04-09T14:02:00Z","pushed_at":"2016-04-11T17:20:17Z","git_url":"git://github.com/TWCable/grabbit.git","ssh_url":"git@github.com:TWCable/grabbit.git","clone_url":"https://github.com/TWCable/grabbit.git","svn_url":"https://github.com/TWCable/grabbit","homepage":"","size":1293,"stargazers_count":46,"watchers_count":46,"language":"Groovy","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":43,"forks":14,"open_issues":43,"watchers":46,"default_branch":"master"}},"base":{"label":"TWCable:master","ref":"master","sha":"fdba9129dcd569c3fae0235d53eb59e0fcff457f","user":{"login":"TWCable","id":10778149,"avatar_url":"https://avatars.githubusercontent.com/u/10778149?v=3","gravatar_id":"","url":"https://api.github.com/users/TWCable","html_url":"https://github.com/TWCable","followers_url":"https://api.github.com/users/TWCable/followers","following_url":"https://api.github.com/users/TWCable/following{/other_user}","gists_url":"https://api.github.com/users/TWCable/gists{/gist_id}","starred_url":"https://api.github.com/users/TWCable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWCable/subscriptions","organizations_url":"https://api.github.com/users/TWCable/orgs","repos_url":"https://api.github.com/users/TWCable/repos","events_url":"https://api.github.com/users/TWCable/events{/privacy}","received_events_url":"https://api.github.com/users/TWCable/received_events","type":"Organization","site_admin":false},"repo":{"id":31395930,"name":"grabbit","full_name":"TWCable/grabbit","owner":{"login":"TWCable","id":10778149,"avatar_url":"https://avatars.githubusercontent.com/u/10778149?v=3","gravatar_id":"","url":"https://api.github.com/users/TWCable","html_url":"https://github.com/TWCable","followers_url":"https://api.github.com/users/TWCable/followers","following_url":"https://api.github.com/users/TWCable/following{/other_user}","gists_url":"https://api.github.com/users/TWCable/gists{/gist_id}","starred_url":"https://api.github.com/users/TWCable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWCable/subscriptions","organizations_url":"https://api.github.com/users/TWCable/orgs","repos_url":"https://api.github.com/users/TWCable/repos","events_url":"https://api.github.com/users/TWCable/events{/privacy}","received_events_url":"https://api.github.com/users/TWCable/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TWCable/grabbit","description":"Grabbit - Fast Content Sync tool for AEM/CQ","fork":false,"url":"https://api.github.com/repos/TWCable/grabbit","forks_url":"https://api.github.com/repos/TWCable/grabbit/forks","keys_url":"https://api.github.com/repos/TWCable/grabbit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TWCable/grabbit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TWCable/grabbit/teams","hooks_url":"https://api.github.com/repos/TWCable/grabbit/hooks","issue_events_url":"https://api.github.com/repos/TWCable/grabbit/issues/events{/number}","events_url":"https://api.github.com/repos/TWCable/grabbit/events","assignees_url":"https://api.github.com/repos/TWCable/grabbit/assignees{/user}","branches_url":"https://api.github.com/repos/TWCable/grabbit/branches{/branch}","tags_url":"https://api.github.com/repos/TWCable/grabbit/tags","blobs_url":"https://api.github.com/repos/TWCable/grabbit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TWCable/grabbit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TWCable/grabbit/git/refs{/sha}","trees_url":"https://api.github.com/repos/TWCable/grabbit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TWCable/grabbit/statuses/{sha}","languages_url":"https://api.github.com/repos/TWCable/grabbit/languages","stargazers_url":"https://api.github.com/repos/TWCable/grabbit/stargazers","contributors_url":"https://api.github.com/repos/TWCable/grabbit/contributors","subscribers_url":"https://api.github.com/repos/TWCable/grabbit/subscribers","subscription_url":"https://api.github.com/repos/TWCable/grabbit/subscription","commits_url":"https://api.github.com/repos/TWCable/grabbit/commits{/sha}","git_commits_url":"https://api.github.com/repos/TWCable/grabbit/git/commits{/sha}","comments_url":"https://api.github.com/repos/TWCable/grabbit/comments{/number}","issue_comment_url":"https://api.github.com/repos/TWCable/grabbit/issues/comments{/number}","contents_url":"https://api.github.com/repos/TWCable/grabbit/contents/{+path}","compare_url":"https://api.github.com/repos/TWCable/grabbit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TWCable/grabbit/merges","archive_url":"https://api.github.com/repos/TWCable/grabbit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TWCable/grabbit/downloads","issues_url":"https://api.github.com/repos/TWCable/grabbit/issues{/number}","pulls_url":"https://api.github.com/repos/TWCable/grabbit/pulls{/number}","milestones_url":"https://api.github.com/repos/TWCable/grabbit/milestones{/number}","notifications_url":"https://api.github.com/repos/TWCable/grabbit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TWCable/grabbit/labels{/name}","releases_url":"https://api.github.com/repos/TWCable/grabbit/releases{/id}","deployments_url":"https://api.github.com/repos/TWCable/grabbit/deployments","created_at":"2015-02-27T00:24:35Z","updated_at":"2016-04-09T14:02:00Z","pushed_at":"2016-04-11T17:20:17Z","git_url":"git://github.com/TWCable/grabbit.git","ssh_url":"git@github.com:TWCable/grabbit.git","clone_url":"https://github.com/TWCable/grabbit.git","svn_url":"https://github.com/TWCable/grabbit","homepage":"","size":1293,"stargazers_count":46,"watchers_count":46,"language":"Groovy","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":43,"forks":14,"open_issues":43,"watchers":46,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TWCable/grabbit/pulls/107"},"html":{"href":"https://github.com/TWCable/grabbit/pull/107"},"issue":{"href":"https://api.github.com/repos/TWCable/grabbit/issues/107"},"comments":{"href":"https://api.github.com/repos/TWCable/grabbit/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/TWCable/grabbit/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/TWCable/grabbit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TWCable/grabbit/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/TWCable/grabbit/statuses/4c70dc259bd0aa5062915b33e21ba1fab4c9480e"}}}}