{"action":"created","comment":{"url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments/28994661","id":28994661,"diff_hunk":"@@ -0,0 +1,622 @@\n+__author__ = 'Pabitra'\n+\n+from django.shortcuts import redirect\n+from django.core.urlresolvers import reverse\n+from django.core.exceptions import ObjectDoesNotExist\n+from django.http import HttpResponseRedirect\n+from rest_framework.pagination import PageNumberPagination\n+from rest_framework.views import APIView\n+from rest_framework.response import Response\n+from rest_framework import status, generics\n+from rest_framework.exceptions import *\n+from hs_core import hydroshare\n+from hs_core.hydroshare import file_size_limit_for_display\n+from hs_core.views import utils\n+import simplejson as sj\n+import serializers\n+from hs_core.signals import *\n+import os\n+\n+class ResourceRetrieveUpdateDelete(APIView):\n+    \"\"\"\n+    Retrieve, update or delete a resource\n+\n+    REST URL: hsapi/resource/{pk}\n+\n+    HTTP method: GET\n+\n+    HTTP status code (on success):200\n+\n+    :return: (on success): resource bag file if request content-type is 'application/zip' otherwise resource science metadata file\n+\n+    REST URL: hsapi/resource/{pk}\n+\n+    HTTP method: DELETE\n+\n+    HTTP status code (on success):200\n+\n+    :return: (on success): json string of the format: {'resource_id':pk}\n+\n+    REST URL: hsapi/resource/{pk}\n+\n+    HTTP method: PUT\n+\n+    HTTP status code (on success):200\n+\n+    :return: (on success): json string of the format: {'resource_id':pk}\n+\n+    :type   str\n+\n+    :param  pk: resource id\n+\n+    :rtype:  json string for http methods DELETE and PUT, and resource file data bytes for GET\n+\n+    :raises:\n+\n+\n+    &nbsp;&nbsp;&nbsp;NotFound: return json format: {'detail': 'No resource was found for resource id':pk}\n+\n+    &nbsp;&nbsp;&nbsp;HTTP status code: 404\n+\n+    &nbsp;&nbsp;&nbsp;PermissionDenied: return json format: {'detail': 'You do not have permission to perform this action.'}\n+\n+    &nbsp;&nbsp;&nbsp;HTTP status code:403\n+\n+    &nbsp;&nbsp;&nbsp;ValidationError: return json format: {parameter-1': ['error message-1'], 'parameter-2': ['error message-2'], .. }\n+\n+    &nbsp;&nbsp;&nbsp;HTTP status code:400\n+    \"\"\"\n+\n+    @property\n+    def allowed_methods(self):\n+        return ['GET', 'PUT', 'DELETE']\n+\n+    def get(self, request, pk):\n+        # check the user is authorized for this action and if the resource exists for the given resource id (pk)\n+        utils.authorize(request, pk, view=True)\n+        resource_bag = hydroshare.get_resource(pk)\n+\n+        if request.content_type == 'application/zip':\n+            # redirects to django_irods/views.download function\n+            return HttpResponseRedirect(resource_bag.bag.url)\n+        else:\n+            return redirect('science_metadata_get_update', pk=pk)\n+\n+    def put(self, request, pk):\n+        # check the user is authorized for this action and if the resource exists for the given resource id (pk)\n+        utils.authorize(request, pk, edit=True)\n+\n+        resource_update_request_validator = serializers.ResourceUpdateRequestValidator(data=request.data)\n+        if not resource_update_request_validator.is_valid():\n+            raise ValidationError(detail=resource_update_request_validator.errors)\n+\n+        # TODO: update resource - not sure what exactly we need to update\n+        raise NotImplementedError()","path":"hs_core/views/resource_rest_api.py","position":94,"original_position":94,"commit_id":"b147bd8de898bb03fc4a122353f6e7d101099e1d","original_commit_id":"b147bd8de898bb03fc4a122353f6e7d101099e1d","user":{"login":"pkdash","id":2523434,"avatar_url":"https://avatars.githubusercontent.com/u/2523434?v=3","gravatar_id":"","url":"https://api.github.com/users/pkdash","html_url":"https://github.com/pkdash","followers_url":"https://api.github.com/users/pkdash/followers","following_url":"https://api.github.com/users/pkdash/following{/other_user}","gists_url":"https://api.github.com/users/pkdash/gists{/gist_id}","starred_url":"https://api.github.com/users/pkdash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkdash/subscriptions","organizations_url":"https://api.github.com/users/pkdash/orgs","repos_url":"https://api.github.com/users/pkdash/repos","events_url":"https://api.github.com/users/pkdash/events{/privacy}","received_events_url":"https://api.github.com/users/pkdash/received_events","type":"User","site_admin":false},"body":"is this mean resource class should have methods like validate_files() and may be extract_metadata()?","created_at":"2015-04-23T19:23:36Z","updated_at":"2015-04-23T19:23:36Z","html_url":"https://github.com/hydroshare/hydroshare/pull/313#discussion_r28994661","pull_request_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313","_links":{"self":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments/28994661"},"html":{"href":"https://github.com/hydroshare/hydroshare/pull/313#discussion_r28994661"},"pull_request":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313"}}},"pull_request":{"url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313","id":33604566,"html_url":"https://github.com/hydroshare/hydroshare/pull/313","diff_url":"https://github.com/hydroshare/hydroshare/pull/313.diff","patch_url":"https://github.com/hydroshare/hydroshare/pull/313.patch","issue_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/313","number":313,"state":"open","locked":false,"title":"285-rest-api-phase-1:code review","user":{"login":"pkdash","id":2523434,"avatar_url":"https://avatars.githubusercontent.com/u/2523434?v=3","gravatar_id":"","url":"https://api.github.com/users/pkdash","html_url":"https://github.com/pkdash","followers_url":"https://api.github.com/users/pkdash/followers","following_url":"https://api.github.com/users/pkdash/following{/other_user}","gists_url":"https://api.github.com/users/pkdash/gists{/gist_id}","starred_url":"https://api.github.com/users/pkdash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkdash/subscriptions","organizations_url":"https://api.github.com/users/pkdash/orgs","repos_url":"https://api.github.com/users/pkdash/repos","events_url":"https://api.github.com/users/pkdash/events{/privacy}","received_events_url":"https://api.github.com/users/pkdash/received_events","type":"User","site_admin":false},"body":"@ironfroggy I have made changes to resource get/delete, resource list, and get science metadata api methods based on our discussion last Thursday. Removed the custom response json format form these api methods. I have added url path to resource bag and science metadata as part of the resource list items. I have yet to make similar changes to resource create, resource file add/get/delete api methods. So if you can review those api methods where I have made the changes that would be great. Due to some merge issues I had to recreate this branch and thus lost all history of this branch.","created_at":"2015-04-18T16:25:41Z","updated_at":"2015-04-23T19:23:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44abf2ba49ebe1e0c27a53b62379162a5f8e24fe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313/commits","review_comments_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313/comments","review_comment_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/313/comments","statuses_url":"https://api.github.com/repos/hydroshare/hydroshare/statuses/b147bd8de898bb03fc4a122353f6e7d101099e1d","head":{"label":"hydroshare:285-rest-api-phase-1A","ref":"285-rest-api-phase-1A","sha":"b147bd8de898bb03fc4a122353f6e7d101099e1d","user":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"repo":{"id":24703136,"name":"hydroshare","full_name":"hydroshare/hydroshare","owner":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hydroshare/hydroshare","description":"HydroShare is a collaborative website being developed for better access to data and models in the hydrologic sciences. ","fork":false,"url":"https://api.github.com/repos/hydroshare/hydroshare","forks_url":"https://api.github.com/repos/hydroshare/hydroshare/forks","keys_url":"https://api.github.com/repos/hydroshare/hydroshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hydroshare/hydroshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hydroshare/hydroshare/teams","hooks_url":"https://api.github.com/repos/hydroshare/hydroshare/hooks","issue_events_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/events{/number}","events_url":"https://api.github.com/repos/hydroshare/hydroshare/events","assignees_url":"https://api.github.com/repos/hydroshare/hydroshare/assignees{/user}","branches_url":"https://api.github.com/repos/hydroshare/hydroshare/branches{/branch}","tags_url":"https://api.github.com/repos/hydroshare/hydroshare/tags","blobs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hydroshare/hydroshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/hydroshare/hydroshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hydroshare/hydroshare/statuses/{sha}","languages_url":"https://api.github.com/repos/hydroshare/hydroshare/languages","stargazers_url":"https://api.github.com/repos/hydroshare/hydroshare/stargazers","contributors_url":"https://api.github.com/repos/hydroshare/hydroshare/contributors","subscribers_url":"https://api.github.com/repos/hydroshare/hydroshare/subscribers","subscription_url":"https://api.github.com/repos/hydroshare/hydroshare/subscription","commits_url":"https://api.github.com/repos/hydroshare/hydroshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/hydroshare/hydroshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/hydroshare/hydroshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/hydroshare/hydroshare/contents/{+path}","compare_url":"https://api.github.com/repos/hydroshare/hydroshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hydroshare/hydroshare/merges","archive_url":"https://api.github.com/repos/hydroshare/hydroshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hydroshare/hydroshare/downloads","issues_url":"https://api.github.com/repos/hydroshare/hydroshare/issues{/number}","pulls_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls{/number}","milestones_url":"https://api.github.com/repos/hydroshare/hydroshare/milestones{/number}","notifications_url":"https://api.github.com/repos/hydroshare/hydroshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hydroshare/hydroshare/labels{/name}","releases_url":"https://api.github.com/repos/hydroshare/hydroshare/releases{/id}","created_at":"2014-10-02T02:19:41Z","updated_at":"2015-04-01T15:17:27Z","pushed_at":"2015-04-23T13:42:33Z","git_url":"git://github.com/hydroshare/hydroshare.git","ssh_url":"git@github.com:hydroshare/hydroshare.git","clone_url":"https://github.com/hydroshare/hydroshare.git","svn_url":"https://github.com/hydroshare/hydroshare","homepage":"https://www.cuahsi.org/hydroshare","size":61061,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":121,"forks":1,"open_issues":121,"watchers":9,"default_branch":"master"}},"base":{"label":"hydroshare:develop","ref":"develop","sha":"acebee62dae971c84190423c4fc8df9df16ed77d","user":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"repo":{"id":24703136,"name":"hydroshare","full_name":"hydroshare/hydroshare","owner":{"login":"hydroshare","id":3444493,"avatar_url":"https://avatars.githubusercontent.com/u/3444493?v=3","gravatar_id":"","url":"https://api.github.com/users/hydroshare","html_url":"https://github.com/hydroshare","followers_url":"https://api.github.com/users/hydroshare/followers","following_url":"https://api.github.com/users/hydroshare/following{/other_user}","gists_url":"https://api.github.com/users/hydroshare/gists{/gist_id}","starred_url":"https://api.github.com/users/hydroshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hydroshare/subscriptions","organizations_url":"https://api.github.com/users/hydroshare/orgs","repos_url":"https://api.github.com/users/hydroshare/repos","events_url":"https://api.github.com/users/hydroshare/events{/privacy}","received_events_url":"https://api.github.com/users/hydroshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hydroshare/hydroshare","description":"HydroShare is a collaborative website being developed for better access to data and models in the hydrologic sciences. ","fork":false,"url":"https://api.github.com/repos/hydroshare/hydroshare","forks_url":"https://api.github.com/repos/hydroshare/hydroshare/forks","keys_url":"https://api.github.com/repos/hydroshare/hydroshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hydroshare/hydroshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hydroshare/hydroshare/teams","hooks_url":"https://api.github.com/repos/hydroshare/hydroshare/hooks","issue_events_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/events{/number}","events_url":"https://api.github.com/repos/hydroshare/hydroshare/events","assignees_url":"https://api.github.com/repos/hydroshare/hydroshare/assignees{/user}","branches_url":"https://api.github.com/repos/hydroshare/hydroshare/branches{/branch}","tags_url":"https://api.github.com/repos/hydroshare/hydroshare/tags","blobs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hydroshare/hydroshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hydroshare/hydroshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/hydroshare/hydroshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hydroshare/hydroshare/statuses/{sha}","languages_url":"https://api.github.com/repos/hydroshare/hydroshare/languages","stargazers_url":"https://api.github.com/repos/hydroshare/hydroshare/stargazers","contributors_url":"https://api.github.com/repos/hydroshare/hydroshare/contributors","subscribers_url":"https://api.github.com/repos/hydroshare/hydroshare/subscribers","subscription_url":"https://api.github.com/repos/hydroshare/hydroshare/subscription","commits_url":"https://api.github.com/repos/hydroshare/hydroshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/hydroshare/hydroshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/hydroshare/hydroshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/hydroshare/hydroshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/hydroshare/hydroshare/contents/{+path}","compare_url":"https://api.github.com/repos/hydroshare/hydroshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hydroshare/hydroshare/merges","archive_url":"https://api.github.com/repos/hydroshare/hydroshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hydroshare/hydroshare/downloads","issues_url":"https://api.github.com/repos/hydroshare/hydroshare/issues{/number}","pulls_url":"https://api.github.com/repos/hydroshare/hydroshare/pulls{/number}","milestones_url":"https://api.github.com/repos/hydroshare/hydroshare/milestones{/number}","notifications_url":"https://api.github.com/repos/hydroshare/hydroshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hydroshare/hydroshare/labels{/name}","releases_url":"https://api.github.com/repos/hydroshare/hydroshare/releases{/id}","created_at":"2014-10-02T02:19:41Z","updated_at":"2015-04-01T15:17:27Z","pushed_at":"2015-04-23T13:42:33Z","git_url":"git://github.com/hydroshare/hydroshare.git","ssh_url":"git@github.com:hydroshare/hydroshare.git","clone_url":"https://github.com/hydroshare/hydroshare.git","svn_url":"https://github.com/hydroshare/hydroshare","homepage":"https://www.cuahsi.org/hydroshare","size":61061,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":121,"forks":1,"open_issues":121,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313"},"html":{"href":"https://github.com/hydroshare/hydroshare/pull/313"},"issue":{"href":"https://api.github.com/repos/hydroshare/hydroshare/issues/313"},"comments":{"href":"https://api.github.com/repos/hydroshare/hydroshare/issues/313/comments"},"review_comments":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313/comments"},"review_comment":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hydroshare/hydroshare/pulls/313/commits"},"statuses":{"href":"https://api.github.com/repos/hydroshare/hydroshare/statuses/b147bd8de898bb03fc4a122353f6e7d101099e1d"}}}}