Subversion Repositories XServices

Rev

Go to most recent revision | Details | 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
 
17
package net.brutex.xservices.types;
18
 
19
import java.io.File;
20
import java.io.IOException;
21
 
22
import javax.activation.DataHandler;
23
import javax.xml.bind.annotation.XmlElement;
24
import javax.xml.bind.annotation.XmlMimeType;
25
 
26
public class AttachmentType {
27
 
28
	private DataHandler content;
29
	private String filename = null;
30
 
31
	public void setContent(DataHandler content) {
32
		this.content = content;
33
	}
34
 
35
	@XmlMimeType("application/octet-stream")
36
	@XmlElement(required=true)
37
	public DataHandler getContent() {
38
		return content;
39
	}
40
 
41
	public String getFilename() {
42
		if(filename==null || filename.equals("")) {
43
			try {
44
				filename = File.createTempFile("XServices_", ".tmp").getPath();
45
			} catch (IOException e) {
46
				// TODO Auto-generated catch block
47
				e.printStackTrace();
48
			}
49
		}
50
		return filename;
51
	}
52
 
53
	public void setFilename(String filename) {
54
		this.filename = filename;
55
	}
56
 
57
}