{"action":"created","comment":{"url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/comments/196909014","pull_request_review_id":130548201,"id":196909014,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NjkwOTAxNA==","diff_hunk":"@@ -0,0 +1,171 @@\n+package creativei.service;\n+\n+import creativei.dao.AmcContractDao;\n+import creativei.entity.AmcContract;\n+import creativei.entity.AmcContractProduct;\n+import creativei.entity.Customer;\n+import creativei.entity.CustomerProduct;\n+import creativei.exception.ApplicationLevelException;\n+import creativei.service.EmailService.MailService;\n+import creativei.service.PdfService.PdfConversionService;\n+import creativei.service.TemplateService.TemplateService;\n+import creativei.util.ServiceConfiguration;\n+import creativei.util.emailutil.MailAddress;\n+import creativei.util.emailutil.MailAttachment;\n+import creativei.util.emailutil.MailObject;\n+import creativei.util.emailutil.Recipient;\n+import creativei.vo.*;\n+import org.apache.commons.lang3.ArrayUtils;\n+import org.apache.commons.lang3.StringUtils;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.core.env.Environment;\n+import org.springframework.scheduling.annotation.Async;\n+import org.springframework.stereotype.Component;\n+\n+import javax.mail.Message;\n+import javax.transaction.Transactional;\n+import java.io.ByteArrayOutputStream;\n+import java.util.ArrayList;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+\n+@Component\n+public class EmailAsyncService{\n+    private static final Logger logger = LoggerFactory.getLogger(EmailAsyncService.class);\n+    @Autowired\n+    private AmcContractDao amcContractDao;\n+\n+    @Autowired\n+    private CustomerService customerService;\n+\n+    @Autowired\n+    private Environment env;\n+\n+    @Autowired\n+    private ServiceConfiguration serviceConfiguration;\n+\n+    @Autowired\n+    private TemplateService templateService;\n+\n+    @Autowired\n+    private PdfConversionService pdfConversionService;\n+\n+    @Autowired\n+    private MailService mailService;\n+\n+    @Autowired\n+    private CustomerProductService customerProductService;\n+\n+    @Autowired\n+    private ProductService productService;\n+\n+    @Async\n+    @Transactional\n+    public void sendAmcContractToCustomer(AmcContract contract){\n+        try {\n+            AmcContractTemplateVO contractVO = this.prepareAmcContractTemplateVO(contract);\n+            String customerMailId = contractVO.getCustomerVO().getEmail();\n+            if (StringUtils.isBlank(customerMailId)) {\n+                logger.error(\"Invalid email id.\");\n+                return;\n+            }\n+            Map<String, Object> ctx = new HashMap<String, Object>();\n+            ctx.put(\"contractTemplateVO\", contractVO);\n+            String coontractHtml = templateService.generateHTML(\"AmcContractOffer.vm\", \"templates/\", ctx);\n+            logger.info(coontractHtml);\n+            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();\n+            pdfConversionService.convertHtmlToPdf(outputStream, coontractHtml);\n+            byte[] bytes = outputStream.toByteArray();\n+\n+            MailObject email = new MailObject();\n+            List<Recipient> recipients = new ArrayList<Recipient>();\n+            Recipient recipient1 = new Recipient();\n+            MailAddress mailAddress = new MailAddress(contractVO.getCustomerVO().getName(), customerMailId);\n+            recipient1.setMailAddress(mailAddress);\n+            recipient1.setRecipientType(Message.RecipientType.TO);\n+            recipients.add(recipient1);\n+            email.setRecipients(recipients);\n+            email.setSubject(\"Offer for AMC Contract for Weighing Systems.\");\n+\n+            // set html content\n+            email.setHtmlBody(this.getMailBodyForContractOffer(contractVO));\n+\n+            // initialized attachment object\n+            MailAttachment attachment = new MailAttachment();\n+\n+            // set file content and file name\n+            attachment.setFile(ArrayUtils.toObject(bytes));\n+            attachment.setFilename(\"Contract.pdf\");\n+            // added attachments in attacchment list\n+            List<MailAttachment> mailAttachments = new ArrayList<MailAttachment>();\n+            mailAttachments.add(attachment);\n+\n+            // set attachment list in attachment array\n+            email.setAttachments(mailAttachments);\n+            // send mail\n+            boolean status = mailService.sendmail(email);","path":"src/main/java/creativei/service/EmailAsyncService.java","position":109,"original_position":109,"commit_id":"aca6867ad91c87496f27bbd7419f889cf9f4eb95","original_commit_id":"aca6867ad91c87496f27bbd7419f889cf9f4eb95","user":{"login":"aayushKhandpur","id":10972958,"node_id":"MDQ6VXNlcjEwOTcyOTU4","avatar_url":"https://avatars0.githubusercontent.com/u/10972958?v=4","gravatar_id":"","url":"https://api.github.com/users/aayushKhandpur","html_url":"https://github.com/aayushKhandpur","followers_url":"https://api.github.com/users/aayushKhandpur/followers","following_url":"https://api.github.com/users/aayushKhandpur/following{/other_user}","gists_url":"https://api.github.com/users/aayushKhandpur/gists{/gist_id}","starred_url":"https://api.github.com/users/aayushKhandpur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aayushKhandpur/subscriptions","organizations_url":"https://api.github.com/users/aayushKhandpur/orgs","repos_url":"https://api.github.com/users/aayushKhandpur/repos","events_url":"https://api.github.com/users/aayushKhandpur/events{/privacy}","received_events_url":"https://api.github.com/users/aayushKhandpur/received_events","type":"User","site_admin":false},"body":"Where are we using this status? Should verify the value of status.","created_at":"2018-06-20T19:07:02Z","updated_at":"2018-06-20T19:07:02Z","html_url":"https://github.com/aayushKhandpur/weightmaster/pull/22#discussion_r196909014","pull_request_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/comments/196909014"},"html":{"href":"https://github.com/aayushKhandpur/weightmaster/pull/22#discussion_r196909014"},"pull_request":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22","id":196028186,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MDI4MTg2","html_url":"https://github.com/aayushKhandpur/weightmaster/pull/22","diff_url":"https://github.com/aayushKhandpur/weightmaster/pull/22.diff","patch_url":"https://github.com/aayushKhandpur/weightmaster/pull/22.patch","issue_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/22","number":22,"state":"open","locked":false,"title":"Contract pdf","user":{"login":"manojkrsaini09","id":16777011,"node_id":"MDQ6VXNlcjE2Nzc3MDEx","avatar_url":"https://avatars0.githubusercontent.com/u/16777011?v=4","gravatar_id":"","url":"https://api.github.com/users/manojkrsaini09","html_url":"https://github.com/manojkrsaini09","followers_url":"https://api.github.com/users/manojkrsaini09/followers","following_url":"https://api.github.com/users/manojkrsaini09/following{/other_user}","gists_url":"https://api.github.com/users/manojkrsaini09/gists{/gist_id}","starred_url":"https://api.github.com/users/manojkrsaini09/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manojkrsaini09/subscriptions","organizations_url":"https://api.github.com/users/manojkrsaini09/orgs","repos_url":"https://api.github.com/users/manojkrsaini09/repos","events_url":"https://api.github.com/users/manojkrsaini09/events{/privacy}","received_events_url":"https://api.github.com/users/manojkrsaini09/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-20T05:50:40Z","updated_at":"2018-06-20T19:07:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e710882a48ba909fef18dca81ed57c50977e67a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22/commits","review_comments_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22/comments","review_comment_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/22/comments","statuses_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/statuses/aca6867ad91c87496f27bbd7419f889cf9f4eb95","head":{"label":"aayushKhandpur:contract-pdf","ref":"contract-pdf","sha":"aca6867ad91c87496f27bbd7419f889cf9f4eb95","user":{"login":"aayushKhandpur","id":10972958,"node_id":"MDQ6VXNlcjEwOTcyOTU4","avatar_url":"https://avatars0.githubusercontent.com/u/10972958?v=4","gravatar_id":"","url":"https://api.github.com/users/aayushKhandpur","html_url":"https://github.com/aayushKhandpur","followers_url":"https://api.github.com/users/aayushKhandpur/followers","following_url":"https://api.github.com/users/aayushKhandpur/following{/other_user}","gists_url":"https://api.github.com/users/aayushKhandpur/gists{/gist_id}","starred_url":"https://api.github.com/users/aayushKhandpur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aayushKhandpur/subscriptions","organizations_url":"https://api.github.com/users/aayushKhandpur/orgs","repos_url":"https://api.github.com/users/aayushKhandpur/repos","events_url":"https://api.github.com/users/aayushKhandpur/events{/privacy}","received_events_url":"https://api.github.com/users/aayushKhandpur/received_events","type":"User","site_admin":false},"repo":{"id":128669293,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg2NjkyOTM=","name":"weightmaster","full_name":"aayushKhandpur/weightmaster","owner":{"login":"aayushKhandpur","id":10972958,"node_id":"MDQ6VXNlcjEwOTcyOTU4","avatar_url":"https://avatars0.githubusercontent.com/u/10972958?v=4","gravatar_id":"","url":"https://api.github.com/users/aayushKhandpur","html_url":"https://github.com/aayushKhandpur","followers_url":"https://api.github.com/users/aayushKhandpur/followers","following_url":"https://api.github.com/users/aayushKhandpur/following{/other_user}","gists_url":"https://api.github.com/users/aayushKhandpur/gists{/gist_id}","starred_url":"https://api.github.com/users/aayushKhandpur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aayushKhandpur/subscriptions","organizations_url":"https://api.github.com/users/aayushKhandpur/orgs","repos_url":"https://api.github.com/users/aayushKhandpur/repos","events_url":"https://api.github.com/users/aayushKhandpur/events{/privacy}","received_events_url":"https://api.github.com/users/aayushKhandpur/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aayushKhandpur/weightmaster","description":null,"fork":false,"url":"https://api.github.com/repos/aayushKhandpur/weightmaster","forks_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/forks","keys_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/teams","hooks_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/hooks","issue_events_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/events{/number}","events_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/events","assignees_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/assignees{/user}","branches_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/branches{/branch}","tags_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/tags","blobs_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/refs{/sha}","trees_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/statuses/{sha}","languages_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/languages","stargazers_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/stargazers","contributors_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/contributors","subscribers_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/subscribers","subscription_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/subscription","commits_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/commits{/sha}","git_commits_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/commits{/sha}","comments_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/comments{/number}","issue_comment_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/comments{/number}","contents_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/contents/{+path}","compare_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/merges","archive_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/downloads","issues_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues{/number}","pulls_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls{/number}","milestones_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/milestones{/number}","notifications_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/labels{/name}","releases_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/releases{/id}","deployments_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/deployments","created_at":"2018-04-08T18:19:15Z","updated_at":"2018-06-18T13:18:18Z","pushed_at":"2018-06-20T06:11:28Z","git_url":"git://github.com/aayushKhandpur/weightmaster.git","ssh_url":"git@github.com:aayushKhandpur/weightmaster.git","clone_url":"https://github.com/aayushKhandpur/weightmaster.git","svn_url":"https://github.com/aayushKhandpur/weightmaster","homepage":null,"size":2962,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"aayushKhandpur:master","ref":"master","sha":"dc21af06a090f01473be7c7baf0fc63a3f51a25c","user":{"login":"aayushKhandpur","id":10972958,"node_id":"MDQ6VXNlcjEwOTcyOTU4","avatar_url":"https://avatars0.githubusercontent.com/u/10972958?v=4","gravatar_id":"","url":"https://api.github.com/users/aayushKhandpur","html_url":"https://github.com/aayushKhandpur","followers_url":"https://api.github.com/users/aayushKhandpur/followers","following_url":"https://api.github.com/users/aayushKhandpur/following{/other_user}","gists_url":"https://api.github.com/users/aayushKhandpur/gists{/gist_id}","starred_url":"https://api.github.com/users/aayushKhandpur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aayushKhandpur/subscriptions","organizations_url":"https://api.github.com/users/aayushKhandpur/orgs","repos_url":"https://api.github.com/users/aayushKhandpur/repos","events_url":"https://api.github.com/users/aayushKhandpur/events{/privacy}","received_events_url":"https://api.github.com/users/aayushKhandpur/received_events","type":"User","site_admin":false},"repo":{"id":128669293,"node_id":"MDEwOlJlcG9zaXRvcnkxMjg2NjkyOTM=","name":"weightmaster","full_name":"aayushKhandpur/weightmaster","owner":{"login":"aayushKhandpur","id":10972958,"node_id":"MDQ6VXNlcjEwOTcyOTU4","avatar_url":"https://avatars0.githubusercontent.com/u/10972958?v=4","gravatar_id":"","url":"https://api.github.com/users/aayushKhandpur","html_url":"https://github.com/aayushKhandpur","followers_url":"https://api.github.com/users/aayushKhandpur/followers","following_url":"https://api.github.com/users/aayushKhandpur/following{/other_user}","gists_url":"https://api.github.com/users/aayushKhandpur/gists{/gist_id}","starred_url":"https://api.github.com/users/aayushKhandpur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aayushKhandpur/subscriptions","organizations_url":"https://api.github.com/users/aayushKhandpur/orgs","repos_url":"https://api.github.com/users/aayushKhandpur/repos","events_url":"https://api.github.com/users/aayushKhandpur/events{/privacy}","received_events_url":"https://api.github.com/users/aayushKhandpur/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aayushKhandpur/weightmaster","description":null,"fork":false,"url":"https://api.github.com/repos/aayushKhandpur/weightmaster","forks_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/forks","keys_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/teams","hooks_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/hooks","issue_events_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/events{/number}","events_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/events","assignees_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/assignees{/user}","branches_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/branches{/branch}","tags_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/tags","blobs_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/refs{/sha}","trees_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/statuses/{sha}","languages_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/languages","stargazers_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/stargazers","contributors_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/contributors","subscribers_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/subscribers","subscription_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/subscription","commits_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/commits{/sha}","git_commits_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/git/commits{/sha}","comments_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/comments{/number}","issue_comment_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/comments{/number}","contents_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/contents/{+path}","compare_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/merges","archive_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/downloads","issues_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues{/number}","pulls_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls{/number}","milestones_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/milestones{/number}","notifications_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/labels{/name}","releases_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/releases{/id}","deployments_url":"https://api.github.com/repos/aayushKhandpur/weightmaster/deployments","created_at":"2018-04-08T18:19:15Z","updated_at":"2018-06-18T13:18:18Z","pushed_at":"2018-06-20T06:11:28Z","git_url":"git://github.com/aayushKhandpur/weightmaster.git","ssh_url":"git@github.com:aayushKhandpur/weightmaster.git","clone_url":"https://github.com/aayushKhandpur/weightmaster.git","svn_url":"https://github.com/aayushKhandpur/weightmaster","homepage":null,"size":2962,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22"},"html":{"href":"https://github.com/aayushKhandpur/weightmaster/pull/22"},"issue":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/22"},"comments":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/aayushKhandpur/weightmaster/statuses/aca6867ad91c87496f27bbd7419f889cf9f4eb95"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"aayushKhandpur"}}