From 939750cda1a1692f3b8abee843ddc724d26a575a Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Mon, 31 Mar 2014 10:09:20 -0400
Subject: [PATCH] Added add functionality for some TPS resources.

The add button in the list page for TPS profiles, connections, and
authenticators has been modified to show a blank form to add a new
entry. Once the entry is added, it will go back to the list page.

The DetailsPage has been renamed into EntryPage and modified to
support an add mode. In add mode the fields are editable. A new
AddEntryPage was added to change the behavior when closing the
page to return to the list page.

The Page container now has to be specified in the constructor. The
load() method is no longer taking any parameter. The open() has
been added to simplify loading page template and content.

The default length of the list page has been changed to 15
entries.

Fixed some bugs in ConnectionModel, AuthenticatorModel,
ConnectionDatabase, and in the HTML template.

Ticket #654
---
 base/server/share/webapps/pki/js/pki-ui.js         | 191 ++++++++++++++-------
 base/tps-tomcat/shared/webapps/tps/js/activity.js  |   5 +-
 .../shared/webapps/tps/js/authenticator.js         |  31 +++-
 base/tps-tomcat/shared/webapps/tps/js/cert.js      |   5 +-
 .../tps-tomcat/shared/webapps/tps/js/connection.js |  31 +++-
 base/tps-tomcat/shared/webapps/tps/js/group.js     |   5 +-
 base/tps-tomcat/shared/webapps/tps/js/profile.js   |  29 +++-
 base/tps-tomcat/shared/webapps/tps/js/selftest.js  |   5 +-
 base/tps-tomcat/shared/webapps/tps/js/token.js     |   5 +-
 base/tps-tomcat/shared/webapps/tps/js/user.js      |   5 +-
 .../shared/webapps/tps/ui/connection.html          |   2 +-
 base/tps-tomcat/shared/webapps/tps/ui/index.html   |  20 +--
 .../server/tps/config/ConfigDatabase.java          |   1 +
 .../server/tps/config/ConnectionDatabase.java      |   2 +-
 14 files changed, 237 insertions(+), 100 deletions(-)

diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js
index dffa7d8e14d436a5cf567ca062071ccdb8e7cc5f..949096c96076c79e856ecb6cb6b48378226f4bfc 100644
--- a/base/server/share/webapps/pki/js/pki-ui.js
+++ b/base/server/share/webapps/pki/js/pki-ui.js
@@ -131,7 +131,15 @@ var Page = Backbone.View.extend({
 
         self.url = options.url;
     },
-    load: function(container) {
+    open: function() {
+        var self = this;
+        // load template
+        self.$el.load(self.url, function(response, status, xhr) {
+            // load content
+            self.load();
+        });
+    },
+    load: function() {
     }
 });
 
@@ -140,7 +148,6 @@ var Navigation = Backbone.View.extend({
         var self = this;
         Navigation.__super__.initialize.call(self, options);
 
-        self.content = options.content;
         self.pages = options.pages;
         self.homePage = options.homePage;
 
@@ -167,14 +174,14 @@ var Navigation = Backbone.View.extend({
     },
     load: function(name) {
         var self = this;
+
         var page = self.pages[name];
         if (!page) {
             alert("Invalid page: " + name);
             return;
         }
-        self.content.load(page.url, function(response, status, xhr) {
-            page.load(self.content);
-        });
+
+        page.open();
     }
 });
 
@@ -408,7 +415,7 @@ var Table = Backbone.View.extend({
         self.tableItem = options.tableItem || TableItem;
 
         // number of table rows
-        self.pageSize = options.pageSize || 5;
+        self.pageSize = options.pageSize || 15;
 
         // current page: 1, 2, 3, ...
         self.page = 1;
@@ -818,12 +825,12 @@ var PropertiesTable = Table.extend({
     }
 });
 
-var DetailsPage = Page.extend({
+var EntryPage = Page.extend({
     initialize: function(options) {
         var self = this;
-        DetailsPage.__super__.initialize.call(self, options);
+        EntryPage.__super__.initialize.call(self, options);
         self.model = options.model;
-        self.mode = "view";
+        self.mode = options.mode || "view";
     },
     load: function() {
         var self = this;
@@ -880,8 +887,7 @@ var DetailsPage = Page.extend({
         });
 
         self.cancelButton.click(function(e) {
-            self.mode = "view";
-            self.render();
+            self.cancel();
             e.preventDefault();
         });
 
@@ -925,43 +931,73 @@ var DetailsPage = Page.extend({
     render: function() {
         var self = this;
 
+        // in add mode, render blank form
+        if (self.mode == "add") {
+            self.attributes = {};
+            self.propertiesTable.properties = [];
+            self.renderContent();
+            return;
+        }
+
+        // in view and edit modes, fetch entry then render the content
         self.model.fetch({
             success: function(model, response, options) {
-
                 self.attributes = _.clone(self.model.attributes);
                 self.propertiesTable.properties = self.attributes.properties;
-
-                self.$("span[name='id']").text(self.model.id);
-
-                var status = self.model.get("status");
-                if (status == "Disabled") {
-                    self.enableLink.show();
-                    self.disableLink.hide();
-                } else if (status == "Enabled") {
-                    self.enableLink.hide();
-                    self.disableLink.show();
-                }
-
-                if (self.mode == "view") {
-                    self.menu.show();
-                    self.buttons.hide();
-                    self.propertiesButtons.hide();
-
-                } else {
-                    self.menu.hide();
-                    self.buttons.show();
-                    self.propertiesButtons.show();
-                }
-
-                self.$(".pki-fields input").each(function(index) {
-                    var input = $(this);
-                    self.renderField(input);
-                });
-
-                self.propertiesTable.render();
+                self.renderContent();
             }
         });
     },
+    renderContent: function() {
+        var self = this;
+
+        if (self.mode == "add") {
+            // In add mode all fields are editable.
+            self.$(".pki-fields input").each(function(index) {
+                var input = $(this);
+                input.removeAttr("readonly");
+            });
+
+        } else {
+            // In view and edit modes show entry ID in the title.
+            self.$("span[name='id']").text(self.attributes.id);
+
+            // In view mode all fields are read-only. In edit mode
+            // currently all fields are read-only too, but it might
+            // need to be changed later to suppot editable fields.
+            self.$(".pki-fields input").each(function(index) {
+                var input = $(this);
+                input.attr("readonly", "readonly");
+            });
+        }
+
+        var status = self.attributes.status;
+        if (status == "Disabled") {
+            self.enableLink.show();
+            self.disableLink.hide();
+        } else if (status == "Enabled") {
+            self.enableLink.hide();
+            self.disableLink.show();
+        }
+
+        if (self.mode == "view") {
+            self.menu.show();
+            self.buttons.hide();
+            self.propertiesButtons.hide();
+
+        } else {
+            self.menu.hide();
+            self.buttons.show();
+            self.propertiesButtons.show();
+        }
+
+        self.$(".pki-fields input").each(function(index) {
+            var input = $(this);
+            self.renderField(input);
+        });
+
+        self.propertiesTable.render();
+    },
     renderField: function(input) {
         var self = this;
         var name = input.attr("name");
@@ -969,6 +1005,15 @@ var DetailsPage = Page.extend({
         if (!value) value = "";
         input.val(value);
     },
+    close: function() {
+        var self = this;
+        self.mode = "view";
+        self.render();
+    },
+    cancel: function() {
+        var self = this;
+        self.close();
+    },
     save: function() {
         var self = this;
 
@@ -985,25 +1030,38 @@ var DetailsPage = Page.extend({
 
         attributes.properties = self.propertiesTable.properties;
 
-        // save changed attributes with PATCH
-        self.model.save(attributes, {
-            patch: true,
-            wait: true,
-            success: function(model, response, options) {
-                // redraw table after saving entries
-                self.mode = "view";
-                self.render();
-            },
-            error: function(model, response, options) {
-                if (response.status == 200) {
-                    // redraw table after saving entries
-                    self.mode = "view";
-                    self.render();
-                    return;
+        if (self.mode == "add") {
+            // save new entry with POST
+            self.model.save(attributes, {
+                wait: true,
+                success: function(model, response, options) {
+                    self.close();
+                },
+                error: function(model, response, options) {
+                    if (response.status == 201) {
+                        self.close();
+                        return;
+                    }
+                    alert("ERROR: " + response.responseText);
                 }
-                alert("ERROR: " + response.responseText);
-            }
-        });
+            });
+        } else {
+            // save changed attributes with PATCH
+            self.model.save(attributes, {
+                patch: true,
+                wait: true,
+                success: function(model, response, options) {
+                    self.close();
+                },
+                error: function(model, response, options) {
+                    if (response.status == 200) {
+                        self.close();
+                        return;
+                    }
+                    alert("ERROR: " + response.responseText);
+                }
+            });
+        }
     },
     saveField: function(input) {
         var self = this;
@@ -1011,3 +1069,18 @@ var DetailsPage = Page.extend({
         self.attributes[name] = input.val();
     }
 });
+
+var AddEntryPage = EntryPage.extend({
+    initialize: function(options) {
+        var self = this;
+        options.mode = "add";
+        AddEntryPage.__super__.initialize.call(self, options);
+        self.parentPage = options.parentPage;
+    },
+    close: function() {
+        var self = this;
+        self.parentPage.$el.load(self.parentPage.url, function(response, status, xhr) {
+            self.parentPage.load();
+        });
+    }
+});;
\ No newline at end of file
diff --git a/base/tps-tomcat/shared/webapps/tps/js/activity.js b/base/tps-tomcat/shared/webapps/tps/js/activity.js
index a2d45147678f643c7e6c4c577e7cda5516c7779d..66e54b3ce6f23adc69f62598cac2982a62ffe4fe 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/activity.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/activity.js
@@ -67,7 +67,9 @@ var ActivityCollection = Collection.extend({
 });
 
 var ActivityPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var editDialog = new Dialog({
             el: $("#activity-dialog"),
             title: "Edit Activity",
@@ -80,6 +82,7 @@ var ActivityPage = Page.extend({
             collection: new ActivityCollection(),
             editDialog: editDialog
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/authenticator.js b/base/tps-tomcat/shared/webapps/tps/js/authenticator.js
index 9c632e160b0e3bb182ef06d1b9a96ac20ff7a8a3..64da4b93809f331b79d3b1fd6eb092d4b75f3989 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/authenticator.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/authenticator.js
@@ -31,7 +31,7 @@ var AuthenticatorModel = Model.extend({
     },
     createRequest: function(attributes) {
         return {
-            id: attributes.profileID,
+            id: attributes.authenticatorID,
             Status: attributes.status,
             Properties: {
                 Property: attributes.properties
@@ -86,29 +86,44 @@ var AuthenticatorsTable = Table.extend({
     initialize: function(options) {
         var self = this;
         AuthenticatorsTable.__super__.initialize.call(self, options);
-        self.container = options.container;
+        self.parentPage = options.parentPage;
     },
     open: function(item) {
         var self = this;
 
-        var page = new DetailsPage({
-            el: self.container,
+        var page = new EntryPage({
+            el: self.parentPage.$el,
+            url: "authenticator.html",
             model: item.model
         });
 
-        self.container.load("authenticator.html", function(response, status, xhr) {
-            page.load();
+        page.open();
+    },
+    add: function() {
+        var self = this;
+
+        var page = new AddEntryPage({
+            el: self.parentPage.$el,
+            url: "authenticator.html",
+            model: new AuthenticatorModel(),
+            mode: "add",
+            parentPage: self.parentPage
         });
+
+        page.open();
     }
 });
 
 var AuthenticatorsPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var table = new AuthenticatorsTable({
             el: $("table[name='authenticators']"),
             collection: new AuthenticatorCollection(),
-            container: container
+            parentPage: self
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/cert.js b/base/tps-tomcat/shared/webapps/tps/js/cert.js
index 51fa8b8ac807ef95a2f0ce7e7e32b412b0753878..e1f8d53df6887188f73f2964893c42b34b3a4bfc 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/cert.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/cert.js
@@ -73,7 +73,9 @@ var CertificateCollection = Collection.extend({
 });
 
 var CertificatePage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var editDialog = new Dialog({
             el: $("#certificate-dialog"),
             title: "Edit Certificate",
@@ -86,6 +88,7 @@ var CertificatePage = Page.extend({
             collection: new CertificateCollection(),
             editDialog: editDialog
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/connection.js b/base/tps-tomcat/shared/webapps/tps/js/connection.js
index 36b17bc27e8092aca2726d271c576fba37d646f7..83bd694a6980e39f3646cc83acf54038daf5b683 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/connection.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/connection.js
@@ -31,7 +31,7 @@ var ConnectionModel = Model.extend({
     },
     createRequest: function(attributes) {
         return {
-            id: attributes.profileID,
+            id: attributes.connectionID,
             Status: attributes.status,
             Properties: {
                 Property: attributes.properties
@@ -86,29 +86,44 @@ var ConnectionsTable = Table.extend({
     initialize: function(options) {
         var self = this;
         ConnectionsTable.__super__.initialize.call(self, options);
-        self.container = options.container;
+        self.parentPage = options.parentPage;
     },
     open: function(item) {
         var self = this;
 
-        var page = new DetailsPage({
-            el: self.container,
+        var page = new EntryPage({
+            el: self.parentPage.$el,
+            url: "connection.html",
             model: item.model
         });
 
-        self.container.load("connection.html", function(response, status, xhr) {
-            page.load();
+        page.open();
+    },
+    add: function() {
+        var self = this;
+
+        var page = new AddEntryPage({
+            el: self.parentPage.$el,
+            url: "connection.html",
+            model: new ConnectionModel(),
+            mode: "add",
+            parentPage: self.parentPage
         });
+
+        page.open();
     }
 });
 
 var ConnectionsPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var table = new ConnectionsTable({
             el: $("table[name='connections']"),
             collection: new ConnectionCollection(),
-            container: container
+            parentPage: self
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/group.js b/base/tps-tomcat/shared/webapps/tps/js/group.js
index 101545454d8d1f26c3f9d8d9dbd975e16000c129..95056860b0da8895148b585480692715f422149c 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/group.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/group.js
@@ -56,7 +56,9 @@ var GroupCollection = Collection.extend({
 });
 
 var GroupPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var addDialog = new Dialog({
             el: $("#group-dialog"),
             title: "Add Group",
@@ -76,6 +78,7 @@ var GroupPage = Page.extend({
             addDialog: addDialog,
             editDialog: editDialog
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/profile.js b/base/tps-tomcat/shared/webapps/tps/js/profile.js
index caaa08ec645df14e730384c0be5adacbfa369123..719a7148828fef50d397f152a8ba410d5b01bbd3 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/profile.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/profile.js
@@ -86,29 +86,44 @@ var ProfilesTable = Table.extend({
     initialize: function(options) {
         var self = this;
         ProfilesTable.__super__.initialize.call(self, options);
-        self.container = options.container;
+        self.parentPage = options.parentPage;
     },
     open: function(item) {
         var self = this;
 
-        var page = new DetailsPage({
-            el: self.container,
+        var page = new EntryPage({
+            el: self.parentPage.$el,
+            url: "profile.html",
             model: item.model
         });
 
-        self.container.load("profile.html", function(response, status, xhr) {
-            page.load();
+        page.open();
+    },
+    add: function() {
+        var self = this;
+
+        var page = new AddEntryPage({
+            el: self.parentPage.$el,
+            url: "profile.html",
+            model: new ProfileModel(),
+            mode: "add",
+            parentPage: self.parentPage
         });
+
+        page.open();
     }
 });
 
 var ProfilesPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var table = new ProfilesTable({
             el: $("table[name='profiles']"),
             collection: new ProfileCollection(),
-            container: container
+            parentPage: self
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/selftest.js b/base/tps-tomcat/shared/webapps/tps/js/selftest.js
index 7ee988d63329401d2d6bbd95ebe6bf5ec2cb53f7..39c0ceb37c737bd22d1890ad5960d5c898a90b86 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/selftest.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/selftest.js
@@ -61,7 +61,9 @@ var SelfTestCollection = Collection.extend({
 });
 
 var SelfTestPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var editDialog = new Dialog({
             el: $("#selftest-dialog"),
             title: "Edit Self Test",
@@ -73,6 +75,7 @@ var SelfTestPage = Page.extend({
             collection: new SelfTestCollection(),
             editDialog: editDialog
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/token.js b/base/tps-tomcat/shared/webapps/tps/js/token.js
index 6f0750ee513627e8e428380e9fa410ad795bdaf7..9da95e622f5a92d96b4a8fbb140eb421759920c7 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/token.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/token.js
@@ -74,7 +74,9 @@ var TokenCollection = Collection.extend({
 });
 
 var TokenPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var addDialog = new Dialog({
             el: $("#token-dialog"),
             title: "Add Token",
@@ -97,6 +99,7 @@ var TokenPage = Page.extend({
             addDialog: addDialog,
             editDialog: editDialog
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/js/user.js b/base/tps-tomcat/shared/webapps/tps/js/user.js
index 8e3a8fe540796aa71ae96480463ff17abfc99f14..6be78fbabb14ff036bd9c068872e151e0ef8320c 100644
--- a/base/tps-tomcat/shared/webapps/tps/js/user.js
+++ b/base/tps-tomcat/shared/webapps/tps/js/user.js
@@ -121,7 +121,9 @@ var UserDialog = Dialog.extend({
 });
 
 var UserPage = Page.extend({
-    load: function(container) {
+    load: function() {
+        var self = this;
+
         var addDialog = new UserDialog({
             el: $("#user-dialog"),
             title: "Add User",
@@ -142,6 +144,7 @@ var UserPage = Page.extend({
             addDialog: addDialog,
             editDialog: editDialog
         });
+
         table.render();
     }
 });
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/connection.html b/base/tps-tomcat/shared/webapps/tps/ui/connection.html
index 61cd4b9edec820ca624c7f82663569395f20f5db..055ef21a22360f25c4f67fcf08bded90d160448f 100644
--- a/base/tps-tomcat/shared/webapps/tps/ui/connection.html
+++ b/base/tps-tomcat/shared/webapps/tps/ui/connection.html
@@ -38,7 +38,7 @@
 <div name="connection" class="pki-fields">
 <fieldset>
     <label>Connection ID</label>
-    <input name="id" readonly="readonly">
+    <input name="connectionID" readonly="readonly">
     <br>
     <label>Status</label>
     <input name="status" readonly="readonly">
diff --git a/base/tps-tomcat/shared/webapps/tps/ui/index.html b/base/tps-tomcat/shared/webapps/tps/ui/index.html
index 4f75c4da443b2814b98b90b6d386b53509393f10..31f4ecacc366b7253efefd912a5d755e76cb2182 100644
--- a/base/tps-tomcat/shared/webapps/tps/ui/index.html
+++ b/base/tps-tomcat/shared/webapps/tps/ui/index.html
@@ -37,20 +37,20 @@
     <script src="/tps/js/user.js"></script>
     <script>
 $(function() {
+    var content = $("#content");
     var account = new Account();
     new Navigation({
         el: $("#navigation"),
-        content: $("#content"),
         pages: {
-            activities: new ActivityPage({ url: "activities.html" }),
-            authenticators: new AuthenticatorsPage({ url: "authenticators.html" }),
-            certs: new CertificatePage({ url: "certs.html" }),
-            connections: new ConnectionsPage({ url: "connections.html" }),
-            groups: new GroupPage({ url: "groups.html" }),
-            profiles: new ProfilesPage({ url: "profiles.html" }),
-            selftests: new SelfTestPage({ url: "selftests.html" }),
-            tokens: new TokenPage({ url: "tokens.html" }),
-            users: new UserPage({ url: "users.html" })
+            activities: new ActivityPage({ el: content, url: "activities.html" }),
+            authenticators: new AuthenticatorsPage({ el: content, url: "authenticators.html" }),
+            certs: new CertificatePage({ el: content, url: "certs.html" }),
+            connections: new ConnectionsPage({ el: content, url: "connections.html" }),
+            groups: new GroupPage({ el: content, url: "groups.html" }),
+            profiles: new ProfilesPage({ el: content, url: "profiles.html" }),
+            selftests: new SelfTestPage({ el: content, url: "selftests.html" }),
+            tokens: new TokenPage({ el: content, url: "tokens.html" }),
+            users: new UserPage({ el: content, url: "users.html" })
         },
         logout: function() {
             account.logout({
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConfigDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConfigDatabase.java
index cded13af57959829ba8c4382802a207e63e01954..8cb874f3dd6f1e5fdddbcf12b16c7448fcef6d1d 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConfigDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConfigDatabase.java
@@ -156,6 +156,7 @@ public class ConfigDatabase extends Database<ConfigRecord> {
         String filter = createFilter(record, key);
         for (String name : properties.keySet()) {
             if (name.matches(filter)) continue;
+            CMS.debug("Property " + name + " doesn't match filter " + filter + ".");
             throw new BadRequestException("Invalid property: " + name);
         }
     }
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
index 9755db85b773ccd86fa256fb36a1dff4cc4aab2a..4e541ed87ec5abed55daf53fb33ccca37a471c45 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
@@ -57,7 +57,7 @@ public class ConnectionDatabase extends CSCfgDatabase<ConnectionRecord> {
 
         Collection<ConnectionRecord> result = new ArrayList<ConnectionRecord>();
         ConfigDatabase configDatabase = new ConfigDatabase();
-        ConfigRecord configRecord = configDatabase.getRecord("Subsystem_Connections");
+        ConfigRecord configRecord = configDatabase.getRecord(substoreName);
 
         for (String connectionID : configRecord.getKeys()) {
             if (filter != null && !connectionID.contains(filter)) continue;
-- 
1.8.4.2

