stmt.setInt(pos++, mbox.getOperationTimestamp());
    public static void copy(MailItem item, int id, int folderId, int parentId, String metadata) throws ServiceException {        Mailbox mbox = item.getMailbox();        if (id <= 0 || folderId <= 0 || parentId == 0)            throw ServiceException.FAILURE("invalid data for DB item copy", null);        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            String table = getMailItemTableName(mbox);            stmt = conn.prepareStatement("INSERT INTO " + table +                    "(id, type, parent_id, folder_id, index_id, date, size, volume_id, blob_digest," +                    " unread, flags, tags, sender, subject, metadata, mod_metadata, mod_content) " +                    "(SELECT ?, type, ?, ?, index_id, date, size, volume_id, blob_digest, unread," +                    " flags, tags, sender, subject, ?, ?, ? FROM " + table + " WHERE id = ?)");            int pos = 1;            stmt.setInt(pos++, id);            if (parentId <= 0)                stmt.setNull(pos++, Types.INTEGER);            else                stmt.setInt(pos++, parentId);            stmt.setInt(pos++, folderId);            stmt.setString(pos++, metadata);            stmt.setInt(pos++, mbox.getOperationChangeID());            stmt.setInt(pos++, mbox.getOperationChangeID());            stmt.setInt(pos++, item.getId());            int num = stmt.executeUpdate();            if (num != 1)                throw ServiceException.FAILURE("failed to create object", null);        } catch (SQLException e) {            // catch item_id uniqueness constraint violation and return failure            if (e.getErrorCode() == Db.Error.DUPLICATE_ROW)                throw MailServiceException.ALREADY_EXISTS(id, e);            else                throw ServiceException.FAILURE("copying " + MailItem.getNameForType(item.getType()) + ": " + item.getId(), e);        } finally {            DbPool.closeStatement(stmt);        }    }