1 /****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 ****************************************************************/
19
20 package org.apache.mailet.base.mail;
21
22 import java.io.IOException;
23 import java.io.OutputStream;
24
25 import javax.activation.ActivationDataFlavor;
26 import javax.activation.DataSource;
27 import javax.mail.MessagingException;
28
29
30 /**
31 * <p>Data Content Handler for...</p>
32 * <dl>
33 * <dt>MIME type name</dt><dd>multipart</dd>
34 * <dt>MIME subtype name</dt><dd>report</dd>
35 * </dl>
36 */
37 public class multipart_report extends AbstractDataContentHandler
38 {
39 /**
40 * Default constructor.
41 */
42 public multipart_report()
43 {
44 super();
45 }
46
47 /**
48 * @see org.apache.mailet.base.mail.AbstractDataContentHandler#computeDataFlavor()
49 */
50 protected ActivationDataFlavor computeDataFlavor()
51 {
52 return new ActivationDataFlavor(MimeMultipartReport.class,
53 "multipart/report", "Multipart Report");
54 }
55
56 /**
57 * @see javax.activation.DataContentHandler#writeTo(java.lang.Object,
58 * java.lang.String, java.io.OutputStream)
59 */
60 public void writeTo(Object aPart, String aMimeType, OutputStream aStream)
61 throws IOException
62 {
63 if (!(aPart instanceof MimeMultipartReport))
64 throw new IOException("Type \"" + aPart.getClass().getName()
65 + "\" is not supported.");
66 try
67 {
68 ((MimeMultipartReport) aPart).writeTo(aStream);
69 }
70 catch (MessagingException e)
71 {
72 throw new IOException(e.getMessage());
73 }
74 }
75
76 /**
77 * @see org.apache.mailet.base.mail.AbstractDataContentHandler#computeContent(javax.activation.DataSource)
78 */
79 protected Object computeContent(DataSource aDataSource)
80 throws MessagingException
81 {
82 return new MimeMultipartReport(aDataSource);
83 }
84 }