01: package org.springframework.ws.mime;
02:
03: import java.io.File;
04: import java.util.Iterator;
05: import javax.activation.DataHandler;
06:
07: import org.springframework.core.io.InputStreamSource;
08: import org.springframework.ws.WebServiceMessage;
09:
10: /**
11: * Represents a Web service message with MIME attachments. Attachments can be added as a file, an {@link
12: * InputStreamSource}, or a {@link DataHandler}.
13: *
14: * @author Arjen Poutsma
15: * @see Attachment
16: * @since 1.0.0
17: */
18: public interface MimeMessage extends WebServiceMessage {
19:
20: /**
21: * Indicates whether this message is a XOP package.
22: *
23: * @return <code>true</code> when the constraints specified in <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying
24: * XOP Documents</a> are met.
25: * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
26: */
27: boolean isXopPackage();
28:
29: /**
30: * Turns this message into a XOP package.
31: *
32: * @return <code>true</code> when the message is a XOP package
33: * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
34: */
35: boolean convertToXopPackage();
36:
37: /**
38: * Returns the {@link Attachment} with the specified content Id.
39: *
40: * @return the attachment with the specified content id; or <code>null</code> if it cannot be found
41: * @throws AttachmentException in case of errors
42: */
43: Attachment getAttachment(String contentId)
44: throws AttachmentException;
45:
46: /**
47: * Returns an <code>Iterator</code> over all {@link Attachment} objects that are part of this message.
48: *
49: * @return an iterator over all attachments
50: * @throws AttachmentException in case of errors
51: * @see Attachment
52: */
53: Iterator getAttachments() throws AttachmentException;
54:
55: /**
56: * Add an attachment to the message, taking the content from a {@link File}.
57: * <p/>
58: * The content type will be determined by the name of the given content file. Do not use this for temporary files
59: * with arbitrary filenames (possibly ending in ".tmp" or the like)!
60: *
61: * @param contentId the content Id of the attachment
62: * @param file the file to take the content from
63: * @return the added attachment
64: * @throws AttachmentException in case of errors
65: */
66: Attachment addAttachment(String contentId, File file)
67: throws AttachmentException;
68:
69: /**
70: * Add an attachment to the message, taking the content from an {@link InputStreamSource}.
71: * <p/>
72: * Note that the stream returned by the source needs to be a <em>fresh one on each call</em>, as underlying
73: * implementations can invoke {@link InputStreamSource#getInputStream()} multiple times.
74: *
75: * @param contentId the content Id of the attachment
76: * @param inputStreamSource the resource to take the content from (all of Spring's Resource implementations can be
77: * passed in here)
78: * @param contentType the content type to use for the element
79: * @return the added attachment
80: * @throws AttachmentException in case of errors
81: * @see org.springframework.core.io.Resource
82: */
83: Attachment addAttachment(String contentId,
84: InputStreamSource inputStreamSource, String contentType);
85:
86: /**
87: * Add an attachment to the message, taking the content from a {@link DataHandler}.
88: *
89: * @param dataHandler the data handler to take the content from
90: * @return the added attachment
91: * @throws AttachmentException in case of errors
92: */
93: Attachment addAttachment(String contentId, DataHandler dataHandler);
94: }
|