{"action":"created","comment":{"url":"https://api.github.com/repos/DSpace/DSpace/pulls/comments/190707770","pull_request_review_id":123143225,"id":190707770,"diff_hunk":"@@ -0,0 +1,121 @@\n+/**\n+ * The contents of this file are subject to the license and copyright\n+ * detailed in the LICENSE and NOTICE files at the root of the source\n+ * tree and available online at\n+ *\n+ * http://www.dspace.org/license/\n+ */\n+package org.dspace.app.rest.repository.patch;\n+\n+import java.sql.SQLException;\n+import java.util.UUID;\n+\n+import org.apache.log4j.Logger;\n+import org.dspace.app.rest.exception.PatchBadRequestException;\n+import org.dspace.app.rest.exception.PatchUnprocessableEntityException;\n+import org.dspace.app.rest.model.patch.Operation;\n+import org.dspace.app.rest.model.patch.Patch;\n+import org.dspace.authorize.AuthorizeException;\n+import org.dspace.content.Item;\n+import org.dspace.content.service.ItemService;\n+import org.dspace.core.Context;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.stereotype.Component;\n+\n+/**\n+ * This is the implementation for item resource patches.\n+ *\n+ * @author Michael Spalti\n+ */\n+@Component\n+public class ItemPatch extends AbstractResourcePatch {\n+\n+    private static final String OPERATION_PATH_WITHDRAW = \"/withdrawn\";\n+\n+    private static final String OPERATION_PATH_DISCOVERABLE = \"/discoverable\";\n+\n+    private static final Logger log = Logger.getLogger(ItemPatch.class);\n+\n+    @Autowired\n+    ItemService is;\n+\n+    @Override\n+    public void replace(Context context, String apiCategory, String model, UUID id, Patch patch, Operation operation)\n+        throws PatchUnprocessableEntityException, PatchBadRequestException, SQLException, AuthorizeException {\n+\n+        Item item;\n+        try {\n+            item = is.find(context, id);\n+        } catch (SQLException e) {\n+            log.error(e.getMessage(), e);\n+            throw e;\n+        }\n+\n+        switch (operation.getPath()) {\n+            case OPERATION_PATH_WITHDRAW:\n+                withdraw(context, item, (Boolean) operation.getValue());\n+                break;\n+            case OPERATION_PATH_DISCOVERABLE:\n+                discoverable(item, (Boolean) operation.getValue());\n+                break;\n+            default:\n+                throw new PatchUnprocessableEntityException(\n+                    \"Unrecognized patch operation path: \" + operation.getPath()\n+                );\n+        }\n+    }\n+\n+    /**\n+     * Withdraw or reinstate item based on boolean value provided by the patch request.\n+     *\n+     * The issue (https://jira.duraspace.org/browse/DS-3909) asks the operation to return the 422 error code","path":"dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/patch/ItemPatch.java","position":71,"original_position":71,"commit_id":"dc33daa15be1a91149894fdf3d0224530ddfff9d","original_commit_id":"dc33daa15be1a91149894fdf3d0224530ddfff9d","user":{"login":"mspalti","id":1308551,"avatar_url":"https://avatars1.githubusercontent.com/u/1308551?v=4","gravatar_id":"","url":"https://api.github.com/users/mspalti","html_url":"https://github.com/mspalti","followers_url":"https://api.github.com/users/mspalti/followers","following_url":"https://api.github.com/users/mspalti/following{/other_user}","gists_url":"https://api.github.com/users/mspalti/gists{/gist_id}","starred_url":"https://api.github.com/users/mspalti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mspalti/subscriptions","organizations_url":"https://api.github.com/users/mspalti/orgs","repos_url":"https://api.github.com/users/mspalti/repos","events_url":"https://api.github.com/users/mspalti/events{/privacy}","received_events_url":"https://api.github.com/users/mspalti/received_events","type":"User","site_admin":false},"body":"This is not implemented because I'm not sure what to test for. What does it mean for something not to be archived?  Should I check the \"isArchived\" flag in the item or is there something else that I should look for?","created_at":"2018-05-24T19:40:22Z","updated_at":"2018-05-24T19:40:22Z","html_url":"https://github.com/DSpace/DSpace/pull/2064#discussion_r190707770","pull_request_url":"https://api.github.com/repos/DSpace/DSpace/pulls/2064","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/DSpace/DSpace/pulls/comments/190707770"},"html":{"href":"https://github.com/DSpace/DSpace/pull/2064#discussion_r190707770"},"pull_request":{"href":"https://api.github.com/repos/DSpace/DSpace/pulls/2064"}}},"pull_request":{"url":"https://api.github.com/repos/DSpace/DSpace/pulls/2064","id":188554358,"html_url":"https://github.com/DSpace/DSpace/pull/2064","diff_url":"https://github.com/DSpace/DSpace/pull/2064.diff","patch_url":"https://github.com/DSpace/DSpace/pull/2064.patch","issue_url":"https://api.github.com/repos/DSpace/DSpace/issues/2064","number":2064,"state":"open","locked":false,"title":"DS-3909: Adding withdraw, reinstate, and isDiscoverable support to item repository.","user":{"login":"mspalti","id":1308551,"avatar_url":"https://avatars1.githubusercontent.com/u/1308551?v=4","gravatar_id":"","url":"https://api.github.com/users/mspalti","html_url":"https://github.com/mspalti","followers_url":"https://api.github.com/users/mspalti/followers","following_url":"https://api.github.com/users/mspalti/following{/other_user}","gists_url":"https://api.github.com/users/mspalti/gists{/gist_id}","starred_url":"https://api.github.com/users/mspalti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mspalti/subscriptions","organizations_url":"https://api.github.com/users/mspalti/orgs","repos_url":"https://api.github.com/users/mspalti/repos","events_url":"https://api.github.com/users/mspalti/events{/privacy}","received_events_url":"https://api.github.com/users/mspalti/received_events","type":"User","site_admin":false},"body":"@abollini  I have a few questions about this work. I think I understand that the task generally. I'm not sure that I've handled exceptions correctly.  And now looking at the documentation at:\r\n \r\nhttps://github.com/DSpace/Rest7Contract/blob/master/patch.md\r\nhttps://github.com/DSpace/Rest7Contract/blob/master/workspaceitem-data-metadata.md\r\n\r\nWhich again makes me think that we need additional error handling if it's not already provided by default (e.g.: 405 Method Not Allowed)\r\n\r\nFor usage, see https://github.com/DSpace/Rest7Contract/pull/25/files\r\n\r\n","created_at":"2018-05-16T20:43:16Z","updated_at":"2018-05-24T19:40:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66c75ca25c6ac087063206655641e925e1eca433","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":646370662,"url":"https://api.github.com/repos/DSpace/DSpace/labels/REST%20API%20v7","name":"REST API v7","color":"92C644","default":false}],"milestone":{"url":"https://api.github.com/repos/DSpace/DSpace/milestones/21","html_url":"https://github.com/DSpace/DSpace/milestone/21","labels_url":"https://api.github.com/repos/DSpace/DSpace/milestones/21/labels","id":2107125,"number":21,"title":"7.0","description":null,"creator":{"login":"helix84","id":201026,"avatar_url":"https://avatars3.githubusercontent.com/u/201026?v=4","gravatar_id":"","url":"https://api.github.com/users/helix84","html_url":"https://github.com/helix84","followers_url":"https://api.github.com/users/helix84/followers","following_url":"https://api.github.com/users/helix84/following{/other_user}","gists_url":"https://api.github.com/users/helix84/gists{/gist_id}","starred_url":"https://api.github.com/users/helix84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helix84/subscriptions","organizations_url":"https://api.github.com/users/helix84/orgs","repos_url":"https://api.github.com/users/helix84/repos","events_url":"https://api.github.com/users/helix84/events{/privacy}","received_events_url":"https://api.github.com/users/helix84/received_events","type":"User","site_admin":false},"open_issues":34,"closed_issues":95,"state":"open","created_at":"2016-11-01T15:14:10Z","updated_at":"2018-05-20T17:12:20Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/DSpace/DSpace/pulls/2064/commits","review_comments_url":"https://api.github.com/repos/DSpace/DSpace/pulls/2064/comments","review_comment_url":"https://api.github.com/repos/DSpace/DSpace/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DSpace/DSpace/issues/2064/comments","statuses_url":"https://api.github.com/repos/DSpace/DSpace/statuses/dc33daa15be1a91149894fdf3d0224530ddfff9d","head":{"label":"mspalti:DS-3909","ref":"DS-3909","sha":"dc33daa15be1a91149894fdf3d0224530ddfff9d","user":{"login":"mspalti","id":1308551,"avatar_url":"https://avatars1.githubusercontent.com/u/1308551?v=4","gravatar_id":"","url":"https://api.github.com/users/mspalti","html_url":"https://github.com/mspalti","followers_url":"https://api.github.com/users/mspalti/followers","following_url":"https://api.github.com/users/mspalti/following{/other_user}","gists_url":"https://api.github.com/users/mspalti/gists{/gist_id}","starred_url":"https://api.github.com/users/mspalti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mspalti/subscriptions","organizations_url":"https://api.github.com/users/mspalti/orgs","repos_url":"https://api.github.com/users/mspalti/repos","events_url":"https://api.github.com/users/mspalti/events{/privacy}","received_events_url":"https://api.github.com/users/mspalti/received_events","type":"User","site_admin":false},"repo":{"id":133075748,"name":"DSpace","full_name":"mspalti/DSpace","owner":{"login":"mspalti","id":1308551,"avatar_url":"https://avatars1.githubusercontent.com/u/1308551?v=4","gravatar_id":"","url":"https://api.github.com/users/mspalti","html_url":"https://github.com/mspalti","followers_url":"https://api.github.com/users/mspalti/followers","following_url":"https://api.github.com/users/mspalti/following{/other_user}","gists_url":"https://api.github.com/users/mspalti/gists{/gist_id}","starred_url":"https://api.github.com/users/mspalti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mspalti/subscriptions","organizations_url":"https://api.github.com/users/mspalti/orgs","repos_url":"https://api.github.com/users/mspalti/repos","events_url":"https://api.github.com/users/mspalti/events{/privacy}","received_events_url":"https://api.github.com/users/mspalti/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mspalti/DSpace","description":"(Official) The DSpace digital asset management system that powers your Institutional Repository","fork":true,"url":"https://api.github.com/repos/mspalti/DSpace","forks_url":"https://api.github.com/repos/mspalti/DSpace/forks","keys_url":"https://api.github.com/repos/mspalti/DSpace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mspalti/DSpace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mspalti/DSpace/teams","hooks_url":"https://api.github.com/repos/mspalti/DSpace/hooks","issue_events_url":"https://api.github.com/repos/mspalti/DSpace/issues/events{/number}","events_url":"https://api.github.com/repos/mspalti/DSpace/events","assignees_url":"https://api.github.com/repos/mspalti/DSpace/assignees{/user}","branches_url":"https://api.github.com/repos/mspalti/DSpace/branches{/branch}","tags_url":"https://api.github.com/repos/mspalti/DSpace/tags","blobs_url":"https://api.github.com/repos/mspalti/DSpace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mspalti/DSpace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mspalti/DSpace/git/refs{/sha}","trees_url":"https://api.github.com/repos/mspalti/DSpace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mspalti/DSpace/statuses/{sha}","languages_url":"https://api.github.com/repos/mspalti/DSpace/languages","stargazers_url":"https://api.github.com/repos/mspalti/DSpace/stargazers","contributors_url":"https://api.github.com/repos/mspalti/DSpace/contributors","subscribers_url":"https://api.github.com/repos/mspalti/DSpace/subscribers","subscription_url":"https://api.github.com/repos/mspalti/DSpace/subscription","commits_url":"https://api.github.com/repos/mspalti/DSpace/commits{/sha}","git_commits_url":"https://api.github.com/repos/mspalti/DSpace/git/commits{/sha}","comments_url":"https://api.github.com/repos/mspalti/DSpace/comments{/number}","issue_comment_url":"https://api.github.com/repos/mspalti/DSpace/issues/comments{/number}","contents_url":"https://api.github.com/repos/mspalti/DSpace/contents/{+path}","compare_url":"https://api.github.com/repos/mspalti/DSpace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mspalti/DSpace/merges","archive_url":"https://api.github.com/repos/mspalti/DSpace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mspalti/DSpace/downloads","issues_url":"https://api.github.com/repos/mspalti/DSpace/issues{/number}","pulls_url":"https://api.github.com/repos/mspalti/DSpace/pulls{/number}","milestones_url":"https://api.github.com/repos/mspalti/DSpace/milestones{/number}","notifications_url":"https://api.github.com/repos/mspalti/DSpace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mspalti/DSpace/labels{/name}","releases_url":"https://api.github.com/repos/mspalti/DSpace/releases{/id}","deployments_url":"https://api.github.com/repos/mspalti/DSpace/deployments","created_at":"2018-05-11T18:37:08Z","updated_at":"2018-05-11T18:37:17Z","pushed_at":"2018-05-24T19:33:03Z","git_url":"git://github.com/mspalti/DSpace.git","ssh_url":"git@github.com:mspalti/DSpace.git","clone_url":"https://github.com/mspalti/DSpace.git","svn_url":"https://github.com/mspalti/DSpace","homepage":"https://wiki.duraspace.org/display/DSDOC6x/Introduction","size":132109,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DSpace:master","ref":"master","sha":"829ee0687a2c84b9d28bff591def8e0ec06048b2","user":{"login":"DSpace","id":428620,"avatar_url":"https://avatars3.githubusercontent.com/u/428620?v=4","gravatar_id":"","url":"https://api.github.com/users/DSpace","html_url":"https://github.com/DSpace","followers_url":"https://api.github.com/users/DSpace/followers","following_url":"https://api.github.com/users/DSpace/following{/other_user}","gists_url":"https://api.github.com/users/DSpace/gists{/gist_id}","starred_url":"https://api.github.com/users/DSpace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DSpace/subscriptions","organizations_url":"https://api.github.com/users/DSpace/orgs","repos_url":"https://api.github.com/users/DSpace/repos","events_url":"https://api.github.com/users/DSpace/events{/privacy}","received_events_url":"https://api.github.com/users/DSpace/received_events","type":"Organization","site_admin":false},"repo":{"id":3743376,"name":"DSpace","full_name":"DSpace/DSpace","owner":{"login":"DSpace","id":428620,"avatar_url":"https://avatars3.githubusercontent.com/u/428620?v=4","gravatar_id":"","url":"https://api.github.com/users/DSpace","html_url":"https://github.com/DSpace","followers_url":"https://api.github.com/users/DSpace/followers","following_url":"https://api.github.com/users/DSpace/following{/other_user}","gists_url":"https://api.github.com/users/DSpace/gists{/gist_id}","starred_url":"https://api.github.com/users/DSpace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DSpace/subscriptions","organizations_url":"https://api.github.com/users/DSpace/orgs","repos_url":"https://api.github.com/users/DSpace/repos","events_url":"https://api.github.com/users/DSpace/events{/privacy}","received_events_url":"https://api.github.com/users/DSpace/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DSpace/DSpace","description":"(Official) The DSpace digital asset management system that powers your Institutional Repository","fork":false,"url":"https://api.github.com/repos/DSpace/DSpace","forks_url":"https://api.github.com/repos/DSpace/DSpace/forks","keys_url":"https://api.github.com/repos/DSpace/DSpace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DSpace/DSpace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DSpace/DSpace/teams","hooks_url":"https://api.github.com/repos/DSpace/DSpace/hooks","issue_events_url":"https://api.github.com/repos/DSpace/DSpace/issues/events{/number}","events_url":"https://api.github.com/repos/DSpace/DSpace/events","assignees_url":"https://api.github.com/repos/DSpace/DSpace/assignees{/user}","branches_url":"https://api.github.com/repos/DSpace/DSpace/branches{/branch}","tags_url":"https://api.github.com/repos/DSpace/DSpace/tags","blobs_url":"https://api.github.com/repos/DSpace/DSpace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DSpace/DSpace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DSpace/DSpace/git/refs{/sha}","trees_url":"https://api.github.com/repos/DSpace/DSpace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DSpace/DSpace/statuses/{sha}","languages_url":"https://api.github.com/repos/DSpace/DSpace/languages","stargazers_url":"https://api.github.com/repos/DSpace/DSpace/stargazers","contributors_url":"https://api.github.com/repos/DSpace/DSpace/contributors","subscribers_url":"https://api.github.com/repos/DSpace/DSpace/subscribers","subscription_url":"https://api.github.com/repos/DSpace/DSpace/subscription","commits_url":"https://api.github.com/repos/DSpace/DSpace/commits{/sha}","git_commits_url":"https://api.github.com/repos/DSpace/DSpace/git/commits{/sha}","comments_url":"https://api.github.com/repos/DSpace/DSpace/comments{/number}","issue_comment_url":"https://api.github.com/repos/DSpace/DSpace/issues/comments{/number}","contents_url":"https://api.github.com/repos/DSpace/DSpace/contents/{+path}","compare_url":"https://api.github.com/repos/DSpace/DSpace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DSpace/DSpace/merges","archive_url":"https://api.github.com/repos/DSpace/DSpace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DSpace/DSpace/downloads","issues_url":"https://api.github.com/repos/DSpace/DSpace/issues{/number}","pulls_url":"https://api.github.com/repos/DSpace/DSpace/pulls{/number}","milestones_url":"https://api.github.com/repos/DSpace/DSpace/milestones{/number}","notifications_url":"https://api.github.com/repos/DSpace/DSpace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DSpace/DSpace/labels{/name}","releases_url":"https://api.github.com/repos/DSpace/DSpace/releases{/id}","deployments_url":"https://api.github.com/repos/DSpace/DSpace/deployments","created_at":"2012-03-16T21:44:52Z","updated_at":"2018-05-23T00:55:13Z","pushed_at":"2018-05-24T19:33:05Z","git_url":"git://github.com/DSpace/DSpace.git","ssh_url":"git@github.com:DSpace/DSpace.git","clone_url":"https://github.com/DSpace/DSpace.git","svn_url":"https://github.com/DSpace/DSpace","homepage":"https://wiki.duraspace.org/display/DSDOC6x/Introduction","size":132195,"stargazers_count":365,"watchers_count":365,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":787,"mirror_url":null,"archived":false,"open_issues_count":134,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":787,"open_issues":134,"watchers":365,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DSpace/DSpace/pulls/2064"},"html":{"href":"https://github.com/DSpace/DSpace/pull/2064"},"issue":{"href":"https://api.github.com/repos/DSpace/DSpace/issues/2064"},"comments":{"href":"https://api.github.com/repos/DSpace/DSpace/issues/2064/comments"},"review_comments":{"href":"https://api.github.com/repos/DSpace/DSpace/pulls/2064/comments"},"review_comment":{"href":"https://api.github.com/repos/DSpace/DSpace/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DSpace/DSpace/pulls/2064/commits"},"statuses":{"href":"https://api.github.com/repos/DSpace/DSpace/statuses/dc33daa15be1a91149894fdf3d0224530ddfff9d"}},"author_association":"NONE"}}
{"actor":{"display_login":"mspalti"}}