{"action":"created","comment":{"url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/comments/61720495","id":61720495,"diff_hunk":"@@ -0,0 +1,167 @@\n+package com.lftechnology.vyaguta.resource.service.impl;\n+\n+import java.time.LocalDate;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+import java.util.Locale;\n+import java.util.UUID;\n+\n+import javax.annotation.Resource;\n+import javax.ejb.Singleton;\n+import javax.inject.Inject;\n+import javax.mail.Message;\n+import javax.mail.MessagingException;\n+import javax.mail.Session;\n+import javax.mail.Transport;\n+import javax.mail.internet.InternetAddress;\n+import javax.mail.internet.MimeMessage;\n+import javax.ws.rs.WebApplicationException;\n+import javax.ws.rs.client.Client;\n+import javax.ws.rs.client.ClientBuilder;\n+import javax.ws.rs.core.GenericType;\n+import javax.ws.rs.core.Response;\n+\n+import org.slf4j.Logger;\n+import org.thymeleaf.TemplateEngine;\n+import org.thymeleaf.context.Context;\n+import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;\n+\n+import com.lftechnology.vyaguta.commons.pojo.ResponseData;\n+import com.lftechnology.vyaguta.commons.util.ArrayUtil;\n+import com.lftechnology.vyaguta.resource.config.Configuration;\n+import com.lftechnology.vyaguta.resource.entity.Contract;\n+import com.lftechnology.vyaguta.resource.entity.ContractMember;\n+import com.lftechnology.vyaguta.resource.pojo.Employee;\n+import com.lftechnology.vyaguta.resource.service.ProjectNotificationService;\n+import com.lftechnology.vyaguta.resource.service.ProjectService;\n+\n+/**\n+ * \n+ * @author Achyut Pokhrel <achyutpokhrel@lftechnology.com>\n+ *\n+ */\n+@Singleton\n+public class ProjectNotificationServiceImpl implements ProjectNotificationService {\n+\n+    private static final String EMPLOYEE_URL = Configuration.instance().getVyagutaCoreUrl() + \"employees\";\n+\n+    @Inject\n+    private ProjectService projectService;\n+\n+    @Resource(lookup = \"java:jboss/mail/ses\")\n+    private Session session;\n+\n+    @Inject\n+    private Logger log;\n+\n+    @Override\n+    public void pushNotification() {\n+        // days before contract ending to send notification\n+        LocalDate date = LocalDate.now().plusDays(Configuration.instance().getEndingNotificationDays());\n+\n+        List<Contract> contracts = projectService.findContractsEndingBefore(date);\n+        for (Contract contract : contracts) {\n+            if (contract.getProject().getAccountManager() == null) {\n+                continue;\n+            }\n+            this.fetchAndMergeAccountManager(contract);\n+            this.fetchAndMergeEmployee(contract);\n+            String mailTo = contract.getProject().getAccountManager().getPrimaryEmail();\n+            if (mailTo == null) {\n+                continue;\n+            }\n+\n+            final String body = this.emailBuilder(contract);\n+            this.sendMail(mailTo, body);\n+        }\n+    }\n+\n+    private void sendMail(String mailTo, String body) {\n+        String from = \"noreply@lftechnology.com\";\n+        String subject = \"Project Ending Reminder\";\n+\n+        try {\n+            // Create a default MimeMessage object.\n+            MimeMessage message = new MimeMessage(session);\n+\n+            message.setFrom(new InternetAddress(from));\n+            message.addRecipient(Message.RecipientType.TO, new InternetAddress(mailTo));\n+            message.setSubject(subject);\n+            message.setContent(body, \"text/html\");\n+            Transport.send(message);\n+        } catch (MessagingException mex) {","path":"src/main/java/com/lftechnology/vyaguta/resource/service/impl/ProjectNotificationServiceImpl.java","position":93,"original_position":93,"commit_id":"c476262822a15cd985ccc6398f2e1f5245990a59","original_commit_id":"c476262822a15cd985ccc6398f2e1f5245990a59","user":{"login":"bhuwang","id":3335673,"avatar_url":"https://avatars.githubusercontent.com/u/3335673?v=3","gravatar_id":"","url":"https://api.github.com/users/bhuwang","html_url":"https://github.com/bhuwang","followers_url":"https://api.github.com/users/bhuwang/followers","following_url":"https://api.github.com/users/bhuwang/following{/other_user}","gists_url":"https://api.github.com/users/bhuwang/gists{/gist_id}","starred_url":"https://api.github.com/users/bhuwang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhuwang/subscriptions","organizations_url":"https://api.github.com/users/bhuwang/orgs","repos_url":"https://api.github.com/users/bhuwang/repos","events_url":"https://api.github.com/users/bhuwang/events{/privacy}","received_events_url":"https://api.github.com/users/bhuwang/received_events","type":"User","site_admin":false},"body":"![CRITICAL](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-critical.png) Either log or rethrow this exception. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](http://sonar.java.lftechnology.com:9000/coding_rules#rule_key=squid%3AS1166)\n","created_at":"2016-05-02T09:38:30Z","updated_at":"2016-05-02T09:38:30Z","html_url":"https://github.com/leapfrogtechnology/vyaguta-resource/pull/502#discussion_r61720495","pull_request_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502","_links":{"self":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/comments/61720495"},"html":{"href":"https://github.com/leapfrogtechnology/vyaguta-resource/pull/502#discussion_r61720495"},"pull_request":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502"}}},"pull_request":{"url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502","id":68540048,"html_url":"https://github.com/leapfrogtechnology/vyaguta-resource/pull/502","diff_url":"https://github.com/leapfrogtechnology/vyaguta-resource/pull/502.diff","patch_url":"https://github.com/leapfrogtechnology/vyaguta-resource/pull/502.patch","issue_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/502","number":502,"state":"open","locked":false,"title":"VY-RES-479 - Configure Mail Notification","user":{"login":"lf-achyutpkl","id":16873122,"avatar_url":"https://avatars.githubusercontent.com/u/16873122?v=3","gravatar_id":"","url":"https://api.github.com/users/lf-achyutpkl","html_url":"https://github.com/lf-achyutpkl","followers_url":"https://api.github.com/users/lf-achyutpkl/followers","following_url":"https://api.github.com/users/lf-achyutpkl/following{/other_user}","gists_url":"https://api.github.com/users/lf-achyutpkl/gists{/gist_id}","starred_url":"https://api.github.com/users/lf-achyutpkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lf-achyutpkl/subscriptions","organizations_url":"https://api.github.com/users/lf-achyutpkl/orgs","repos_url":"https://api.github.com/users/lf-achyutpkl/repos","events_url":"https://api.github.com/users/lf-achyutpkl/events{/privacy}","received_events_url":"https://api.github.com/users/lf-achyutpkl/received_events","type":"User","site_admin":false},"body":"@lf-kailashraj please review my code","created_at":"2016-05-02T09:35:29Z","updated_at":"2016-05-02T09:38:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fec8d322e9e4aca0639eb036da386c47789b201","assignee":{"login":"lf-kailashraj","id":7426244,"avatar_url":"https://avatars.githubusercontent.com/u/7426244?v=3","gravatar_id":"","url":"https://api.github.com/users/lf-kailashraj","html_url":"https://github.com/lf-kailashraj","followers_url":"https://api.github.com/users/lf-kailashraj/followers","following_url":"https://api.github.com/users/lf-kailashraj/following{/other_user}","gists_url":"https://api.github.com/users/lf-kailashraj/gists{/gist_id}","starred_url":"https://api.github.com/users/lf-kailashraj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lf-kailashraj/subscriptions","organizations_url":"https://api.github.com/users/lf-kailashraj/orgs","repos_url":"https://api.github.com/users/lf-kailashraj/repos","events_url":"https://api.github.com/users/lf-kailashraj/events{/privacy}","received_events_url":"https://api.github.com/users/lf-kailashraj/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502/commits","review_comments_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502/comments","review_comment_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/comments{/number}","comments_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/502/comments","statuses_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/statuses/c476262822a15cd985ccc6398f2e1f5245990a59","head":{"label":"leapfrogtechnology:VY-RES-479","ref":"VY-RES-479","sha":"c476262822a15cd985ccc6398f2e1f5245990a59","user":{"login":"leapfrogtechnology","id":3176020,"avatar_url":"https://avatars.githubusercontent.com/u/3176020?v=3","gravatar_id":"","url":"https://api.github.com/users/leapfrogtechnology","html_url":"https://github.com/leapfrogtechnology","followers_url":"https://api.github.com/users/leapfrogtechnology/followers","following_url":"https://api.github.com/users/leapfrogtechnology/following{/other_user}","gists_url":"https://api.github.com/users/leapfrogtechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/leapfrogtechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapfrogtechnology/subscriptions","organizations_url":"https://api.github.com/users/leapfrogtechnology/orgs","repos_url":"https://api.github.com/users/leapfrogtechnology/repos","events_url":"https://api.github.com/users/leapfrogtechnology/events{/privacy}","received_events_url":"https://api.github.com/users/leapfrogtechnology/received_events","type":"Organization","site_admin":false},"repo":{"id":50503051,"name":"vyaguta-resource","full_name":"leapfrogtechnology/vyaguta-resource","owner":{"login":"leapfrogtechnology","id":3176020,"avatar_url":"https://avatars.githubusercontent.com/u/3176020?v=3","gravatar_id":"","url":"https://api.github.com/users/leapfrogtechnology","html_url":"https://github.com/leapfrogtechnology","followers_url":"https://api.github.com/users/leapfrogtechnology/followers","following_url":"https://api.github.com/users/leapfrogtechnology/following{/other_user}","gists_url":"https://api.github.com/users/leapfrogtechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/leapfrogtechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapfrogtechnology/subscriptions","organizations_url":"https://api.github.com/users/leapfrogtechnology/orgs","repos_url":"https://api.github.com/users/leapfrogtechnology/repos","events_url":"https://api.github.com/users/leapfrogtechnology/events{/privacy}","received_events_url":"https://api.github.com/users/leapfrogtechnology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/leapfrogtechnology/vyaguta-resource","description":"","fork":false,"url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource","forks_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/forks","keys_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/teams","hooks_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/hooks","issue_events_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/events{/number}","events_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/events","assignees_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/assignees{/user}","branches_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/branches{/branch}","tags_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/tags","blobs_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/refs{/sha}","trees_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/statuses/{sha}","languages_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/languages","stargazers_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/stargazers","contributors_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/contributors","subscribers_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/subscribers","subscription_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/subscription","commits_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/commits{/sha}","git_commits_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/commits{/sha}","comments_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/comments{/number}","issue_comment_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/comments{/number}","contents_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/contents/{+path}","compare_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/merges","archive_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/downloads","issues_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues{/number}","pulls_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls{/number}","milestones_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/milestones{/number}","notifications_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/labels{/name}","releases_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/releases{/id}","deployments_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/deployments","created_at":"2016-01-27T11:33:05Z","updated_at":"2016-02-29T11:13:57Z","pushed_at":"2016-05-02T09:35:29Z","git_url":"git://github.com/leapfrogtechnology/vyaguta-resource.git","ssh_url":"git@github.com:leapfrogtechnology/vyaguta-resource.git","clone_url":"https://github.com/leapfrogtechnology/vyaguta-resource.git","svn_url":"https://github.com/leapfrogtechnology/vyaguta-resource","homepage":null,"size":2834,"stargazers_count":4,"watchers_count":4,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":104,"forks":0,"open_issues":104,"watchers":4,"default_branch":"master"}},"base":{"label":"leapfrogtechnology:dev","ref":"dev","sha":"5214ce67a3c2285ec7bb497cc1cdc2aa1bee6cad","user":{"login":"leapfrogtechnology","id":3176020,"avatar_url":"https://avatars.githubusercontent.com/u/3176020?v=3","gravatar_id":"","url":"https://api.github.com/users/leapfrogtechnology","html_url":"https://github.com/leapfrogtechnology","followers_url":"https://api.github.com/users/leapfrogtechnology/followers","following_url":"https://api.github.com/users/leapfrogtechnology/following{/other_user}","gists_url":"https://api.github.com/users/leapfrogtechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/leapfrogtechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapfrogtechnology/subscriptions","organizations_url":"https://api.github.com/users/leapfrogtechnology/orgs","repos_url":"https://api.github.com/users/leapfrogtechnology/repos","events_url":"https://api.github.com/users/leapfrogtechnology/events{/privacy}","received_events_url":"https://api.github.com/users/leapfrogtechnology/received_events","type":"Organization","site_admin":false},"repo":{"id":50503051,"name":"vyaguta-resource","full_name":"leapfrogtechnology/vyaguta-resource","owner":{"login":"leapfrogtechnology","id":3176020,"avatar_url":"https://avatars.githubusercontent.com/u/3176020?v=3","gravatar_id":"","url":"https://api.github.com/users/leapfrogtechnology","html_url":"https://github.com/leapfrogtechnology","followers_url":"https://api.github.com/users/leapfrogtechnology/followers","following_url":"https://api.github.com/users/leapfrogtechnology/following{/other_user}","gists_url":"https://api.github.com/users/leapfrogtechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/leapfrogtechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leapfrogtechnology/subscriptions","organizations_url":"https://api.github.com/users/leapfrogtechnology/orgs","repos_url":"https://api.github.com/users/leapfrogtechnology/repos","events_url":"https://api.github.com/users/leapfrogtechnology/events{/privacy}","received_events_url":"https://api.github.com/users/leapfrogtechnology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/leapfrogtechnology/vyaguta-resource","description":"","fork":false,"url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource","forks_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/forks","keys_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/teams","hooks_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/hooks","issue_events_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/events{/number}","events_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/events","assignees_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/assignees{/user}","branches_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/branches{/branch}","tags_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/tags","blobs_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/refs{/sha}","trees_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/statuses/{sha}","languages_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/languages","stargazers_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/stargazers","contributors_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/contributors","subscribers_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/subscribers","subscription_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/subscription","commits_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/commits{/sha}","git_commits_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/git/commits{/sha}","comments_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/comments{/number}","issue_comment_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/comments{/number}","contents_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/contents/{+path}","compare_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/merges","archive_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/downloads","issues_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues{/number}","pulls_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls{/number}","milestones_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/milestones{/number}","notifications_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/labels{/name}","releases_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/releases{/id}","deployments_url":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/deployments","created_at":"2016-01-27T11:33:05Z","updated_at":"2016-02-29T11:13:57Z","pushed_at":"2016-05-02T09:35:29Z","git_url":"git://github.com/leapfrogtechnology/vyaguta-resource.git","ssh_url":"git@github.com:leapfrogtechnology/vyaguta-resource.git","clone_url":"https://github.com/leapfrogtechnology/vyaguta-resource.git","svn_url":"https://github.com/leapfrogtechnology/vyaguta-resource","homepage":null,"size":2834,"stargazers_count":4,"watchers_count":4,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":104,"forks":0,"open_issues":104,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502"},"html":{"href":"https://github.com/leapfrogtechnology/vyaguta-resource/pull/502"},"issue":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/502"},"comments":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/issues/502/comments"},"review_comments":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502/comments"},"review_comment":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/pulls/502/commits"},"statuses":{"href":"https://api.github.com/repos/leapfrogtechnology/vyaguta-resource/statuses/c476262822a15cd985ccc6398f2e1f5245990a59"}}}}