Skip to content

Commit

Permalink
Move RequestQueue.findRequestBySourceId() to RequestRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Nov 13, 2023
1 parent 317e715 commit 6a47b03
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import com.netscape.cmscore.connector.HttpRequestEncoder;
import com.netscape.cmscore.request.Request;
import com.netscape.cmscore.request.RequestQueue;
import com.netscape.cmscore.request.RequestRepository;

/**
* Clone servlet - part of the Clone Authority (CLA)
Expand Down Expand Up @@ -303,14 +302,13 @@ protected IPKIMessage processRequest(
throws EBaseException {
IPKIMessage replymsg = null;
CMSEngine engine = getCMSEngine();
RequestRepository requestRepository = engine.getRequestRepository();
RequestQueue queue = engine.getRequestQueue();
String srcid = source + ":" + msg.getReqId();

logger.info("CloneServlet: processRequest");

// find request in request queue and return result.
RequestId thisreqid = queue.findRequestBySourceId(srcid);
RequestId thisreqid = requestRepository.findRequestBySourceId(srcid);
Request thisreq = null;

if (thisreqid != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ protected IPKIMessage processRequest(
logger.debug(method + "srcid =" + srcid);

// find request in request queue and return result.
RequestId thisreqid = queue.findRequestBySourceId(srcid);
RequestId thisreqid = requestRepository.findRequestBySourceId(srcid);
Request thisreq = null;

if (thisreqid != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,24 +415,6 @@ public void markAsServiced(Request request) throws EBaseException {
}
}

/**
* Locates a request from the SourceId.
*
* @param id a unique identifier for the record that is based on the source
* of the request, and possibly an identify assigned by the source.
* @return The requestid corresponding to this source id. null is
* returned if the source id does not exist.
*/
public RequestId findRequestBySourceId(String id) throws EBaseException {
Collection<RequestRecord> records = requestRepository.findRequestsBySourceId(id);

if (records.isEmpty())
return null;

RequestRecord record = records.iterator().next();
return record.getRequestId();
}

/**
* Protected access for setting the modification time of a request.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,4 +614,22 @@ public Collection<RequestRecord> findRequestsBySourceId(String id) throws EBaseE
String filter = "(" + RequestRecord.ATTR_SOURCE_ID + "=" + id + ")";
return listRequestsByFilter(filter);
}

/**
* Locates a request from the SourceId.
*
* @param id a unique identifier for the record that is based on the source
* of the request, and possibly an identify assigned by the source.
* @return The requestid corresponding to this source id. null is
* returned if the source id does not exist.
*/
public RequestId findRequestBySourceId(String id) throws EBaseException {
Collection<RequestRecord> records = findRequestsBySourceId(id);

if (records.isEmpty())
return null;

RequestRecord record = records.iterator().next();
return record.getRequestId();
}
}

0 comments on commit 6a47b03

Please sign in to comment.