{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/59903942","id":59903942,"diff_hunk":"@@ -0,0 +1,114 @@\n+/**\n+ * Copyright (c) Codice Foundation\n+ * <p/>\n+ * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser\n+ * General Public License as published by the Free Software Foundation, either version 3 of the\n+ * License, or any later version.\n+ * <p/>\n+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\n+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ * Lesser General Public License for more details. A copy of the GNU Lesser General Public License\n+ * is distributed along with this program and can be found at\n+ * <http://www.gnu.org/licenses/lgpl.html>.\n+ */\n+package org.codice.ddf.catalog.content.resource.reader;\n+\n+import java.net.MalformedURLException;\n+import java.net.URI;\n+import java.net.URISyntaxException;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.List;\n+\n+import org.apache.commons.lang.StringUtils;\n+import org.apache.http.client.utils.URIBuilder;\n+import org.apache.http.message.BasicNameValuePair;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import ddf.action.Action;\n+import ddf.action.ActionProvider;\n+import ddf.action.impl.ActionImpl;\n+import ddf.catalog.content.data.ContentItem;\n+import ddf.catalog.data.Metacard;\n+\n+public class DerivedContentActionProvider implements ActionProvider {\n+\n+    private static final String ID = \"catalog.data.metacard.derived-content\";\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(DerivedContentActionProvider.class);\n+\n+    private final ActionProvider resourceActionProvider;\n+\n+    private static final String DESCRIPTION_PREFIX = \"Retrieves derived resource: \";\n+\n+    public DerivedContentActionProvider(ActionProvider actionProvider) {\n+        this.resourceActionProvider = actionProvider;\n+    }\n+\n+    @Override\n+    public <T> List<Action> getActions(T input) {\n+        if (!canHandle(input)) {\n+            return Collections.emptyList();\n+        }\n+        // Expect only 1\n+        List<Action> resourceActions = resourceActionProvider.getActions(input);\n+        if (resourceActions.isEmpty()) {\n+            return Collections.emptyList();\n+        }\n+        List<Action> actions = new ArrayList<>();\n+        ((Metacard) input).getAttribute(Metacard.DERIVED_RESOURCE_URI)\n+                .getValues()\n+                .stream()\n+                .forEach(value -> {\n+                    try {\n+                        URI uri = new URI(value.toString());\n+                        URIBuilder builder = new URIBuilder(resourceActions.get(0)\n+                                .getUrl()\n+                                .toURI());\n+                        if (StringUtils.equals(uri.getScheme(), ContentItem.CONTENT_SCHEME)) {\n+                            String qualifier = uri.getFragment();\n+\n+                            builder.addParameters(Arrays.asList(new BasicNameValuePair(\"options\",","path":"catalog/core/catalog-core-contentresourcereader/src/main/java/org/codice/ddf/catalog/content/resource/reader/DerivedContentActionProvider.java","position":73,"original_position":73,"commit_id":"5895eeab5beeb925f395983db35c52af01a49a32","original_commit_id":"5895eeab5beeb925f395983db35c52af01a49a32","user":{"login":"glenhein","id":17837152,"avatar_url":"https://avatars.githubusercontent.com/u/17837152?v=3","gravatar_id":"","url":"https://api.github.com/users/glenhein","html_url":"https://github.com/glenhein","followers_url":"https://api.github.com/users/glenhein/followers","following_url":"https://api.github.com/users/glenhein/following{/other_user}","gists_url":"https://api.github.com/users/glenhein/gists{/gist_id}","starred_url":"https://api.github.com/users/glenhein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glenhein/subscriptions","organizations_url":"https://api.github.com/users/glenhein/orgs","repos_url":"https://api.github.com/users/glenhein/repos","events_url":"https://api.github.com/users/glenhein/events{/privacy}","received_events_url":"https://api.github.com/users/glenhein/received_events","type":"User","site_admin":false},"body":"How about Collections.singletonList instead of Arrays.asList?","created_at":"2016-04-15T16:46:07Z","updated_at":"2016-04-15T16:46:07Z","html_url":"https://github.com/codice/ddf/pull/703#discussion_r59903942","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/703","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/59903942"},"html":{"href":"https://github.com/codice/ddf/pull/703#discussion_r59903942"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/703"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/703","id":66548813,"html_url":"https://github.com/codice/ddf/pull/703","diff_url":"https://github.com/codice/ddf/pull/703.diff","patch_url":"https://github.com/codice/ddf/pull/703.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/703","number":703,"state":"open","locked":false,"title":"DDF-2025 - updated ActionProvider to return a List of Actions. Added …","user":{"login":"kcwire","id":4631300,"avatar_url":"https://avatars.githubusercontent.com/u/4631300?v=3","gravatar_id":"","url":"https://api.github.com/users/kcwire","html_url":"https://github.com/kcwire","followers_url":"https://api.github.com/users/kcwire/followers","following_url":"https://api.github.com/users/kcwire/following{/other_user}","gists_url":"https://api.github.com/users/kcwire/gists{/gist_id}","starred_url":"https://api.github.com/users/kcwire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcwire/subscriptions","organizations_url":"https://api.github.com/users/kcwire/orgs","repos_url":"https://api.github.com/users/kcwire/repos","events_url":"https://api.github.com/users/kcwire/events{/privacy}","received_events_url":"https://api.github.com/users/kcwire/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nUpdates the experimental ActionProvider interface to return a List<Action>.\r\nAdds DerivedContentActionProvider as an implemenation.\r\n#### Who is reviewing it (please choose AT LEAST two reviewers that need to approve the PR before it can get merged; if a component team is listed, at least one of its members needs to approve)?\r\n@jaymcnallie @dcruver \r\n#### Choose 2 committers to review/merge the PR (please choose ONLY two committers from below, delete the rest).\r\n@kcwire\r\n@pklinef\r\n#### How should this be tested?\r\nVerify Integration tests. For a live Install the sample-storageplugins bundle, ingest a jpg through the search ui, verify the derived content uris are in the details tab & the new action under the Actions tab downloads a thumbnails of the jpg.\r\n#### Any background context you want to provide?\r\n#### What are the relevant tickets?\r\nDDF-2025\r\n#### Screenshots (if appropriate)\r\n#### Checklist:\r\n- [ ] Documentation Updated\r\n- [x] Update / Add Unit Tests\r\n- [x] Update / Add Integration Tests\r\n\r\n…DerivedContentActionProvider for derived content items.","created_at":"2016-04-14T20:31:18Z","updated_at":"2016-04-15T16:46:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"957858222ffaf8bfdd3dc270a260efff7c6268cc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codice/ddf/pulls/703/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/703/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/703/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/5895eeab5beeb925f395983db35c52af01a49a32","head":{"label":"kcwire:DDF-2025","ref":"DDF-2025","sha":"5895eeab5beeb925f395983db35c52af01a49a32","user":{"login":"kcwire","id":4631300,"avatar_url":"https://avatars.githubusercontent.com/u/4631300?v=3","gravatar_id":"","url":"https://api.github.com/users/kcwire","html_url":"https://github.com/kcwire","followers_url":"https://api.github.com/users/kcwire/followers","following_url":"https://api.github.com/users/kcwire/following{/other_user}","gists_url":"https://api.github.com/users/kcwire/gists{/gist_id}","starred_url":"https://api.github.com/users/kcwire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcwire/subscriptions","organizations_url":"https://api.github.com/users/kcwire/orgs","repos_url":"https://api.github.com/users/kcwire/repos","events_url":"https://api.github.com/users/kcwire/events{/privacy}","received_events_url":"https://api.github.com/users/kcwire/received_events","type":"User","site_admin":false},"repo":{"id":39475870,"name":"ddf","full_name":"kcwire/ddf","owner":{"login":"kcwire","id":4631300,"avatar_url":"https://avatars.githubusercontent.com/u/4631300?v=3","gravatar_id":"","url":"https://api.github.com/users/kcwire","html_url":"https://github.com/kcwire","followers_url":"https://api.github.com/users/kcwire/followers","following_url":"https://api.github.com/users/kcwire/following{/other_user}","gists_url":"https://api.github.com/users/kcwire/gists{/gist_id}","starred_url":"https://api.github.com/users/kcwire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcwire/subscriptions","organizations_url":"https://api.github.com/users/kcwire/orgs","repos_url":"https://api.github.com/users/kcwire/repos","events_url":"https://api.github.com/users/kcwire/events{/privacy}","received_events_url":"https://api.github.com/users/kcwire/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kcwire/ddf","description":"The Distributed Data Framework - Distribution, SDK, and Test","fork":true,"url":"https://api.github.com/repos/kcwire/ddf","forks_url":"https://api.github.com/repos/kcwire/ddf/forks","keys_url":"https://api.github.com/repos/kcwire/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kcwire/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kcwire/ddf/teams","hooks_url":"https://api.github.com/repos/kcwire/ddf/hooks","issue_events_url":"https://api.github.com/repos/kcwire/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/kcwire/ddf/events","assignees_url":"https://api.github.com/repos/kcwire/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/kcwire/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/kcwire/ddf/tags","blobs_url":"https://api.github.com/repos/kcwire/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kcwire/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kcwire/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/kcwire/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kcwire/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/kcwire/ddf/languages","stargazers_url":"https://api.github.com/repos/kcwire/ddf/stargazers","contributors_url":"https://api.github.com/repos/kcwire/ddf/contributors","subscribers_url":"https://api.github.com/repos/kcwire/ddf/subscribers","subscription_url":"https://api.github.com/repos/kcwire/ddf/subscription","commits_url":"https://api.github.com/repos/kcwire/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/kcwire/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/kcwire/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/kcwire/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/kcwire/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/kcwire/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kcwire/ddf/merges","archive_url":"https://api.github.com/repos/kcwire/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kcwire/ddf/downloads","issues_url":"https://api.github.com/repos/kcwire/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/kcwire/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/kcwire/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/kcwire/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kcwire/ddf/labels{/name}","releases_url":"https://api.github.com/repos/kcwire/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/kcwire/ddf/deployments","created_at":"2015-07-22T00:02:09Z","updated_at":"2015-07-22T00:04:00Z","pushed_at":"2016-04-15T00:03:06Z","git_url":"git://github.com/kcwire/ddf.git","ssh_url":"git@github.com:kcwire/ddf.git","clone_url":"https://github.com/kcwire/ddf.git","svn_url":"https://github.com/kcwire/ddf","homepage":"","size":141457,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"codice:master","ref":"master","sha":"45eb505c26fe9c25532d64962e468a98fa5ac4f7","user":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"repo":{"id":15173563,"name":"ddf","full_name":"codice/ddf","owner":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codice/ddf","description":"The Distributed Data Framework - Federated Open Geospatial Consortium (OGC) filter powered metadata catalog with SAML Web SSO secured container","fork":false,"url":"https://api.github.com/repos/codice/ddf","forks_url":"https://api.github.com/repos/codice/ddf/forks","keys_url":"https://api.github.com/repos/codice/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codice/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codice/ddf/teams","hooks_url":"https://api.github.com/repos/codice/ddf/hooks","issue_events_url":"https://api.github.com/repos/codice/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/codice/ddf/events","assignees_url":"https://api.github.com/repos/codice/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/codice/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/codice/ddf/tags","blobs_url":"https://api.github.com/repos/codice/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codice/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codice/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/codice/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/codice/ddf/languages","stargazers_url":"https://api.github.com/repos/codice/ddf/stargazers","contributors_url":"https://api.github.com/repos/codice/ddf/contributors","subscribers_url":"https://api.github.com/repos/codice/ddf/subscribers","subscription_url":"https://api.github.com/repos/codice/ddf/subscription","commits_url":"https://api.github.com/repos/codice/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/codice/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/codice/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/codice/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/codice/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/codice/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codice/ddf/merges","archive_url":"https://api.github.com/repos/codice/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codice/ddf/downloads","issues_url":"https://api.github.com/repos/codice/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/codice/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/codice/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/codice/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codice/ddf/labels{/name}","releases_url":"https://api.github.com/repos/codice/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/codice/ddf/deployments","created_at":"2013-12-13T20:38:28Z","updated_at":"2016-04-10T11:25:35Z","pushed_at":"2016-04-15T16:15:53Z","git_url":"git://github.com/codice/ddf.git","ssh_url":"git@github.com:codice/ddf.git","clone_url":"https://github.com/codice/ddf.git","svn_url":"https://github.com/codice/ddf","homepage":"","size":156910,"stargazers_count":37,"watchers_count":37,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":74,"mirror_url":null,"open_issues_count":16,"forks":74,"open_issues":16,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/703"},"html":{"href":"https://github.com/codice/ddf/pull/703"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/703"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/703/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/703/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/703/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/5895eeab5beeb925f395983db35c52af01a49a32"}}}}