summaryrefslogtreecommitdiffstats
path: root/base/tps/src
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-03-15 21:10:30 +0100
committerEndi S. Dewata <edewata@redhat.com>2016-03-17 01:03:43 +0100
commit2e02c078fb57fa806d3ff2bf7a1ed2df34966acc (patch)
tree03c9803a6445b3fcbc982359adc82d36fccb76ab /base/tps/src
parentb5637ae9c646c99efce4ff874666b75400502b2d (diff)
Added TPS token filter dialog.
The TPS UI Tokens page and the pki tps-token-find CLI have been modified to provide an interface to filter tokens based on their attributes. The TokenService.findTokens() has been modified to accept additional search criteria based on token attributes. https://fedorahosted.org/pki/ticket/1482
Diffstat (limited to 'base/tps/src')
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
index 226f039f4..a0ca7add3 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
@@ -268,7 +268,14 @@ public class TokenService extends PKIService implements TokenResource {
}
@Override
- public Response findTokens(String filter, Integer start, Integer size) {
+ public Response findTokens(
+ String filter,
+ String tokenID,
+ String userID,
+ String type,
+ String status,
+ Integer start,
+ Integer size) {
CMS.debug("TokenService.findTokens()");
@@ -276,6 +283,24 @@ public class TokenService extends PKIService implements TokenResource {
throw new BadRequestException("Filter is too short.");
}
+ Map<String, String> attributes = new HashMap<String, String>();
+
+ if (StringUtils.isNotEmpty(tokenID)) {
+ attributes.put("id", tokenID);
+ }
+
+ if (StringUtils.isNotEmpty(userID)) {
+ attributes.put("userID", userID);
+ }
+
+ if (StringUtils.isNotEmpty(type)) {
+ attributes.put("type", type);
+ }
+
+ if (StringUtils.isNotEmpty(status)) {
+ attributes.put("status", status);
+ }
+
start = start == null ? 0 : start;
size = size == null ? DEFAULT_SIZE : size;
@@ -283,7 +308,7 @@ public class TokenService extends PKIService implements TokenResource {
TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID);
TokenDatabase database = subsystem.getTokenDatabase();
- Iterator<TokenRecord> tokens = database.findRecords(filter).iterator();
+ Iterator<TokenRecord> tokens = database.findRecords(filter, attributes).iterator();
TokenCollection response = new TokenCollection();
int i = 0;