summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2013-11-13 12:00:06 -0500
committerEndi S. Dewata <edewata@redhat.com>2013-11-14 16:54:39 -0500
commit4d1ec71c790e467ecae184df01abf825f94d1dc3 (patch)
tree8f821411a4ec5d275b4ee0702e438cafc3e92c60 /base
parent17a52b686bd81cda1bce76b454b3127d6575de62 (diff)
downloadpki-4d1ec71c790e467ecae184df01abf825f94d1dc3.tar.gz
pki-4d1ec71c790e467ecae184df01abf825f94d1dc3.tar.xz
pki-4d1ec71c790e467ecae184df01abf825f94d1dc3.zip
Added paging on all find commands.
The find commands in some REST services have been modified to support paging to be consistent with others. The other find commands have been cleaned up as well.
Diffstat (limited to 'base')
-rw-r--r--base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java14
-rw-r--r--base/common/src/com/netscape/certsrv/base/DataCollection.java10
-rw-r--r--base/common/src/com/netscape/certsrv/ca/CAClient.java4
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertClient.java8
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertDataInfos.java46
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java108
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertRequestResource.java4
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertResource.java10
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyClient.java5
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyDataInfos.java70
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java109
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyResource.java4
-rw-r--r--base/common/src/com/netscape/certsrv/kra/KRAClient.java4
-rw-r--r--base/common/src/com/netscape/certsrv/profile/ProfileClient.java4
-rw-r--r--base/common/src/com/netscape/certsrv/profile/ProfileDataInfos.java58
-rw-r--r--base/common/src/com/netscape/certsrv/profile/ProfileResource.java4
-rw-r--r--base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java56
-rw-r--r--base/common/src/com/netscape/certsrv/system/TPSConnectorResource.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java23
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertRequestFindCLI.java24
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertRequestProfileFindCLI.java38
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java2
-rw-r--r--base/java-tools/src/com/netscape/cmstools/group/GroupFindCLI.java5
-rw-r--r--base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java5
-rw-r--r--base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java16
-rw-r--r--base/java-tools/src/com/netscape/cmstools/key/KeyRequestFindCLI.java6
-rw-r--r--base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java36
-rw-r--r--base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java2
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/token/TokenFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java5
-rw-r--r--base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java5
-rw-r--r--base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java5
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/cert/CertRequestDAO.java10
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java102
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java6
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java51
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java54
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/request/CMSRequestDAO.java9
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java66
46 files changed, 420 insertions, 604 deletions
diff --git a/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java b/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java
index d50bfedf3..a2be4c4b0 100644
--- a/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java
+++ b/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java
@@ -167,7 +167,7 @@ public class CATest {
Collection<CertRequestInfo> list = null;
try {
- list = certClient.listRequests("complete", null, null, null, null, null).getRequests();
+ list = certClient.listRequests("complete", null, null, null, null, null).getEntries();
} catch (Exception e) {
e.printStackTrace();
}
@@ -205,7 +205,7 @@ public class CATest {
CertDataInfos infos = null;
try {
- infos = certClient.listCerts("VALID", 100, 10);
+ infos = certClient.listCerts("VALID", null, null, null, null);
} catch (Exception e) {
e.printStackTrace();
}
@@ -268,7 +268,7 @@ public class CATest {
//Get a list of Profiles
- ProfileDataInfos pInfos = client.listProfiles();
+ ProfileDataInfos pInfos = client.listProfiles(null, null);
printProfileInfos(pInfos);
@@ -289,7 +289,7 @@ public class CATest {
log(e.toString());
}
- for (CertRequestInfo info : reqInfo.getRequests()) {
+ for (CertRequestInfo info : reqInfo.getEntries()) {
printRequestInfo(info);
CertReviewResponse reviewData = client.reviewRequest(info.getRequestId());
@@ -309,7 +309,7 @@ public class CATest {
log(e.toString());
}
- for (CertRequestInfo info : reqInfo.getRequests()) {
+ for (CertRequestInfo info : reqInfo.getEntries()) {
printRequestInfo(info);
}
}
@@ -402,7 +402,7 @@ public class CATest {
return;
}
- Collection<ProfileDataInfo> listProfiles = pInfos.getProfileInfos();
+ Collection<ProfileDataInfo> listProfiles = pInfos.getEntries();
if (listProfiles != null) {
log("\nProfiles found. \n");
for (ProfileDataInfo info: listProfiles) {
@@ -455,7 +455,7 @@ public class CATest {
return;
}
- Collection<CertDataInfo> listCerts = infos.getCertInfos();
+ Collection<CertDataInfo> listCerts = infos.getEntries();
if (listCerts != null) {
log("\nCertificates found with search filter: " + filter + "\n");
for (CertDataInfo info: listCerts) {
diff --git a/base/common/src/com/netscape/certsrv/base/DataCollection.java b/base/common/src/com/netscape/certsrv/base/DataCollection.java
index 8432604f0..f5f46bcb8 100644
--- a/base/common/src/com/netscape/certsrv/base/DataCollection.java
+++ b/base/common/src/com/netscape/certsrv/base/DataCollection.java
@@ -47,7 +47,9 @@ public class DataCollection<E> {
}
public void setEntries(Collection<E> entries) {
- this.entries = entries;
+ this.entries.clear();
+ if (entries == null) return;
+ this.entries.addAll(entries);
}
public void addEntry(E entry) {
@@ -63,8 +65,10 @@ public class DataCollection<E> {
return links;
}
- public void setLink(Collection<Link> links) {
- this.links = links;
+ public void setLinks(Collection<Link> links) {
+ this.links.clear();
+ if (links == null) return;
+ this.links.addAll(links);
}
public void addLink(Link link) {
diff --git a/base/common/src/com/netscape/certsrv/ca/CAClient.java b/base/common/src/com/netscape/certsrv/ca/CAClient.java
index 24a84a2ea..fecef38f5 100644
--- a/base/common/src/com/netscape/certsrv/ca/CAClient.java
+++ b/base/common/src/com/netscape/certsrv/ca/CAClient.java
@@ -50,8 +50,8 @@ public class CAClient extends SubsystemClient {
profileClient = createProxy(ProfileResource.class);
}
- public ProfileDataInfos listProfiles() {
- return profileClient.listProfiles();
+ public ProfileDataInfos listProfiles(Integer start, Integer size) {
+ return profileClient.listProfiles(start, size);
}
public ProfileData getProfile(String id) {
diff --git a/base/common/src/com/netscape/certsrv/cert/CertClient.java b/base/common/src/com/netscape/certsrv/cert/CertClient.java
index 9de548cad..ab7ad9a55 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertClient.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertClient.java
@@ -51,8 +51,8 @@ public class CertClient extends Client {
return certClient.reviewCert(id);
}
- public CertDataInfos listCerts(String status, Integer start, Integer size) {
- return certClient.listCerts(status, start, size);
+ public CertDataInfos listCerts(String status, Integer maxResults, Integer maxTime, Integer start, Integer size) {
+ return certClient.listCerts(status, maxResults, maxTime, start, size);
}
public CertDataInfos findCerts(CertSearchRequest data, Integer start, Integer size) {
@@ -120,8 +120,8 @@ public class CertClient extends Client {
return certRequestClient.getEnrollmentTemplate(id);
}
- public ProfileDataInfos listEnrollmentTemplates() {
- return certRequestClient.listEnrollmentTemplates();
+ public ProfileDataInfos listEnrollmentTemplates(Integer start, Integer size) {
+ return certRequestClient.listEnrollmentTemplates(start, size);
}
}
diff --git a/base/common/src/com/netscape/certsrv/cert/CertDataInfos.java b/base/common/src/com/netscape/certsrv/cert/CertDataInfos.java
index 475e90815..1010f3d40 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertDataInfos.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertDataInfos.java
@@ -17,56 +17,18 @@
//--- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.cert;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
-import org.jboss.resteasy.plugins.providers.atom.Link;
+import com.netscape.certsrv.base.DataCollection;
@XmlRootElement(name = "CertDataInfos")
-public class CertDataInfos {
+public class CertDataInfos extends DataCollection<CertDataInfo> {
- protected Collection<CertDataInfo> certInfos = new ArrayList<CertDataInfo>();
- protected List<Link> links = new ArrayList<Link>();
-
- /**
- * @return the CertInfos
- */
- @XmlElementRef
- public Collection<CertDataInfo> getCertInfos() {
- return certInfos;
- }
-
- /**
- * @param certInfos the CertInfos to set
- */
- public void setCertInfos(Collection<CertDataInfo> certInfos) {
- this.certInfos = certInfos;
- }
-
- /**
- * @return the links
- */
@XmlElementRef
- public List<Link> getLinks() {
- return links;
- }
-
- /**
- * @param links the links to set
- */
- public void setLinks(List<Link> links) {
- this.links = links;
- }
-
- public void addCertData(CertDataInfo certInfo){
- this.certInfos.add(certInfo);
- }
-
- public void addLink(Link link) {
- this.links.add(link);
+ public Collection<CertDataInfo> getEntries() {
+ return super.getEntries();
}
}
diff --git a/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java b/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java
index a6a520c23..6948b285b 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java
@@ -19,84 +19,33 @@ package com.netscape.certsrv.cert;
import java.io.StringReader;
import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-import com.netscape.certsrv.base.Link;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
+import com.netscape.certsrv.base.DataCollection;
import com.netscape.certsrv.request.RequestStatus;
@XmlRootElement(name = "CertRequestInfos")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class CertRequestInfos {
+public class CertRequestInfos extends DataCollection<CertRequestInfo> {
@XmlElementRef
- protected Collection<CertRequestInfo> requests = new ArrayList<CertRequestInfo>();
-
- @XmlElement(name = "Links")
- protected List<Link> links = new ArrayList<Link>();
-
- /**
- * @return the requests
- */
- public Collection<CertRequestInfo> getRequests() {
- return requests;
- }
-
- /**
- * @param requests the requests to set
- */
- public void setRequests(Collection<CertRequestInfo> requests) {
- this.requests.clear();
- if (requests == null) return;
- this.requests.addAll(requests);
- }
-
- /**
- * @param requests the request to add
- */
- public void addRequest(CertRequestInfo request) {
- requests.add(request);
- }
-
- /**
- * @return the links
- */
- public List<Link> getLinks() {
- return links;
- }
-
- /**
- * @param links the links to set
- */
- public void setLinks(List<Link> links) {
- this.links.clear();
- if (links == null) return;
- this.links.addAll(links);
- }
-
- /**
- * @param links the link to add
- */
- public void addLink(Link link) {
- links.add(link);
+ public Collection<CertRequestInfo> getEntries() {
+ return super.getEntries();
}
@XmlTransient
public String getNext() {
- for (Link link : links) {
- if ("next".equals(link.getRelationship())) {
- return link.getHref();
+ for (Link link : getLinks()) {
+ if ("next".equals(link.getRel())) {
+ return link.getHref().toString();
}
}
return null;
@@ -104,45 +53,14 @@ public class CertRequestInfos {
@XmlTransient
public String getPrevious() {
- for (Link link : links) {
- if ("previous".equals(link.getRelationship())) {
- return link.getHref();
+ for (Link link : getLinks()) {
+ if ("previous".equals(link.getRel())) {
+ return link.getHref().toString();
}
}
return null;
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((links == null) ? 0 : links.hashCode());
- result = prime * result + ((requests == null) ? 0 : requests.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- CertRequestInfos other = (CertRequestInfos) obj;
- if (links == null) {
- if (other.links != null)
- return false;
- } else if (!links.equals(other.links))
- return false;
- if (requests == null) {
- if (other.requests != null)
- return false;
- } else if (!requests.equals(other.requests))
- return false;
- return true;
- }
-
public String toString() {
try {
StringWriter sw = new StringWriter();
@@ -173,7 +91,7 @@ public class CertRequestInfos {
request.setRequestType("enrollment");
request.setRequestStatus(RequestStatus.COMPLETE);
request.setCertRequestType("pkcs10");
- before.addRequest(request);
+ before.addEntry(request);
String string = before.toString();
System.out.println(string);
diff --git a/base/common/src/com/netscape/certsrv/cert/CertRequestResource.java b/base/common/src/com/netscape/certsrv/cert/CertRequestResource.java
index 0d58be282..7656080a1 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertRequestResource.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertRequestResource.java
@@ -81,7 +81,9 @@ public interface CertRequestResource {
@GET
@Path("certrequests/profiles")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public ProfileDataInfos listEnrollmentTemplates();
+ public ProfileDataInfos listEnrollmentTemplates(
+ @QueryParam("start") Integer start,
+ @QueryParam("size") Integer size);
@GET
@Path("certrequests/profiles/{id}")
diff --git a/base/common/src/com/netscape/certsrv/cert/CertResource.java b/base/common/src/com/netscape/certsrv/cert/CertResource.java
index a667fdc2d..b5b282b18 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertResource.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertResource.java
@@ -1,7 +1,6 @@
package com.netscape.certsrv.cert;
import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -17,16 +16,15 @@ import com.netscape.certsrv.dbs.certdb.CertId;
@Path("")
public interface CertResource {
- public static final int DEFAULT_MAXTIME = 0;
- public static final int DEFAULT_MAXRESULTS = 20;
-
@GET
@Path("certs")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CertDataInfos listCerts(
@QueryParam("status") String status,
- @DefaultValue("" + DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
- @DefaultValue("" + DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("maxTime") Integer maxTime,
+ @QueryParam("start") Integer start,
+ @QueryParam("size") Integer size);
@POST
@Path("certs/search")
diff --git a/base/common/src/com/netscape/certsrv/key/KeyClient.java b/base/common/src/com/netscape/certsrv/key/KeyClient.java
index 385996eed..272f8ca04 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyClient.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyClient.java
@@ -41,8 +41,9 @@ public class KeyClient extends Client {
keyRequestClient = createProxy(KeyRequestResource.class);
}
- public KeyDataInfos findKeys(String clientID, String status, Integer maxSize, Integer maxTime) {
- return keyClient.listKeys(clientID, status, maxSize, maxTime);
+ public KeyDataInfos findKeys(String clientID, String status, Integer maxSize, Integer maxTime,
+ Integer start, Integer size) {
+ return keyClient.listKeys(clientID, status, maxSize, maxTime, start, size);
}
public KeyData retrieveKey(KeyRecoveryRequest data) {
diff --git a/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
index d9fc885b4..eab8ae97c 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
@@ -17,82 +17,18 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.key;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-import com.netscape.certsrv.base.Link;
+import com.netscape.certsrv.base.DataCollection;
@XmlRootElement(name = "KeyDataInfos")
-public class KeyDataInfos {
+public class KeyDataInfos extends DataCollection<KeyDataInfo> {
- protected Collection<KeyDataInfo> keyInfos = new ArrayList<KeyDataInfo>();
- protected List<Link> links = new ArrayList<Link>();
-
- /**
- * @return the keyInfos
- */
@XmlElementRef
public Collection<KeyDataInfo> getKeyInfos() {
- return keyInfos;
- }
-
- /**
- * @param keyInfos the keyInfos to set
- */
- public void setKeyInfos(Collection<KeyDataInfo> keyInfos) {
- this.keyInfos = keyInfos;
- }
-
- /**
- * @param keyInfo the keyInfo to add
- */
- public void addKeyInfo(KeyDataInfo keyInfo) {
- keyInfos.add(keyInfo);
- }
-
- /**
- * @return the links
- */
- @XmlElementRef
- public List<Link> getLinks() {
- return links;
- }
-
- /**
- * @param links the links to set
- */
- public void setLinks(List<Link> links) {
- this.links = links;
- }
-
- @XmlTransient
- public String getNext() {
- if (links == null) {
- return null;
- }
- for (Link link : links) {
- if ("next".equals(link.getRelationship())) {
- return link.getHref();
- }
- }
- return null;
- }
-
- @XmlTransient
- public String getPrevious() {
- if (links == null) {
- return null;
- }
- for (Link link : links) {
- if ("previous".equals(link.getRelationship())) {
- return link.getHref();
- }
- }
- return null;
+ return super.getEntries();
}
}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java b/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
index 90756f8d3..403dc7d41 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
@@ -19,84 +19,32 @@ package com.netscape.certsrv.key;
import java.io.StringReader;
import java.io.StringWriter;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-import com.netscape.certsrv.base.Link;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
+import com.netscape.certsrv.base.DataCollection;
import com.netscape.certsrv.request.RequestStatus;
@XmlRootElement(name = "KeyRequestInfos")
-@XmlAccessorType(XmlAccessType.FIELD)
-public class KeyRequestInfos {
+public class KeyRequestInfos extends DataCollection<KeyRequestInfo> {
@XmlElementRef
- protected Collection<KeyRequestInfo> requests = new ArrayList<KeyRequestInfo>();
-
- @XmlElement(name = "Link")
- protected List<Link> links = new ArrayList<Link>();
-
- /**
- * @return the requests
- */
- public Collection<KeyRequestInfo> getRequests() {
- return requests;
- }
-
- /**
- * @param requests the requests to set
- */
- public void setRequests(Collection<KeyRequestInfo> requests) {
- this.requests.clear();
- if (requests == null) return;
- this.requests.addAll(requests);
- }
-
- /**
- * @param request the request to add
- */
- public void addRequest(KeyRequestInfo request) {
- requests.add(request);
- }
-
- /**
- * @return the links
- */
- public List<Link> getLinks() {
- return links;
+ public Collection<KeyRequestInfo> getEntries() {
+ return super.getEntries();
}
-
- /**
- * @param links the links to set
- */
- public void setLinks(List<Link> links) {
- this.links.clear();
- if (links == null) return;
- this.links.addAll(links);
- }
-
- /**
- * @param links the link to add
- */
- public void addLink(Link link) {
- this.links.add(link);
- }
-
@XmlTransient
public String getNext() {
- for (Link link : links) {
- if ("next".equals(link.getRelationship())) {
- return link.getHref();
+ for (Link link : getLinks()) {
+ if ("next".equals(link.getRel())) {
+ return link.getHref().toString();
}
}
return null;
@@ -104,45 +52,14 @@ public class KeyRequestInfos {
@XmlTransient
public String getPrevious() {
- for (Link link : links) {
- if ("previous".equals(link.getRelationship())) {
- return link.getHref();
+ for (Link link : getLinks()) {
+ if ("previous".equals(link.getRel())) {
+ return link.getHref().toString();
}
}
return null;
}
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((links == null) ? 0 : links.hashCode());
- result = prime * result + ((requests == null) ? 0 : requests.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- KeyRequestInfos other = (KeyRequestInfos) obj;
- if (links == null) {
- if (other.links != null)
- return false;
- } else if (!links.equals(other.links))
- return false;
- if (requests == null) {
- if (other.requests != null)
- return false;
- } else if (!requests.equals(other.requests))
- return false;
- return true;
- }
-
public String toString() {
try {
StringWriter sw = new StringWriter();
@@ -172,7 +89,7 @@ public class KeyRequestInfos {
KeyRequestInfo request = new KeyRequestInfo();
request.setRequestType("securityDataEnrollment");
request.setRequestStatus(RequestStatus.COMPLETE);
- before.addRequest(request);
+ before.addEntry(request);
String string = before.toString();
System.out.println(string);
diff --git a/base/common/src/com/netscape/certsrv/key/KeyResource.java b/base/common/src/com/netscape/certsrv/key/KeyResource.java
index bcca6bb97..a574abb65 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyResource.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyResource.java
@@ -23,7 +23,9 @@ public interface KeyResource {
public KeyDataInfos listKeys(@QueryParam("clientID") String clientID,
@QueryParam("status") String status,
@QueryParam("maxResults") Integer maxResults,
- @QueryParam("maxTime") Integer maxTime);
+ @QueryParam("maxTime") Integer maxTime,
+ @QueryParam("start") Integer start,
+ @QueryParam("size") Integer size);
/**
diff --git a/base/common/src/com/netscape/certsrv/kra/KRAClient.java b/base/common/src/com/netscape/certsrv/kra/KRAClient.java
index 73ad56454..ebccd664d 100644
--- a/base/common/src/com/netscape/certsrv/kra/KRAClient.java
+++ b/base/common/src/com/netscape/certsrv/kra/KRAClient.java
@@ -63,7 +63,7 @@ public class KRAClient extends SubsystemClient {
KeyRequestInfos infos = keyRequestClient.listRequests(
requestState, requestType, null, new RequestId(0), 100, 100, 10
);
- Collection<KeyRequestInfo> list = infos.getRequests();
+ Collection<KeyRequestInfo> list = infos.getEntries();
return list;
}
@@ -82,7 +82,7 @@ public class KRAClient extends SubsystemClient {
}
public KeyDataInfo getKeyData(String clientId, String status) {
- KeyDataInfos infos = keyClient.listKeys(clientId, status, 100, 10);
+ KeyDataInfos infos = keyClient.listKeys(clientId, status, null, null, null, null);
Collection<KeyDataInfo> list = infos.getKeyInfos();
Iterator<KeyDataInfo> iter = list.iterator();
diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileClient.java b/base/common/src/com/netscape/certsrv/profile/ProfileClient.java
index eefd0660e..2ea6d8698 100644
--- a/base/common/src/com/netscape/certsrv/profile/ProfileClient.java
+++ b/base/common/src/com/netscape/certsrv/profile/ProfileClient.java
@@ -44,8 +44,8 @@ public class ProfileClient extends Client {
return profileClient.retrieveProfile(id);
}
- public ProfileDataInfos listProfiles() {
- return profileClient.listProfiles();
+ public ProfileDataInfos listProfiles(Integer start, Integer size) {
+ return profileClient.listProfiles(start, size);
}
public void enableProfile(String id) {
diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileDataInfos.java b/base/common/src/com/netscape/certsrv/profile/ProfileDataInfos.java
index ed2c11cf7..a323491b4 100644
--- a/base/common/src/com/netscape/certsrv/profile/ProfileDataInfos.java
+++ b/base/common/src/com/netscape/certsrv/profile/ProfileDataInfos.java
@@ -18,58 +18,29 @@
package com.netscape.certsrv.profile;
import java.util.Collection;
-import java.util.List;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-import com.netscape.certsrv.base.Link;
+import org.jboss.resteasy.plugins.providers.atom.Link;
-@XmlRootElement(name = "ProfileDataInfos")
-public class ProfileDataInfos {
-
- protected Collection<ProfileDataInfo> profileInfos;
- protected List<Link> links;
-
- /**
- * @return the ProfileInfos
- */
- @XmlElementRef
- public Collection<ProfileDataInfo> getProfileInfos() {
- return profileInfos;
- }
+import com.netscape.certsrv.base.DataCollection;
+//import com.netscape.certsrv.base.Link;
- /**
- * @param ProfileInfos theProfileInfos to set
- */
- public void setProfileInfos(Collection<ProfileDataInfo> profileInfos) {
- this.profileInfos = profileInfos;
- }
+@XmlRootElement(name = "ProfileDataInfos")
+public class ProfileDataInfos extends DataCollection<ProfileDataInfo> {
- /**
- * @return the links
- */
@XmlElementRef
- public List<Link> getLinks() {
- return links;
- }
-
- /**
- * @param links the links to set
- */
- public void setLinks(List<Link> links) {
- this.links = links;
+ public Collection<ProfileDataInfo> getEntries() {
+ return super.getEntries();
}
@XmlTransient
public String getNext() {
- if (links == null) {
- return null;
- }
- for (Link link : links) {
- if ("next".equals(link.getRelationship())) {
- return link.getHref();
+ for (Link link : getLinks()) {
+ if ("next".equals(link. getRel())) {
+ return link.getHref().toString();
}
}
return null;
@@ -77,12 +48,9 @@ public class ProfileDataInfos {
@XmlTransient
public String getPrevious() {
- if (links == null) {
- return null;
- }
- for (Link link : links) {
- if ("previous".equals(link.getRelationship())) {
- return link.getHref();
+ for (Link link : getLinks()) {
+ if ("previous".equals(link.getRel())) {
+ return link.getHref().toString();
}
}
return null;
diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileResource.java b/base/common/src/com/netscape/certsrv/profile/ProfileResource.java
index 06dd785c3..5af61bff7 100644
--- a/base/common/src/com/netscape/certsrv/profile/ProfileResource.java
+++ b/base/common/src/com/netscape/certsrv/profile/ProfileResource.java
@@ -24,7 +24,9 @@ public interface ProfileResource {
@GET
@ACLMapping("profile.list")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public ProfileDataInfos listProfiles();
+ public ProfileDataInfos listProfiles(
+ @QueryParam("start") Integer start,
+ @QueryParam("size") Integer size);
@GET
@Path("{id}")
diff --git a/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java b/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java
index 7e9445dbc..157c8db26 100644
--- a/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java
+++ b/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java
@@ -17,61 +17,9 @@
//--- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.request;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.netscape.certsrv.base.Link;
+import com.netscape.certsrv.base.DataCollection;
//Convenience class to simply hold a Collection of CMSRequests and a List of Links.
-public class CMSRequestInfos {
-
- protected Collection<CMSRequestInfo> requests = new ArrayList<CMSRequestInfo>();
- protected List<Link> links = new ArrayList<Link>();
-
- /**
- * @return the requests
- */
- public Collection<CMSRequestInfo> getRequests() {
- return requests;
- }
-
- /**
- * @param requests the requests to set
- */
- public void setRequests(Collection<CMSRequestInfo> requests) {
- this.requests.clear();
- if (requests == null) return;
- this.requests.addAll(requests);
- }
-
- /**
- * @param requests the requests to add
- */
- public void addRequest(CMSRequestInfo request) {
- requests.add(request);
- }
-
- /**
- * @return the links
- */
- public List<Link> getLinks() {
- return links;
- }
-
- /**
- * @param links the links to set
- */
- public void setLinks(List<Link> links) {
- this.links.clear();
- if (links == null) return;
- this.links.addAll(links);
- }
+public class CMSRequestInfos extends DataCollection<CMSRequestInfo> {
- /**
- * @param links the link to add
- */
- public void addLink(Link link) {
- links.add(link);
- }
}
diff --git a/base/common/src/com/netscape/certsrv/system/TPSConnectorResource.java b/base/common/src/com/netscape/certsrv/system/TPSConnectorResource.java
index c29fa3d19..aeee39071 100644
--- a/base/common/src/com/netscape/certsrv/system/TPSConnectorResource.java
+++ b/base/common/src/com/netscape/certsrv/system/TPSConnectorResource.java
@@ -43,7 +43,9 @@ import com.netscape.certsrv.key.KeyData;
public interface TPSConnectorResource {
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public TPSConnectorCollection findConnectors(Integer start, Integer size);
+ public TPSConnectorCollection findConnectors(
+ @QueryParam("start") Integer start,
+ @QueryParam("size") Integer size);
@GET
@Path("{id}")
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
index 7f8eb75f1..97a76d793 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertFindCLI.java
@@ -21,6 +21,7 @@ package com.netscape.cmstools.cert;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
import javax.xml.bind.JAXBException;
@@ -29,7 +30,6 @@ import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
-import com.netscape.certsrv.base.PKIException;
import com.netscape.certsrv.cert.CertDataInfo;
import com.netscape.certsrv.cert.CertDataInfos;
import com.netscape.certsrv.cert.CertSearchRequest;
@@ -118,24 +118,15 @@ public class CertFindCLI extends CLI {
addSearchAttribute(cmd, searchData);
- CertDataInfos certs = null;
- try {
- certs = certCLI.certClient.findCerts(searchData, start, size);
- } catch (PKIException e) {
- System.err.println("Error: Cannot list certificates. " + e.getMessage());
- System.exit(1);
- }
-
- if (certs.getCertInfos() == null || certs.getCertInfos().isEmpty()) {
- MainCLI.printMessage("No certificates found");
- System.exit(0); // valid result
- }
+ CertDataInfos certs = certCLI.certClient.findCerts(searchData, start, size);
- MainCLI.printMessage(certs.getCertInfos().size() + " certificate(s) found");
+ MainCLI.printMessage(certs.getTotal() + " entries found");
+ if (certs.getTotal() == 0) return;
boolean first = true;
- for (CertDataInfo cert : certs.getCertInfos()) {
+ Collection<CertDataInfo> entries = certs.getEntries();
+ for (CertDataInfo cert : entries) {
if (first) {
first = false;
} else {
@@ -145,7 +136,7 @@ public class CertFindCLI extends CLI {
CertCLI.printCertInfo(cert);
}
- MainCLI.printMessage("Number of entries returned " + certs.getCertInfos().size());
+ MainCLI.printMessage("Number of entries returned " + certs.getEntries().size());
}
public void addOptions() {
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestFindCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestFindCLI.java
index 79970393c..d09c7698f 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestFindCLI.java
@@ -18,11 +18,12 @@
package com.netscape.cmstools.cert;
+import java.util.Collection;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
-import com.netscape.certsrv.base.PKIException;
import com.netscape.certsrv.cert.CertRequestInfo;
import com.netscape.certsrv.cert.CertRequestInfos;
import com.netscape.certsrv.request.RequestId;
@@ -50,7 +51,6 @@ public class CertRequestFindCLI extends CLI {
addOptions();
CommandLine cmd = null;
- CertRequestInfos certRequests = null;
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
@@ -82,19 +82,15 @@ public class CertRequestFindCLI extends CLI {
String requestType = cmd.getOptionValue("type");
if (requestType != null && requestType.equals("all")) requestType = null;
- try {
- certRequests = certCLI.certClient.certRequestClient.listRequests(requestState, requestType, start, size, maxResults, maxTime);
- } catch (PKIException e) {
- System.err.println("Error: Cannot list certificate requests. " + e.getMessage());
- System.exit(-1);
- }
- if (certRequests.getRequests() == null || certRequests.getRequests().isEmpty()) {
- MainCLI.printMessage("No matches found.");
- System.exit(-1);
- }
+ CertRequestInfos response = certCLI.certClient.certRequestClient.listRequests(requestState, requestType, start, size, maxResults, maxTime);
+ MainCLI.printMessage(response.getTotal() + " entries matched");
+ if (response.getTotal() == 0) return;
+
+ Collection<CertRequestInfo> entries = response.getEntries();
boolean first = true;
- for (CertRequestInfo certRequest : certRequests.getRequests()) {
+
+ for (CertRequestInfo certRequest : entries) {
if (first) {
first = false;
} else {
@@ -104,7 +100,7 @@ public class CertRequestFindCLI extends CLI {
CertCLI.printCertRequestInfo(certRequest);
}
- MainCLI.printMessage("Number of entries returned " + certRequests.getRequests().size());
+ MainCLI.printMessage("Number of entries returned " + entries.size());
}
public void addOptions() {
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestProfileFindCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestProfileFindCLI.java
index 48c051905..72172535a 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestProfileFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestProfileFindCLI.java
@@ -2,7 +2,12 @@ package com.netscape.cmstools.cert;
import java.util.Collection;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.ParseException;
+
import com.netscape.certsrv.profile.ProfileDataInfo;
+import com.netscape.certsrv.profile.ProfileDataInfos;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
import com.netscape.cmstools.profile.ProfileCLI;
@@ -21,7 +26,38 @@ public class CertRequestProfileFindCLI extends CLI {
}
public void execute(String[] args) throws Exception {
- Collection<ProfileDataInfo> infos = certCLI.certClient.listEnrollmentTemplates().getProfileInfos();
+
+ Option option = new Option(null, "start", true, "Page start");
+ option.setArgName("start");
+ options.addOption(option);
+
+ option = new Option(null, "size", true, "Page size");
+ option.setArgName("size");
+ options.addOption(option);
+
+ CommandLine cmd = null;
+
+ try {
+ cmd = parser.parse(options, args);
+
+ } catch (ParseException e) {
+ System.err.println("Error: " + e.getMessage());
+ printHelp();
+ System.exit(1);
+ }
+
+ String s = cmd.getOptionValue("start");
+ Integer start = s == null ? null : Integer.valueOf(s);
+
+ s = cmd.getOptionValue("size");
+ Integer size = s == null ? null : Integer.valueOf(s);
+
+ ProfileDataInfos response = certCLI.certClient.listEnrollmentTemplates(start, size);
+
+ MainCLI.printMessage(response.getTotal() + " entries matched");
+ if (response.getTotal() == 0) return;
+
+ Collection<ProfileDataInfo> infos = response.getEntries();
boolean first = true;
for (ProfileDataInfo info: infos) {
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java
index d43763f11..205e2884d 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestSubmitCLI.java
@@ -73,7 +73,7 @@ public class CertRequestSubmitCLI extends CLI {
}
private void printRequestInformation(CertRequestInfos cri) {
- Collection<CertRequestInfo> allRequests = cri.getRequests();
+ Collection<CertRequestInfo> allRequests = cri.getEntries();
boolean first = true;
for (CertRequestInfo x : allRequests) {
if (first) {
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupFindCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupFindCLI.java
index 45c2acf16..b7bc81d90 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupFindCLI.java
@@ -76,11 +76,10 @@ public class GroupFindCLI extends CLI {
GroupCollection response = groupCLI.groupClient.findGroups(filter, start, size);
- Collection<GroupData> entries = response.getEntries();
-
- MainCLI.printMessage(response.getTotal() + " group(s) matched");
+ MainCLI.printMessage(response.getTotal() + " entries matched");
if (response.getTotal() == 0) return;
+ Collection<GroupData> entries = response.getEntries();
boolean first = true;
for (GroupData groupData : entries) {
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
index ee694912d..841a0f8c4 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupMemberFindCLI.java
@@ -82,11 +82,10 @@ public class GroupMemberFindCLI extends CLI {
GroupMemberCollection response = groupMemberCLI.groupClient.findGroupMembers(groupID, start, size);
- Collection<GroupMemberData> entries = response.getEntries();
-
- MainCLI.printMessage(response.getTotal() + " group member(s) matched");
+ MainCLI.printMessage(response.getTotal() + " entries matched");
if (response.getTotal() == 0) return;
+ Collection<GroupMemberData> entries = response.getEntries();
boolean first = true;
for (GroupMemberData groupMemberData : entries) {
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java
index 9a91f37e2..25fe6af3c 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyFindCLI.java
@@ -63,6 +63,14 @@ public class KeyFindCLI extends CLI {
option.setArgName("max time");
options.addOption(option);
+ option = new Option(null, "start", true, "Page start");
+ option.setArgName("start");
+ options.addOption(option);
+
+ option = new Option(null, "size", true, "Page size");
+ option.setArgName("size");
+ options.addOption(option);
+
CommandLine cmd = null;
try {
@@ -83,7 +91,13 @@ public class KeyFindCLI extends CLI {
s = cmd.getOptionValue("maxTime");
Integer maxTime = s == null ? null : Integer.valueOf(s);
- KeyDataInfos keys = keyCLI.keyClient.findKeys(clientID, status, maxResults, maxTime);
+ s = cmd.getOptionValue("start");
+ Integer start = s == null ? null : Integer.valueOf(s);
+
+ s = cmd.getOptionValue("size");
+ Integer size = s == null ? null : Integer.valueOf(s);
+
+ KeyDataInfos keys = keyCLI.keyClient.findKeys(clientID, status, maxResults, maxTime, start, size);
Collection<KeyDataInfo> entries = keys.getKeyInfos();
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyRequestFindCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyRequestFindCLI.java
index d74a2c2f1..5ed2bf729 100644
--- a/base/java-tools/src/com/netscape/cmstools/key/KeyRequestFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/key/KeyRequestFindCLI.java
@@ -106,10 +106,10 @@ public class KeyRequestFindCLI extends CLI {
KeyRequestInfos keys = keyCLI.keyClient.findKeyRequests(
status, type, clientID, start, pageSize, maxResults, maxTime);
- Collection<KeyRequestInfo> entries = keys.getRequests();
-
- MainCLI.printMessage(entries.size() + " key request(s) matched");
+ MainCLI.printMessage(keys.getTotal() + " entries matched");
+ if (keys.getTotal() == 0) return;
+ Collection<KeyRequestInfo> entries = keys.getEntries();
boolean first = true;
for (KeyRequestInfo info : entries) {
diff --git a/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java b/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java
index 08c8496ca..88b817798 100644
--- a/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/logging/ActivityFindCLI.java
@@ -72,11 +72,11 @@ public class ActivityFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
ActivityCollection result = activityCLI.activityClient.findActivities(start, size);
- Collection<ActivityData> activities = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " activity(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<ActivityData> activities = result.getEntries();
boolean first = true;
for (ActivityData activityData : activities) {
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
index 1370319f9..21559551c 100644
--- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileFindCLI.java
@@ -2,7 +2,11 @@ package com.netscape.cmstools.profile;
import java.util.Collection;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
import com.netscape.certsrv.profile.ProfileDataInfo;
+import com.netscape.certsrv.profile.ProfileDataInfos;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -21,7 +25,37 @@ public class ProfileFindCLI extends CLI {
public void execute(String[] args) throws Exception {
- Collection<ProfileDataInfo> infos = profileCLI.profileClient.listProfiles().getProfileInfos();
+ Option option = new Option(null, "start", true, "Page start");
+ option.setArgName("start");
+ options.addOption(option);
+
+ option = new Option(null, "size", true, "Page size");
+ option.setArgName("size");
+ options.addOption(option);
+
+ CommandLine cmd = null;
+
+ try {
+ cmd = parser.parse(options, args);
+
+ } catch (Exception e) {
+ System.err.println("Error: " + e.getMessage());
+ printHelp();
+ System.exit(1);
+ }
+
+ String s = cmd.getOptionValue("start");
+ Integer start = s == null ? null : Integer.valueOf(s);
+
+ s = cmd.getOptionValue("size");
+ Integer size = s == null ? null : Integer.valueOf(s);
+
+ ProfileDataInfos response = profileCLI.profileClient.listProfiles(start, size);
+
+ MainCLI.printMessage(response.getTotal() + " entries matched");
+ if (response.getTotal() == 0) return;
+
+ Collection<ProfileDataInfo> infos = response.getEntries();
boolean first = true;
for (ProfileDataInfo info: infos) {
diff --git a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
index 4570d9a91..241f6c300 100644
--- a/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/selftests/SelfTestFindCLI.java
@@ -72,11 +72,11 @@ public class SelfTestFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
SelfTestCollection result = selfTestCLI.selfTestClient.findSelfTests(start, size);
- Collection<SelfTestData> selfTests = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " self test(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<SelfTestData> selfTests = result.getEntries();
boolean first = true;
for (SelfTestData selfTestInfo : selfTests) {
diff --git a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java
index 737851704..a210d3ab3 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/TPSConnectorFindCLI.java
@@ -72,7 +72,7 @@ public class TPSConnectorFindCLI extends CLI {
TPSConnectorCollection result = tpsConnectorCLI.tpsConnectorClient.findConnectors(start, size);
- MainCLI.printMessage(result.getTotal() + " TPS connector(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
Collection<TPSConnectorData> conns = result.getEntries();
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java
index 81724bb31..683d2891c 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java
@@ -72,11 +72,11 @@ public class AuthenticatorFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
AuthenticatorCollection result = authenticatorCLI.authenticatorClient.findAuthenticators(start, size);
- Collection<AuthenticatorData> authenticators = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " authenticator(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<AuthenticatorData> authenticators = result.getEntries();
boolean first = true;
for (AuthenticatorData authenticatorData : authenticators) {
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java
index 9ba66a62a..12ec1b9da 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/cert/TPSCertFindCLI.java
@@ -72,11 +72,11 @@ public class TPSCertFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
TPSCertCollection result = certCLI.certClient.findCerts(start, size);
- Collection<TPSCertData> certs = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " certificate(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<TPSCertData> certs = result.getEntries();
boolean first = true;
for (TPSCertData certData : certs) {
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java
index 7cb4c1b16..d78727d7b 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java
@@ -72,11 +72,11 @@ public class ConnectionFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
ConnectionCollection result = connectionCLI.connectionClient.findConnections(start, size);
- Collection<ConnectionData> connections = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " connection(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<ConnectionData> connections = result.getEntries();
boolean first = true;
for (ConnectionData connectionData : connections) {
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java
index 907641462..cabacaacd 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java
@@ -72,11 +72,11 @@ public class ProfileFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
ProfileCollection result = profileCLI.profileClient.findProfiles(start, size);
- Collection<ProfileData> profiles = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " profile(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<ProfileData> profiles = result.getEntries();
boolean first = true;
for (ProfileData profileData : profiles) {
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java
index 6e101a049..9d87cc43c 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java
@@ -72,11 +72,11 @@ public class ProfileMappingFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
ProfileMappingCollection result = profileMappingCLI.profileMappingClient.findProfileMappings(start, size);
- Collection<ProfileMappingData> profileMappings = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " profile mapping(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<ProfileMappingData> profileMappings = result.getEntries();
boolean first = true;
for (ProfileMappingData profileMappingData : profileMappings) {
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/token/TokenFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/token/TokenFindCLI.java
index 2e43f3cdd..6cfb1fb00 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/token/TokenFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/token/TokenFindCLI.java
@@ -72,11 +72,11 @@ public class TokenFindCLI extends CLI {
Integer size = s == null ? null : Integer.valueOf(s);
TokenCollection result = tokenCLI.tokenClient.findTokens(start, size);
- Collection<TokenData> tokens = result.getEntries();
- MainCLI.printMessage(result.getTotal() + " token(s) matched");
+ MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
+ Collection<TokenData> tokens = result.getEntries();
boolean first = true;
for (TokenData tokenData : tokens) {
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
index db7c0304b..dd8f68762 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCertFindCLI.java
@@ -82,11 +82,10 @@ public class UserCertFindCLI extends CLI {
UserCertCollection response = userCertCLI.userClient.findUserCerts(userID, start, size);
- Collection<UserCertData> entries = response.getEntries();
-
- MainCLI.printMessage(response.getTotal() + " user cert(s) matched");
+ MainCLI.printMessage(response.getTotal() + " entries matched");
if (response.getTotal() == 0) return;
+ Collection<UserCertData> entries = response.getEntries();
boolean first = true;
for (UserCertData userCertData : entries) {
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java
index ed49d1c65..6142a3712 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserFindCLI.java
@@ -76,11 +76,10 @@ public class UserFindCLI extends CLI {
UserCollection response = userCLI.userClient.findUsers(filter, start, size);
- Collection<UserData> entries = response.getEntries();
-
- MainCLI.printMessage(response.getTotal() + " user(s) matched");
+ MainCLI.printMessage(response.getTotal() + " entries matched");
if (response.getTotal() == 0) return;
+ Collection<UserData> entries = response.getEntries();
boolean first = true;
for (UserData userData : entries) {
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
index 66b8f36bb..33ea72d21 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserMembershipFindCLI.java
@@ -82,11 +82,10 @@ public class UserMembershipFindCLI extends CLI {
UserMembershipCollection response = userMembershipCLI.userClient.findUserMemberships(userID, start, size);
- Collection<UserMembershipData> entries = response.getEntries();
-
- MainCLI.printMessage(response.getTotal() + " membership(s) matched");
+ MainCLI.printMessage(response.getTotal() + " entries matched");
if (response.getTotal() == 0) return;
+ Collection<UserMembershipData> entries = response.getEntries();
boolean first = true;
for (UserMembershipData userMembershipData : entries) {
diff --git a/base/server/cms/src/com/netscape/cms/servlet/cert/CertRequestDAO.java b/base/server/cms/src/com/netscape/cms/servlet/cert/CertRequestDAO.java
index 70433339f..c94ee1496 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/cert/CertRequestDAO.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/cert/CertRequestDAO.java
@@ -93,14 +93,16 @@ public class CertRequestDAO extends CMSRequestDAO {
CMSRequestInfos cmsInfos = listCMSRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
- Collection<? extends CMSRequestInfo> cmsList = cmsInfos.getRequests();
+ ret.setTotal(cmsInfos.getTotal());
+
+ Collection<? extends CMSRequestInfo> cmsList = cmsInfos.getEntries();
// We absolutely know 100% that this list is a list
// of CertRequestInfo objects. This is because the method
// createCMSRequestInfo. Is the only one adding to it
List<CertRequestInfo> list = (List<CertRequestInfo>) cmsList;
- ret.setRequests(list);
+ ret.setEntries(list);
ret.setLinks(cmsInfos.getLinks());
@@ -179,9 +181,11 @@ public class CertRequestDAO extends CMSRequestDAO {
IRequest reqs[] = (IRequest[]) results.get(CAProcessor.ARG_REQUESTS);
for (IRequest req : reqs) {
CertRequestInfo info = CertRequestInfoFactory.create(req, uriInfo);
- ret.addRequest(info);
+ ret.addEntry(info);
}
+ ret.setTotal(ret.getEntries().size());
+
// TODO - what happens if the errorCode is internal error ?
return ret;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java b/base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java
index 483ae139c..1b4954822 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java
@@ -103,6 +103,8 @@ public class CertService extends PKIService implements CertResource {
ICertificateRepository repo;
Random random;
+ public static final int DEFAULT_MAXTIME = 0;
+ public static final int DEFAULT_MAXRESULTS = 20;
public final static int DEFAULT_SIZE = 20;
public CertService() {
@@ -387,36 +389,74 @@ public class CertService extends PKIService implements CertResource {
}
@Override
- public CertDataInfos listCerts(String status, int maxResults, int maxTime) {
- // get ldap filter
+ public CertDataInfos listCerts(String status, Integer maxResults, Integer maxTime, Integer start, Integer size) {
+
+ maxResults = maxResults == null ? DEFAULT_MAXRESULTS : maxResults;
+ maxTime = maxTime == null ? DEFAULT_MAXTIME : maxTime;
+ start = start == null ? 0 : start;
+ size = size == null ? DEFAULT_SIZE : size;
+
String filter = createSearchFilter(status);
- CMS.debug("listKeys: filter is " + filter);
+ CMS.debug("listCerts: filter is " + filter);
- CertDataInfos infos;
+ CertDataInfos infos = new CertDataInfos();
try {
- infos = getCertList(filter, maxResults, maxTime);
+ Enumeration<ICertRecord> e = repo.searchCertificates(filter, maxResults, maxTime);
+ if (e == null) {
+ throw new EBaseException("search results are null");
+ }
+
+ // store non-null results in a list
+ List<CertDataInfo> results = new ArrayList<CertDataInfo>();
+ while (e.hasMoreElements()) {
+ ICertRecord rec = e.nextElement();
+ if (rec == null) continue;
+ results.add(createCertDataInfo(rec));
+ }
+
+ int total = results.size();
+ infos.setTotal(total);
+
+ // return entries in the requested page
+ for (int i = start; i < start + size && i < total ; i++) {
+ infos.addEntry(results.get(i));
+ }
+
+ if (start > 0) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", Math.max(start - size, 0)).build();
+ infos.addLink(new Link("prev", uri));
+ }
+
+ if (start + size < total) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", start + size).build();
+ infos.addLink(new Link("next", uri));
+ }
+
} catch (Exception e) {
e.printStackTrace();
- throw new PKIException("Error listing certs in CertsResourceService.listCerts!", e);
+ throw new PKIException("Error listing certs in CertService.listCerts!", e);
}
+
return infos;
}
@Override
public CertDataInfos searchCerts(CertSearchRequest data, Integer start, Integer size) {
+
if (data == null) {
throw new BadRequestException("Search request is null.");
}
+
start = start == null ? 0 : start;
size = size == null ? DEFAULT_SIZE : size;
String filter = createSearchFilter(data);
CertDataInfos infos = new CertDataInfos();
-
- Enumeration<ICertRecord> e = null;
try {
-
- e = repo.findCertRecords(filter);
+ Enumeration<ICertRecord> e = repo.findCertRecords(filter);
+ if (e == null) {
+ throw new EBaseException("search results are null");
+ }
int i = 0;
@@ -427,13 +467,15 @@ public class CertService extends PKIService implements CertResource {
// return entries up to the page size
for (; i < start + size && e.hasMoreElements(); i++) {
ICertRecord user = e.nextElement();
- infos.addCertData(createCertDataInfo(user));
+ infos.addEntry(createCertDataInfo(user));
}
// count the total entries
for (; e.hasMoreElements(); i++)
e.nextElement();
+ infos.setTotal(i);
+
if (start > 0) {
URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", Math.max(start - size, 0)).build();
infos.addLink(new Link("prev", uri));
@@ -443,48 +485,14 @@ public class CertService extends PKIService implements CertResource {
URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", start + size).build();
infos.addLink(new Link("next", uri));
}
+
} catch (Exception e1) {
- throw new PKIException("Error listing certs in CertsResourceService.listCerts!", e1);
+ throw new PKIException("Error searching certs in CertService.searchCerts!", e1);
}
return infos;
}
- /**
- * Returns list of certs meeting specified search filter.
- * Currently, vlv searches are not used for certs.
- *
- * @param filter
- * @param maxResults
- * @param maxTime
- * @param uriInfo
- * @return
- * @throws EBaseException
- * @throws InvalidKeyException
- */
- private CertDataInfos getCertList(String filter, int maxResults, int maxTime)
- throws EBaseException, InvalidKeyException {
- List<CertDataInfo> list = new ArrayList<CertDataInfo>();
- Enumeration<ICertRecord> e = null;
-
- e = repo.searchCertificates(filter, maxResults, maxTime);
- if (e == null) {
- throw new EBaseException("search results are null");
- }
-
- while (e.hasMoreElements()) {
- ICertRecord rec = e.nextElement();
- if (rec != null) {
- list.add(createCertDataInfo(rec));
- }
- }
-
- CertDataInfos ret = new CertDataInfos();
- ret.setCertInfos(list);
-
- return ret;
- }
-
public CertData getCert(CertRetrievalRequest data, boolean generateNonce) throws EBaseException, CertificateEncodingException {
CertId certId = data.getCertId();
diff --git a/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java b/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
index bef0455a9..49cd4515d 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
@@ -88,14 +88,16 @@ public class KeyRequestDAO extends CMSRequestDAO {
CMSRequestInfos cmsInfos = listCMSRequests(filter, start, pageSize, maxResults, maxTime, uriInfo);
- Collection<? extends CMSRequestInfo> cmsList = cmsInfos.getRequests();
+ ret.setTotal(cmsInfos.getTotal());
+
+ Collection<? extends CMSRequestInfo> cmsList = cmsInfos.getEntries();
// We absolutely know 100% that this list is a list
// of KeyRequestInfo objects. This is because the method
// createCMSRequestInfo. Is the only one adding to it
List<KeyRequestInfo> list = (List<KeyRequestInfo>) cmsList;
- ret.setRequests(list);
+ ret.setEntries(list);
ret.setLinks(cmsInfos.getLinks());
diff --git a/base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java b/base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java
index 90bc61d2d..27cc909e5 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java
@@ -20,8 +20,11 @@ package com.netscape.cms.servlet.key;
import java.math.BigInteger;
+import java.net.URI;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
@@ -32,6 +35,8 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.base.BadRequestException;
import com.netscape.certsrv.base.EBaseException;
@@ -74,15 +79,16 @@ public class KeyService extends PKIService implements KeyResource {
@Context
private HttpServletRequest servletRequest;
- private IKeyRepository repo;
- private IKeyRecoveryAuthority kra;
- private IRequestQueue queue;
-
private final static String LOGGING_SIGNED_AUDIT_SECURITY_DATA_RETRIEVE_KEY =
"LOGGING_SIGNED_AUDIT_SECURITY_DATA_RETRIEVE_KEY_5";
public static final int DEFAULT_MAXRESULTS = 100;
public static final int DEFAULT_MAXTIME = 10;
+ public final static int DEFAULT_SIZE = 20;
+
+ private IKeyRepository repo;
+ private IKeyRecoveryAuthority kra;
+ private IRequestQueue queue;
public KeyService() {
kra = ( IKeyRecoveryAuthority ) CMS.getSubsystem( "kra" );
@@ -288,8 +294,11 @@ public class KeyService extends PKIService implements KeyResource {
* Used to generate list of key infos based on the search parameters
*/
@Override
- public KeyDataInfos listKeys(String clientID, String status, Integer maxResults, Integer maxTime) {
- // auth and authz
+ public KeyDataInfos listKeys(String clientID, String status, Integer maxResults, Integer maxTime,
+ Integer start, Integer size) {
+
+ start = start == null ? 0 : start;
+ size = size == null ? DEFAULT_SIZE : size;
// get ldap filter
String filter = createSearchFilter(status, clientID);
@@ -300,24 +309,42 @@ public class KeyService extends PKIService implements KeyResource {
KeyDataInfos infos = new KeyDataInfos();
try {
- Enumeration<IKeyRecord> e = null;
-
- e = repo.searchKeys(filter, maxResults, maxTime);
+ Enumeration<IKeyRecord> e = repo.searchKeys(filter, maxResults, maxTime);
if (e == null) {
return infos;
}
+ // store non-null results in a list
+ List<KeyDataInfo> results = new ArrayList<KeyDataInfo>();
while (e.hasMoreElements()) {
IKeyRecord rec = e.nextElement();
- if (rec != null) {
- infos.addKeyInfo(createKeyDataInfo(rec));
- }
+ if (rec == null) continue;
+ results.add(createKeyDataInfo(rec));
+ }
+
+ int total = results.size();
+ infos.setTotal(total);
+
+ // return entries in the requested page
+ for (int i = start; i < start + size && i < total; i++) {
+ infos.addEntry(results.get(i));
+ }
+
+ if (start > 0) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", Math.max(start-size, 0)).build();
+ infos.addLink(new Link("prev", uri));
+ }
+
+ if (start + size < total) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", start+size).build();
+ infos.addLink(new Link("next", uri));
}
} catch (EBaseException e) {
e.printStackTrace();
throw new PKIException(e.getMessage());
}
+
return infos;
}
diff --git a/base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java b/base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java
index 1ee810769..02840451c 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java
@@ -96,6 +96,8 @@ public class ProfileService extends PKIService implements ProfileResource {
@Context
private HttpServletRequest servletRequest;
+ public final static int DEFAULT_SIZE = 20;
+
private IProfileSubsystem ps = (IProfileSubsystem) CMS.getSubsystem(IProfileSubsystem.ID);
private IPluginRegistry registry = (IPluginRegistry) CMS.getSubsystem(CMS.SUBSYSTEM_REGISTRY);
private IConfigStore cs = CMS.getConfigStore().getSubStore("profile");
@@ -106,8 +108,11 @@ public class ProfileService extends PKIService implements ProfileResource {
"LOGGING_SIGNED_AUDIT_CONFIG_CERT_PROFILE_3";
@Override
- public ProfileDataInfos listProfiles() {
- List<ProfileDataInfo> list = new ArrayList<ProfileDataInfo>();
+ public ProfileDataInfos listProfiles(Integer start, Integer size) {
+
+ start = start == null ? 0 : start;
+ size = size == null ? DEFAULT_SIZE : size;
+
ProfileDataInfos infos = new ProfileDataInfos();
boolean visibleOnly = true;
@@ -122,24 +127,41 @@ public class ProfileService extends PKIService implements ProfileResource {
principal.hasRole("Certificate Manager Administrators"))) {
visibleOnly = false;
}
- Enumeration<String> profileIds = ps.getProfileIds();
- if (profileIds != null) {
- while (profileIds.hasMoreElements()) {
- String id = profileIds.nextElement();
- ProfileDataInfo info = null;
- try {
- info = createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers));
- } catch (EBaseException e) {
- continue;
- }
- if (info != null) {
- list.add(info);
- }
+ Enumeration<String> e = ps.getProfileIds();
+ if (e == null) return infos;
+
+ // store non-null results in a list
+ List<ProfileDataInfo> results = new ArrayList<ProfileDataInfo>();
+ while (e.hasMoreElements()) {
+ try {
+ String id = e.nextElement();
+ ProfileDataInfo info = createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers));
+ if (info == null) continue;
+ results.add(info);
+ } catch (EBaseException ex) {
+ continue;
}
}
- infos.setProfileInfos(list);
+ int total = results.size();
+ infos.setTotal(total);
+
+ // return entries in the requested page
+ for (int i = start; i < start + size && i < total; i++) {
+ infos.addEntry(results.get(i));
+ }
+
+ if (start > 0) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", Math.max(start-size, 0)).build();
+ infos.addLink(new Link("prev", uri));
+ }
+
+ if (start + size < total) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", start+size).build();
+ infos.addLink(new Link("next", uri));
+ }
+
return infos;
}
diff --git a/base/server/cms/src/com/netscape/cms/servlet/request/CMSRequestDAO.java b/base/server/cms/src/com/netscape/cms/servlet/request/CMSRequestDAO.java
index e54f8a4c6..931ade159 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/request/CMSRequestDAO.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/request/CMSRequestDAO.java
@@ -23,10 +23,11 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authority.IAuthority;
import com.netscape.certsrv.base.EBaseException;
-import com.netscape.certsrv.base.Link;
import com.netscape.certsrv.request.CMSRequestInfo;
import com.netscape.certsrv.request.CMSRequestInfos;
import com.netscape.certsrv.request.IRequest;
@@ -91,6 +92,7 @@ public abstract class CMSRequestDAO {
IRequestVirtualList vlvlist = queue.getPagedRequestsByFilter(start, false, filter,
pageSize + 1, "requestId");
totalSize = vlvlist.getSize();
+ ret.setTotal(totalSize);
current = vlvlist.getCurrentIndex();
int numRecords = (totalSize > (current + pageSize)) ? pageSize :
@@ -98,7 +100,7 @@ public abstract class CMSRequestDAO {
for (int i = 0; i < numRecords; i++) {
IRequest request = vlvlist.getElementAt(i);
- ret.addRequest(createCMSRequestInfo(request, uriInfo));
+ ret.addEntry(createCMSRequestInfo(request, uriInfo));
}
} else {
// The non-vlv requests are indexed, but are not paginated.
@@ -113,9 +115,10 @@ public abstract class CMSRequestDAO {
RequestId rid = requests.nextElement();
IRequest request = queue.findRequest(rid);
if (request != null) {
- ret.addRequest(createCMSRequestInfo(request, uriInfo));
+ ret.addEntry(createCMSRequestInfo(request, uriInfo));
}
}
+ ret.setTotal(ret.getEntries().size());
}
// builder for vlv links
diff --git a/base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java b/base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java
index 56da823d2..cd3ffee5a 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java
@@ -18,6 +18,7 @@
package com.netscape.cms.servlet.request;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
@@ -30,6 +31,8 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.authentication.EAuthException;
import com.netscape.certsrv.authorization.EAuthzException;
@@ -119,13 +122,15 @@ public class CertRequestService extends PKIService implements CertRequestResourc
@Override
public CertRequestInfos enrollCert(CertEnrollmentRequest data) {
- CertRequestInfos infos;
+
if (data == null) {
CMS.debug("enrollCert: data is null");
throw new BadRequestException("Unable to create enrollment reequest: Invalid input data");
}
+
CertRequestDAO dao = new CertRequestDAO();
+ CertRequestInfos infos;
try {
infos = dao.submitRequest(data, servletRequest, uriInfo, getLocale(headers));
} catch (EAuthException e) {
@@ -354,35 +359,54 @@ public class CertRequestService extends PKIService implements CertRequestResourc
}
@Override
- public ProfileDataInfos listEnrollmentTemplates() {
+ public ProfileDataInfos listEnrollmentTemplates(Integer start, Integer size) {
+
+ start = start == null ? DEFAULT_START : start;
+ size = size == null ? DEFAULT_PAGESIZE : size;
+
IProfileSubsystem ps = (IProfileSubsystem) CMS.getSubsystem(IProfileSubsystem.ID);
- List<ProfileDataInfo> list = new ArrayList<ProfileDataInfo>();
- ProfileDataInfos infos = new ProfileDataInfos();
- boolean visibleOnly = true;
if (ps == null) {
- return null;
+ throw new PKIException("Profile subsystem unavailable.");
}
- Enumeration<String> profileIds = ps.getProfileIds();
- if (profileIds != null) {
- while (profileIds.hasMoreElements()) {
- String id = profileIds.nextElement();
- ProfileDataInfo info = null;
- try {
- info = ProfileService.createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers));
- } catch (EBaseException e) {
- continue;
- }
+ ProfileDataInfos infos = new ProfileDataInfos();
+ boolean visibleOnly = true;
- if (info != null) {
- list.add(info);
- }
+ Enumeration<String> e = ps.getProfileIds();
+ if (e == null) return infos;
+
+ // store non-null results in a list
+ List<ProfileDataInfo> results = new ArrayList<ProfileDataInfo>();
+ while (e.hasMoreElements()) {
+ try {
+ String id = e.nextElement();
+ ProfileDataInfo info = ProfileService.createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers));
+ if (info == null) continue;
+ results.add(info);
+ } catch (EBaseException ex) {
+ continue;
}
}
- infos.setProfileInfos(list);
+ int total = results.size();
+ infos.setTotal(total);
+
+ // return entries in the requested page
+ for (int i = start; i < start + size && i < total; i++) {
+ infos.addEntry(results.get(i));
+ }
+
+ if (start > 0) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", Math.max(start-size, 0)).build();
+ infos.addLink(new Link("prev", uri));
+ }
+
+ if (start + size < total) {
+ URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", start+size).build();
+ infos.addLink(new Link("next", uri));
+ }
+
return infos;
}
-
}