Set the specified labels for the given array of messages. @param msgs the messages @param labels the labels to add or remove @param set true to add, false to remove @exception MessagingException for failures @since JavaMail 1.5.5
(Message[] msgs, String[] labels, boolean set)
| 136 | * @since JavaMail 1.5.5 |
| 137 | */ |
| 138 | public synchronized void setLabels(Message[] msgs, |
| 139 | String[] labels, boolean set) |
| 140 | throws MessagingException { |
| 141 | checkOpened(); |
| 142 | |
| 143 | if (msgs.length == 0) // boundary condition |
| 144 | return; |
| 145 | |
| 146 | synchronized(messageCacheLock) { |
| 147 | try { |
| 148 | IMAPProtocol ip = getProtocol(); |
| 149 | assert ip instanceof GmailProtocol; |
| 150 | GmailProtocol p = (GmailProtocol)ip; |
| 151 | MessageSet[] ms = Utility.toMessageSetSorted(msgs, null); |
| 152 | if (ms == null) |
| 153 | throw new MessageRemovedException( |
| 154 | "Messages have been removed"); |
| 155 | p.storeLabels(ms, labels, set); |
| 156 | } catch (ConnectionException cex) { |
| 157 | throw new FolderClosedException(this, cex.getMessage()); |
| 158 | } catch (ProtocolException pex) { |
| 159 | throw new MessagingException(pex.getMessage(), pex); |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Set the specified labels for the given range of message numbers. |
no test coverage detected