1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.saaj;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import javax.activation.DataHandler;
22 import javax.xml.soap.AttachmentPart;
23 import javax.xml.soap.SOAPException;
24
25 import org.springframework.util.Assert;
26 import org.springframework.ws.mime.Attachment;
27
28
29
30
31
32
33
34
35 class SaajAttachment implements Attachment {
36
37 private final AttachmentPart saajAttachment;
38
39 public SaajAttachment(AttachmentPart saajAttachment) {
40 Assert.notNull(saajAttachment, "saajAttachment must not be null");
41 this.saajAttachment = saajAttachment;
42 }
43
44 public String getContentId() {
45 return saajAttachment.getContentId();
46 }
47
48 public String getContentType() {
49 return saajAttachment.getContentType();
50 }
51
52 public InputStream getInputStream() throws IOException {
53 try {
54 return saajAttachment.getDataHandler().getInputStream();
55 }
56 catch (SOAPException ex) {
57 throw new SaajAttachmentException(ex);
58 }
59 }
60
61 public long getSize() {
62 try {
63 return saajAttachment.getSize();
64 }
65 catch (SOAPException ex) {
66 throw new SaajAttachmentException(ex);
67 }
68 }
69
70 public DataHandler getDataHandler() {
71 try {
72 return saajAttachment.getDataHandler();
73 }
74 catch (SOAPException ex) {
75 throw new SaajAttachmentException(ex);
76 }
77 }
78 }