{"action":"created","comment":{"url":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments/60127140","id":60127140,"diff_hunk":"@@ -317,103 +341,102 @@ private String getAccessUrl(String contentId, String assignmentRef, String userI\n \t\t//assignmentRef: /assignment/a/f7d8c921-7d5a-4116-8781-9b61a7c92c43/cbb993da-ea12-4e74-bab1-20d16185a655\n \t\tString context = getSiteIdFromConentId(contentId);\n \t\tif(context != null){\n+\t\t\tString externalContentId = getAttachmentId(contentId);\n+\t\t\tString returnUrl = null;\n \t\t\tString assignmentId = getAssignmentId(assignmentRef, isA2(contentId, assignmentRef));\n-\t\t\tMap<String, String> params = new HashMap<String, String>();\n-\t\t\tparams.put(PARAM_CONSUMER, consumer);\n-\t\t\tString token = null;\n-\t\t\tif(instructor){\n-\t\t\t\t//see if token already exist and isn't expired (we'll expire it after 1 minute so the user has enough time to use the token)\n-\t\t\t\tif(instructorSiteTokenCache.containsKey(context)){\n-\t\t\t\t\tObject[] cacheItem = instructorSiteTokenCache.get(context);\n-\t\t\t\t\tCalendar cal = Calendar.getInstance();\n-\t\t\t\t    cal.setTime(new Date());\n-\t\t\t\t    //subtract the exipre time (currently set to 20 while the plag token is set to 30, leaving 10 mins in worse case for instructor to use token)\n-\t\t\t\t    cal.add(Calendar.MINUTE, CACHE_EXPIRE_MINS * -1);\n-\t\t\t\t    if(((Date) cacheItem[1]).after(cal.getTime())){\n-\t\t\t\t    \t//token hasn't expired, use it\n-\t\t\t\t    \ttoken = (String) cacheItem[0];\n-\t\t\t\t    }else{\n-\t\t\t\t    \t//token is expired, remove it\n-\t\t\t\t    \tinstructorSiteTokenCache.remove(context);\n-\t\t\t\t    }\n-\t\t\t\t}\n-\t\t\t\t//this is an instructor, give them instructor role when viewing a report \n-\t\t\t\tparams.put(PARAM_USER_ROLE, PARAM_USER_ROLE_INSTRUCTOR); \n-\t\t\t}else{\n-\t\t\t\t//if the user is not an instructor, make sure the content id is set for the token request and access url\n-\t\t\t\tparams.put(PARAM_EXTERNAL_CONTENT_ID, contentId);\n-\t\t\t\t//make sure to set the token to expect the learner role only for non-instructors\n-\t\t\t\tparams.put(PARAM_USER_ROLE, PARAM_USER_ROLE_LEARNER);\n-\t\t\t}\n-\t\t\t\n-\t\t\tif(token == null){\n-\t\t\t\t//token wasn't cached, let's look it up\n-\t\t\t\tparams.put(PARAM_CONSUMER_SECRET, consumerSecret);\n-\t\t\t\tparams.put(PARAM_TOKEN_REQUEST, \"true\");\n-\t\t\t\tJSONObject results;\n-\t\t\t\ttry {\n-\t\t\t\t\tString url = \"\";\n-\t\t\t\t\tif(instructor){\n-\t\t\t\t\t\t//use a generic url (no assignment or user) since this is an instructor and we want any instructor in this site\n-\t\t\t\t\t\t//to user this cached token for any assignment in this site\n-\t\t\t\t\t\turl = generateUrl(context, null, null);\n-\t\t\t\t\t}else{\n-\t\t\t\t\t\turl = generateUrl(context, assignmentId, userId);\n-\t\t\t\t\t}\n-\t\t\t\t\tresults = getResults(url, params);\n-\t\t\t\t\tif(results != null){\n-\t\t\t\t\t\t//check for error message:\n-\t\t\t\t\t\tString errorMsg = getErrorMessage(results);\n-\t\t\t\t\t\tif(errorMsg == null){\n-\t\t\t\t\t\t\ttoken = results.getString(PARAM_TOKEN);\n+\t\t\tString cacheKey = context + \":\" + assignmentId + \":\" + userId;\n+\t\t\t//first check if cache already has the URL for this contentId and user\n+\t\t\tif(userUrlCache.containsKey(cacheKey)){\n+\t\t\t\tObject cacheObj = userUrlCache.get(cacheKey);\n+\t\t\t\tif(cacheObj != null && cacheObj instanceof Map){","path":"content-review/impl/vericite/src/main/java/org/sakaiproject/contentreview/vericite/ContentReviewServiceVeriCite.java","position":438,"original_position":438,"commit_id":"0ffe1f293bd19f6f235c738a993757903387dae1","original_commit_id":"0ffe1f293bd19f6f235c738a993757903387dae1","user":{"login":"ern","id":209420,"avatar_url":"https://avatars.githubusercontent.com/u/209420?v=3","gravatar_id":"","url":"https://api.github.com/users/ern","html_url":"https://github.com/ern","followers_url":"https://api.github.com/users/ern/followers","following_url":"https://api.github.com/users/ern/following{/other_user}","gists_url":"https://api.github.com/users/ern/gists{/gist_id}","starred_url":"https://api.github.com/users/ern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ern/subscriptions","organizations_url":"https://api.github.com/users/ern/orgs","repos_url":"https://api.github.com/users/ern/repos","events_url":"https://api.github.com/users/ern/events{/privacy}","received_events_url":"https://api.github.com/users/ern/received_events","type":"User","site_admin":false},"body":"Does it make sense to extract this into a concrete object?","created_at":"2016-04-18T20:21:05Z","updated_at":"2016-04-18T20:21:05Z","html_url":"https://github.com/sakaiproject/sakai/pull/2250#discussion_r60127140","pull_request_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250","_links":{"self":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments/60127140"},"html":{"href":"https://github.com/sakaiproject/sakai/pull/2250#discussion_r60127140"},"pull_request":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250"}}},"pull_request":{"url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250","id":66724535,"html_url":"https://github.com/sakaiproject/sakai/pull/2250","diff_url":"https://github.com/sakaiproject/sakai/pull/2250.diff","patch_url":"https://github.com/sakaiproject/sakai/pull/2250.patch","issue_url":"https://api.github.com/repos/sakaiproject/sakai/issues/2250","number":2250,"state":"open","locked":false,"title":"SAK-30813 Update VeriCite integration for new API and Content Review","user":{"login":"baholladay","id":345790,"avatar_url":"https://avatars.githubusercontent.com/u/345790?v=3","gravatar_id":"","url":"https://api.github.com/users/baholladay","html_url":"https://github.com/baholladay","followers_url":"https://api.github.com/users/baholladay/followers","following_url":"https://api.github.com/users/baholladay/following{/other_user}","gists_url":"https://api.github.com/users/baholladay/gists{/gist_id}","starred_url":"https://api.github.com/users/baholladay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baholladay/subscriptions","organizations_url":"https://api.github.com/users/baholladay/orgs","repos_url":"https://api.github.com/users/baholladay/repos","events_url":"https://api.github.com/users/baholladay/events{/privacy}","received_events_url":"https://api.github.com/users/baholladay/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-16T02:05:20Z","updated_at":"2016-04-18T20:21:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"644a4135fac19d6cf02cf09592b3bb47db4cfc07","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250/commits","review_comments_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250/comments","review_comment_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sakaiproject/sakai/issues/2250/comments","statuses_url":"https://api.github.com/repos/sakaiproject/sakai/statuses/0ffe1f293bd19f6f235c738a993757903387dae1","head":{"label":"baholladay:SAK-30813","ref":"SAK-30813","sha":"0ffe1f293bd19f6f235c738a993757903387dae1","user":{"login":"baholladay","id":345790,"avatar_url":"https://avatars.githubusercontent.com/u/345790?v=3","gravatar_id":"","url":"https://api.github.com/users/baholladay","html_url":"https://github.com/baholladay","followers_url":"https://api.github.com/users/baholladay/followers","following_url":"https://api.github.com/users/baholladay/following{/other_user}","gists_url":"https://api.github.com/users/baholladay/gists{/gist_id}","starred_url":"https://api.github.com/users/baholladay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baholladay/subscriptions","organizations_url":"https://api.github.com/users/baholladay/orgs","repos_url":"https://api.github.com/users/baholladay/repos","events_url":"https://api.github.com/users/baholladay/events{/privacy}","received_events_url":"https://api.github.com/users/baholladay/received_events","type":"User","site_admin":false},"repo":{"id":28716065,"name":"sakai","full_name":"baholladay/sakai","owner":{"login":"baholladay","id":345790,"avatar_url":"https://avatars.githubusercontent.com/u/345790?v=3","gravatar_id":"","url":"https://api.github.com/users/baholladay","html_url":"https://github.com/baholladay","followers_url":"https://api.github.com/users/baholladay/followers","following_url":"https://api.github.com/users/baholladay/following{/other_user}","gists_url":"https://api.github.com/users/baholladay/gists{/gist_id}","starred_url":"https://api.github.com/users/baholladay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baholladay/subscriptions","organizations_url":"https://api.github.com/users/baholladay/orgs","repos_url":"https://api.github.com/users/baholladay/repos","events_url":"https://api.github.com/users/baholladay/events{/privacy}","received_events_url":"https://api.github.com/users/baholladay/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/baholladay/sakai","description":"Sakai is a freely available, feature-rich technology solution for learning, teaching, research and collaboration. Sakai is an open source software suite developed by a diverse and global adopter community.","fork":true,"url":"https://api.github.com/repos/baholladay/sakai","forks_url":"https://api.github.com/repos/baholladay/sakai/forks","keys_url":"https://api.github.com/repos/baholladay/sakai/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baholladay/sakai/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baholladay/sakai/teams","hooks_url":"https://api.github.com/repos/baholladay/sakai/hooks","issue_events_url":"https://api.github.com/repos/baholladay/sakai/issues/events{/number}","events_url":"https://api.github.com/repos/baholladay/sakai/events","assignees_url":"https://api.github.com/repos/baholladay/sakai/assignees{/user}","branches_url":"https://api.github.com/repos/baholladay/sakai/branches{/branch}","tags_url":"https://api.github.com/repos/baholladay/sakai/tags","blobs_url":"https://api.github.com/repos/baholladay/sakai/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baholladay/sakai/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baholladay/sakai/git/refs{/sha}","trees_url":"https://api.github.com/repos/baholladay/sakai/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baholladay/sakai/statuses/{sha}","languages_url":"https://api.github.com/repos/baholladay/sakai/languages","stargazers_url":"https://api.github.com/repos/baholladay/sakai/stargazers","contributors_url":"https://api.github.com/repos/baholladay/sakai/contributors","subscribers_url":"https://api.github.com/repos/baholladay/sakai/subscribers","subscription_url":"https://api.github.com/repos/baholladay/sakai/subscription","commits_url":"https://api.github.com/repos/baholladay/sakai/commits{/sha}","git_commits_url":"https://api.github.com/repos/baholladay/sakai/git/commits{/sha}","comments_url":"https://api.github.com/repos/baholladay/sakai/comments{/number}","issue_comment_url":"https://api.github.com/repos/baholladay/sakai/issues/comments{/number}","contents_url":"https://api.github.com/repos/baholladay/sakai/contents/{+path}","compare_url":"https://api.github.com/repos/baholladay/sakai/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baholladay/sakai/merges","archive_url":"https://api.github.com/repos/baholladay/sakai/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baholladay/sakai/downloads","issues_url":"https://api.github.com/repos/baholladay/sakai/issues{/number}","pulls_url":"https://api.github.com/repos/baholladay/sakai/pulls{/number}","milestones_url":"https://api.github.com/repos/baholladay/sakai/milestones{/number}","notifications_url":"https://api.github.com/repos/baholladay/sakai/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baholladay/sakai/labels{/name}","releases_url":"https://api.github.com/repos/baholladay/sakai/releases{/id}","deployments_url":"https://api.github.com/repos/baholladay/sakai/deployments","created_at":"2015-01-02T14:50:06Z","updated_at":"2016-01-12T13:08:09Z","pushed_at":"2016-04-15T19:34:19Z","git_url":"git://github.com/baholladay/sakai.git","ssh_url":"git@github.com:baholladay/sakai.git","clone_url":"https://github.com/baholladay/sakai.git","svn_url":"https://github.com/baholladay/sakai","homepage":"https://www.sakaiproject.org","size":253339,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sakaiproject:master","ref":"master","sha":"89a4f5c5aeacbd6c501f3f27edbd5d585509941d","user":{"login":"sakaiproject","id":314726,"avatar_url":"https://avatars.githubusercontent.com/u/314726?v=3","gravatar_id":"","url":"https://api.github.com/users/sakaiproject","html_url":"https://github.com/sakaiproject","followers_url":"https://api.github.com/users/sakaiproject/followers","following_url":"https://api.github.com/users/sakaiproject/following{/other_user}","gists_url":"https://api.github.com/users/sakaiproject/gists{/gist_id}","starred_url":"https://api.github.com/users/sakaiproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sakaiproject/subscriptions","organizations_url":"https://api.github.com/users/sakaiproject/orgs","repos_url":"https://api.github.com/users/sakaiproject/repos","events_url":"https://api.github.com/users/sakaiproject/events{/privacy}","received_events_url":"https://api.github.com/users/sakaiproject/received_events","type":"Organization","site_admin":false},"repo":{"id":28589709,"name":"sakai","full_name":"sakaiproject/sakai","owner":{"login":"sakaiproject","id":314726,"avatar_url":"https://avatars.githubusercontent.com/u/314726?v=3","gravatar_id":"","url":"https://api.github.com/users/sakaiproject","html_url":"https://github.com/sakaiproject","followers_url":"https://api.github.com/users/sakaiproject/followers","following_url":"https://api.github.com/users/sakaiproject/following{/other_user}","gists_url":"https://api.github.com/users/sakaiproject/gists{/gist_id}","starred_url":"https://api.github.com/users/sakaiproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sakaiproject/subscriptions","organizations_url":"https://api.github.com/users/sakaiproject/orgs","repos_url":"https://api.github.com/users/sakaiproject/repos","events_url":"https://api.github.com/users/sakaiproject/events{/privacy}","received_events_url":"https://api.github.com/users/sakaiproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sakaiproject/sakai","description":"Sakai is a freely available, feature-rich technology solution for learning, teaching, research and collaboration. Sakai is an open source software suite developed by a diverse and global adopter community.","fork":false,"url":"https://api.github.com/repos/sakaiproject/sakai","forks_url":"https://api.github.com/repos/sakaiproject/sakai/forks","keys_url":"https://api.github.com/repos/sakaiproject/sakai/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sakaiproject/sakai/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sakaiproject/sakai/teams","hooks_url":"https://api.github.com/repos/sakaiproject/sakai/hooks","issue_events_url":"https://api.github.com/repos/sakaiproject/sakai/issues/events{/number}","events_url":"https://api.github.com/repos/sakaiproject/sakai/events","assignees_url":"https://api.github.com/repos/sakaiproject/sakai/assignees{/user}","branches_url":"https://api.github.com/repos/sakaiproject/sakai/branches{/branch}","tags_url":"https://api.github.com/repos/sakaiproject/sakai/tags","blobs_url":"https://api.github.com/repos/sakaiproject/sakai/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sakaiproject/sakai/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sakaiproject/sakai/git/refs{/sha}","trees_url":"https://api.github.com/repos/sakaiproject/sakai/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sakaiproject/sakai/statuses/{sha}","languages_url":"https://api.github.com/repos/sakaiproject/sakai/languages","stargazers_url":"https://api.github.com/repos/sakaiproject/sakai/stargazers","contributors_url":"https://api.github.com/repos/sakaiproject/sakai/contributors","subscribers_url":"https://api.github.com/repos/sakaiproject/sakai/subscribers","subscription_url":"https://api.github.com/repos/sakaiproject/sakai/subscription","commits_url":"https://api.github.com/repos/sakaiproject/sakai/commits{/sha}","git_commits_url":"https://api.github.com/repos/sakaiproject/sakai/git/commits{/sha}","comments_url":"https://api.github.com/repos/sakaiproject/sakai/comments{/number}","issue_comment_url":"https://api.github.com/repos/sakaiproject/sakai/issues/comments{/number}","contents_url":"https://api.github.com/repos/sakaiproject/sakai/contents/{+path}","compare_url":"https://api.github.com/repos/sakaiproject/sakai/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sakaiproject/sakai/merges","archive_url":"https://api.github.com/repos/sakaiproject/sakai/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sakaiproject/sakai/downloads","issues_url":"https://api.github.com/repos/sakaiproject/sakai/issues{/number}","pulls_url":"https://api.github.com/repos/sakaiproject/sakai/pulls{/number}","milestones_url":"https://api.github.com/repos/sakaiproject/sakai/milestones{/number}","notifications_url":"https://api.github.com/repos/sakaiproject/sakai/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sakaiproject/sakai/labels{/name}","releases_url":"https://api.github.com/repos/sakaiproject/sakai/releases{/id}","deployments_url":"https://api.github.com/repos/sakaiproject/sakai/deployments","created_at":"2014-12-29T11:14:17Z","updated_at":"2016-04-17T21:13:12Z","pushed_at":"2016-04-18T18:36:45Z","git_url":"git://github.com/sakaiproject/sakai.git","ssh_url":"git@github.com:sakaiproject/sakai.git","clone_url":"https://github.com/sakaiproject/sakai.git","svn_url":"https://github.com/sakaiproject/sakai","homepage":"https://www.sakaiproject.org","size":262675,"stargazers_count":134,"watchers_count":134,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":236,"mirror_url":null,"open_issues_count":111,"forks":236,"open_issues":111,"watchers":134,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250"},"html":{"href":"https://github.com/sakaiproject/sakai/pull/2250"},"issue":{"href":"https://api.github.com/repos/sakaiproject/sakai/issues/2250"},"comments":{"href":"https://api.github.com/repos/sakaiproject/sakai/issues/2250/comments"},"review_comments":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250/comments"},"review_comment":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2250/commits"},"statuses":{"href":"https://api.github.com/repos/sakaiproject/sakai/statuses/0ffe1f293bd19f6f235c738a993757903387dae1"}}}}