throw ServiceException.FAILURE("rewriting row data for mailbox " + item.getMailboxId() + ", item " + item.getId(), e);
if (e.getErrorCode() == Db.Error.DUPLICATE_ROW) throw MailServiceException.ALREADY_EXISTS(item.getName(), e); else throw ServiceException.FAILURE("rewriting row data for mailbox " + item.getMailboxId() + ", item " + item.getId(), e);
    public static void saveData(MailItem item, String sender, String metadata)    throws ServiceException {        Mailbox mbox = item.getMailbox();        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        String name = item.getName().equals("") ? null : item.getName();        String subject = item.getSubject();        if (item instanceof Conversation)            subject = ((Conversation) item).getNormalizedSubject();        else if (item instanceof Message)            subject = ((Message) item).getNormalizedSubject();        try {            stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(item) +                    " SET type = ?, parent_id = ?, date = ?, size = ?, blob_digest = ?, flags = ?," +                    "  sender = ?, subject = ?, name = ?, metadata = ?," +                    "  mod_metadata = ?, change_date = ?, mod_content = ?, volume_id = ?" +                    " WHERE " + IN_THIS_MAILBOX_AND + "id = ?");            int pos = 1;            stmt.setByte(pos++, item.getType());            if (item.getParentId() <= 0)                // Messages in virtual conversations are stored with a null parent_id                stmt.setNull(pos++, Types.INTEGER);            else            	stmt.setInt(pos++, item.getParentId());            stmt.setInt(pos++, (int) (item.getDate() / 1000));            stmt.setInt(pos++, item.getSize());            stmt.setString(pos++, item.getDigest(true));            stmt.setInt(pos++, item.getInternalFlagBitmask());            stmt.setString(pos++, checkSenderLength(sender));            stmt.setString(pos++, subject);            stmt.setString(pos++, name);            stmt.setString(pos++, checkTextLength(metadata));            stmt.setInt(pos++, mbox.getOperationChangeID());            stmt.setInt(pos++, mbox.getOperationTimestamp());            stmt.setInt(pos++, item.getSavedSequence());            short vol = item.getVolumeId();            if (vol > 0)                stmt.setShort(pos++, item.getVolumeId());            else                stmt.setNull(pos++, Types.TINYINT);            if (!DebugConfig.disableMailboxGroup)                stmt.setInt(pos++, mbox.getId());            stmt.setInt(pos++, item.getId());            stmt.executeUpdate();                        // Update the flagset cache.  Assume that the item's in-memory            // data has already been updated.            if (areFlagsetsLoaded(mbox.getId())) {                TagsetCache flagsets = getFlagsetCache(conn, mbox);                flagsets.addTagset(item.getInternalFlagBitmask());            }        } catch (SQLException e) {            throw ServiceException.FAILURE("rewriting row data for mailbox " + item.getMailboxId() + ", item " + item.getId(), e);        } finally {            DbPool.closeStatement(stmt);        }    }