String charset = ct.getParameter(Mime.P_CHARSET); if (charset == null) charset = Mime.P_CHARSET_DEFAULT; Reader reader = new InputStreamReader(mpi.getMimePart().getInputStream(), charset);
String charset = mpi.getContentTypeParameter(Mime.P_CHARSET); if (charset == null || charset.trim().equals("")) charset = Mime.P_CHARSET_DEFAULT; Reader reader = new InputStreamReader(mpi.getMimePart().getInputStream(), charset);
    private void analyzePart(MPartInfo mpi, MPartInfo mpiBody, TopLevelMessageHandler allTextHandler)    throws MimeHandlerException, ObjectHandlerException, MessagingException, ServiceException {        ContentType ct = mpi.getContentType();        // ignore multipart "container" parts        if (ct.match(Mime.CT_MULTIPART_WILD))            return;        MimeHandler handler = MimeHandler.getMimeHandler(ct.getBaseType());        assert(handler != null);        boolean isTextType = ct.match(Mime.CT_TEXT_WILD);        boolean isMessageType = ct.match(Mime.CT_MESSAGE_RFC822);        if (handler.isIndexingEnabled()) {            handler.init(mpi.getMimePart().getDataHandler().getDataSource());            handler.setPartName(mpi.getPartName());            handler.setFilename(mpi.getFilename());            try {                handler.setMessageDigest(getRawDigest());            } catch (MessagingException e) {                throw new MimeHandlerException("unable to get message digest", e);            } catch (IOException e) {                throw new MimeHandlerException("unable to get message digest", e);            }            // remember the first iCalendar attachment            if (miCalendar == null)                miCalendar = handler.getICalendar();            if (mpi == mpiBody ||                    (mIndexAttachments && !DebugConfig.disableIndexingAttachmentsTogether)) {                // add ALL TEXT from EVERY PART to the toplevel body content.                // This is necessary for queries with multiple words -- where                // one word is in the body and one is in a sub-attachment.                allTextHandler.addContent(handler.getContent(), mpi == mpiBody);            }            if (mIndexAttachments && !DebugConfig.disableIndexingAttachmentsSeparately &&                    !isTextType && !isMessageType) {                // Each non-text MIME part is also indexed as a separate                // Lucene document.  This is necessary so that we can tell the                // client what parts match if a search matched a particular                // part.                Document doc = handler.getDocument();                if (doc != null) {                    int partSize = mpi.getMimePart().getSize();                    doc.add(Field.Text(LuceneFields.L_SIZE, Integer.toString(partSize)));                    mLuceneDocuments.add(doc);                }            }        }        // make sure we've got the text/calendar handler installed        if (miCalendar == null && ct.match(Mime.CT_TEXT_CALENDAR)) {            if (handler.isIndexingEnabled())                ZimbraLog.index.warn("TextCalendarHandler not correctly installed");            try {                String charset = ct.getParameter(Mime.P_CHARSET);                if (charset == null) charset = Mime.P_CHARSET_DEFAULT;                Reader reader =                    new InputStreamReader(mpi.getMimePart().getInputStream(),                                          charset);                miCalendar = ZCalendarBuilder.build(reader);            } catch (IOException ioe) {                ZimbraLog.index.warn("error reading text/calendar mime part", ioe);            }        }    }