{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/68348028","id":68348028,"diff_hunk":"@@ -0,0 +1,146 @@\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.api.impl;\n+\n+import java.util.Optional;\n+import java.util.concurrent.ConcurrentHashMap;\n+\n+import org.codice.ddf.registry.api.RegistryStore;\n+import org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType;\n+import org.codice.ddf.registry.federationadmin.service.FederationAdminService;\n+import org.codice.ddf.registry.federationadmin.service.RegistryPublicationService;\n+import org.codice.ddf.security.common.Security;\n+import org.osgi.framework.Bundle;\n+import org.osgi.framework.BundleContext;\n+import org.osgi.framework.Constants;\n+import org.osgi.framework.FrameworkUtil;\n+import org.osgi.framework.ServiceEvent;\n+import org.osgi.framework.ServiceReference;\n+import org.osgi.service.event.Event;\n+import org.osgi.service.event.EventConstants;\n+import org.osgi.service.event.EventHandler;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import ddf.catalog.data.Metacard;\n+import ddf.catalog.source.SourceMonitor;\n+\n+public class RegistryStoreAutoPublisher implements EventHandler {\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(RegistryStoreAutoPublisher.class);\n+\n+    private FederationAdminService federationAdminService;\n+\n+    private RegistryPublicationService registryPublicationService;\n+\n+    private ConcurrentHashMap<String, Boolean> registryStoreMap = new ConcurrentHashMap<>();\n+\n+    public void setFederationAdminService(FederationAdminService federationAdminService) {\n+        this.federationAdminService = federationAdminService;\n+    }\n+\n+    public void setRegistryPublicationService(\n+            RegistryPublicationService registryPublicationService) {\n+        this.registryPublicationService = registryPublicationService;\n+    }\n+\n+    public void bindRegistryStore(ServiceReference reference) {\n+\n+        BundleContext bundleContext = getBundleContext();\n+\n+        if (reference != null && bundleContext != null) {\n+            RegistryStore registryStore = (RegistryStore) bundleContext.getService(reference);\n+\n+            Boolean previousState = registryStoreMap.put(registryStore.getConfigurationPid(), registryStore.isAutoPush());\n+\n+            SourceMonitor storeRegisteredSourceMonitor = new SourceMonitor() {\n+                @Override\n+                public void setAvailable() {\n+                    if (registryStore.isAutoPush()) {\n+                        registryPublish(registryStore);\n+                    }\n+                }\n+\n+                @Override\n+                public void setUnavailable() {\n+                }\n+            };\n+\n+            if (registryStore.isAvailable(storeRegisteredSourceMonitor) && registryStore.isAutoPush()) {\n+                if(previousState == null || !previousState) {\n+                    registryPublish(registryStore);\n+                }\n+            }\n+        }\n+    }\n+\n+    void registryPublish(RegistryStore registryStore) {\n+\n+        if (!registryStore.getRegistryId()\n+                .isEmpty()) {\n+            try {\n+\n+                Optional<Metacard> registryIdentityMetacardOpt =\n+                        Security.runAsAdminWithException(() -> federationAdminService.getLocalRegistryIdentityMetacard());\n+\n+                if (registryIdentityMetacardOpt.isPresent()) {\n+                    Metacard registryIdentityMetacard = registryIdentityMetacardOpt.get();\n+                    String localRegistryId = registryIdentityMetacard.getAttribute(\n+                            RegistryObjectMetacardType.REGISTRY_ID)\n+                            .getValue()\n+                            .toString();\n+                    Security.runAsAdminWithException(() -> {\n+                        registryPublicationService.publish(localRegistryId,\n+                                registryStore.getRegistryId());\n+                        return null;\n+                    });\n+                }\n+            } catch (Exception e) {\n+                LOGGER.error(\"Failed to auto-push registry configuration from {}, {}\",\n+                        registryStore.getRegistryId(),\n+                        e);","path":"catalog/spatial/registry/registry-api-impl/src/main/java/org/codice/ddf/registry/api/impl/RegistryStoreAutoPublisher.java","position":112,"original_position":112,"commit_id":"0d061ca024793b9c54e22424958c1d45cef1ca2e","original_commit_id":"0d061ca024793b9c54e22424958c1d45cef1ca2e","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":"Removed","created_at":"2016-06-24T02:58:23Z","updated_at":"2016-06-24T02:58:23Z","html_url":"https://github.com/codice/ddf/pull/897#discussion_r68348028","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/897","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/68348028"},"html":{"href":"https://github.com/codice/ddf/pull/897#discussion_r68348028"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/897"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/897","id":75012915,"html_url":"https://github.com/codice/ddf/pull/897","diff_url":"https://github.com/codice/ddf/pull/897.diff","patch_url":"https://github.com/codice/ddf/pull/897.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/897","number":897,"state":"open","locked":false,"title":"DDF-2177 Add Auto Push configuration property to the registry store","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\nAdd an Auto-Publish(Auto Push) Configuration property to the RegistryStore. This configuration is accessible in the add/edit modal on the remote registries tab in the registry app ui.\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@gordocanchola @vinamartin @ani6gup @clockard \r\n\r\n#### Choose 2 committers to review/merge the PR (please choose ONLY two committers from below, delete the rest).\r\n@coyotesqrl @figliold \r\n\r\n#### How should this be tested?\r\nInstall registry app (with security) and connect to a second registry by adding it in the remote registries tab of the registry app with Auto-Push on. Observe presence of registry identity metacard when querying metacards in the second DDF's solr once the remote becomes 'available' on the first registry. \r\n\r\n#### Any background context you want to provide?\r\nMinor UI updates are in this PR fixing the remote name as well as adding the autoPush to the registry model/modal. \r\n\r\n#### What are the relevant tickets?\r\nDDF-2177 Add a configuration property to the registry store, 'Auto push identity node', which is disabled by default\t\r\n\r\nIf the auto publish is enabled and push is enabled then the registry store will publish the local identity node to the remote registry when the it becomes available.\r\n\r\n#### Screenshots (if appropriate)\r\n![screen shot 2016-06-23 at 3 29 34 pm](https://cloud.githubusercontent.com/assets/11355332/16322345/5730eb1e-3957-11e6-9869-a96af2201aba.png)\r\n\r\n#### Checklist:\r\n- [ ] Documentation Updated\r\n- [x] Update / Add Unit Tests\r\n- [ ] Update / Add Integration Tests\r\n\r\n","created_at":"2016-06-23T19:28:56Z","updated_at":"2016-06-24T02:58:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0dbc286c042da3f88ccd7aca9ad905542471dcd","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/codice/ddf/pulls/897/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/897/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/897/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/0d061ca024793b9c54e22424958c1d45cef1ca2e","head":{"label":"mcalcote:DDF-2177","ref":"DDF-2177","sha":"0d061ca024793b9c54e22424958c1d45cef1ca2e","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-06-23T22:16:44Z","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":146458,"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":"0cc69646c2e8fa0bb3e8ca029259bd6b9a6e3a3d","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-14T21:40:37Z","pushed_at":"2016-06-24T02:16:56Z","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":272080,"stargazers_count":39,"watchers_count":39,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":81,"mirror_url":null,"open_issues_count":25,"forks":81,"open_issues":25,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/897"},"html":{"href":"https://github.com/codice/ddf/pull/897"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/897"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/897/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/897/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/897/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/0d061ca024793b9c54e22424958c1d45cef1ca2e"}}}}
{"actor":{"display_login":"mcalcote"}}