{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/64247935","id":64247935,"diff_hunk":"@@ -0,0 +1,147 @@\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.registry.report.action.provider;\n+\n+import java.io.UnsupportedEncodingException;\n+import java.net.MalformedURLException;\n+import java.net.URI;\n+import java.net.URISyntaxException;\n+import java.net.URL;\n+import java.net.URLEncoder;\n+import java.nio.charset.StandardCharsets;\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.codice.ddf.configuration.SystemBaseUrl;\n+import org.codice.ddf.registry.common.RegistryConstants;\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.data.Metacard;\n+\n+public class RegistryMetacardActionProvider implements ActionProvider {\n+\n+    public static final String TITLE = \"Export Registry Metacard Information\";\n+\n+    public static final String DESCRIPTION = \"Provides a URL to the metacard\";\n+\n+    private static final String UNKNOWN_TARGET = \"0.0.0.0\";\n+\n+    private static final String REGISTRY_PATH = \"/registries\";\n+\n+    private static final String REPORT_PATH = \"/report\";\n+\n+    private static final String FORMAT = \".html\";\n+\n+    private static final String SOURCE_ID_QUERY_PARAM = \"?sourceId=\";\n+\n+    private final String actionProviderId;\n+\n+    private static final Logger LOGGER =\n+            LoggerFactory.getLogger(RegistryMetacardActionProvider.class);\n+\n+    public RegistryMetacardActionProvider(String id) {\n+        this.actionProviderId = id;\n+    }\n+\n+    public <T> List<Action> getActions(T subject) {\n+\n+        if (canHandle(subject)) {\n+            Metacard metacard = (Metacard) subject;\n+\n+            if (StringUtils.isBlank(metacard.getId())) {\n+                LOGGER.info(\"No id given. No action to provide.\");\n+                return Collections.emptyList();\n+            }\n+\n+            if (isHostUnset(SystemBaseUrl.getHost())) {\n+                LOGGER.info(\"Host name/ip not set. Cannot create link for metacard.\");\n+                return Collections.emptyList();\n+            }\n+\n+            String metacardId;\n+            String sourceId;\n+\n+            try {\n+                metacardId = URLEncoder.encode(metacard.getId(), (StandardCharsets.UTF_8).toString());\n+                sourceId = URLEncoder.encode(getSource(metacard), (StandardCharsets.UTF_8).toString());\n+            } catch (UnsupportedEncodingException e) {\n+                LOGGER.info(\"Unsupported Encoding exception\", e);\n+                return Collections.emptyList();\n+            }\n+\n+            Action action = getAction(metacardId, sourceId);\n+            if (action == null) {\n+                return Collections.emptyList();\n+            }\n+            return Arrays.asList(action);\n+        }\n+\n+        return Collections.emptyList();\n+    }\n+\n+    private Action getAction(String metacardId, String sourceId) {\n+\n+        if(StringUtils.isNotBlank(sourceId)) {\n+            sourceId = SOURCE_ID_QUERY_PARAM + sourceId;\n+        }\n+\n+        URL url;\n+        try {\n+\n+            URI uri = new URI(SystemBaseUrl.constructUrl(REGISTRY_PATH + \"/\" + metacardId + REPORT_PATH + FORMAT + sourceId,\n+                    true));\n+            url = uri.toURL();\n+\n+        } catch (MalformedURLException e) {\n+            LOGGER.info(\"Malformed URL exception\", e);\n+            return null;\n+        } catch (URISyntaxException e) {\n+            LOGGER.info(\"URI Syntax exception\", e);\n+            return null;\n+        }\n+\n+        return new ActionImpl(getId(), TITLE, DESCRIPTION, url);\n+    }\n+\n+    private boolean isHostUnset(String host) {\n+        return (host == null || host.trim()","path":"catalog/spatial/registry/registry-report-action-provider/src/main/java/org/codice/ddf/registry/report/action/provider/RegistryMetacardActionProvider.java","position":124,"original_position":124,"commit_id":"71d3b821dedfa7ea32076d07661b8917c301a038","original_commit_id":"71d3b821dedfa7ea32076d07661b8917c301a038","user":{"login":"mcalcote","id":11355332,"avatar_url":"https://avatars.githubusercontent.com/u/11355332?v=3","gravatar_id":"","url":"https://api.github.com/users/mcalcote","html_url":"https://github.com/mcalcote","followers_url":"https://api.github.com/users/mcalcote/followers","following_url":"https://api.github.com/users/mcalcote/following{/other_user}","gists_url":"https://api.github.com/users/mcalcote/gists{/gist_id}","starred_url":"https://api.github.com/users/mcalcote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcalcote/subscriptions","organizations_url":"https://api.github.com/users/mcalcote/orgs","repos_url":"https://api.github.com/users/mcalcote/repos","events_url":"https://api.github.com/users/mcalcote/events{/privacy}","received_events_url":"https://api.github.com/users/mcalcote/received_events","type":"User","site_admin":false},"body":"I think `SystemBaseUrl` has default string values when `System.setProperty` isn't called, and if someone set the property to an empty string, there would be other exceptions/failures before we got here.","created_at":"2016-05-23T16:33:41Z","updated_at":"2016-05-23T16:33:41Z","html_url":"https://github.com/codice/ddf/pull/794#discussion_r64247935","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/794","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/64247935"},"html":{"href":"https://github.com/codice/ddf/pull/794#discussion_r64247935"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/794"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/794","id":70739712,"html_url":"https://github.com/codice/ddf/pull/794","diff_url":"https://github.com/codice/ddf/pull/794.diff","patch_url":"https://github.com/codice/ddf/pull/794.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/794","number":794,"state":"open","locked":false,"title":"DDF-2008 Merge registry report action provider from ddf-registry into ddf","user":{"login":"mcalcote","id":11355332,"avatar_url":"https://avatars.githubusercontent.com/u/11355332?v=3","gravatar_id":"","url":"https://api.github.com/users/mcalcote","html_url":"https://github.com/mcalcote","followers_url":"https://api.github.com/users/mcalcote/followers","following_url":"https://api.github.com/users/mcalcote/following{/other_user}","gists_url":"https://api.github.com/users/mcalcote/gists{/gist_id}","starred_url":"https://api.github.com/users/mcalcote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcalcote/subscriptions","organizations_url":"https://api.github.com/users/mcalcote/orgs","repos_url":"https://api.github.com/users/mcalcote/repos","events_url":"https://api.github.com/users/mcalcote/events{/privacy}","received_events_url":"https://api.github.com/users/mcalcote/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nCreate ActionProvider for registry metacards to provide an action (url). Currently this ActionProvider link is accessible when searching for metacards with the registry tag in the search UI and then checking the available actions. \r\n\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@rzwiefel @kcwire @coyotesqrl \r\n#### Choose 2 committers to review/merge the PR (please choose ONLY two committers from below, delete the rest).\r\n@pklinef\r\n@shaundmorris\r\n#### How should this be tested?\r\nBuild, Confirm ActionProvider link in Search UI\r\n\r\nThis can be tested by following these steps:\r\n1. Installing the registry app\r\n2. Ingesting a registry metacard `ingest -t rim:RegistryPackage /Users/PathToYourDDF/ddf/catalog/spatial/registry/registry-ebrim-transformer/src/test/resources/csw-full-registry-package.xml`\r\n3. Ingesting a second non-registry metacard\r\n4. Open the search UI and do a wildcard search, the use the Details option to search for a **metacard-tags** contains **registry** search\r\n5. Select the registry metacard returned by this second search and select the Action tab\r\n6. Observe the URL generated when selecting **Export Registry Metacard Information** -> Display in new tab/window\r\n\r\n#### Any background context you want to provide?\r\nThe code to generate the resulting report at the link provided is in another module. \r\n#### What are the relevant tickets?\r\nDDF-2008\r\nDDF-2059\r\n#### Checklist:\r\n- [ ] Documentation Updated\r\n- [x] Update / Add Unit Tests\r\n- [ ] Update / Add Integration Tests\r\n","created_at":"2016-05-19T18:11:06Z","updated_at":"2016-05-23T16:33:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"073aec9daf638a180235f72ce8cf6a2bf1b250a0","assignee":{"login":"shaundmorris","id":4359166,"avatar_url":"https://avatars.githubusercontent.com/u/4359166?v=3","gravatar_id":"","url":"https://api.github.com/users/shaundmorris","html_url":"https://github.com/shaundmorris","followers_url":"https://api.github.com/users/shaundmorris/followers","following_url":"https://api.github.com/users/shaundmorris/following{/other_user}","gists_url":"https://api.github.com/users/shaundmorris/gists{/gist_id}","starred_url":"https://api.github.com/users/shaundmorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shaundmorris/subscriptions","organizations_url":"https://api.github.com/users/shaundmorris/orgs","repos_url":"https://api.github.com/users/shaundmorris/repos","events_url":"https://api.github.com/users/shaundmorris/events{/privacy}","received_events_url":"https://api.github.com/users/shaundmorris/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/codice/ddf/pulls/794/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/794/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/794/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/71d3b821dedfa7ea32076d07661b8917c301a038","head":{"label":"mcalcote:DDF2008","ref":"DDF2008","sha":"71d3b821dedfa7ea32076d07661b8917c301a038","user":{"login":"mcalcote","id":11355332,"avatar_url":"https://avatars.githubusercontent.com/u/11355332?v=3","gravatar_id":"","url":"https://api.github.com/users/mcalcote","html_url":"https://github.com/mcalcote","followers_url":"https://api.github.com/users/mcalcote/followers","following_url":"https://api.github.com/users/mcalcote/following{/other_user}","gists_url":"https://api.github.com/users/mcalcote/gists{/gist_id}","starred_url":"https://api.github.com/users/mcalcote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcalcote/subscriptions","organizations_url":"https://api.github.com/users/mcalcote/orgs","repos_url":"https://api.github.com/users/mcalcote/repos","events_url":"https://api.github.com/users/mcalcote/events{/privacy}","received_events_url":"https://api.github.com/users/mcalcote/received_events","type":"User","site_admin":false},"repo":{"id":50143494,"name":"ddf","full_name":"mcalcote/ddf","owner":{"login":"mcalcote","id":11355332,"avatar_url":"https://avatars.githubusercontent.com/u/11355332?v=3","gravatar_id":"","url":"https://api.github.com/users/mcalcote","html_url":"https://github.com/mcalcote","followers_url":"https://api.github.com/users/mcalcote/followers","following_url":"https://api.github.com/users/mcalcote/following{/other_user}","gists_url":"https://api.github.com/users/mcalcote/gists{/gist_id}","starred_url":"https://api.github.com/users/mcalcote/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcalcote/subscriptions","organizations_url":"https://api.github.com/users/mcalcote/orgs","repos_url":"https://api.github.com/users/mcalcote/repos","events_url":"https://api.github.com/users/mcalcote/events{/privacy}","received_events_url":"https://api.github.com/users/mcalcote/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mcalcote/ddf","description":"The Distributed Data Framework - Federated Open Geospatial Consortium (OGC) filter powered metadata catalog with SAML Web SSO secured container","fork":true,"url":"https://api.github.com/repos/mcalcote/ddf","forks_url":"https://api.github.com/repos/mcalcote/ddf/forks","keys_url":"https://api.github.com/repos/mcalcote/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mcalcote/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mcalcote/ddf/teams","hooks_url":"https://api.github.com/repos/mcalcote/ddf/hooks","issue_events_url":"https://api.github.com/repos/mcalcote/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/mcalcote/ddf/events","assignees_url":"https://api.github.com/repos/mcalcote/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/mcalcote/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/mcalcote/ddf/tags","blobs_url":"https://api.github.com/repos/mcalcote/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mcalcote/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mcalcote/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/mcalcote/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mcalcote/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/mcalcote/ddf/languages","stargazers_url":"https://api.github.com/repos/mcalcote/ddf/stargazers","contributors_url":"https://api.github.com/repos/mcalcote/ddf/contributors","subscribers_url":"https://api.github.com/repos/mcalcote/ddf/subscribers","subscription_url":"https://api.github.com/repos/mcalcote/ddf/subscription","commits_url":"https://api.github.com/repos/mcalcote/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/mcalcote/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/mcalcote/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/mcalcote/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/mcalcote/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/mcalcote/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mcalcote/ddf/merges","archive_url":"https://api.github.com/repos/mcalcote/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mcalcote/ddf/downloads","issues_url":"https://api.github.com/repos/mcalcote/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/mcalcote/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/mcalcote/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/mcalcote/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mcalcote/ddf/labels{/name}","releases_url":"https://api.github.com/repos/mcalcote/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/mcalcote/ddf/deployments","created_at":"2016-01-21T23:19:10Z","updated_at":"2016-01-21T23:19:21Z","pushed_at":"2016-05-19T20:01:58Z","git_url":"git://github.com/mcalcote/ddf.git","ssh_url":"git@github.com:mcalcote/ddf.git","clone_url":"https://github.com/mcalcote/ddf.git","svn_url":"https://github.com/mcalcote/ddf","homepage":"","size":145029,"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":"codice:master","ref":"master","sha":"3a3b8d05b1cb7cc6d6c663b33275a1a4af86dc5e","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":"Distributed Data Framework - an open source, modular integration framework.","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-05-13T16:09:48Z","pushed_at":"2016-05-23T16:32:35Z","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":"http://ddf.codice.org","size":163909,"stargazers_count":37,"watchers_count":37,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":76,"mirror_url":null,"open_issues_count":25,"forks":76,"open_issues":25,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/794"},"html":{"href":"https://github.com/codice/ddf/pull/794"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/794"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/794/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/794/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/794/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/71d3b821dedfa7ea32076d07661b8917c301a038"}}}}
{"actor":{"display_login":"mcalcote"}}