}
idList.add(suppliedId);
if (receiptHandle.isEmpty()) {
failedList.add(new CQSBatchResultErrorEntry(suppliedId, true, "ReceiptHandleIsInvalid", "No Value Found for " + this.actionName + CQSConstants.REQUEST_ENTRY + index + "." + CQSConstants.RECEIPT_HANDLE));
} else {
String visibilityTimeoutStr = request.getParameter(this.actionName + CQSConstants.REQUEST_ENTRY + index + "." + CQSConstants.VISIBILITY_TIMEOUT);
if (visibilityTimeoutStr != null) {
Integer visibilityTimeout = Integer.parseInt(visibilityTimeoutStr);
if (visibilityTimeout < 0 || visibilityTimeout > CMBProperties.getInstance().getCQSMaxVisibilityTimeOut()) {
throw new CMBException(CMBErrorCodes.InvalidParameterValue, "VisibilityTimeout is limited from 0 to " + CMBProperties.getInstance().getCQSMaxVisibilityTimeOut() + " seconds");
}
}
idMap.put(suppliedId, Arrays.asList(receiptHandle, visibilityTimeoutStr));
}
index++;
suppliedId = request.getParameter(this.actionName + CQSConstants.REQUEST_ENTRY + index + ".Id");
receiptHandle = request.getParameter(this.actionName + CQSConstants.REQUEST_ENTRY + index + "." + CQSConstants.RECEIPT_HANDLE);
}
if (idMap.size() == 0) {
throw new CMBException(CMBErrorCodes.InvalidQueryParameter, "Both user supplied message Id and receiptHandle are required");
}
List<String> successList = new ArrayList<String>();
for (Map.Entry<String, List<String>> entry : idMap.entrySet()) {
if (PersistenceFactory.getCQSMessagePersistence().changeMessageVisibility(queue, entry.getValue().get(0), Integer.parseInt(entry.getValue().get(1)))) {
successList.add(entry.getKey());
} else {
failedList.add(new CQSBatchResultErrorEntry(entry.getKey(), true, "ReceiptHandleIsInvalid", "The input receipt handle is invalid."));
}
}
String out = CQSMessagePopulator.getChangeMessageVisibilityBatchResponse(successList, failedList);
writeResponse(out, response);