Subversion Repositories XServices

Rev

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

Rev 54 Rev 81
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;
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.XmlElement;
-
 
24
import javax.xml.bind.annotation.XmlMimeType;
23
import javax.xml.bind.annotation.XmlMimeType;
-
 
24
 
-
 
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
 */
25
 
36
@XmlType(name=AttachmentType.XML_NAME, namespace=BrutexNamespaces.WS_XSERVICES)
26
public class AttachmentType {
37
public class AttachmentType {
-
 
38
 
27
	
39
	public static final String XML_NAME="attachment";
28
	private DataHandler content;
40
	private DataHandler content;
29
	private String filename = null;
41
	private String filename = null;
-
 
42
 
-
 
43
	@XmlMimeType("application/octet-stream")
30
 
44
	@XmlElement(minOccurs="1")
31
	public void setContent(DataHandler content) {
45
	public void setContent(DataHandler content) {
32
		this.content = content;
46
		this.content = content;
33
	}
47
	}
34
 
-
 
35
	@XmlMimeType("application/octet-stream")
-
 
36
	@XmlElement(required=true)
48
 
37
	public DataHandler getContent() {
49
	public DataHandler getContent() {
38
		return content;
50
		return content;
39
	}
51
	}
40
	
52
	
41
	public String getFilename() {
53
	public String getFilename() {
42
		if(filename==null || filename.equals("")) {
54
		if(filename==null || filename.equals("")) {
43
			try {
55
			try {
44
				filename = File.createTempFile("XServices_", ".tmp").getPath();
56
				filename = File.createTempFile("XServices_", ".tmp").getPath();
45
			} catch (IOException e) {
57
			} catch (IOException e) {
46
				// TODO Auto-generated catch block
58
				// TODO Auto-generated catch block
47
				e.printStackTrace();
59
				e.printStackTrace();
48
			}
60
			}
49
		}
61
		}
50
		return filename;
62
		return filename;
51
	}
63
	}
52
	
64
	
53
	public void setFilename(String filename) {
65
	public void setFilename(String filename) {
54
		this.filename = filename;
66
		this.filename = filename;
55
	}
67
	}
56
 
68
 
57
}
69
}