} else if (!ImapFolder.isFolderWritable(folder)) {
} else if (!ImapFolder.isFolderWritable(folder, mSession)) {
    boolean doCOPY(String tag, String sequenceSet, String folderName, boolean byUID) throws IOException {        if (!checkState(tag, ImapSession.STATE_SELECTED))            return CONTINUE_PROCESSING;        folderName = ImapFolder.importPath(folderName, mSession);        String command = (byUID ? "UID COPY" : "COPY");        String copyuid = "";        List<MailItem> newMessages = new ArrayList<MailItem>();        try {            Folder folder = mMailbox.getFolderByPath(getContext(), folderName);            if (!ImapFolder.isFolderVisible(folder)) {                ZimbraLog.imap.info(command + " failed: folder is hidden: " + folderName);                sendNO(tag, command + " failed");                return CONTINUE_PROCESSING;            } else if (!ImapFolder.isFolderWritable(folder)) {                ZimbraLog.imap.info(command + " failed: folder is READ-ONLY: " + folderName);                sendNO(tag, command + " failed: target mailbox is READ-ONLY");                return CONTINUE_PROCESSING;            }            Set<ImapMessage> i4set;            synchronized (mMailbox) {                i4set = mSession.getFolder().getSubsequence(sequenceSet, byUID);            }            // RFC 2180 4.4.1: "The server MAY disallow the COPY of messages in a multi-            //                  accessed mailbox that contains expunged messages."            if (i4set.contains(null) && !byUID) {                sendNO(tag, "COPY rejected because some of the requested messages were expunged");                return CONTINUE_PROCESSING;            }            List<Integer> srcUIDs = new ArrayList<Integer>(), copyUIDs = new ArrayList<Integer>();            long checkpoint = System.currentTimeMillis();            for (ImapMessage i4msg : i4set) {                if (i4msg == null)                    continue;                // FIXME: should optimize to a move, as 95% of IMAP COPY ops are really moves...                MailItem copy = mMailbox.copy(getContext(), i4msg.id, MailItem.TYPE_MESSAGE, folder.getId());                if (copy == null)                    continue;                newMessages.add(copy);                srcUIDs.add(i4msg.uid);                copyUIDs.add(copy.getId());                // send a gratuitous untagged response to keep pissy clients from closing the socket from inactivity                long now = System.currentTimeMillis();                if (now - checkpoint > MAXIMUM_IDLE_PROCESSING_MILLIS) {                    sendIdleUntagged();  checkpoint = now;                }            }            if (srcUIDs.size() > 0)                copyuid = "[COPYUID " + ImapFolder.getUIDValidity(folder) + ' ' +                          ImapFolder.encodeSubsequence(srcUIDs) + ' ' +                          ImapFolder.encodeSubsequence(copyUIDs) + "] ";        } catch (IOException e) {            // 6.4.7: "If the COPY command is unsuccessful for any reason, server implementations            //         MUST restore the destination mailbox to its state before the COPY attempt."            deleteMessages(newMessages);            ZimbraLog.imap.warn(command + " failed", e);            sendNO(tag, command + " failed");            return CONTINUE_PROCESSING;        } catch (ServiceException e) {            // 6.4.7: "If the COPY command is unsuccessful for any reason, server implementations            //         MUST restore the destination mailbox to its state before the COPY attempt."            deleteMessages(newMessages);            String rcode = "";            if (e.getCode() == MailServiceException.NO_SUCH_FOLDER) {                ZimbraLog.imap.info(command + " failed: no such folder: " + folderName);                if (ImapFolder.isPathCreatable('/' + folderName))                    rcode = "[TRYCREATE] ";            } else                ZimbraLog.imap.warn(command + " failed", e);            sendNO(tag, rcode + command + " failed");            return canContinue(e);        }        // RFC 2180 4.4: "COPY is the only IMAP4 sequence number command that is safe to allow        //                an EXPUNGE response on.  This is because a client is not permitted        //                to cascade several COPY commands together."        sendNotifications(true, false);    	sendOK(tag, copyuid + command + " completed");        return CONTINUE_PROCESSING;    }