1 | /** |
---|
2 | * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface. |
---|
3 | * Copyright (C) 2012 Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior |
---|
4 | * |
---|
5 | * This program is free software: you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU Affero General Public License as |
---|
7 | * published by the Free Software Foundation, either version 3 of the |
---|
8 | * License, or (at your option) any later version. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | * GNU Affero General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU Affero General Public License |
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | */ |
---|
18 | |
---|
19 | /******************************************************************************\ |
---|
20 | * |
---|
21 | * This product was developed by |
---|
22 | * |
---|
23 | * SERVIÃO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), |
---|
24 | * |
---|
25 | * a government company established under Brazilian law (5.615/70), |
---|
26 | * at Department of Development of Porto Alegre. |
---|
27 | * |
---|
28 | \******************************************************************************/ |
---|
29 | |
---|
30 | package serpro.mailarchiver.service.dto; |
---|
31 | |
---|
32 | import javax.xml.bind.annotation.XmlRootElement; |
---|
33 | import serpro.mailarchiver.domain.metaarchive.BinaryBody; |
---|
34 | import serpro.mailarchiver.domain.metaarchive.ContentTypeField; |
---|
35 | import serpro.mailarchiver.domain.metaarchive.UnstructuredField.ContentTransferEncodingField; |
---|
36 | |
---|
37 | @XmlRootElement(name="Attachment") |
---|
38 | public class TAttachment implements Identifiable, Comparable<TAttachment> { |
---|
39 | |
---|
40 | private String id; |
---|
41 | @Override |
---|
42 | public String getId() { return id; } |
---|
43 | @Override |
---|
44 | public void setId(String id) { this.id = id; } |
---|
45 | |
---|
46 | //-------------------------------------------------------------------------- |
---|
47 | private String name; |
---|
48 | public String getName() { return name; } |
---|
49 | public void setName(String name) { this.name = name; } |
---|
50 | |
---|
51 | //-------------------------------------------------------------------------- |
---|
52 | private long size; |
---|
53 | public long getSize() { return size; } |
---|
54 | public void setSize(long size) { this.size = size; } |
---|
55 | |
---|
56 | //-------------------------------------------------------------------------- |
---|
57 | private String contentType; |
---|
58 | public String getContentType() { return contentType; } |
---|
59 | public void setContentType(String contentType) { this.contentType = contentType; } |
---|
60 | |
---|
61 | //-------------------------------------------------------------------------- |
---|
62 | private String encoding; |
---|
63 | public String getEncodinng() { return encoding; } |
---|
64 | public void setEncoding(String encoding) { this.encoding = encoding; } |
---|
65 | |
---|
66 | //-------------------------------------------------------------------------- |
---|
67 | // TODO ? |
---|
68 | //private String url; |
---|
69 | |
---|
70 | //========================================================================== |
---|
71 | public TAttachment() {} |
---|
72 | |
---|
73 | public TAttachment(BinaryBody body) { |
---|
74 | |
---|
75 | id = body.getOid(); |
---|
76 | |
---|
77 | name = "todo"; |
---|
78 | |
---|
79 | size = body.getSize(); |
---|
80 | |
---|
81 | ContentTypeField contentTypeField = body.getEntity().getContentTypeField(); |
---|
82 | contentType = (contentTypeField != null) ? contentTypeField.getMediaType() + "/" + contentTypeField.getSubType() : ""; |
---|
83 | |
---|
84 | ContentTransferEncodingField contentTransferEncodingField = body.getEntity().getContentTransferEncoding(); |
---|
85 | encoding = (contentTransferEncodingField != null) ? contentTransferEncodingField.getEncoding() : ""; |
---|
86 | |
---|
87 | |
---|
88 | //DEBUG |
---|
89 | System.out.println(toString()); |
---|
90 | } |
---|
91 | |
---|
92 | @Override |
---|
93 | public String toString() { |
---|
94 | return String.format( |
---|
95 | "TAttachment%n" |
---|
96 | + "%1$sid: %2$s%n" |
---|
97 | + "%1$sname: %3$s%n" |
---|
98 | + "%1$ssize: %4$d%n" |
---|
99 | + "%1$scontentType: %5$s%n" |
---|
100 | + "%1$sencoding: %6$s" |
---|
101 | , " " |
---|
102 | , id |
---|
103 | , name |
---|
104 | , size |
---|
105 | , contentType |
---|
106 | , encoding); |
---|
107 | } |
---|
108 | |
---|
109 | //========================================================================== |
---|
110 | @Override |
---|
111 | public int compareTo(TAttachment o) { |
---|
112 | return getName().compareTo(o.getName()); |
---|
113 | } |
---|
114 | } |
---|