1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.waarp.openr66.protocol.http.restv2.utils;
22
23 import org.waarp.common.role.RoleDefault;
24 import org.waarp.openr66.database.data.DbTaskRunner;
25 import org.waarp.openr66.pojo.Host;
26 import org.waarp.openr66.pojo.Rule;
27 import org.waarp.openr66.pojo.RuleTask;
28 import org.waarp.openr66.pojo.Transfer;
29
30 import javax.xml.bind.annotation.XmlAccessType;
31 import javax.xml.bind.annotation.XmlAccessorType;
32 import javax.xml.bind.annotation.XmlElement;
33 import javax.xml.bind.annotation.XmlElementWrapper;
34 import javax.xml.bind.annotation.XmlList;
35 import javax.xml.bind.annotation.XmlRootElement;
36 import javax.xml.bind.annotation.XmlType;
37 import java.util.ArrayList;
38 import java.util.List;
39
40 import static org.waarp.openr66.configuration.FileBasedElements.*;
41 import static org.waarp.openr66.configuration.RuleFileBasedConfiguration.*;
42 import static org.waarp.openr66.database.data.DbHostConfiguration.*;
43
44
45
46
47
48
49
50
51
52
53
54
55 @SuppressWarnings("CanBeFinal")
56 @XmlRootElement
57 @XmlAccessorType(XmlAccessType.NONE)
58 public interface XmlSerializable {
59
60
61
62
63
64 @XmlRootElement(name = XML_BUSINESS)
65 final class Businesses implements XmlSerializable {
66
67
68
69 @XmlElement(name = XML_BUSINESSID)
70 public List<String> business = new ArrayList<String>();
71 }
72
73
74
75
76 @XmlRootElement(name = XML_ROLES)
77 final class Roles implements XmlSerializable {
78
79
80
81 @XmlElement(name = XML_ROLE)
82 public List<RoleEntry> roles = new ArrayList<RoleEntry>();
83
84 public Roles() {
85 }
86
87 public Roles(final List<RoleEntry> roles) {
88 this.roles = roles;
89 }
90
91
92
93
94 @XmlType
95 public static final class RoleEntry {
96
97
98
99 @XmlElement(name = XML_ROLEID)
100 public String hostName;
101
102
103
104
105 @XmlElement(name = XML_ROLESET)
106 @XmlList
107 public List<RoleDefault.ROLE> roleList =
108 new ArrayList<RoleDefault.ROLE>();
109 }
110 }
111
112
113
114
115 @XmlRootElement(name = XML_ALIASES)
116 final class Aliases implements XmlSerializable {
117
118
119
120 @XmlElement(name = XML_ALIAS)
121 public List<AliasEntry> aliases = new ArrayList<AliasEntry>();
122
123 public Aliases() {
124 }
125
126 public Aliases(final List<AliasEntry> aliases) {
127 this.aliases = aliases;
128 }
129
130
131
132
133
134 @XmlType
135 public static final class AliasEntry {
136
137
138
139 @XmlElement(name = XML_REALID)
140 public String hostName;
141
142
143
144
145 @XmlElement(name = XML_ALIASID)
146 @XmlList
147 public List<String> aliasList = new ArrayList<String>();
148 }
149 }
150
151
152
153
154 @XmlRootElement(name = XML_AUTHENTICATION_ROOT)
155 final class Hosts implements XmlSerializable {
156
157
158
159 @XmlElement(name = XML_AUTHENTICATION_ENTRY)
160 public List<Host> hosts = new ArrayList<Host>();
161
162 public Hosts() {
163 }
164
165 public Hosts(final List<Host> hosts) {
166 this.hosts = hosts;
167 }
168 }
169
170
171
172
173 @XmlRootElement(name = MULTIPLEROOT)
174 final class Rules implements XmlSerializable {
175
176
177
178 @XmlElement(name = ROOT)
179 public List<Rule> rules = new ArrayList<Rule>();
180
181 public Rules() {
182 }
183
184 public Rules(final List<Rule> rules) {
185 this.rules = rules;
186 }
187
188
189
190
191
192 @XmlType(name = XTASKS)
193 public static final class Tasks {
194
195
196
197 @XmlElementWrapper(name = XTASKS)
198 @XmlElement(name = XTASK)
199 public List<RuleTask> tasks;
200
201 public Tasks() {
202 }
203
204 public Tasks(final List<RuleTask> tasks) {
205 this.tasks = tasks;
206 }
207 }
208 }
209
210
211
212
213 @XmlRootElement(name = DbTaskRunner.XMLRUNNERS)
214 class Transfers implements XmlSerializable {
215 @XmlElement(name = DbTaskRunner.XMLRUNNER)
216 public List<Transfer> transfers = new ArrayList<Transfer>();
217
218 public Transfers() {
219 }
220
221 public Transfers(final List<Transfer> transfers) {
222 this.transfers = transfers;
223 }
224 }
225 }