Subversion Repositories XServices

Rev

Rev 82 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 brianR 1
/*
2
 *   Copyright 2011 Brian Rosenberger (Brutex Network)
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
15
 */
16
 
82 brianR 17
package net.brutex.xservices.types.ant;
54 brianR 18
 
19
import java.io.File;
20
import java.io.IOException;
21
 
22
import javax.activation.DataHandler;
23
import javax.xml.bind.annotation.XmlMimeType;
24
 
81 brianR 25
import net.brutex.xservices.util.BrutexNamespaces;
26
 
27
import org.apache.cxf.aegis.type.java5.XmlElement;
28
import org.apache.cxf.aegis.type.java5.XmlType;
29
 
30
 
31
/**
32
 * Represents a single file based attachment type.
33
 * @author Brian Rosenberger, bru@brutex.de
34
 * @since 0.4.0
35
 */
36
@XmlType(name=AttachmentType.XML_NAME, namespace=BrutexNamespaces.WS_XSERVICES)
54 brianR 37
public class AttachmentType {
81 brianR 38
 
39
	public static final String XML_NAME="attachment";
54 brianR 40
	private DataHandler content;
41
	private String filename = null;
42
 
81 brianR 43
	@XmlMimeType("application/octet-stream")
44
	@XmlElement(minOccurs="1")
54 brianR 45
	public void setContent(DataHandler content) {
46
		this.content = content;
47
	}
48
 
49
	public DataHandler getContent() {
50
		return content;
51
	}
52
 
53
	public String getFilename() {
54
		if(filename==null || filename.equals("")) {
55
			try {
56
				filename = File.createTempFile("XServices_", ".tmp").getPath();
57
			} catch (IOException e) {
58
				// TODO Auto-generated catch block
59
				e.printStackTrace();
60
			}
61
		}
62
		return filename;
63
	}
64
 
65
	public void setFilename(String filename) {
66
		this.filename = filename;
67
	}
68
 
69
}