summaryrefslogtreecommitdiffstats
path: root/base/common
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2013-09-24 10:06:35 -0400
committerEndi S. Dewata <edewata@redhat.com>2013-10-01 19:25:28 -0400
commita3ac3ef0ca5e720a4cd5b17e9181124c17d17ea7 (patch)
tree0c2376346a001bb4fee229d52b10ea0398442080 /base/common
parent2b9fcdae818eded53ab64e5b86b947c80a262722 (diff)
downloadpki-a3ac3ef0ca5e720a4cd5b17e9181124c17d17ea7.tar.gz
pki-a3ac3ef0ca5e720a4cd5b17e9181124c17d17ea7.tar.xz
pki-a3ac3ef0ca5e720a4cd5b17e9181124c17d17ea7.zip
Refactored CLI framework.
The CLI framework has been modified to remove duplicate code in various CLI modules.
Diffstat (limited to 'base/common')
-rw-r--r--base/common/src/com/netscape/certsrv/client/Client.java15
-rw-r--r--base/common/src/com/netscape/certsrv/client/SubsystemClient.java12
-rw-r--r--base/common/src/com/netscape/certsrv/tps/TPSClient.java2
3 files changed, 17 insertions, 12 deletions
diff --git a/base/common/src/com/netscape/certsrv/client/Client.java b/base/common/src/com/netscape/certsrv/client/Client.java
index f47717d3f..8833c1710 100644
--- a/base/common/src/com/netscape/certsrv/client/Client.java
+++ b/base/common/src/com/netscape/certsrv/client/Client.java
@@ -18,6 +18,7 @@
package com.netscape.certsrv.client;
import java.net.URISyntaxException;
+import java.util.LinkedHashMap;
/**
* @author Endi S. Dewata
@@ -33,6 +34,8 @@ public class Client {
// client name
public String name;
+ public LinkedHashMap<String, Client> clients = new LinkedHashMap<String, Client>();
+
public Client(PKIClient client, String name) {
// by default use the subsystem specified in server URI
this(client, client.getSubsystem(), name);
@@ -52,6 +55,18 @@ public class Client {
return name;
}
+ public void addClient(Client client) {
+ clients.put(client.getName(), client);
+ }
+
+ public Client getClient(String name) {
+ return clients.get(name);
+ }
+
+ public void removeClient(String name) {
+ clients.remove(name);
+ }
+
public <T> T createProxy(Class<T> clazz) throws URISyntaxException {
return client.createProxy(subsystem, clazz);
}
diff --git a/base/common/src/com/netscape/certsrv/client/SubsystemClient.java b/base/common/src/com/netscape/certsrv/client/SubsystemClient.java
index 7acdcce38..d694b397c 100644
--- a/base/common/src/com/netscape/certsrv/client/SubsystemClient.java
+++ b/base/common/src/com/netscape/certsrv/client/SubsystemClient.java
@@ -18,7 +18,6 @@
package com.netscape.certsrv.client;
import java.net.URISyntaxException;
-import java.util.LinkedHashMap;
import com.netscape.certsrv.account.AccountClient;
@@ -30,21 +29,12 @@ public class SubsystemClient extends Client {
public AccountClient accountClient;
- public LinkedHashMap<String, Client> clients = new LinkedHashMap<String, Client>();
-
public SubsystemClient(PKIClient client, String name) throws URISyntaxException {
// subsystem name should match the client name
super(client, name, name);
accountClient = new AccountClient(client, name);
- }
-
- public void addClient(Client client) {
- clients.put(client.getName(), client);
- }
-
- public Client getClient(String name) {
- return clients.get(name);
+ addClient(accountClient);
}
/**
diff --git a/base/common/src/com/netscape/certsrv/tps/TPSClient.java b/base/common/src/com/netscape/certsrv/tps/TPSClient.java
index e30858bfe..b35893505 100644
--- a/base/common/src/com/netscape/certsrv/tps/TPSClient.java
+++ b/base/common/src/com/netscape/certsrv/tps/TPSClient.java
@@ -43,11 +43,11 @@ public class TPSClient extends SubsystemClient {
public void init() throws URISyntaxException {
addClient(new ActivityClient(client, name));
addClient(new AuthenticatorClient(client, name));
+ addClient(new TPSCertClient(client, name));
addClient(new ConfigClient(client, name));
addClient(new ConnectionClient(client, name));
addClient(new GroupClient(client, name));
addClient(new TokenClient(client, name));
- addClient(new TPSCertClient(client, name));
addClient(new UserClient(client, name));
}
}