{"action":"created","comment":{"url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/comments/90625558","pull_request_review_id":11143877,"id":90625558,"diff_hunk":"@@ -0,0 +1,101 @@\n+package sg.ncl.service.upload.logic;\n+\n+import lombok.extern.slf4j.Slf4j;\n+import org.apache.tomcat.util.codec.binary.Base64;\n+import org.springframework.stereotype.Service;\n+import sg.ncl.common.exception.base.BadRequestException;\n+import sg.ncl.service.upload.DirectoryProperties;\n+import sg.ncl.service.upload.data.ResumableEntity;\n+import sg.ncl.service.upload.data.ResumableStorage;\n+import sg.ncl.service.upload.domain.UploadService;\n+import sg.ncl.service.upload.domain.UploadStatus;\n+import sg.ncl.service.upload.util.HttpUtils;\n+import sg.ncl.service.upload.web.ResumableInfo;\n+\n+import javax.inject.Inject;\n+import java.io.IOException;\n+import java.io.RandomAccessFile;\n+import java.nio.file.Files;\n+import java.nio.file.Path;\n+\n+/**\n+ * Created by dcsjnh on 11/24/2016.\n+ */\n+@Service\n+@Slf4j\n+public class UploadServiceImpl implements UploadService {\n+\n+    private final ResumableStorage storage;\n+    private final DirectoryProperties properties;\n+\n+    @Inject\n+    UploadServiceImpl(final ResumableStorage storage, final DirectoryProperties properties) {\n+        this.storage = storage;\n+        this.properties = properties;\n+    }\n+\n+    @Override\n+    public UploadStatus checkChunk(String resumableIdentifier, int resumableChunkNumber) {\n+        ResumableEntity entity = storage.get(resumableIdentifier);\n+        if (entity != null && entity.uploadedChunks.contains(new ResumableEntity.ResumableChunkNumber(resumableChunkNumber))) {\n+            return UploadStatus.UPLOADED;\n+        } else {\n+            return  UploadStatus.NOT_FOUND;\n+        }\n+    }\n+\n+    @Override\n+    public UploadStatus addChunk(ResumableInfo resumableInfo, int resumableChunkNumber, String subDirKey, String preDir) {\n+        Path path = HttpUtils.getPath(properties, subDirKey, preDir);\n+        //if directory exists?\n+        if (!path.toFile().exists()) {\n+            try {\n+                Files.createDirectories(path);\n+            } catch (IOException e) {","path":"service-upload/src/main/java/sg/ncl/service/upload/logic/UploadServiceImpl.java","position":54,"original_position":54,"commit_id":"911fc51707fe0239ec2640bf20bbd2657350fec9","original_commit_id":"911fc51707fe0239ec2640bf20bbd2657350fec9","user":{"login":"ChrisZhong","id":1946052,"avatar_url":"https://avatars.githubusercontent.com/u/1946052?v=3","gravatar_id":"","url":"https://api.github.com/users/ChrisZhong","html_url":"https://github.com/ChrisZhong","followers_url":"https://api.github.com/users/ChrisZhong/followers","following_url":"https://api.github.com/users/ChrisZhong/following{/other_user}","gists_url":"https://api.github.com/users/ChrisZhong/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisZhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisZhong/subscriptions","organizations_url":"https://api.github.com/users/ChrisZhong/orgs","repos_url":"https://api.github.com/users/ChrisZhong/repos","events_url":"https://api.github.com/users/ChrisZhong/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisZhong/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Either log or rethrow this exception. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://sonarqube.com/coding_rules#rule_key=squid%3AS1166)\n","created_at":"2016-12-02T11:14:47Z","updated_at":"2016-12-02T11:14:47Z","html_url":"https://github.com/nus-ncl/services-in-one/pull/200#discussion_r90625558","pull_request_url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200","_links":{"self":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/comments/90625558"},"html":{"href":"https://github.com/nus-ncl/services-in-one/pull/200#discussion_r90625558"},"pull_request":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200"}}},"pull_request":{"url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200","id":96248549,"html_url":"https://github.com/nus-ncl/services-in-one/pull/200","diff_url":"https://github.com/nus-ncl/services-in-one/pull/200.diff","patch_url":"https://github.com/nus-ncl/services-in-one/pull/200.patch","issue_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues/200","number":200,"state":"open","locked":false,"title":"Dev-727 Added upload/download data resources functionality","user":{"login":"nghianja","id":1296470,"avatar_url":"https://avatars.githubusercontent.com/u/1296470?v=3","gravatar_id":"","url":"https://api.github.com/users/nghianja","html_url":"https://github.com/nghianja","followers_url":"https://api.github.com/users/nghianja/followers","following_url":"https://api.github.com/users/nghianja/following{/other_user}","gists_url":"https://api.github.com/users/nghianja/gists{/gist_id}","starred_url":"https://api.github.com/users/nghianja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nghianja/subscriptions","organizations_url":"https://api.github.com/users/nghianja/orgs","repos_url":"https://api.github.com/users/nghianja/repos","events_url":"https://api.github.com/users/nghianja/events{/privacy}","received_events_url":"https://api.github.com/users/nghianja/received_events","type":"User","site_admin":false},"body":null,"created_at":"2016-12-02T09:43:07Z","updated_at":"2016-12-02T11:14:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8bc5ee123036b3baa5a45d6882953c6b06ad567f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200/commits","review_comments_url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200/comments","review_comment_url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues/200/comments","statuses_url":"https://api.github.com/repos/nus-ncl/services-in-one/statuses/911fc51707fe0239ec2640bf20bbd2657350fec9","head":{"label":"nus-ncl:DEV-727","ref":"DEV-727","sha":"911fc51707fe0239ec2640bf20bbd2657350fec9","user":{"login":"nus-ncl","id":15359055,"avatar_url":"https://avatars.githubusercontent.com/u/15359055?v=3","gravatar_id":"","url":"https://api.github.com/users/nus-ncl","html_url":"https://github.com/nus-ncl","followers_url":"https://api.github.com/users/nus-ncl/followers","following_url":"https://api.github.com/users/nus-ncl/following{/other_user}","gists_url":"https://api.github.com/users/nus-ncl/gists{/gist_id}","starred_url":"https://api.github.com/users/nus-ncl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nus-ncl/subscriptions","organizations_url":"https://api.github.com/users/nus-ncl/orgs","repos_url":"https://api.github.com/users/nus-ncl/repos","events_url":"https://api.github.com/users/nus-ncl/events{/privacy}","received_events_url":"https://api.github.com/users/nus-ncl/received_events","type":"Organization","site_admin":false},"repo":{"id":56112257,"name":"services-in-one","full_name":"nus-ncl/services-in-one","owner":{"login":"nus-ncl","id":15359055,"avatar_url":"https://avatars.githubusercontent.com/u/15359055?v=3","gravatar_id":"","url":"https://api.github.com/users/nus-ncl","html_url":"https://github.com/nus-ncl","followers_url":"https://api.github.com/users/nus-ncl/followers","following_url":"https://api.github.com/users/nus-ncl/following{/other_user}","gists_url":"https://api.github.com/users/nus-ncl/gists{/gist_id}","starred_url":"https://api.github.com/users/nus-ncl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nus-ncl/subscriptions","organizations_url":"https://api.github.com/users/nus-ncl/orgs","repos_url":"https://api.github.com/users/nus-ncl/repos","events_url":"https://api.github.com/users/nus-ncl/events{/privacy}","received_events_url":"https://api.github.com/users/nus-ncl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nus-ncl/services-in-one","description":null,"fork":false,"url":"https://api.github.com/repos/nus-ncl/services-in-one","forks_url":"https://api.github.com/repos/nus-ncl/services-in-one/forks","keys_url":"https://api.github.com/repos/nus-ncl/services-in-one/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nus-ncl/services-in-one/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nus-ncl/services-in-one/teams","hooks_url":"https://api.github.com/repos/nus-ncl/services-in-one/hooks","issue_events_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues/events{/number}","events_url":"https://api.github.com/repos/nus-ncl/services-in-one/events","assignees_url":"https://api.github.com/repos/nus-ncl/services-in-one/assignees{/user}","branches_url":"https://api.github.com/repos/nus-ncl/services-in-one/branches{/branch}","tags_url":"https://api.github.com/repos/nus-ncl/services-in-one/tags","blobs_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/refs{/sha}","trees_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nus-ncl/services-in-one/statuses/{sha}","languages_url":"https://api.github.com/repos/nus-ncl/services-in-one/languages","stargazers_url":"https://api.github.com/repos/nus-ncl/services-in-one/stargazers","contributors_url":"https://api.github.com/repos/nus-ncl/services-in-one/contributors","subscribers_url":"https://api.github.com/repos/nus-ncl/services-in-one/subscribers","subscription_url":"https://api.github.com/repos/nus-ncl/services-in-one/subscription","commits_url":"https://api.github.com/repos/nus-ncl/services-in-one/commits{/sha}","git_commits_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/commits{/sha}","comments_url":"https://api.github.com/repos/nus-ncl/services-in-one/comments{/number}","issue_comment_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues/comments{/number}","contents_url":"https://api.github.com/repos/nus-ncl/services-in-one/contents/{+path}","compare_url":"https://api.github.com/repos/nus-ncl/services-in-one/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nus-ncl/services-in-one/merges","archive_url":"https://api.github.com/repos/nus-ncl/services-in-one/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nus-ncl/services-in-one/downloads","issues_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues{/number}","pulls_url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls{/number}","milestones_url":"https://api.github.com/repos/nus-ncl/services-in-one/milestones{/number}","notifications_url":"https://api.github.com/repos/nus-ncl/services-in-one/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nus-ncl/services-in-one/labels{/name}","releases_url":"https://api.github.com/repos/nus-ncl/services-in-one/releases{/id}","deployments_url":"https://api.github.com/repos/nus-ncl/services-in-one/deployments","created_at":"2016-04-13T01:52:23Z","updated_at":"2016-10-24T07:57:31Z","pushed_at":"2016-12-02T11:07:20Z","git_url":"git://github.com/nus-ncl/services-in-one.git","ssh_url":"git@github.com:nus-ncl/services-in-one.git","clone_url":"https://github.com/nus-ncl/services-in-one.git","svn_url":"https://github.com/nus-ncl/services-in-one","homepage":null,"size":2915,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"nus-ncl:master","ref":"master","sha":"6a67c4942498ee123014cfc187bc56abddd66c04","user":{"login":"nus-ncl","id":15359055,"avatar_url":"https://avatars.githubusercontent.com/u/15359055?v=3","gravatar_id":"","url":"https://api.github.com/users/nus-ncl","html_url":"https://github.com/nus-ncl","followers_url":"https://api.github.com/users/nus-ncl/followers","following_url":"https://api.github.com/users/nus-ncl/following{/other_user}","gists_url":"https://api.github.com/users/nus-ncl/gists{/gist_id}","starred_url":"https://api.github.com/users/nus-ncl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nus-ncl/subscriptions","organizations_url":"https://api.github.com/users/nus-ncl/orgs","repos_url":"https://api.github.com/users/nus-ncl/repos","events_url":"https://api.github.com/users/nus-ncl/events{/privacy}","received_events_url":"https://api.github.com/users/nus-ncl/received_events","type":"Organization","site_admin":false},"repo":{"id":56112257,"name":"services-in-one","full_name":"nus-ncl/services-in-one","owner":{"login":"nus-ncl","id":15359055,"avatar_url":"https://avatars.githubusercontent.com/u/15359055?v=3","gravatar_id":"","url":"https://api.github.com/users/nus-ncl","html_url":"https://github.com/nus-ncl","followers_url":"https://api.github.com/users/nus-ncl/followers","following_url":"https://api.github.com/users/nus-ncl/following{/other_user}","gists_url":"https://api.github.com/users/nus-ncl/gists{/gist_id}","starred_url":"https://api.github.com/users/nus-ncl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nus-ncl/subscriptions","organizations_url":"https://api.github.com/users/nus-ncl/orgs","repos_url":"https://api.github.com/users/nus-ncl/repos","events_url":"https://api.github.com/users/nus-ncl/events{/privacy}","received_events_url":"https://api.github.com/users/nus-ncl/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nus-ncl/services-in-one","description":null,"fork":false,"url":"https://api.github.com/repos/nus-ncl/services-in-one","forks_url":"https://api.github.com/repos/nus-ncl/services-in-one/forks","keys_url":"https://api.github.com/repos/nus-ncl/services-in-one/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nus-ncl/services-in-one/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nus-ncl/services-in-one/teams","hooks_url":"https://api.github.com/repos/nus-ncl/services-in-one/hooks","issue_events_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues/events{/number}","events_url":"https://api.github.com/repos/nus-ncl/services-in-one/events","assignees_url":"https://api.github.com/repos/nus-ncl/services-in-one/assignees{/user}","branches_url":"https://api.github.com/repos/nus-ncl/services-in-one/branches{/branch}","tags_url":"https://api.github.com/repos/nus-ncl/services-in-one/tags","blobs_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/refs{/sha}","trees_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nus-ncl/services-in-one/statuses/{sha}","languages_url":"https://api.github.com/repos/nus-ncl/services-in-one/languages","stargazers_url":"https://api.github.com/repos/nus-ncl/services-in-one/stargazers","contributors_url":"https://api.github.com/repos/nus-ncl/services-in-one/contributors","subscribers_url":"https://api.github.com/repos/nus-ncl/services-in-one/subscribers","subscription_url":"https://api.github.com/repos/nus-ncl/services-in-one/subscription","commits_url":"https://api.github.com/repos/nus-ncl/services-in-one/commits{/sha}","git_commits_url":"https://api.github.com/repos/nus-ncl/services-in-one/git/commits{/sha}","comments_url":"https://api.github.com/repos/nus-ncl/services-in-one/comments{/number}","issue_comment_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues/comments{/number}","contents_url":"https://api.github.com/repos/nus-ncl/services-in-one/contents/{+path}","compare_url":"https://api.github.com/repos/nus-ncl/services-in-one/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nus-ncl/services-in-one/merges","archive_url":"https://api.github.com/repos/nus-ncl/services-in-one/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nus-ncl/services-in-one/downloads","issues_url":"https://api.github.com/repos/nus-ncl/services-in-one/issues{/number}","pulls_url":"https://api.github.com/repos/nus-ncl/services-in-one/pulls{/number}","milestones_url":"https://api.github.com/repos/nus-ncl/services-in-one/milestones{/number}","notifications_url":"https://api.github.com/repos/nus-ncl/services-in-one/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nus-ncl/services-in-one/labels{/name}","releases_url":"https://api.github.com/repos/nus-ncl/services-in-one/releases{/id}","deployments_url":"https://api.github.com/repos/nus-ncl/services-in-one/deployments","created_at":"2016-04-13T01:52:23Z","updated_at":"2016-10-24T07:57:31Z","pushed_at":"2016-12-02T11:07:20Z","git_url":"git://github.com/nus-ncl/services-in-one.git","ssh_url":"git@github.com:nus-ncl/services-in-one.git","clone_url":"https://github.com/nus-ncl/services-in-one.git","svn_url":"https://github.com/nus-ncl/services-in-one","homepage":null,"size":2915,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200"},"html":{"href":"https://github.com/nus-ncl/services-in-one/pull/200"},"issue":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/issues/200"},"comments":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/issues/200/comments"},"review_comments":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200/comments"},"review_comment":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/pulls/200/commits"},"statuses":{"href":"https://api.github.com/repos/nus-ncl/services-in-one/statuses/911fc51707fe0239ec2640bf20bbd2657350fec9"}}}}
{"actor":{"display_login":"ChrisZhong"}}