-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert ca-cert-find server command to paged search
- Loading branch information
Showing
10 changed files
with
321 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* @author Marco Fargetta <[email protected]> | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CAServlet extends HttpServlet { | ||
public static final long serialVersionUID = 1L; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* @author Marco Fargetta <[email protected]> | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
@WebServlet("/v2/info") | ||
public class CAInfoServlet extends CAServlet { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ | |
import com.netscape.cmscore.dbs.RevocationInfo; | ||
|
||
/** | ||
* @author Marco Fargetta <[email protected]> | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
@WebServlet("/v2/certs/*") | ||
public class CertServlet extends CAServlet { | ||
|
36 changes: 36 additions & 0 deletions
36
base/server/src/main/java/com/netscape/certsrv/dbs/DBPagedSearch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// --- BEGIN COPYRIGHT BLOCK --- | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; version 2 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, write to the Free Software Foundation, Inc., | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
// | ||
// (C) 2023 Red Hat, Inc. | ||
// All rights reserved. | ||
// --- END COPYRIGHT BLOCK --- | ||
package com.netscape.certsrv.dbs; | ||
|
||
import java.util.List; | ||
|
||
import com.netscape.certsrv.base.EBaseException; | ||
import com.netscape.cmscore.dbs.CertRecord; | ||
|
||
/** | ||
* A class represents a paged search. | ||
* | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public abstract class DBPagedSearch<E extends IDBObj> { | ||
|
||
public abstract List<CertRecord> getPage() throws EBaseException; | ||
|
||
public abstract List<CertRecord> getPage(int size) throws EBaseException; | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
base/server/src/main/java/com/netscape/cmscore/dbs/CertRecordPagedList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// --- BEGIN COPYRIGHT BLOCK --- | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; version 2 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, write to the Free Software Foundation, Inc., | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
// | ||
// (C) 2023 Red Hat, Inc. | ||
// All rights reserved. | ||
// --- END COPYRIGHT BLOCK --- | ||
package com.netscape.cmscore.dbs; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import com.netscape.certsrv.base.EBaseException; | ||
import com.netscape.certsrv.dbs.DBPagedSearch; | ||
|
||
/** | ||
* Contain all records in a page for a paged search. | ||
* | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CertRecordPagedList implements Iterable<CertRecord> { | ||
public static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CertRecordPagedList.class); | ||
|
||
private DBPagedSearch<CertRecord> pages; | ||
private Iterator<CertRecord> pageEntries; | ||
/** | ||
* Constructs a request paged. | ||
*/ | ||
public CertRecordPagedList(DBPagedSearch<CertRecord> pages) { | ||
this.pages = pages; | ||
try { | ||
pageEntries = pages.getPage().iterator(); | ||
} catch (EBaseException e) { | ||
throw new RuntimeException("CertRecordPagedList: Error to get a new page", e); | ||
} | ||
} | ||
|
||
@Override | ||
public Iterator<CertRecord> iterator() { | ||
return new CertRecordPageIterator(); | ||
} | ||
|
||
class CertRecordPageIterator implements Iterator<CertRecord> { | ||
|
||
@Override | ||
public boolean hasNext() { | ||
if (!pageEntries.hasNext()) { | ||
try { | ||
List<CertRecord> newPage = pages.getPage(); | ||
pageEntries = newPage.iterator(); | ||
} catch (EBaseException e) { | ||
throw new RuntimeException("CertRecordPagedList: Error to get a new page", e); | ||
} | ||
} | ||
return pageEntries.hasNext(); | ||
} | ||
|
||
@Override | ||
public CertRecord next() { | ||
if (hasNext()) { | ||
return pageEntries.next(); | ||
} | ||
return null; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.