in src/main/java/com/uber/cadence/migration/MigrationIWorkflowService.java [312:362]
public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
ListClosedWorkflowExecutionsRequest listRequest) throws TException {
ListClosedWorkflowExecutionsResponse response;
if (listRequest == null) {
throw new BadRequestError("List request is null");
} else if (Strings.isNullOrEmpty(listRequest.getDomain())) {
throw new BadRequestError("Domain is null or empty");
}
if (!listRequest.isSetMaximumPageSize()) {
listRequest.maximumPageSize = _defaultPageSize;
}
if (!listRequest.isSetNextPageToken()
|| listRequest.getNextPageToken().length == 0
|| hasPrefix(listRequest.getNextPageToken(), _marker)) {
if (hasPrefix(listRequest.getNextPageToken(), _marker)) {
listRequest.setNextPageToken(
Arrays.copyOfRange(
listRequest.getNextPageToken(),
_marker.length,
listRequest.getNextPageToken().length));
}
response = serviceNew.ListClosedWorkflowExecutions(listRequest);
if (response == null) return serviceOld.ListClosedWorkflowExecutions(listRequest);
if (response.getExecutionsSize() < listRequest.getMaximumPageSize()) {
int neededPageSize = listRequest.getMaximumPageSize() - response.getExecutionsSize();
ListClosedWorkflowExecutionsRequest copiedRequest =
new ListClosedWorkflowExecutionsRequest(listRequest);
copiedRequest.maximumPageSize = neededPageSize;
ListClosedWorkflowExecutionsResponse fromResponse =
serviceOld.ListClosedWorkflowExecutions(copiedRequest);
if (fromResponse == null) return response;
fromResponse.getExecutions().addAll(response.getExecutions());
return fromResponse;
}
byte[] combinedNextPageToken = new byte[_marker.length + response.getNextPageToken().length];
System.arraycopy(_marker, 0, combinedNextPageToken, 0, _marker.length);
System.arraycopy(
response.getNextPageToken(),
0,
combinedNextPageToken,
_marker.length,
response.getNextPageToken().length);
response.setNextPageToken(combinedNextPageToken);
return response;
}
return serviceOld.ListClosedWorkflowExecutions(listRequest);
}