List<MessageResult> validResults = new ArrayList<MessageResult>();
if (uidList.isEmpty() == false) {
Iterator<MessageResult> results;
if (uidList.size() > 1) {
results = session.getUserMailbox().getMessages(MessageRange.range(uidList.get(0), uidList.get(uidList.size() - 1)), new FetchGroupImpl(FetchGroup.MINIMAL), mailboxSession);
} else {
results = session.getUserMailbox().getMessages(MessageRange.one(uidList.get(0)), new FetchGroupImpl(FetchGroup.MINIMAL), mailboxSession);
}
while (results.hasNext()) {
MessageResult result = results.next();
if (deletedUidList.contains(result.getUid()) == false) {
size += result.getSize();
count++;
validResults.add(result);
}
}
}
StringBuilder responseBuffer = new StringBuilder(32).append(count).append(" ").append(size);
response = new POP3Response(POP3Response.OK_RESPONSE, responseBuffer.toString());
count = 0;
for (int i = 0; i < validResults.size(); i++) {
responseBuffer = new StringBuilder(16).append(i + 1).append(" ").append(validResults.get(i).getSize());
response.appendLine(responseBuffer.toString());
}
response.appendLine(".");
} catch (MailboxException me) {
response = new POP3Response(POP3Response.ERR_RESPONSE);
}
} else {
int num = 0;
try {
num = Integer.parseInt(parameters);
Long uid = uidList.get(num - 1);
if (deletedUidList.contains(uid) == false) {
Iterator<MessageResult> results = session.getUserMailbox().getMessages(MessageRange.one(uid), new FetchGroupImpl(FetchGroup.MINIMAL), mailboxSession);
StringBuilder responseBuffer = new StringBuilder(64).append(num).append(" ").append(results.next().getSize());
response = new POP3Response(POP3Response.OK_RESPONSE, responseBuffer.toString());
} else {
StringBuilder responseBuffer = new StringBuilder(64).append("Message (").append(num).append(") already deleted.");