From 02e2b43e68b8332cec539d31ea5b5f239a901c02 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Mon, 5 May 2014 22:01:40 -0400
Subject: [PATCH] Renamed TPS connection to TPS connector (part 5).

The TPS connection database has been renamed into TPS connector.

Ticket #977
---
 .../src/org/dogtagpki/server/tps/TPSSubsystem.java | 10 +--
 ...nectionDatabase.java => ConnectorDatabase.java} | 86 +++++++++++-----------
 ...{ConnectionRecord.java => ConnectorRecord.java} |  2 +-
 .../server/tps/installer/TPSInstaller.java         | 12 +--
 .../server/tps/rest/ConnectorService.java          | 30 ++++----
 5 files changed, 70 insertions(+), 70 deletions(-)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/config/{ConnectionDatabase.java => ConnectorDatabase.java} (70%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/config/{ConnectionRecord.java => ConnectorRecord.java} (94%)

diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
index 10920ed9e77f264020811ecb326cd010f342038b..1d5c9d2b9c9d7a0fe01646e7792fff061b7df2d7 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
@@ -19,7 +19,7 @@ package org.dogtagpki.server.tps;
 
 import org.dogtagpki.server.tps.cms.ConnectionManager;
 import org.dogtagpki.server.tps.config.ConfigDatabase;
-import org.dogtagpki.server.tps.config.ConnectionDatabase;
+import org.dogtagpki.server.tps.config.ConnectorDatabase;
 import org.dogtagpki.server.tps.config.ProfileDatabase;
 import org.dogtagpki.server.tps.config.ProfileMappingDatabase;
 import org.dogtagpki.server.tps.dbs.ActivityDatabase;
@@ -61,7 +61,7 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
     public AuthenticatorDatabase authenticatorDatabase;
     public TPSCertDatabase certDatabase;
     public ConfigDatabase configDatabase;
-    public ConnectionDatabase connectionDatabase;
+    public ConnectorDatabase connectorDatabase;
     public ProfileDatabase profileDatabase;
     public ProfileMappingDatabase profileMappingDatabase;
     public TokenDatabase tokenDatabase;
@@ -97,7 +97,7 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
 
         configDatabase = new ConfigDatabase();
         authenticatorDatabase = new AuthenticatorDatabase();
-        connectionDatabase = new ConnectionDatabase();
+        connectorDatabase = new ConnectorDatabase();
         profileDatabase = new ProfileDatabase();
         profileMappingDatabase = new ProfileMappingDatabase();
         engine = new TPSEngine();
@@ -169,8 +169,8 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
         return configDatabase;
     }
 
-    public ConnectionDatabase getConnectionDatabase() {
-        return connectionDatabase;
+    public ConnectorDatabase getConnectorDatabase() {
+        return connectorDatabase;
     }
 
     public ProfileDatabase getProfileDatabase() {
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectorDatabase.java
similarity index 70%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectorDatabase.java
index 628fc029eef031710214976d4756520efc7c0be8..6abbafa1dab1d13f8199f8bee70d15a0026c686c 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectorDatabase.java
@@ -31,114 +31,114 @@ import com.netscape.cmscore.dbs.CSCfgDatabase;
  *
  * @author Endi S. Dewata
  */
-public class ConnectionDatabase extends CSCfgDatabase<ConnectionRecord> {
+public class ConnectorDatabase extends CSCfgDatabase<ConnectorRecord> {
 
     public String prefix = "tps.connector";
 
-    public ConnectionDatabase() {
-        super("Connection", "Subsystem_Connections");
+    public ConnectorDatabase() {
+        super("Connector", "Subsystem_Connections");
     }
 
-    public ConnectionRecord createConnectionRecord(ConfigDatabase configDatabase, ConfigRecord configRecord, String connectionID) throws EBaseException {
-        ConnectionRecord connectionRecord = new ConnectionRecord();
-        connectionRecord.setID(connectionID);
+    public ConnectorRecord createConnectorRecord(ConfigDatabase configDatabase, ConfigRecord configRecord, String connectorID) throws EBaseException {
+        ConnectorRecord connectorRecord = new ConnectorRecord();
+        connectorRecord.setID(connectorID);
 
-        String status = getRecordStatus(connectionID);
-        connectionRecord.setStatus(status);
+        String status = getRecordStatus(connectorID);
+        connectorRecord.setStatus(status);
 
-        Map<String, String> properties = configDatabase.getProperties(configRecord, connectionID);
-        connectionRecord.setProperties(properties);
-        return connectionRecord;
+        Map<String, String> properties = configDatabase.getProperties(configRecord, connectorID);
+        connectorRecord.setProperties(properties);
+        return connectorRecord;
     }
 
     @Override
-    public Collection<ConnectionRecord> findRecords(String filter) throws Exception {
+    public Collection<ConnectorRecord> findRecords(String filter) throws Exception {
 
-        Collection<ConnectionRecord> result = new ArrayList<ConnectionRecord>();
+        Collection<ConnectorRecord> result = new ArrayList<ConnectorRecord>();
         ConfigDatabase configDatabase = new ConfigDatabase();
         ConfigRecord configRecord = configDatabase.getRecord(substoreName);
 
-        for (String connectionID : configRecord.getKeys()) {
-            if (filter != null && !connectionID.contains(filter)) continue;
-            ConnectionRecord connectionRecord = createConnectionRecord(configDatabase, configRecord, connectionID);
-            result.add(connectionRecord);
+        for (String connectorID : configRecord.getKeys()) {
+            if (filter != null && !connectorID.contains(filter)) continue;
+            ConnectorRecord connectorRecord = createConnectorRecord(configDatabase, configRecord, connectorID);
+            result.add(connectorRecord);
         }
 
         return result;
     }
 
     @Override
-    public ConnectionRecord getRecord(String connectionID) throws Exception {
+    public ConnectorRecord getRecord(String connectionID) throws Exception {
 
         ConfigDatabase configDatabase = new ConfigDatabase();
         ConfigRecord configRecord = configDatabase.getRecord(substoreName);
 
-        return createConnectionRecord(configDatabase, configRecord, connectionID);
+        return createConnectorRecord(configDatabase, configRecord, connectionID);
     }
 
     @Override
-    public void addRecord(String connectionID, ConnectionRecord connectionRecord) throws Exception {
+    public void addRecord(String connectorID, ConnectorRecord connectorRecord) throws Exception {
 
-        CMS.debug("ConnectionDatabase.addRecord(\"" + connectionID + "\")");
+        CMS.debug("ConnectorDatabase.addRecord(\"" + connectorID + "\")");
         ConfigDatabase configDatabase = new ConfigDatabase();
         ConfigRecord configRecord = configDatabase.getRecord(substoreName);
 
         // validate new properties
-        Map<String, String> properties = connectionRecord.getProperties();
-        configDatabase.validateProperties(configRecord, connectionID, properties);
+        Map<String, String> properties = connectorRecord.getProperties();
+        configDatabase.validateProperties(configRecord, connectorID, properties);
 
-        // add new connection
-        configRecord.addKey(connectionID);
+        // add new connector
+        configRecord.addKey(connectorID);
         configDatabase.updateRecord(substoreName, configRecord);
 
         // store new properties
-        configDatabase.addProperties(configRecord, connectionID, properties);
+        configDatabase.addProperties(configRecord, connectorID, properties);
 
         // create status
-        createRecordStatus(connectionID, connectionRecord.getStatus());
+        createRecordStatus(connectorID, connectorRecord.getStatus());
 
         configDatabase.commit();
     }
 
     @Override
-    public void updateRecord(String connectionID, ConnectionRecord connectionRecord) throws Exception {
+    public void updateRecord(String connectorID, ConnectorRecord connectorRecord) throws Exception {
 
-        CMS.debug("ConnectionDatabase.updateRecord(\"" + connectionID + "\")");
+        CMS.debug("ConnectorDatabase.updateRecord(\"" + connectorID + "\")");
         ConfigDatabase configDatabase = new ConfigDatabase();
         ConfigRecord configRecord = configDatabase.getRecord(substoreName);
 
         // validate new properties
-        Map<String, String> properties = connectionRecord.getProperties();
-        configDatabase.validateProperties(configRecord, connectionID, properties);
+        Map<String, String> properties = connectorRecord.getProperties();
+        configDatabase.validateProperties(configRecord, connectorID, properties);
 
         // remove old properties
-        configDatabase.removeProperties(configRecord, connectionID);
+        configDatabase.removeProperties(configRecord, connectorID);
 
         // add new properties
-        configDatabase.addProperties(configRecord, connectionID, properties);
+        configDatabase.addProperties(configRecord, connectorID, properties);
 
         // update status
-        setRecordStatus(connectionID, connectionRecord.getStatus());
+        setRecordStatus(connectorID, connectorRecord.getStatus());
 
         configDatabase.commit();
     }
 
     @Override
-    public void removeRecord(String connectionID) throws Exception {
+    public void removeRecord(String connectorID) throws Exception {
 
-        CMS.debug("ConnectionDatabase.removeRecord(\"" + connectionID + "\")");
+        CMS.debug("ConnectorDatabase.removeRecord(\"" + connectorID + "\")");
         ConfigDatabase configDatabase = new ConfigDatabase();
         ConfigRecord configRecord = configDatabase.getRecord(substoreName);
 
         // remove properties
-        configDatabase.removeProperties(configRecord, connectionID);
+        configDatabase.removeProperties(configRecord, connectorID);
 
-        // remove connection
-        configRecord.removeKey(connectionID);
+        // remove connector
+        configRecord.removeKey(connectorID);
         configDatabase.updateRecord(substoreName, configRecord);
 
         // remove status
-        removeRecordStatus(connectionID);
+        removeRecordStatus(connectorID);
 
         configDatabase.commit();
     }
@@ -172,7 +172,7 @@ public class ConnectionDatabase extends CSCfgDatabase<ConnectionRecord> {
 
         String id  = getNextID("ca");
 
-        ConnectionRecord record = new ConnectionRecord();
+        ConnectorRecord record = new ConnectorRecord();
         record.setID(id);
         record.setStatus("Enabled");
 
@@ -195,7 +195,7 @@ public class ConnectionDatabase extends CSCfgDatabase<ConnectionRecord> {
 
         String id  = getNextID("kra");
 
-        ConnectionRecord record = new ConnectionRecord();
+        ConnectorRecord record = new ConnectorRecord();
         record.setID(id);
         record.setStatus("Enabled");
 
@@ -216,7 +216,7 @@ public class ConnectionDatabase extends CSCfgDatabase<ConnectionRecord> {
 
         String id  = getNextID("tks");
 
-        ConnectionRecord record = new ConnectionRecord();
+        ConnectorRecord record = new ConnectorRecord();
         record.setID(id);
         record.setStatus("Enabled");
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectorRecord.java
similarity index 94%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectorRecord.java
index 3a2f78037bb44b33aa0f9c83e9a648d2e2c94a9b..3123718b16b4ec0894ac6188c6be1c035e0dc81f 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectorRecord.java
@@ -24,5 +24,5 @@ import com.netscape.cmscore.dbs.CSCfgRecord;
 /**
  * @author Endi S. Dewata
  */
-public class ConnectionRecord extends CSCfgRecord {
+public class ConnectorRecord extends CSCfgRecord {
 }
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/installer/TPSInstaller.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/installer/TPSInstaller.java
index 9d9226b46ed2a14b8b39f795481ab1718a94d5de..2779e5b983b596aa58b83e3eddeee3581e892776 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/installer/TPSInstaller.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/installer/TPSInstaller.java
@@ -20,8 +20,8 @@ package org.dogtagpki.server.tps.installer;
 import java.net.URI;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
-import org.dogtagpki.server.tps.config.ConnectionDatabase;
-import org.dogtagpki.server.tps.config.ConnectionRecord;
+import org.dogtagpki.server.tps.config.ConnectorDatabase;
+import org.dogtagpki.server.tps.config.ConnectorRecord;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.IConfigStore;
@@ -43,7 +43,7 @@ public class TPSInstaller {
     public void configureCAConnector(URI uri, String nickname) {
 
         TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-        ConnectionDatabase database = subsystem.getConnectionDatabase();
+        ConnectorDatabase database = subsystem.getConnectorDatabase();
         IConfigStore cs = CMS.getConfigStore();
 
         // TODO: see if this is only needed by wizard-based installation
@@ -60,7 +60,7 @@ public class TPSInstaller {
     public void configureTKSConnector(URI uri, String nickname) {
 
         TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-        ConnectionDatabase database = subsystem.getConnectionDatabase();
+        ConnectorDatabase database = subsystem.getConnectorDatabase();
         IConfigStore cs = CMS.getConfigStore();
 
         // TODO: see if this is only needed by wizard-based installation
@@ -77,7 +77,7 @@ public class TPSInstaller {
     public void configureKRAConnector(Boolean keygen, URI uri, String nickname) {
 
         TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-        ConnectionDatabase database = subsystem.getConnectionDatabase();
+        ConnectorDatabase database = subsystem.getConnectorDatabase();
         IConfigStore cs = CMS.getConfigStore();
 
         if (keygen) {
@@ -113,7 +113,7 @@ public class TPSInstaller {
             String id = "tks1"; // there is only one default TKS connector
 
             // update keygen in TKS connector
-            ConnectionRecord record = database.getRecord(id);
+            ConnectorRecord record = database.getRecord(id);
             record.setProperty(database.prefix + "." + id + ".serverKeygen", keygen.toString());
             database.updateRecord(id, record);
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectorService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectorService.java
index 5eee52f7c9583e91d6f9900d3c7f9e1850c4ff0d..91b7fe64b13463a0b9389ed8e5b334d8aaa69cbd 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectorService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectorService.java
@@ -33,8 +33,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
-import org.dogtagpki.server.tps.config.ConnectionDatabase;
-import org.dogtagpki.server.tps.config.ConnectionRecord;
+import org.dogtagpki.server.tps.config.ConnectorDatabase;
+import org.dogtagpki.server.tps.config.ConnectorRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
@@ -69,7 +69,7 @@ public class ConnectorService extends PKIService implements ConnectorResource {
         CMS.debug("ConnectorService.<init>()");
     }
 
-    public ConnectorData createConnectorData(ConnectionRecord connectionRecord) throws UnsupportedEncodingException {
+    public ConnectorData createConnectorData(ConnectorRecord connectionRecord) throws UnsupportedEncodingException {
 
         String connectorID = connectionRecord.getID();
 
@@ -85,9 +85,9 @@ public class ConnectorService extends PKIService implements ConnectorResource {
         return connectorData;
     }
 
-    public ConnectionRecord createConnectorRecord(ConnectorData connectorData) {
+    public ConnectorRecord createConnectorRecord(ConnectorData connectorData) {
 
-        ConnectionRecord connectorRecord = new ConnectionRecord();
+        ConnectorRecord connectorRecord = new ConnectorRecord();
         connectorRecord.setID(connectorData.getID());
         connectorRecord.setStatus(connectorData.getStatus());
         connectorRecord.setProperties(connectorData.getProperties());
@@ -105,9 +105,9 @@ public class ConnectorService extends PKIService implements ConnectorResource {
             size = size == null ? DEFAULT_SIZE : size;
 
             TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            ConnectorDatabase database = subsystem.getConnectorDatabase();
 
-            Iterator<ConnectionRecord> connections = database.findRecords(filter).iterator();
+            Iterator<ConnectorRecord> connections = database.findRecords(filter).iterator();
 
             ConnectorCollection response = new ConnectorCollection();
             int i = 0;
@@ -154,7 +154,7 @@ public class ConnectorService extends PKIService implements ConnectorResource {
 
         try {
             TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            ConnectorDatabase database = subsystem.getConnectorDatabase();
 
             return createOKResponse(createConnectorData(database.getRecord(connectorID)));
 
@@ -176,7 +176,7 @@ public class ConnectorService extends PKIService implements ConnectorResource {
 
         try {
             TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            ConnectorDatabase database = subsystem.getConnectorDatabase();
 
             database.addRecord(connectorData.getID(), createConnectorRecord(connectorData));
             connectorData = createConnectorData(database.getRecord(connectorData.getID()));
@@ -202,9 +202,9 @@ public class ConnectorService extends PKIService implements ConnectorResource {
 
         try {
             TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            ConnectorDatabase database = subsystem.getConnectorDatabase();
 
-            ConnectionRecord record = database.getRecord(connectorID);
+            ConnectorRecord record = database.getRecord(connectorID);
 
             // only disabled connector can be updated
             if (!"Disabled".equals(record.getStatus())) {
@@ -259,9 +259,9 @@ public class ConnectorService extends PKIService implements ConnectorResource {
 
         try {
             TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            ConnectorDatabase database = subsystem.getConnectorDatabase();
 
-            ConnectionRecord record = database.getRecord(connectorID);
+            ConnectorRecord record = database.getRecord(connectorID);
             String status = record.getStatus();
 
             if ("Disabled".equals(status)) {
@@ -316,9 +316,9 @@ public class ConnectorService extends PKIService implements ConnectorResource {
 
         try {
             TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
-            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            ConnectorDatabase database = subsystem.getConnectorDatabase();
 
-            ConnectionRecord record = database.getRecord(connectorID);
+            ConnectorRecord record = database.getRecord(connectorID);
             String status = record.getStatus();
 
             if (!"Disabled".equals(status)) {
-- 
1.8.4.2

