{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/66612640","id":66612640,"diff_hunk":"@@ -0,0 +1,265 @@\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.publication.action.provider;\n+\n+import java.io.IOException;\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.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Objects;\n+import java.util.concurrent.ConcurrentHashMap;\n+import java.util.stream.Collectors;\n+\n+import org.apache.commons.collections.CollectionUtils;\n+import org.apache.commons.lang3.StringUtils;\n+import org.codice.ddf.configuration.SystemBaseUrl;\n+import org.codice.ddf.registry.api.RegistryStore;\n+import org.codice.ddf.registry.common.RegistryConstants;\n+import org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType;\n+import org.codice.ddf.registry.federationadmin.service.FederationAdminException;\n+import org.codice.ddf.registry.federationadmin.service.FederationAdminService;\n+import org.osgi.framework.InvalidSyntaxException;\n+import org.osgi.service.cm.Configuration;\n+import org.osgi.service.cm.ConfigurationAdmin;\n+import org.osgi.service.event.Event;\n+import org.osgi.service.event.EventHandler;\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.Attribute;\n+import ddf.catalog.data.Metacard;\n+import ddf.catalog.source.Source;\n+\n+public class RegistryPublicationActionProvider implements ActionProvider, EventHandler {\n+\n+    private static final Logger LOGGER =\n+            LoggerFactory.getLogger(RegistryPublicationActionProvider.class);\n+\n+    private static final String REGISTRY_PATH = \"/registries\";\n+\n+    private static final String PUBLICATION_PATH = \"publication\";\n+\n+    private static final String PUBLISH_DESCRIPTION = \"Publishes this nodes information to \";\n+\n+    private static final String PUBLISH_OPERATION = \"publish\";\n+\n+    private static final String PUBLISH_TITLE = \"Publish to \";\n+\n+    private static final String UNPUBLISH_DESCRIPTION = \"Unpublishes this nodes information from \";\n+\n+    private static final String UNPUBLISH_OPERATION = \"unpublish\";\n+\n+    private static final String UNPUBLISH_TITLE = \"Unpublish from \";\n+\n+    private static final String HTTP_POST = \"HTTP_POST\";\n+\n+    private static final String HTTP_DELETE = \"HTTP_DELETE\";\n+\n+    private static final String METACARD_PROPERTY = \"ddf.catalog.event.metacard\";\n+\n+    private static final String CREATED_TOPIC = \"ddf/catalog/event/CREATED\";\n+\n+    private static final String UPDATED_TOPIC = \"ddf/catalog/event/UPDATED\";\n+\n+    private static final String DELETED_TOPIC = \"ddf/catalog/event/DELETED\";\n+\n+    private String providerId;\n+\n+    private ConfigurationAdmin configAdmin;\n+\n+    private FederationAdminService federationAdminService;\n+\n+    private List<RegistryStore> registryStores;\n+\n+    private Map<String, List<String>> publications = new ConcurrentHashMap<>();\n+\n+    @Override\n+    public <T> List<Action> getActions(T subject) {\n+        String registryId = getRegistryId(subject);\n+        if (registryId == null) {\n+            return Collections.emptyList();\n+        }\n+        List<Action> actions = new ArrayList<>();\n+        List<String> currentPublications = publications.get(registryId);\n+\n+        for (RegistryStore registry : registryStores) {\n+            //can't publish to yourself\n+            if (!registry.isPushAllowed() || StringUtils.isBlank(registry.getRegistryId())\n+                    || registryId.equals(registry.getRegistryId())) {\n+                continue;\n+            }\n+\n+            if (currentPublications.contains(registry.getId())) {\n+                CollectionUtils.addIgnoreNull(actions,\n+                        getAction(registryId, registry.getId(), false));\n+            } else {\n+                CollectionUtils.addIgnoreNull(actions,\n+                        getAction(registryId, registry.getId(), true));\n+            }","path":"catalog/spatial/registry/registry-publication-action-provider/src/main/java/org/codice/ddf/registry/publication/action/provider/RegistryPublicationActionProvider.java","position":120,"original_position":120,"commit_id":"480cc21e0c66f6e3df7020bb405b77c06ae3ea02","original_commit_id":"480cc21e0c66f6e3df7020bb405b77c06ae3ea02","user":{"login":"gordocanchola","id":14877145,"avatar_url":"https://avatars.githubusercontent.com/u/14877145?v=3","gravatar_id":"","url":"https://api.github.com/users/gordocanchola","html_url":"https://github.com/gordocanchola","followers_url":"https://api.github.com/users/gordocanchola/followers","following_url":"https://api.github.com/users/gordocanchola/following{/other_user}","gists_url":"https://api.github.com/users/gordocanchola/gists{/gist_id}","starred_url":"https://api.github.com/users/gordocanchola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordocanchola/subscriptions","organizations_url":"https://api.github.com/users/gordocanchola/orgs","repos_url":"https://api.github.com/users/gordocanchola/repos","events_url":"https://api.github.com/users/gordocanchola/events{/privacy}","received_events_url":"https://api.github.com/users/gordocanchola/received_events","type":"User","site_admin":false},"body":"Cool. Changed it to one line.","created_at":"2016-06-10T13:30:41Z","updated_at":"2016-06-10T13:30:41Z","html_url":"https://github.com/codice/ddf/pull/850#discussion_r66612640","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/850","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/66612640"},"html":{"href":"https://github.com/codice/ddf/pull/850#discussion_r66612640"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/850"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/850","id":73267558,"html_url":"https://github.com/codice/ddf/pull/850","diff_url":"https://github.com/codice/ddf/pull/850.diff","patch_url":"https://github.com/codice/ddf/pull/850.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/850","number":850,"state":"open","locked":false,"title":"DDF-2165 Create registry action provider for publishing/unpublishing","user":{"login":"gordocanchola","id":14877145,"avatar_url":"https://avatars.githubusercontent.com/u/14877145?v=3","gravatar_id":"","url":"https://api.github.com/users/gordocanchola","html_url":"https://github.com/gordocanchola","followers_url":"https://api.github.com/users/gordocanchola/followers","following_url":"https://api.github.com/users/gordocanchola/following{/other_user}","gists_url":"https://api.github.com/users/gordocanchola/gists{/gist_id}","starred_url":"https://api.github.com/users/gordocanchola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordocanchola/subscriptions","organizations_url":"https://api.github.com/users/gordocanchola/orgs","repos_url":"https://api.github.com/users/gordocanchola/repos","events_url":"https://api.github.com/users/gordocanchola/events{/privacy}","received_events_url":"https://api.github.com/users/gordocanchola/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n  A new action provider is being added that returns a RESTful endpoint used for publishing/unpublishing a registry node.\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@ryeats @lessarderic \r\n#### Choose 2 committers to review/merge the PR (please choose ONLY two committers from below, delete the rest).\r\n@figliold\r\n@shaundmorris \r\n#### How should this be tested?\r\nVerify the build\r\n#### Any background context you want to provide?\r\n#### What are the relevant tickets?\r\nDDF-2165\r\n#### Screenshots (if appropriate)\r\n#### Checklist:\r\n- [ ] Documentation Updated\r\n- [X] Update / Add Unit Tests\r\n- [ ] Update / Add Integration Tests\r\n\r\nAdding RegistryPublicationActionProvider\r\n  Provides the action(RESTful endpoint) to publish/unpublish a registry entry to an external source","created_at":"2016-06-09T19:00:12Z","updated_at":"2016-06-10T13:30:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"710d0766786c6bb7ae666913a9f8b38000fc6858","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/850/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/850/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/850/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/480cc21e0c66f6e3df7020bb405b77c06ae3ea02","head":{"label":"gordocanchola:DDF-2165","ref":"DDF-2165","sha":"480cc21e0c66f6e3df7020bb405b77c06ae3ea02","user":{"login":"gordocanchola","id":14877145,"avatar_url":"https://avatars.githubusercontent.com/u/14877145?v=3","gravatar_id":"","url":"https://api.github.com/users/gordocanchola","html_url":"https://github.com/gordocanchola","followers_url":"https://api.github.com/users/gordocanchola/followers","following_url":"https://api.github.com/users/gordocanchola/following{/other_user}","gists_url":"https://api.github.com/users/gordocanchola/gists{/gist_id}","starred_url":"https://api.github.com/users/gordocanchola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordocanchola/subscriptions","organizations_url":"https://api.github.com/users/gordocanchola/orgs","repos_url":"https://api.github.com/users/gordocanchola/repos","events_url":"https://api.github.com/users/gordocanchola/events{/privacy}","received_events_url":"https://api.github.com/users/gordocanchola/received_events","type":"User","site_admin":false},"repo":{"id":43379971,"name":"ddf","full_name":"gordocanchola/ddf","owner":{"login":"gordocanchola","id":14877145,"avatar_url":"https://avatars.githubusercontent.com/u/14877145?v=3","gravatar_id":"","url":"https://api.github.com/users/gordocanchola","html_url":"https://github.com/gordocanchola","followers_url":"https://api.github.com/users/gordocanchola/followers","following_url":"https://api.github.com/users/gordocanchola/following{/other_user}","gists_url":"https://api.github.com/users/gordocanchola/gists{/gist_id}","starred_url":"https://api.github.com/users/gordocanchola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gordocanchola/subscriptions","organizations_url":"https://api.github.com/users/gordocanchola/orgs","repos_url":"https://api.github.com/users/gordocanchola/repos","events_url":"https://api.github.com/users/gordocanchola/events{/privacy}","received_events_url":"https://api.github.com/users/gordocanchola/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gordocanchola/ddf","description":"The Distributed Data Framework - Distribution, SDK, and Test","fork":true,"url":"https://api.github.com/repos/gordocanchola/ddf","forks_url":"https://api.github.com/repos/gordocanchola/ddf/forks","keys_url":"https://api.github.com/repos/gordocanchola/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gordocanchola/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gordocanchola/ddf/teams","hooks_url":"https://api.github.com/repos/gordocanchola/ddf/hooks","issue_events_url":"https://api.github.com/repos/gordocanchola/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/gordocanchola/ddf/events","assignees_url":"https://api.github.com/repos/gordocanchola/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/gordocanchola/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/gordocanchola/ddf/tags","blobs_url":"https://api.github.com/repos/gordocanchola/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gordocanchola/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gordocanchola/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/gordocanchola/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gordocanchola/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/gordocanchola/ddf/languages","stargazers_url":"https://api.github.com/repos/gordocanchola/ddf/stargazers","contributors_url":"https://api.github.com/repos/gordocanchola/ddf/contributors","subscribers_url":"https://api.github.com/repos/gordocanchola/ddf/subscribers","subscription_url":"https://api.github.com/repos/gordocanchola/ddf/subscription","commits_url":"https://api.github.com/repos/gordocanchola/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/gordocanchola/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/gordocanchola/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/gordocanchola/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/gordocanchola/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/gordocanchola/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gordocanchola/ddf/merges","archive_url":"https://api.github.com/repos/gordocanchola/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gordocanchola/ddf/downloads","issues_url":"https://api.github.com/repos/gordocanchola/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/gordocanchola/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/gordocanchola/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/gordocanchola/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gordocanchola/ddf/labels{/name}","releases_url":"https://api.github.com/repos/gordocanchola/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/gordocanchola/ddf/deployments","created_at":"2015-09-29T16:34:02Z","updated_at":"2016-04-13T22:04:54Z","pushed_at":"2016-06-09T21:36:28Z","git_url":"git://github.com/gordocanchola/ddf.git","ssh_url":"git@github.com:gordocanchola/ddf.git","clone_url":"https://github.com/gordocanchola/ddf.git","svn_url":"https://github.com/gordocanchola/ddf","homepage":"","size":143919,"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":"9b3913ac45770c3c12327cf93d473890237201d6","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-06-09T11:41:29Z","pushed_at":"2016-06-10T04:51:54Z","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":271291,"stargazers_count":38,"watchers_count":38,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":81,"mirror_url":null,"open_issues_count":24,"forks":81,"open_issues":24,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/850"},"html":{"href":"https://github.com/codice/ddf/pull/850"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/850"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/850/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/850/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/850/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/480cc21e0c66f6e3df7020bb405b77c06ae3ea02"}}}}
{"actor":{"display_login":"gordocanchola"}}