{"action":"created","comment":{"url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/comments/132454975","pull_request_review_id":55536877,"id":132454975,"diff_hunk":"@@ -103,356 +103,321 @@\n      * http://puspendu.wordpress.com/2012/08/23/restful-webservice-file-upload-with-jersey/\n      */\n     public static Response uploadObject(UriInfo info, HttpServletRequest request, InputStream uploadedInputStream,\n-        FormDataContentDisposition fileDetails) {\n-        try {\n-            if (MCRRestAPIUtil.checkWriteAccessForIP(request)) {\n-                SignedJWT signedJWT = MCRJSONWebTokenUtil.retrieveAuthenticationToken(request);\n-                java.nio.file.Path fXML = null;\n-                try (MCRJPATransactionWrapper mtw = new MCRJPATransactionWrapper()) {\n-                    SAXBuilder sb = new SAXBuilder();\n-                    Document docOut = sb.build(uploadedInputStream);\n-\n-                    MCRObjectID mcrID = MCRObjectID.getInstance(docOut.getRootElement().getAttributeValue(\"ID\"));\n-                    if (mcrID.getNumberAsInteger() == 0) {\n-                        mcrID = MCRObjectID.getNextFreeId(mcrID.getBase());\n-                    }\n+        FormDataContentDisposition fileDetails) throws MCRRestAPIException {\n \n-                    fXML = UPLOAD_DIR.resolve(mcrID.toString() + \".xml\");\n+        SignedJWT signedJWT = MCRJSONWebTokenUtil.retrieveAuthenticationToken(request);\n+        java.nio.file.Path fXML = null;\n+        try (MCRJPATransactionWrapper mtw = new MCRJPATransactionWrapper()) {\n+            SAXBuilder sb = new SAXBuilder();\n+            Document docOut = sb.build(uploadedInputStream);\n \n-                    docOut.getRootElement().setAttribute(\"ID\", mcrID.toString());\n-                    docOut.getRootElement().setAttribute(\"label\", mcrID.toString());\n-                    XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());\n-                    try (BufferedWriter bw = Files.newBufferedWriter(fXML, StandardCharsets.UTF_8)) {\n-                        xmlOut.output(docOut, bw);\n-                    }\n+            MCRObjectID mcrID = MCRObjectID.getInstance(docOut.getRootElement().getAttributeValue(\"ID\"));\n+            if (mcrID.getNumberAsInteger() == 0) {\n+                mcrID = MCRObjectID.getNextFreeId(mcrID.getBase());\n+            }\n \n-                    MCRSession mcrSession = MCRSessionMgr.getCurrentSession();\n-                    MCRUserInformation currentUser = mcrSession.getUserInformation();\n-                    MCRUserInformation apiUser = MCRUserManager\n-                        .getUser(MCRJSONWebTokenUtil.retrieveUsernameFromAuthenticationToken(signedJWT));\n-                    mcrSession.setUserInformation(apiUser);\n-                    MCRObjectCommands.updateFromFile(fXML.toString(), false); // handles \"create\" as well\n-                    mcrSession.setUserInformation(currentUser);\n+            fXML = UPLOAD_DIR.resolve(mcrID.toString() + \".xml\");\n \n-                    return Response.created(info.getBaseUriBuilder().path(\"v1/objects/\" + mcrID.toString()).build())\n-                        .type(\"application/xml; charset=UTF-8\")\n-                        .header(\"Authorization\", \"Bearer \" + MCRJSONWebTokenUtil.createJWT(signedJWT).serialize())\n-                        .build();\n+            docOut.getRootElement().setAttribute(\"ID\", mcrID.toString());\n+            docOut.getRootElement().setAttribute(\"label\", mcrID.toString());\n+            XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());\n+            try (BufferedWriter bw = Files.newBufferedWriter(fXML, StandardCharsets.UTF_8)) {\n+                xmlOut.output(docOut, bw);\n+            }\n \n-                } catch (Exception e) {\n-                    LOGGER.error(\"Unable to Upload file: \" + String.valueOf(fXML), e);\n-                    throw new MCRRestAPIException(\n-                        MCRRestAPIError.create(Status.BAD_REQUEST, MCRRestAPIError.CODE_WRONG_PARAMETER,\n-                            \"Unable to Upload file: \" + String.valueOf(fXML), e.getMessage()));\n-                } finally {\n-                    if (fXML != null) {\n-                        try {\n-                            Files.delete(fXML);\n-                        } catch (IOException e) {\n-                            LOGGER.error(\"Unable to delete temporary workflow file: \" + String.valueOf(fXML), e);\n-                        }\n-                    }\n+            MCRSession mcrSession = MCRSessionMgr.getCurrentSession();\n+            MCRUserInformation currentUser = mcrSession.getUserInformation();\n+            MCRUserInformation apiUser = MCRUserManager\n+                .getUser(MCRJSONWebTokenUtil.retrieveUsernameFromAuthenticationToken(signedJWT));\n+            mcrSession.setUserInformation(apiUser);\n+            MCRObjectCommands.updateFromFile(fXML.toString(), false); // handles \"create\" as well\n+            mcrSession.setUserInformation(currentUser);\n+\n+            return Response.created(info.getBaseUriBuilder().path(\"v1/objects/\" + mcrID.toString()).build())\n+                .type(\"application/xml; charset=UTF-8\")\n+                .header(\"Authorization\", \"Bearer \" + MCRJSONWebTokenUtil.createJWT(signedJWT).serialize()).build();","path":"mycore-restapi/src/main/java/org/mycore/restapi/v1/utils/MCRRestAPIUploadHelper.java","position":80,"original_position":80,"commit_id":"7ac641c776ebcebd90465fa859a790dd712b7c76","original_commit_id":"7ac641c776ebcebd90465fa859a790dd712b7c76","user":{"login":"codacy-bot","id":19940114,"avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [The String literal \"Authorization\" appears 5 times in this file; the first occurrence is on line 138](https://www.codacy.com/app/MyCoRe/mycore/pullRequest?prid=832751)","created_at":"2017-08-10T13:40:24Z","updated_at":"2017-08-10T13:40:24Z","html_url":"https://github.com/MyCoRe-Org/mycore/pull/358#discussion_r132454975","pull_request_url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358","_links":{"self":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/comments/132454975"},"html":{"href":"https://github.com/MyCoRe-Org/mycore/pull/358#discussion_r132454975"},"pull_request":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358"}}},"pull_request":{"url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358","id":135115385,"html_url":"https://github.com/MyCoRe-Org/mycore/pull/358","diff_url":"https://github.com/MyCoRe-Org/mycore/pull/358.diff","patch_url":"https://github.com/MyCoRe-Org/mycore/pull/358.patch","issue_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/358","number":358,"state":"open","locked":false,"title":"MCR-1685 #comment integrate ACL-checks in REST-API","user":{"login":"rsteph-de","id":20067327,"avatar_url":"https://avatars2.githubusercontent.com/u/20067327?v=4","gravatar_id":"","url":"https://api.github.com/users/rsteph-de","html_url":"https://github.com/rsteph-de","followers_url":"https://api.github.com/users/rsteph-de/followers","following_url":"https://api.github.com/users/rsteph-de/following{/other_user}","gists_url":"https://api.github.com/users/rsteph-de/gists{/gist_id}","starred_url":"https://api.github.com/users/rsteph-de/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsteph-de/subscriptions","organizations_url":"https://api.github.com/users/rsteph-de/orgs","repos_url":"https://api.github.com/users/rsteph-de/repos","events_url":"https://api.github.com/users/rsteph-de/events{/privacy}","received_events_url":"https://api.github.com/users/rsteph-de/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-10T12:45:47Z","updated_at":"2017-08-10T13:40:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a825ef122b9f342195b6d0dc35fa99ae7f574efe","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358/commits","review_comments_url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358/comments","review_comment_url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/358/comments","statuses_url":"https://api.github.com/repos/MyCoRe-Org/mycore/statuses/7ac641c776ebcebd90465fa859a790dd712b7c76","head":{"label":"MyCoRe-Org:issues/MCR-1685-RESTAPI_Writes_protected_by_an_access_permission","ref":"issues/MCR-1685-RESTAPI_Writes_protected_by_an_access_permission","sha":"7ac641c776ebcebd90465fa859a790dd712b7c76","user":{"login":"MyCoRe-Org","id":20062922,"avatar_url":"https://avatars0.githubusercontent.com/u/20062922?v=4","gravatar_id":"","url":"https://api.github.com/users/MyCoRe-Org","html_url":"https://github.com/MyCoRe-Org","followers_url":"https://api.github.com/users/MyCoRe-Org/followers","following_url":"https://api.github.com/users/MyCoRe-Org/following{/other_user}","gists_url":"https://api.github.com/users/MyCoRe-Org/gists{/gist_id}","starred_url":"https://api.github.com/users/MyCoRe-Org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MyCoRe-Org/subscriptions","organizations_url":"https://api.github.com/users/MyCoRe-Org/orgs","repos_url":"https://api.github.com/users/MyCoRe-Org/repos","events_url":"https://api.github.com/users/MyCoRe-Org/events{/privacy}","received_events_url":"https://api.github.com/users/MyCoRe-Org/received_events","type":"Organization","site_admin":false},"repo":{"id":70219747,"name":"mycore","full_name":"MyCoRe-Org/mycore","owner":{"login":"MyCoRe-Org","id":20062922,"avatar_url":"https://avatars0.githubusercontent.com/u/20062922?v=4","gravatar_id":"","url":"https://api.github.com/users/MyCoRe-Org","html_url":"https://github.com/MyCoRe-Org","followers_url":"https://api.github.com/users/MyCoRe-Org/followers","following_url":"https://api.github.com/users/MyCoRe-Org/following{/other_user}","gists_url":"https://api.github.com/users/MyCoRe-Org/gists{/gist_id}","starred_url":"https://api.github.com/users/MyCoRe-Org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MyCoRe-Org/subscriptions","organizations_url":"https://api.github.com/users/MyCoRe-Org/orgs","repos_url":"https://api.github.com/users/MyCoRe-Org/repos","events_url":"https://api.github.com/users/MyCoRe-Org/events{/privacy}","received_events_url":"https://api.github.com/users/MyCoRe-Org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MyCoRe-Org/mycore","description":"MyCoRe (acronym for My Content Repository) is an open source repository software framework for building disciplinary or institutional repositories, digital archives, digital libraries, and scientific journals.","fork":false,"url":"https://api.github.com/repos/MyCoRe-Org/mycore","forks_url":"https://api.github.com/repos/MyCoRe-Org/mycore/forks","keys_url":"https://api.github.com/repos/MyCoRe-Org/mycore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MyCoRe-Org/mycore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MyCoRe-Org/mycore/teams","hooks_url":"https://api.github.com/repos/MyCoRe-Org/mycore/hooks","issue_events_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/events{/number}","events_url":"https://api.github.com/repos/MyCoRe-Org/mycore/events","assignees_url":"https://api.github.com/repos/MyCoRe-Org/mycore/assignees{/user}","branches_url":"https://api.github.com/repos/MyCoRe-Org/mycore/branches{/branch}","tags_url":"https://api.github.com/repos/MyCoRe-Org/mycore/tags","blobs_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/refs{/sha}","trees_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MyCoRe-Org/mycore/statuses/{sha}","languages_url":"https://api.github.com/repos/MyCoRe-Org/mycore/languages","stargazers_url":"https://api.github.com/repos/MyCoRe-Org/mycore/stargazers","contributors_url":"https://api.github.com/repos/MyCoRe-Org/mycore/contributors","subscribers_url":"https://api.github.com/repos/MyCoRe-Org/mycore/subscribers","subscription_url":"https://api.github.com/repos/MyCoRe-Org/mycore/subscription","commits_url":"https://api.github.com/repos/MyCoRe-Org/mycore/commits{/sha}","git_commits_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/commits{/sha}","comments_url":"https://api.github.com/repos/MyCoRe-Org/mycore/comments{/number}","issue_comment_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/comments{/number}","contents_url":"https://api.github.com/repos/MyCoRe-Org/mycore/contents/{+path}","compare_url":"https://api.github.com/repos/MyCoRe-Org/mycore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MyCoRe-Org/mycore/merges","archive_url":"https://api.github.com/repos/MyCoRe-Org/mycore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MyCoRe-Org/mycore/downloads","issues_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues{/number}","pulls_url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls{/number}","milestones_url":"https://api.github.com/repos/MyCoRe-Org/mycore/milestones{/number}","notifications_url":"https://api.github.com/repos/MyCoRe-Org/mycore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MyCoRe-Org/mycore/labels{/name}","releases_url":"https://api.github.com/repos/MyCoRe-Org/mycore/releases{/id}","deployments_url":"https://api.github.com/repos/MyCoRe-Org/mycore/deployments","created_at":"2016-10-07T06:02:02Z","updated_at":"2017-08-03T12:28:12Z","pushed_at":"2017-08-10T13:34:19Z","git_url":"git://github.com/MyCoRe-Org/mycore.git","ssh_url":"git@github.com:MyCoRe-Org/mycore.git","clone_url":"https://github.com/MyCoRe-Org/mycore.git","svn_url":"https://github.com/MyCoRe-Org/mycore","homepage":null,"size":226766,"stargazers_count":9,"watchers_count":9,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":9,"default_branch":"master"}},"base":{"label":"MyCoRe-Org:2017.06.0.x","ref":"2017.06.0.x","sha":"f806ba07995f6a5f2a69591608c4aa4665023e88","user":{"login":"MyCoRe-Org","id":20062922,"avatar_url":"https://avatars0.githubusercontent.com/u/20062922?v=4","gravatar_id":"","url":"https://api.github.com/users/MyCoRe-Org","html_url":"https://github.com/MyCoRe-Org","followers_url":"https://api.github.com/users/MyCoRe-Org/followers","following_url":"https://api.github.com/users/MyCoRe-Org/following{/other_user}","gists_url":"https://api.github.com/users/MyCoRe-Org/gists{/gist_id}","starred_url":"https://api.github.com/users/MyCoRe-Org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MyCoRe-Org/subscriptions","organizations_url":"https://api.github.com/users/MyCoRe-Org/orgs","repos_url":"https://api.github.com/users/MyCoRe-Org/repos","events_url":"https://api.github.com/users/MyCoRe-Org/events{/privacy}","received_events_url":"https://api.github.com/users/MyCoRe-Org/received_events","type":"Organization","site_admin":false},"repo":{"id":70219747,"name":"mycore","full_name":"MyCoRe-Org/mycore","owner":{"login":"MyCoRe-Org","id":20062922,"avatar_url":"https://avatars0.githubusercontent.com/u/20062922?v=4","gravatar_id":"","url":"https://api.github.com/users/MyCoRe-Org","html_url":"https://github.com/MyCoRe-Org","followers_url":"https://api.github.com/users/MyCoRe-Org/followers","following_url":"https://api.github.com/users/MyCoRe-Org/following{/other_user}","gists_url":"https://api.github.com/users/MyCoRe-Org/gists{/gist_id}","starred_url":"https://api.github.com/users/MyCoRe-Org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MyCoRe-Org/subscriptions","organizations_url":"https://api.github.com/users/MyCoRe-Org/orgs","repos_url":"https://api.github.com/users/MyCoRe-Org/repos","events_url":"https://api.github.com/users/MyCoRe-Org/events{/privacy}","received_events_url":"https://api.github.com/users/MyCoRe-Org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MyCoRe-Org/mycore","description":"MyCoRe (acronym for My Content Repository) is an open source repository software framework for building disciplinary or institutional repositories, digital archives, digital libraries, and scientific journals.","fork":false,"url":"https://api.github.com/repos/MyCoRe-Org/mycore","forks_url":"https://api.github.com/repos/MyCoRe-Org/mycore/forks","keys_url":"https://api.github.com/repos/MyCoRe-Org/mycore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MyCoRe-Org/mycore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MyCoRe-Org/mycore/teams","hooks_url":"https://api.github.com/repos/MyCoRe-Org/mycore/hooks","issue_events_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/events{/number}","events_url":"https://api.github.com/repos/MyCoRe-Org/mycore/events","assignees_url":"https://api.github.com/repos/MyCoRe-Org/mycore/assignees{/user}","branches_url":"https://api.github.com/repos/MyCoRe-Org/mycore/branches{/branch}","tags_url":"https://api.github.com/repos/MyCoRe-Org/mycore/tags","blobs_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/refs{/sha}","trees_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MyCoRe-Org/mycore/statuses/{sha}","languages_url":"https://api.github.com/repos/MyCoRe-Org/mycore/languages","stargazers_url":"https://api.github.com/repos/MyCoRe-Org/mycore/stargazers","contributors_url":"https://api.github.com/repos/MyCoRe-Org/mycore/contributors","subscribers_url":"https://api.github.com/repos/MyCoRe-Org/mycore/subscribers","subscription_url":"https://api.github.com/repos/MyCoRe-Org/mycore/subscription","commits_url":"https://api.github.com/repos/MyCoRe-Org/mycore/commits{/sha}","git_commits_url":"https://api.github.com/repos/MyCoRe-Org/mycore/git/commits{/sha}","comments_url":"https://api.github.com/repos/MyCoRe-Org/mycore/comments{/number}","issue_comment_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/comments{/number}","contents_url":"https://api.github.com/repos/MyCoRe-Org/mycore/contents/{+path}","compare_url":"https://api.github.com/repos/MyCoRe-Org/mycore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MyCoRe-Org/mycore/merges","archive_url":"https://api.github.com/repos/MyCoRe-Org/mycore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MyCoRe-Org/mycore/downloads","issues_url":"https://api.github.com/repos/MyCoRe-Org/mycore/issues{/number}","pulls_url":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls{/number}","milestones_url":"https://api.github.com/repos/MyCoRe-Org/mycore/milestones{/number}","notifications_url":"https://api.github.com/repos/MyCoRe-Org/mycore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MyCoRe-Org/mycore/labels{/name}","releases_url":"https://api.github.com/repos/MyCoRe-Org/mycore/releases{/id}","deployments_url":"https://api.github.com/repos/MyCoRe-Org/mycore/deployments","created_at":"2016-10-07T06:02:02Z","updated_at":"2017-08-03T12:28:12Z","pushed_at":"2017-08-10T13:34:19Z","git_url":"git://github.com/MyCoRe-Org/mycore.git","ssh_url":"git@github.com:MyCoRe-Org/mycore.git","clone_url":"https://github.com/MyCoRe-Org/mycore.git","svn_url":"https://github.com/MyCoRe-Org/mycore","homepage":null,"size":226766,"stargazers_count":9,"watchers_count":9,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358"},"html":{"href":"https://github.com/MyCoRe-Org/mycore/pull/358"},"issue":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/358"},"comments":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/issues/358/comments"},"review_comments":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358/comments"},"review_comment":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/pulls/358/commits"},"statuses":{"href":"https://api.github.com/repos/MyCoRe-Org/mycore/statuses/7ac641c776ebcebd90465fa859a790dd712b7c76"}}}}
{"actor":{"display_login":"codacy-bot"}}