Subversion Repositories XServices

Rev

Rev 81 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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