TagsetCache flagsets = getFlagsetCache(conn, mbox.getId()); flagsets.addTagset(data.flags);
    public static void create(Mailbox mbox, UnderlyingData data) throws ServiceException {        if (data == null || data.id <= 0 || data.folderId <= 0 || data.parentId == 0 || data.indexId == 0)            throw ServiceException.FAILURE("invalid data for DB item create", null);        // TODO: This should be the system-wide current volume, not mailbox's volume.        short volumeId = mbox.getMessageVolumeId();        data.volumeId = volumeId;        Connection conn = mbox.getOperationConnection();        PreparedStatement stmt = null;        try {            stmt = conn.prepareStatement("INSERT INTO " + getMailItemTableName(mbox) +                    "(id, type, parent_id, folder_id, index_id, date, size, volume_id, blob_digest," +                    " unread, flags, tags, sender, subject, metadata, mod_metadata, mod_content) " +                    "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");            int pos = 1;            stmt.setInt(pos++, data.id);            stmt.setByte(pos++, data.type);            if (data.parentId <= 0)                stmt.setNull(pos++, Types.INTEGER);            else                stmt.setInt(pos++, data.parentId);            stmt.setInt(pos++, data.folderId);            if (data.indexId <= 0)                stmt.setNull(pos++, Types.INTEGER);            else                stmt.setInt(pos++, data.indexId);            stmt.setInt(pos++, data.date);            stmt.setInt(pos++, (int) data.size);            stmt.setShort(pos++, data.volumeId);            stmt.setString(pos++, data.blobDigest);//            if (data.type == MailItem.TYPE_MESSAGE || data.type == MailItem.TYPE_INVITE)            if (data.type == MailItem.TYPE_MESSAGE)                stmt.setBoolean(pos++, data.isUnread());            else                stmt.setNull(pos++, java.sql.Types.BOOLEAN);            stmt.setInt(pos++, data.flags);            stmt.setLong(pos++, data.tags);            stmt.setString(pos++, data.sender);            stmt.setString(pos++, data.subject);            stmt.setString(pos++, data.metadata);            stmt.setInt(pos++, data.modMetadata);            stmt.setInt(pos++, data.modContent);            int num = stmt.executeUpdate();            if (num != 1)                throw ServiceException.FAILURE("failed to create object", null);                        TagsetCache tagsets = getTagsetCache(conn, mbox.getId());            tagsets.addTagset(data.tags);        } catch (SQLException e) {            // catch item_id uniqueness constraint violation and return failure            if (e.getErrorCode() == Db.Error.DUPLICATE_ROW)                throw MailServiceException.ALREADY_EXISTS(data.id, e);            else                throw ServiceException.FAILURE("writing new object of type " + data.type, e);        } finally {            DbPool.closeStatement(stmt);        }    }