1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support;
14
15 import java.io.File;
16 import java.io.IOException;
17
18 import com.eviware.soapui.config.AttachmentConfig;
19 import com.eviware.soapui.impl.support.AbstractHttpRequest;
20 import com.eviware.soapui.impl.support.AbstractHttpRequestInterface;
21 import com.eviware.soapui.impl.wsdl.WsdlAttachmentContainer;
22
23 /***
24 * Attachment for a WsdlRequest
25 *
26 * @author ole.matzura
27 */
28
29 public class RequestFileAttachment extends FileAttachment<AbstractHttpRequest<?>>
30 {
31 public RequestFileAttachment( AttachmentConfig config, AbstractHttpRequestInterface<?> request )
32 {
33 super( ( AbstractHttpRequest<?> )request, config );
34 }
35
36 public RequestFileAttachment( File file, boolean cache, AbstractHttpRequest<?> request ) throws IOException
37 {
38 super( request, file, cache, request.getConfig().addNewAttachment() );
39 }
40
41 public AttachmentEncoding getEncoding()
42 {
43 AbstractHttpRequestInterface<?> request = getModelItem();
44 if( request instanceof WsdlAttachmentContainer && ( ( WsdlAttachmentContainer )request ).isEncodeAttachments() )
45 return ( ( WsdlAttachmentContainer )request ).getAttachmentEncoding( getPart() );
46 else
47 return AttachmentEncoding.NONE;
48 }
49
50 @Override
51 public AttachmentType getAttachmentType()
52 {
53 if( getModelItem() == null || getPart() == null || getModelItem().getAttachmentPart( getPart() ) == null )
54 return AttachmentType.UNKNOWN;
55 else
56 return getModelItem().getAttachmentPart( getPart() ).getAttachmentType();
57 }
58 }