{"action":"created","comment":{"url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/comments/151150165","pull_request_review_id":76790006,"id":151150165,"diff_hunk":"@@ -0,0 +1,75 @@\n+package uk.gov.hmcts.cmc.claimstore.services;\n+\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.beans.factory.annotation.Value;\n+import org.springframework.stereotype.Service;\n+import uk.gov.hmcts.cmc.claimstore.documents.DefendantResponseCopyService;\n+import uk.gov.hmcts.cmc.claimstore.documents.LegalSealedClaimPdfService;\n+import uk.gov.hmcts.cmc.domain.models.Claim;\n+\n+import static org.apache.commons.lang3.StringUtils.isBlank;\n+import static uk.gov.hmcts.cmc.claimstore.services.DocumentManagementService.PDF_EXTENSION;\n+\n+@Service\n+public class DocumentsService {\n+    public static final String APPLICATION_PDF = \"application/pdf\";\n+    private final ClaimService claimService;\n+    private final DefendantResponseCopyService defendantResponseCopyService;\n+    private final LegalSealedClaimPdfService legalSealedClaimPdfService;\n+    private final CountyCourtJudgmentService countyCourtJudgmentService;\n+    private final DocumentManagementService documentManagementService;\n+    private final boolean documentManagementFeatureEnabled;\n+\n+    @Autowired\n+    public DocumentsService(\n+        final ClaimService claimService,\n+        final DefendantResponseCopyService defendantResponseCopyService,\n+        final LegalSealedClaimPdfService legalSealedClaimPdfService,\n+        final CountyCourtJudgmentService countyCourtJudgmentService,\n+        final DocumentManagementService documentManagementService,\n+        @Value(\"${feature_toggles.document_management}\") final boolean documentManagementFeatureEnabled\n+    ) {\n+        this.claimService = claimService;\n+        this.defendantResponseCopyService = defendantResponseCopyService;\n+        this.legalSealedClaimPdfService = legalSealedClaimPdfService;\n+        this.countyCourtJudgmentService = countyCourtJudgmentService;\n+        this.documentManagementService = documentManagementService;\n+        this.documentManagementFeatureEnabled = documentManagementFeatureEnabled;\n+    }\n+\n+    public byte[] defendantResponseCopy(final String claimExternalId) {\n+        final Claim claim = claimService.getClaimByExternalId(claimExternalId);\n+        return defendantResponseCopyService.createPdf(claim);\n+    }\n+\n+    public byte[] legalSealedClaim(final String claimExternalId, final String authorisation) {\n+        final Claim claim = claimService.getClaimByExternalId(claimExternalId);\n+        return getLegalN1FormPdfDocument(claim, authorisation);\n+    }\n+\n+    private byte[] getLegalN1FormPdfDocument(final Claim claim, final String authorisation) {\n+        final byte[] n1ClaimPdf = legalSealedClaimPdfService.createPdf(claim);","path":"src/main/java/uk/gov/hmcts/cmc/claimstore/services/DocumentsService.java","position":51,"original_position":51,"commit_id":"5e92e2df10a735e7a138fb0a33b3ef0444d34b7c","original_commit_id":"5e92e2df10a735e7a138fb0a33b3ef0444d34b7c","user":{"login":"geek-soft","id":1724691,"avatar_url":"https://avatars0.githubusercontent.com/u/1724691?v=4","gravatar_id":"","url":"https://api.github.com/users/geek-soft","html_url":"https://github.com/geek-soft","followers_url":"https://api.github.com/users/geek-soft/followers","following_url":"https://api.github.com/users/geek-soft/following{/other_user}","gists_url":"https://api.github.com/users/geek-soft/gists{/gist_id}","starred_url":"https://api.github.com/users/geek-soft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geek-soft/subscriptions","organizations_url":"https://api.github.com/users/geek-soft/orgs","repos_url":"https://api.github.com/users/geek-soft/repos","events_url":"https://api.github.com/users/geek-soft/events{/privacy}","received_events_url":"https://api.github.com/users/geek-soft/received_events","type":"User","site_admin":false},"body":"I would also reshape the logic to early return if document is in DM, otherwise more logic to generate.\r\n\r\nOne more thing since we have both retrieval a upload make name to reflect that fact e.g. `downloadOrGenerateAndUploadN1Form`. Not too pretty but doing so many actions is bad thing in the first place. I would prefer to generate PDF for all the claims and not having this issue.","created_at":"2017-11-15T15:01:12Z","updated_at":"2017-11-15T15:08:51Z","html_url":"https://github.com/hmcts/cmc-claim-store/pull/80#discussion_r151150165","pull_request_url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/comments/151150165"},"html":{"href":"https://github.com/hmcts/cmc-claim-store/pull/80#discussion_r151150165"},"pull_request":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80"}},"in_reply_to_id":151147827},"pull_request":{"url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80","id":150537108,"html_url":"https://github.com/hmcts/cmc-claim-store/pull/80","diff_url":"https://github.com/hmcts/cmc-claim-store/pull/80.diff","patch_url":"https://github.com/hmcts/cmc-claim-store/pull/80.patch","issue_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/80","number":80,"state":"open","locked":false,"title":"ROC-2506: Document Management integration ","user":{"login":"dharmendrak","id":581234,"avatar_url":"https://avatars2.githubusercontent.com/u/581234?v=4","gravatar_id":"","url":"https://api.github.com/users/dharmendrak","html_url":"https://github.com/dharmendrak","followers_url":"https://api.github.com/users/dharmendrak/followers","following_url":"https://api.github.com/users/dharmendrak/following{/other_user}","gists_url":"https://api.github.com/users/dharmendrak/gists{/gist_id}","starred_url":"https://api.github.com/users/dharmendrak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dharmendrak/subscriptions","organizations_url":"https://api.github.com/users/dharmendrak/orgs","repos_url":"https://api.github.com/users/dharmendrak/repos","events_url":"https://api.github.com/users/dharmendrak/events{/privacy}","received_events_url":"https://api.github.com/users/dharmendrak/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-11-03T14:10:15Z","updated_at":"2017-11-15T15:08:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1391bf0ad25b56a55b554e9500f3d8526c953150","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80/commits","review_comments_url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80/comments","review_comment_url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/80/comments","statuses_url":"https://api.github.com/repos/hmcts/cmc-claim-store/statuses/5e92e2df10a735e7a138fb0a33b3ef0444d34b7c","head":{"label":"hmcts:feature/ROC-2506-DM-integration","ref":"feature/ROC-2506-DM-integration","sha":"5e92e2df10a735e7a138fb0a33b3ef0444d34b7c","user":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"repo":{"id":101856095,"name":"cmc-claim-store","full_name":"hmcts/cmc-claim-store","owner":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmcts/cmc-claim-store","description":"Backend service for Civil Money Claims","fork":false,"url":"https://api.github.com/repos/hmcts/cmc-claim-store","forks_url":"https://api.github.com/repos/hmcts/cmc-claim-store/forks","keys_url":"https://api.github.com/repos/hmcts/cmc-claim-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/cmc-claim-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/cmc-claim-store/teams","hooks_url":"https://api.github.com/repos/hmcts/cmc-claim-store/hooks","issue_events_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/cmc-claim-store/events","assignees_url":"https://api.github.com/repos/hmcts/cmc-claim-store/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/cmc-claim-store/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/cmc-claim-store/tags","blobs_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/cmc-claim-store/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/cmc-claim-store/languages","stargazers_url":"https://api.github.com/repos/hmcts/cmc-claim-store/stargazers","contributors_url":"https://api.github.com/repos/hmcts/cmc-claim-store/contributors","subscribers_url":"https://api.github.com/repos/hmcts/cmc-claim-store/subscribers","subscription_url":"https://api.github.com/repos/hmcts/cmc-claim-store/subscription","commits_url":"https://api.github.com/repos/hmcts/cmc-claim-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/cmc-claim-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/cmc-claim-store/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/cmc-claim-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/cmc-claim-store/merges","archive_url":"https://api.github.com/repos/hmcts/cmc-claim-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/cmc-claim-store/downloads","issues_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/cmc-claim-store/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/cmc-claim-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/cmc-claim-store/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/cmc-claim-store/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/cmc-claim-store/deployments","created_at":"2017-08-30T08:17:34Z","updated_at":"2017-11-06T21:15:06Z","pushed_at":"2017-11-15T15:02:31Z","git_url":"git://github.com/hmcts/cmc-claim-store.git","ssh_url":"git@github.com:hmcts/cmc-claim-store.git","clone_url":"https://github.com/hmcts/cmc-claim-store.git","svn_url":"https://github.com/hmcts/cmc-claim-store","homepage":"","size":1111,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"hmcts:master","ref":"master","sha":"956484c8fdc51eb473452afef6b71426946135b6","user":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"repo":{"id":101856095,"name":"cmc-claim-store","full_name":"hmcts/cmc-claim-store","owner":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmcts/cmc-claim-store","description":"Backend service for Civil Money Claims","fork":false,"url":"https://api.github.com/repos/hmcts/cmc-claim-store","forks_url":"https://api.github.com/repos/hmcts/cmc-claim-store/forks","keys_url":"https://api.github.com/repos/hmcts/cmc-claim-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/cmc-claim-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/cmc-claim-store/teams","hooks_url":"https://api.github.com/repos/hmcts/cmc-claim-store/hooks","issue_events_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/cmc-claim-store/events","assignees_url":"https://api.github.com/repos/hmcts/cmc-claim-store/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/cmc-claim-store/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/cmc-claim-store/tags","blobs_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/cmc-claim-store/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/cmc-claim-store/languages","stargazers_url":"https://api.github.com/repos/hmcts/cmc-claim-store/stargazers","contributors_url":"https://api.github.com/repos/hmcts/cmc-claim-store/contributors","subscribers_url":"https://api.github.com/repos/hmcts/cmc-claim-store/subscribers","subscription_url":"https://api.github.com/repos/hmcts/cmc-claim-store/subscription","commits_url":"https://api.github.com/repos/hmcts/cmc-claim-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/cmc-claim-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/cmc-claim-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/cmc-claim-store/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/cmc-claim-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/cmc-claim-store/merges","archive_url":"https://api.github.com/repos/hmcts/cmc-claim-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/cmc-claim-store/downloads","issues_url":"https://api.github.com/repos/hmcts/cmc-claim-store/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/cmc-claim-store/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/cmc-claim-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/cmc-claim-store/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/cmc-claim-store/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/cmc-claim-store/deployments","created_at":"2017-08-30T08:17:34Z","updated_at":"2017-11-06T21:15:06Z","pushed_at":"2017-11-15T15:02:31Z","git_url":"git://github.com/hmcts/cmc-claim-store.git","ssh_url":"git@github.com:hmcts/cmc-claim-store.git","clone_url":"https://github.com/hmcts/cmc-claim-store.git","svn_url":"https://github.com/hmcts/cmc-claim-store","homepage":"","size":1111,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80"},"html":{"href":"https://github.com/hmcts/cmc-claim-store/pull/80"},"issue":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/80"},"comments":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/hmcts/cmc-claim-store/statuses/5e92e2df10a735e7a138fb0a33b3ef0444d34b7c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"geek-soft"}}