Set the specified flags for the given array of messages.
(Message[] msgs, Flags flag, boolean value)
| 1403 | * Set the specified flags for the given array of messages. |
| 1404 | */ |
| 1405 | @Override |
| 1406 | public synchronized void setFlags(Message[] msgs, Flags flag, boolean value) |
| 1407 | throws MessagingException { |
| 1408 | checkOpened(); |
| 1409 | checkFlags(flag); // validate flags |
| 1410 | |
| 1411 | if (msgs.length == 0) // boundary condition |
| 1412 | return; |
| 1413 | |
| 1414 | synchronized(messageCacheLock) { |
| 1415 | try { |
| 1416 | IMAPProtocol p = getProtocol(); |
| 1417 | if (p.hasCapability("X-UIDONLY") || |
| 1418 | (p.hasCapability("UIDPLUS") && |
| 1419 | Boolean.parseBoolean(System.getProperty("fairemail.uid_command")))) { |
| 1420 | // Verizon |
| 1421 | FetchProfile fp = new FetchProfile(); |
| 1422 | fp.add(UIDFolder.FetchProfileItem.UID); |
| 1423 | fetch(msgs, fp); |
| 1424 | |
| 1425 | UIDSet[] uids = Utility.toUIDSet(msgs); |
| 1426 | if (uids == null) |
| 1427 | return; |
| 1428 | Response[] r = p.command("UID STORE " + UIDSet.toString(uids) + |
| 1429 | " " + (value ? '+' : '-') + "FLAGS " + p.createFlagList(new Flags(flag)), null); |
| 1430 | p.notifyResponseHandlers(r); |
| 1431 | p.handleResult(r[r.length - 1]); |
| 1432 | return; |
| 1433 | } |
| 1434 | MessageSet[] ms = Utility.toMessageSetSorted(msgs, null); |
| 1435 | if (ms == null) |
| 1436 | throw new MessageRemovedException( |
| 1437 | "Messages have been removed"); |
| 1438 | p.storeFlags(ms, flag, value); |
| 1439 | } catch (ConnectionException cex) { |
| 1440 | throw new FolderClosedException(this, cex.getMessage()); |
| 1441 | } catch (ProtocolException pex) { |
| 1442 | throw new MessagingException(pex.getMessage(), pex); |
| 1443 | } |
| 1444 | } |
| 1445 | } |
| 1446 | |
| 1447 | /** |
| 1448 | * Set the specified flags for the given range of message numbers. |
no test coverage detected