public String getPreamble() { return ((Multipart) mimeMessage.getBody()).getPreamble(); }
@Override public void close() { if (mimeMessage != null) { try { mimeMessage.dispose(); } catch (Exception e) { } } }
public InputStream getBody() throws IOException { Body body = bodyPart.getBody(); InputStream result = null; if (body instanceof TextBody) { throw new UnsupportedOperationException(); /* InputStreamReader reader = (InputStreamReader)((TextBody) body).getReader(); StringBuilder inputBuilder = new StringBuilder(); char[] buffer = new char[1024]; while (true) { int readCount = reader.read(buffer); if (readCount < 0) { break; } inputBuilder.append(buffer, 0, readCount); } String str = inputBuilder.toString(); return new ByteArrayInputStream(str.getBytes(reader.getEncoding())); */ } else if (body instanceof BinaryBody) { return ((BinaryBody)body).getInputStream(); } return result; }
public MultipartBuilder addBinaryPart(byte[] bin, String mimeType) throws IOException { BinaryBody body = bodyFactory != null ? bodyFactory.binaryBody(InputStreams.create(bin)) : BasicBodyFactory.INSTANCE.binaryBody(bin); BodyPart bodyPart = BodyPartBuilder.create() .setBody(body) .setContentType(mimeType != null ? mimeType : "application/octet-stream") .setContentTransferEncoding("base64") .build(); return addBodyPart(bodyPart); }
public MultipartBuilder addBodyPart(BodyPartBuilder bodyPart) { return this.addBodyPart(bodyPart.build()); }
public Multipart newMultipart(MultipartBuilder source) { return newMultipart(source.build()); }
String contentDispositionType = maximalBody.getContentDispositionType(); if (contentDispositionType != null && !contentDispositionType.isEmpty()) { StringBuilder contentDisposition = new StringBuilder(contentDispositionType); Map<String, String> contentDispositionParameters = maximalBody.getContentDispositionParameters(); for (Entry<String, String> param : contentDispositionParameters.entrySet()) { contentDisposition.append("; ") String contentDispositionFileName = maximalBody.getContentDispositionFilename(); if (contentDispositionFileName != null) { submd.set(TikaCoreProperties.RESOURCE_NAME_KEY, contentDispositionFileName);
protected void extractParts() throws IOException { Multipart multipart = (Multipart) mimeMessage.getBody(); for (BodyPart bodyPart : multipart.getBodyParts()) parts.add(extractPart(bodyPart)); }
body = factory.binaryBody(decodedStream); entity.setBody(body);
/** * @see org.apache.james.mime4j.parser.AbstractContentHandler#startHeader() */ @Override public final void startHeader() { currHeader = new HeaderImpl(); }
MimeStreamParser parser = new MimeStreamParser(config, null, new DefaultBodyDescriptorBuilder()); XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
@Override protected InputPart extractPart(BodyPart bodyPart) throws IOException { InputPart currPart = super.extractPart(bodyPart); Field disposition = bodyPart.getHeader().getField( FieldName.CONTENT_DISPOSITION); if (disposition == null) throw new RuntimeException(Messages.MESSAGES.couldFindNoContentDispositionHeader()); if (disposition instanceof ContentDispositionField) { String name = ((ContentDispositionField) disposition) .getParameter("name"); List<InputPart> list = formDataMap.get(name); if (list == null) { list = new LinkedList<InputPart>(); formDataMap.put(name, list); } list.add(currPart); } else { throw new RuntimeException(Messages.MESSAGES.couldNotParseContentDisposition(disposition)); } return currPart; }
public MultipartInputImpl(final Multipart multipart, final Providers workers) throws IOException { for (BodyPart bodyPart : multipart.getBodyParts()) parts.add(extractPart(bodyPart)); this.workers = workers; }
@Override public void parse(InputStream is) throws IOException { super.parse(is); ContentTypeField contentTypeField = (ContentTypeField) mimeMessage .getHeader().getField(FieldName.CONTENT_TYPE); start = contentTypeField.getParameter("start"); startInfo = contentTypeField.getParameter("start-info"); type = contentTypeField.getParameter("type"); rootPart = start == null ? getParts().get(0) : relatedMap.get(start); }
public PartImpl(final BodyPart bodyPart) { this.bodyPart = bodyPart; for (Field field : bodyPart.getHeader()) { headers.add(field.getName(), field.getBody()); if (field instanceof ContentTypeField) { contentType = MediaType.valueOf(field.getBody()); contentTypeFromMessage = true; } } if (contentType == null) contentType = defaultPartContentType; if (getCharset(contentType) == null) { if (defaultPartCharset != null) { contentType = getMediaTypeWithDefaultCharset(contentType); } else if (contentType.getType().equalsIgnoreCase("text")) { contentType = getMediaTypeWithCharset(contentType, "us-ascii"); } } }
/** * Returns the value of the <i>From</i> header field of this message as * <code>MailboxList</code> object or <code>null</code> if it is not * present. * * @return value of the from field of this message. */ public MailboxList getFrom() { return getMailboxList(FieldName.FROM); }
public String getPreamble() { return ((Multipart) mimeMessage.getBody()).getPreamble(); }
@Override public void close() { if (mimeMessage != null) { try { mimeMessage.dispose(); } catch (Exception e) { } } }