* See {@link Queue#deleteTaskAsync(List<TaskHandle>)}.
*/
@Override
public Future<List<Boolean>> deleteTaskAsync(List<TaskHandle> taskHandles) {
final TaskQueueDeleteRequest deleteRequest = new TaskQueueDeleteRequest();
deleteRequest.setQueueName(queueName);
for (TaskHandle taskHandle : taskHandles) {
if (taskHandle.getQueueName().equals(this.queueName)) {
deleteRequest.addTaskName(taskHandle.getName());
} else {
throw new QueueNameMismatchException(
String.format("The task %s is associated with the queue named %s "
+ "and cannot be deleted from the queue named %s.",
taskHandle.getName(), taskHandle.getQueueName(), this.queueName));
}
}
Future<TaskQueueDeleteResponse> responseFuture = makeAsyncCall(
"Delete", deleteRequest, new TaskQueueDeleteResponse());
return new FutureAdapter<TaskQueueDeleteResponse, List<Boolean>>(responseFuture) {
@Override
protected List<Boolean> wrap(TaskQueueDeleteResponse deleteResponse) {
List<Boolean> result = new ArrayList<Boolean>(deleteResponse.resultSize());
for (int i = 0; i < deleteResponse.resultSize(); ++i) {
int errorCode = deleteResponse.getResult(i);
if (errorCode != TaskQueueServiceError.ErrorCode.OK.getValue() &&
errorCode != TaskQueueServiceError.ErrorCode.TOMBSTONED_TASK.getValue() &&
errorCode != TaskQueueServiceError.ErrorCode.UNKNOWN_TASK.getValue()) {
throw QueueApiHelper.translateError(errorCode, deleteRequest.getTaskName(i));
}
result.add(errorCode == TaskQueueServiceError.ErrorCode.OK.getValue());
}
return result;