1 | |
package org.apache.maven.plugins.shade.pom; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
import java.io.OutputStream; |
29 | |
import java.io.OutputStreamWriter; |
30 | |
import java.io.Writer; |
31 | |
import java.util.ArrayList; |
32 | |
import java.util.Collection; |
33 | |
import java.util.Iterator; |
34 | |
import java.util.ListIterator; |
35 | |
import java.util.Map; |
36 | |
|
37 | |
import org.apache.maven.model.ActivationFile; |
38 | |
import org.apache.maven.model.ActivationOS; |
39 | |
import org.apache.maven.model.ActivationProperty; |
40 | |
import org.apache.maven.model.Build; |
41 | |
import org.apache.maven.model.BuildBase; |
42 | |
import org.apache.maven.model.CiManagement; |
43 | |
import org.apache.maven.model.ConfigurationContainer; |
44 | |
import org.apache.maven.model.Contributor; |
45 | |
import org.apache.maven.model.Dependency; |
46 | |
import org.apache.maven.model.DependencyManagement; |
47 | |
import org.apache.maven.model.DeploymentRepository; |
48 | |
import org.apache.maven.model.Developer; |
49 | |
import org.apache.maven.model.DistributionManagement; |
50 | |
import org.apache.maven.model.Exclusion; |
51 | |
import org.apache.maven.model.Extension; |
52 | |
import org.apache.maven.model.FileSet; |
53 | |
import org.apache.maven.model.IssueManagement; |
54 | |
import org.apache.maven.model.License; |
55 | |
import org.apache.maven.model.MailingList; |
56 | |
import org.apache.maven.model.Model; |
57 | |
import org.apache.maven.model.ModelBase; |
58 | |
import org.apache.maven.model.Notifier; |
59 | |
import org.apache.maven.model.Organization; |
60 | |
import org.apache.maven.model.Parent; |
61 | |
import org.apache.maven.model.PatternSet; |
62 | |
import org.apache.maven.model.Plugin; |
63 | |
import org.apache.maven.model.PluginConfiguration; |
64 | |
import org.apache.maven.model.PluginContainer; |
65 | |
import org.apache.maven.model.PluginExecution; |
66 | |
import org.apache.maven.model.PluginManagement; |
67 | |
import org.apache.maven.model.Prerequisites; |
68 | |
import org.apache.maven.model.Profile; |
69 | |
import org.apache.maven.model.Relocation; |
70 | |
import org.apache.maven.model.ReportPlugin; |
71 | |
import org.apache.maven.model.ReportSet; |
72 | |
import org.apache.maven.model.Reporting; |
73 | |
import org.apache.maven.model.Repository; |
74 | |
import org.apache.maven.model.RepositoryBase; |
75 | |
import org.apache.maven.model.RepositoryPolicy; |
76 | |
import org.apache.maven.model.Resource; |
77 | |
import org.apache.maven.model.Scm; |
78 | |
import org.apache.maven.model.Site; |
79 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
80 | |
import org.jdom.Content; |
81 | |
import org.jdom.DefaultJDOMFactory; |
82 | |
import org.jdom.Document; |
83 | |
import org.jdom.Element; |
84 | |
import org.jdom.Text; |
85 | |
import org.jdom.output.Format; |
86 | |
import org.jdom.output.XMLOutputter; |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public class MavenJDOMWriter { |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
private DefaultJDOMFactory factory; |
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
private String lineSeparator; |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | 0 | public MavenJDOMWriter() { |
116 | 0 | factory = new DefaultJDOMFactory(); |
117 | 0 | lineSeparator = "\n"; |
118 | 0 | } |
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
protected Element findAndReplaceProperties(Counter counter, Element parent, String name, Map props) |
134 | |
{ |
135 | 0 | boolean shouldExist = props != null && ! props.isEmpty(); |
136 | 0 | Element element = updateElement(counter, parent, name, shouldExist); |
137 | 0 | if (shouldExist) { |
138 | 0 | Iterator it = props.keySet().iterator(); |
139 | 0 | Counter innerCounter = new Counter(counter.getDepth() + 1); |
140 | 0 | while (it.hasNext()) { |
141 | 0 | String key = (String) it.next(); |
142 | 0 | findAndReplaceSimpleElement(innerCounter, element, key, (String)props.get(key), null); |
143 | 0 | } |
144 | 0 | ArrayList lst = new ArrayList(props.keySet()); |
145 | 0 | it = element.getChildren().iterator(); |
146 | 0 | while (it.hasNext()) { |
147 | 0 | Element elem = (Element) it.next(); |
148 | 0 | String key = elem.getName(); |
149 | 0 | if (!lst.contains(key)) { |
150 | 0 | it.remove(); |
151 | |
} |
152 | 0 | } |
153 | |
} |
154 | 0 | return element; |
155 | |
} |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
protected Element findAndReplaceSimpleElement(Counter counter, Element parent, String name, String text, String defaultValue) |
167 | |
{ |
168 | 0 | if (defaultValue != null && text != null && defaultValue.equals(text)) { |
169 | 0 | Element element = parent.getChild(name, parent.getNamespace()); |
170 | |
|
171 | 0 | if ((element != null && defaultValue.equals(element.getText())) || element == null) { |
172 | 0 | return element; |
173 | |
} |
174 | |
} |
175 | 0 | boolean shouldExist = text != null && text.trim().length() > 0; |
176 | 0 | Element element = updateElement(counter, parent, name, shouldExist); |
177 | 0 | if (shouldExist) { |
178 | 0 | element.setText(text); |
179 | |
} |
180 | 0 | return element; |
181 | |
} |
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
protected Element findAndReplaceSimpleLists(Counter counter, Element parent, java.util.Collection list, String parentName, String childName) |
193 | |
{ |
194 | 0 | boolean shouldExist = list != null && list.size() > 0; |
195 | 0 | Element element = updateElement(counter, parent, parentName, shouldExist); |
196 | 0 | if (shouldExist) { |
197 | 0 | Iterator it = list.iterator(); |
198 | 0 | Iterator elIt = element.getChildren(childName, element.getNamespace()).iterator(); |
199 | 0 | if (! elIt.hasNext()) elIt = null; |
200 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
201 | 0 | while (it.hasNext()) { |
202 | 0 | String value = (String) it.next(); |
203 | |
Element el; |
204 | 0 | if (elIt != null && elIt.hasNext()) { |
205 | 0 | el = (Element) elIt.next(); |
206 | 0 | if (! elIt.hasNext()) elIt = null; |
207 | |
} else { |
208 | 0 | el = factory.element(childName, element.getNamespace()); |
209 | 0 | insertAtPreferredLocation(element, el, innerCount); |
210 | |
} |
211 | 0 | el.setText(value); |
212 | 0 | innerCount.increaseCount(); |
213 | 0 | } |
214 | 0 | if (elIt != null) { |
215 | 0 | while (elIt.hasNext()) { |
216 | 0 | elIt.next(); |
217 | 0 | elIt.remove(); |
218 | |
} |
219 | |
} |
220 | |
} |
221 | 0 | return element; |
222 | |
} |
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
protected Element findAndReplaceXpp3DOM(Counter counter, Element parent, String name, Xpp3Dom dom) |
233 | |
{ |
234 | 0 | boolean shouldExist = dom != null && (dom.getChildCount() > 0 || dom.getValue() != null); |
235 | 0 | Element element = updateElement(counter, parent, name, shouldExist); |
236 | 0 | if (shouldExist) { |
237 | 0 | replaceXpp3DOM(element, dom, new Counter(counter.getDepth() + 1)); |
238 | |
} |
239 | 0 | return element; |
240 | |
} |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
protected void insertAtPreferredLocation(Element parent, Element child, Counter counter) |
250 | |
{ |
251 | 0 | int contentIndex = 0; |
252 | 0 | int elementCounter = 0; |
253 | 0 | Iterator it = parent.getContent().iterator(); |
254 | 0 | Text lastText = null; |
255 | 0 | int offset = 0; |
256 | 0 | while (it.hasNext() && elementCounter <= counter.getCurrentIndex()) { |
257 | 0 | Object next = it.next(); |
258 | 0 | offset = offset + 1; |
259 | 0 | if (next instanceof Element) { |
260 | 0 | elementCounter = elementCounter + 1; |
261 | 0 | contentIndex = contentIndex + offset; |
262 | 0 | offset = 0; |
263 | |
} |
264 | 0 | if (next instanceof Text && it.hasNext()) { |
265 | 0 | lastText = (Text)next; |
266 | |
} |
267 | 0 | } |
268 | 0 | if (lastText != null && lastText.getTextTrim().length() == 0) { |
269 | 0 | lastText = (Text)lastText.clone(); |
270 | |
} else { |
271 | 0 | String starter = lineSeparator; |
272 | 0 | for (int i = 0; i < counter.getDepth(); i++) { |
273 | 0 | starter = starter + " "; |
274 | |
} |
275 | 0 | lastText = factory.text(starter); |
276 | |
} |
277 | 0 | if (parent.getContentSize() == 0) { |
278 | 0 | Text finalText = (Text)lastText.clone(); |
279 | 0 | finalText.setText(finalText.getText().substring(0, finalText.getText().length() - " ".length())); |
280 | 0 | parent.addContent(contentIndex, finalText); |
281 | |
} |
282 | 0 | parent.addContent(contentIndex, child); |
283 | 0 | parent.addContent(contentIndex, lastText); |
284 | 0 | } |
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
protected void iterateContributor(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
296 | |
{ |
297 | 0 | boolean shouldExist = list != null && list.size() > 0; |
298 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
299 | 0 | if (shouldExist) { |
300 | 0 | Iterator it = list.iterator(); |
301 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
302 | 0 | if (!elIt.hasNext()) elIt = null; |
303 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
304 | 0 | while (it.hasNext()) { |
305 | 0 | Contributor value = (Contributor) it.next(); |
306 | |
Element el; |
307 | 0 | if (elIt != null && elIt.hasNext()) { |
308 | 0 | el = (Element) elIt.next(); |
309 | 0 | if (! elIt.hasNext()) elIt = null; |
310 | |
} else { |
311 | 0 | el = factory.element(childTag, element.getNamespace()); |
312 | 0 | insertAtPreferredLocation(element, el, innerCount); |
313 | |
} |
314 | 0 | updateContributor(value, childTag, innerCount, el); |
315 | 0 | innerCount.increaseCount(); |
316 | 0 | } |
317 | 0 | if (elIt != null) { |
318 | 0 | while (elIt.hasNext()) { |
319 | 0 | elIt.next(); |
320 | 0 | elIt.remove(); |
321 | |
} |
322 | |
} |
323 | |
} |
324 | 0 | } |
325 | |
|
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
protected void iterateDependency(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
336 | |
{ |
337 | 0 | boolean shouldExist = list != null && list.size() > 0; |
338 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
339 | 0 | if (shouldExist) { |
340 | 0 | Iterator it = list.iterator(); |
341 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
342 | 0 | if (!elIt.hasNext()) elIt = null; |
343 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
344 | 0 | while (it.hasNext()) { |
345 | 0 | Dependency value = (Dependency) it.next(); |
346 | |
Element el; |
347 | 0 | if (elIt != null && elIt.hasNext()) { |
348 | 0 | el = (Element) elIt.next(); |
349 | 0 | if (! elIt.hasNext()) elIt = null; |
350 | |
} else { |
351 | 0 | el = factory.element(childTag, element.getNamespace()); |
352 | 0 | insertAtPreferredLocation(element, el, innerCount); |
353 | |
} |
354 | 0 | updateDependency(value, childTag, innerCount, el); |
355 | 0 | innerCount.increaseCount(); |
356 | 0 | } |
357 | 0 | if (elIt != null) { |
358 | 0 | while (elIt.hasNext()) { |
359 | 0 | elIt.next(); |
360 | 0 | elIt.remove(); |
361 | |
} |
362 | |
} |
363 | |
} |
364 | 0 | } |
365 | |
|
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
protected void iterateDeveloper(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
376 | |
{ |
377 | 0 | boolean shouldExist = list != null && list.size() > 0; |
378 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
379 | 0 | if (shouldExist) { |
380 | 0 | Iterator it = list.iterator(); |
381 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
382 | 0 | if (!elIt.hasNext()) elIt = null; |
383 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
384 | 0 | while (it.hasNext()) { |
385 | 0 | Developer value = (Developer) it.next(); |
386 | |
Element el; |
387 | 0 | if (elIt != null && elIt.hasNext()) { |
388 | 0 | el = (Element) elIt.next(); |
389 | 0 | if (! elIt.hasNext()) elIt = null; |
390 | |
} else { |
391 | 0 | el = factory.element(childTag, element.getNamespace()); |
392 | 0 | insertAtPreferredLocation(element, el, innerCount); |
393 | |
} |
394 | 0 | updateDeveloper(value, childTag, innerCount, el); |
395 | 0 | innerCount.increaseCount(); |
396 | 0 | } |
397 | 0 | if (elIt != null) { |
398 | 0 | while (elIt.hasNext()) { |
399 | 0 | elIt.next(); |
400 | 0 | elIt.remove(); |
401 | |
} |
402 | |
} |
403 | |
} |
404 | 0 | } |
405 | |
|
406 | |
|
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
protected void iterateExclusion(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
416 | |
{ |
417 | 0 | boolean shouldExist = list != null && list.size() > 0; |
418 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
419 | 0 | if (shouldExist) { |
420 | 0 | Iterator it = list.iterator(); |
421 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
422 | 0 | if (!elIt.hasNext()) elIt = null; |
423 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
424 | 0 | while (it.hasNext()) { |
425 | 0 | Exclusion value = (Exclusion) it.next(); |
426 | |
Element el; |
427 | 0 | if (elIt != null && elIt.hasNext()) { |
428 | 0 | el = (Element) elIt.next(); |
429 | 0 | if (! elIt.hasNext()) elIt = null; |
430 | |
} else { |
431 | 0 | el = factory.element(childTag, element.getNamespace()); |
432 | 0 | insertAtPreferredLocation(element, el, innerCount); |
433 | |
} |
434 | 0 | updateExclusion(value, childTag, innerCount, el); |
435 | 0 | innerCount.increaseCount(); |
436 | 0 | } |
437 | 0 | if (elIt != null) { |
438 | 0 | while (elIt.hasNext()) { |
439 | 0 | elIt.next(); |
440 | 0 | elIt.remove(); |
441 | |
} |
442 | |
} |
443 | |
} |
444 | 0 | } |
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
protected void iterateExtension(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
456 | |
{ |
457 | 0 | boolean shouldExist = list != null && list.size() > 0; |
458 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
459 | 0 | if (shouldExist) { |
460 | 0 | Iterator it = list.iterator(); |
461 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
462 | 0 | if (!elIt.hasNext()) elIt = null; |
463 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
464 | 0 | while (it.hasNext()) { |
465 | 0 | Extension value = (Extension) it.next(); |
466 | |
Element el; |
467 | 0 | if (elIt != null && elIt.hasNext()) { |
468 | 0 | el = (Element) elIt.next(); |
469 | 0 | if (! elIt.hasNext()) elIt = null; |
470 | |
} else { |
471 | 0 | el = factory.element(childTag, element.getNamespace()); |
472 | 0 | insertAtPreferredLocation(element, el, innerCount); |
473 | |
} |
474 | 0 | updateExtension(value, childTag, innerCount, el); |
475 | 0 | innerCount.increaseCount(); |
476 | 0 | } |
477 | 0 | if (elIt != null) { |
478 | 0 | while (elIt.hasNext()) { |
479 | 0 | elIt.next(); |
480 | 0 | elIt.remove(); |
481 | |
} |
482 | |
} |
483 | |
} |
484 | 0 | } |
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
protected void iterateLicense(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
496 | |
{ |
497 | 0 | boolean shouldExist = list != null && list.size() > 0; |
498 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
499 | 0 | if (shouldExist) { |
500 | 0 | Iterator it = list.iterator(); |
501 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
502 | 0 | if (!elIt.hasNext()) elIt = null; |
503 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
504 | 0 | while (it.hasNext()) { |
505 | 0 | License value = (License) it.next(); |
506 | |
Element el; |
507 | 0 | if (elIt != null && elIt.hasNext()) { |
508 | 0 | el = (Element) elIt.next(); |
509 | 0 | if (! elIt.hasNext()) elIt = null; |
510 | |
} else { |
511 | 0 | el = factory.element(childTag, element.getNamespace()); |
512 | 0 | insertAtPreferredLocation(element, el, innerCount); |
513 | |
} |
514 | 0 | updateLicense(value, childTag, innerCount, el); |
515 | 0 | innerCount.increaseCount(); |
516 | 0 | } |
517 | 0 | if (elIt != null) { |
518 | 0 | while (elIt.hasNext()) { |
519 | 0 | elIt.next(); |
520 | 0 | elIt.remove(); |
521 | |
} |
522 | |
} |
523 | |
} |
524 | 0 | } |
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
protected void iterateMailingList(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
536 | |
{ |
537 | 0 | boolean shouldExist = list != null && list.size() > 0; |
538 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
539 | 0 | if (shouldExist) { |
540 | 0 | Iterator it = list.iterator(); |
541 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
542 | 0 | if (!elIt.hasNext()) elIt = null; |
543 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
544 | 0 | while (it.hasNext()) { |
545 | 0 | MailingList value = (MailingList) it.next(); |
546 | |
Element el; |
547 | 0 | if (elIt != null && elIt.hasNext()) { |
548 | 0 | el = (Element) elIt.next(); |
549 | 0 | if (! elIt.hasNext()) elIt = null; |
550 | |
} else { |
551 | 0 | el = factory.element(childTag, element.getNamespace()); |
552 | 0 | insertAtPreferredLocation(element, el, innerCount); |
553 | |
} |
554 | 0 | updateMailingList(value, childTag, innerCount, el); |
555 | 0 | innerCount.increaseCount(); |
556 | 0 | } |
557 | 0 | if (elIt != null) { |
558 | 0 | while (elIt.hasNext()) { |
559 | 0 | elIt.next(); |
560 | 0 | elIt.remove(); |
561 | |
} |
562 | |
} |
563 | |
} |
564 | 0 | } |
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
protected void iterateNotifier(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
576 | |
{ |
577 | 0 | boolean shouldExist = list != null && list.size() > 0; |
578 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
579 | 0 | if (shouldExist) { |
580 | 0 | Iterator it = list.iterator(); |
581 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
582 | 0 | if (!elIt.hasNext()) elIt = null; |
583 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
584 | 0 | while (it.hasNext()) { |
585 | 0 | Notifier value = (Notifier) it.next(); |
586 | |
Element el; |
587 | 0 | if (elIt != null && elIt.hasNext()) { |
588 | 0 | el = (Element) elIt.next(); |
589 | 0 | if (! elIt.hasNext()) elIt = null; |
590 | |
} else { |
591 | 0 | el = factory.element(childTag, element.getNamespace()); |
592 | 0 | insertAtPreferredLocation(element, el, innerCount); |
593 | |
} |
594 | 0 | updateNotifier(value, childTag, innerCount, el); |
595 | 0 | innerCount.increaseCount(); |
596 | 0 | } |
597 | 0 | if (elIt != null) { |
598 | 0 | while (elIt.hasNext()) { |
599 | 0 | elIt.next(); |
600 | 0 | elIt.remove(); |
601 | |
} |
602 | |
} |
603 | |
} |
604 | 0 | } |
605 | |
|
606 | |
|
607 | |
|
608 | |
|
609 | |
|
610 | |
|
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
protected void iteratePlugin(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
616 | |
{ |
617 | 0 | boolean shouldExist = list != null && list.size() > 0; |
618 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
619 | 0 | if (shouldExist) { |
620 | 0 | Iterator it = list.iterator(); |
621 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
622 | 0 | if (!elIt.hasNext()) elIt = null; |
623 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
624 | 0 | while (it.hasNext()) { |
625 | 0 | Plugin value = (Plugin) it.next(); |
626 | |
Element el; |
627 | 0 | if (elIt != null && elIt.hasNext()) { |
628 | 0 | el = (Element) elIt.next(); |
629 | 0 | if (! elIt.hasNext()) elIt = null; |
630 | |
} else { |
631 | 0 | el = factory.element(childTag, element.getNamespace()); |
632 | 0 | insertAtPreferredLocation(element, el, innerCount); |
633 | |
} |
634 | 0 | updatePlugin(value, childTag, innerCount, el); |
635 | 0 | innerCount.increaseCount(); |
636 | 0 | } |
637 | 0 | if (elIt != null) { |
638 | 0 | while (elIt.hasNext()) { |
639 | 0 | elIt.next(); |
640 | 0 | elIt.remove(); |
641 | |
} |
642 | |
} |
643 | |
} |
644 | 0 | } |
645 | |
|
646 | |
|
647 | |
|
648 | |
|
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
protected void iteratePluginExecution(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
656 | |
{ |
657 | 0 | boolean shouldExist = list != null && list.size() > 0; |
658 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
659 | 0 | if (shouldExist) { |
660 | 0 | Iterator it = list.iterator(); |
661 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
662 | 0 | if (!elIt.hasNext()) elIt = null; |
663 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
664 | 0 | while (it.hasNext()) { |
665 | 0 | PluginExecution value = (PluginExecution) it.next(); |
666 | |
Element el; |
667 | 0 | if (elIt != null && elIt.hasNext()) { |
668 | 0 | el = (Element) elIt.next(); |
669 | 0 | if (! elIt.hasNext()) elIt = null; |
670 | |
} else { |
671 | 0 | el = factory.element(childTag, element.getNamespace()); |
672 | 0 | insertAtPreferredLocation(element, el, innerCount); |
673 | |
} |
674 | 0 | updatePluginExecution(value, childTag, innerCount, el); |
675 | 0 | innerCount.increaseCount(); |
676 | 0 | } |
677 | 0 | if (elIt != null) { |
678 | 0 | while (elIt.hasNext()) { |
679 | 0 | elIt.next(); |
680 | 0 | elIt.remove(); |
681 | |
} |
682 | |
} |
683 | |
} |
684 | 0 | } |
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
|
691 | |
|
692 | |
|
693 | |
|
694 | |
|
695 | |
protected void iterateProfile(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
696 | |
{ |
697 | 0 | boolean shouldExist = list != null && list.size() > 0; |
698 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
699 | 0 | if (shouldExist) { |
700 | 0 | Iterator it = list.iterator(); |
701 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
702 | 0 | if (!elIt.hasNext()) elIt = null; |
703 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
704 | 0 | while (it.hasNext()) { |
705 | 0 | Profile value = (Profile) it.next(); |
706 | |
Element el; |
707 | 0 | if (elIt != null && elIt.hasNext()) { |
708 | 0 | el = (Element) elIt.next(); |
709 | 0 | if (! elIt.hasNext()) elIt = null; |
710 | |
} else { |
711 | 0 | el = factory.element(childTag, element.getNamespace()); |
712 | 0 | insertAtPreferredLocation(element, el, innerCount); |
713 | |
} |
714 | 0 | updateProfile(value, childTag, innerCount, el); |
715 | 0 | innerCount.increaseCount(); |
716 | 0 | } |
717 | 0 | if (elIt != null) { |
718 | 0 | while (elIt.hasNext()) { |
719 | 0 | elIt.next(); |
720 | 0 | elIt.remove(); |
721 | |
} |
722 | |
} |
723 | |
} |
724 | 0 | } |
725 | |
|
726 | |
|
727 | |
|
728 | |
|
729 | |
|
730 | |
|
731 | |
|
732 | |
|
733 | |
|
734 | |
|
735 | |
protected void iterateReportPlugin(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
736 | |
{ |
737 | 0 | boolean shouldExist = list != null && list.size() > 0; |
738 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
739 | 0 | if (shouldExist) { |
740 | 0 | Iterator it = list.iterator(); |
741 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
742 | 0 | if (!elIt.hasNext()) elIt = null; |
743 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
744 | 0 | while (it.hasNext()) { |
745 | 0 | ReportPlugin value = (ReportPlugin) it.next(); |
746 | |
Element el; |
747 | 0 | if (elIt != null && elIt.hasNext()) { |
748 | 0 | el = (Element) elIt.next(); |
749 | 0 | if (! elIt.hasNext()) elIt = null; |
750 | |
} else { |
751 | 0 | el = factory.element(childTag, element.getNamespace()); |
752 | 0 | insertAtPreferredLocation(element, el, innerCount); |
753 | |
} |
754 | 0 | updateReportPlugin(value, childTag, innerCount, el); |
755 | 0 | innerCount.increaseCount(); |
756 | 0 | } |
757 | 0 | if (elIt != null) { |
758 | 0 | while (elIt.hasNext()) { |
759 | 0 | elIt.next(); |
760 | 0 | elIt.remove(); |
761 | |
} |
762 | |
} |
763 | |
} |
764 | 0 | } |
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
|
772 | |
|
773 | |
|
774 | |
|
775 | |
protected void iterateReportSet(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
776 | |
{ |
777 | 0 | boolean shouldExist = list != null && list.size() > 0; |
778 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
779 | 0 | if (shouldExist) { |
780 | 0 | Iterator it = list.iterator(); |
781 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
782 | 0 | if (!elIt.hasNext()) elIt = null; |
783 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
784 | 0 | while (it.hasNext()) { |
785 | 0 | ReportSet value = (ReportSet) it.next(); |
786 | |
Element el; |
787 | 0 | if (elIt != null && elIt.hasNext()) { |
788 | 0 | el = (Element) elIt.next(); |
789 | 0 | if (! elIt.hasNext()) elIt = null; |
790 | |
} else { |
791 | 0 | el = factory.element(childTag, element.getNamespace()); |
792 | 0 | insertAtPreferredLocation(element, el, innerCount); |
793 | |
} |
794 | 0 | updateReportSet(value, childTag, innerCount, el); |
795 | 0 | innerCount.increaseCount(); |
796 | 0 | } |
797 | 0 | if (elIt != null) { |
798 | 0 | while (elIt.hasNext()) { |
799 | 0 | elIt.next(); |
800 | 0 | elIt.remove(); |
801 | |
} |
802 | |
} |
803 | |
} |
804 | 0 | } |
805 | |
|
806 | |
|
807 | |
|
808 | |
|
809 | |
|
810 | |
|
811 | |
|
812 | |
|
813 | |
|
814 | |
|
815 | |
protected void iterateRepository(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
816 | |
{ |
817 | 0 | boolean shouldExist = list != null && list.size() > 0; |
818 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
819 | 0 | if (shouldExist) { |
820 | 0 | Iterator it = list.iterator(); |
821 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
822 | 0 | if (!elIt.hasNext()) elIt = null; |
823 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
824 | 0 | while (it.hasNext()) { |
825 | 0 | Repository value = (Repository) it.next(); |
826 | |
Element el; |
827 | 0 | if (elIt != null && elIt.hasNext()) { |
828 | 0 | el = (Element) elIt.next(); |
829 | 0 | if (! elIt.hasNext()) elIt = null; |
830 | |
} else { |
831 | 0 | el = factory.element(childTag, element.getNamespace()); |
832 | 0 | insertAtPreferredLocation(element, el, innerCount); |
833 | |
} |
834 | 0 | updateRepository(value, childTag, innerCount, el); |
835 | 0 | innerCount.increaseCount(); |
836 | 0 | } |
837 | 0 | if (elIt != null) { |
838 | 0 | while (elIt.hasNext()) { |
839 | 0 | elIt.next(); |
840 | 0 | elIt.remove(); |
841 | |
} |
842 | |
} |
843 | |
} |
844 | 0 | } |
845 | |
|
846 | |
|
847 | |
|
848 | |
|
849 | |
|
850 | |
|
851 | |
|
852 | |
|
853 | |
|
854 | |
|
855 | |
protected void iterateResource(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) |
856 | |
{ |
857 | 0 | boolean shouldExist = list != null && list.size() > 0; |
858 | 0 | Element element = updateElement(counter, parent, parentTag, shouldExist); |
859 | 0 | if (shouldExist) { |
860 | 0 | Iterator it = list.iterator(); |
861 | 0 | Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator(); |
862 | 0 | if (!elIt.hasNext()) elIt = null; |
863 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
864 | 0 | while (it.hasNext()) { |
865 | 0 | Resource value = (Resource) it.next(); |
866 | |
Element el; |
867 | 0 | if (elIt != null && elIt.hasNext()) { |
868 | 0 | el = (Element) elIt.next(); |
869 | 0 | if (! elIt.hasNext()) elIt = null; |
870 | |
} else { |
871 | 0 | el = factory.element(childTag, element.getNamespace()); |
872 | 0 | insertAtPreferredLocation(element, el, innerCount); |
873 | |
} |
874 | 0 | updateResource(value, childTag, innerCount, el); |
875 | 0 | innerCount.increaseCount(); |
876 | 0 | } |
877 | 0 | if (elIt != null) { |
878 | 0 | while (elIt.hasNext()) { |
879 | 0 | elIt.next(); |
880 | 0 | elIt.remove(); |
881 | |
} |
882 | |
} |
883 | |
} |
884 | 0 | } |
885 | |
|
886 | |
|
887 | |
|
888 | |
|
889 | |
|
890 | |
|
891 | |
|
892 | |
|
893 | |
protected void replaceXpp3DOM(Element parent, Xpp3Dom parentDom, Counter counter) |
894 | |
{ |
895 | 0 | if (parentDom.getChildCount() > 0) { |
896 | 0 | Xpp3Dom[] childs = parentDom.getChildren(); |
897 | 0 | Collection domChilds = new ArrayList(); |
898 | 0 | for (int i = 0; i < childs.length; i++) { |
899 | 0 | domChilds.add(childs[i]); |
900 | |
} |
901 | |
|
902 | 0 | ListIterator it = parent.getChildren().listIterator(); |
903 | 0 | while (it.hasNext()) { |
904 | 0 | Element elem = (Element) it.next(); |
905 | 0 | Iterator it2 = domChilds.iterator(); |
906 | 0 | Xpp3Dom corrDom = null; |
907 | 0 | while (it2.hasNext()) { |
908 | 0 | Xpp3Dom dm = (Xpp3Dom)it2.next(); |
909 | 0 | if (dm.getName().equals(elem.getName())) { |
910 | 0 | corrDom = dm; |
911 | 0 | break; |
912 | |
} |
913 | 0 | } |
914 | 0 | if (corrDom != null) { |
915 | 0 | domChilds.remove(corrDom); |
916 | 0 | replaceXpp3DOM(elem, corrDom, new Counter(counter.getDepth() + 1)); |
917 | 0 | counter.increaseCount(); |
918 | |
} else { |
919 | 0 | parent.removeContent(elem); |
920 | |
} |
921 | 0 | } |
922 | 0 | Iterator it2 = domChilds.iterator(); |
923 | 0 | while (it2.hasNext()) { |
924 | 0 | Xpp3Dom dm = (Xpp3Dom) it2.next(); |
925 | 0 | Element elem = factory.element(dm.getName(), parent.getNamespace()); |
926 | 0 | insertAtPreferredLocation(parent, elem, counter); |
927 | 0 | counter.increaseCount(); |
928 | 0 | replaceXpp3DOM(elem, dm, new Counter(counter.getDepth() + 1)); |
929 | 0 | } |
930 | 0 | } else if (parentDom.getValue() != null) { |
931 | 0 | parent.setText(parentDom.getValue()); |
932 | |
} |
933 | 0 | } |
934 | |
|
935 | |
|
936 | |
|
937 | |
|
938 | |
|
939 | |
|
940 | |
|
941 | |
|
942 | |
|
943 | |
|
944 | |
|
945 | |
|
946 | |
|
947 | |
|
948 | |
|
949 | |
|
950 | |
|
951 | |
|
952 | |
|
953 | |
|
954 | |
|
955 | |
|
956 | |
|
957 | |
|
958 | |
|
959 | |
|
960 | |
|
961 | |
|
962 | |
|
963 | |
|
964 | |
|
965 | |
|
966 | |
|
967 | |
|
968 | |
|
969 | |
|
970 | |
|
971 | |
|
972 | |
|
973 | |
|
974 | |
|
975 | |
|
976 | |
|
977 | |
|
978 | |
|
979 | |
|
980 | |
|
981 | |
|
982 | |
|
983 | |
|
984 | |
|
985 | |
|
986 | |
|
987 | |
|
988 | |
|
989 | |
protected void updateActivationFile(ActivationFile value, String xmlTag, Counter counter, Element element) |
990 | |
{ |
991 | 0 | boolean shouldExist = value != null; |
992 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
993 | 0 | if (shouldExist) { |
994 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
995 | 0 | findAndReplaceSimpleElement(innerCount, root, "missing", value.getMissing(), null); |
996 | 0 | findAndReplaceSimpleElement(innerCount, root, "exists", value.getExists(), null); |
997 | |
} |
998 | 0 | } |
999 | |
|
1000 | |
|
1001 | |
|
1002 | |
|
1003 | |
|
1004 | |
|
1005 | |
|
1006 | |
|
1007 | |
|
1008 | |
protected void updateActivationOS(ActivationOS value, String xmlTag, Counter counter, Element element) |
1009 | |
{ |
1010 | 0 | boolean shouldExist = value != null; |
1011 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1012 | 0 | if (shouldExist) { |
1013 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1014 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1015 | 0 | findAndReplaceSimpleElement(innerCount, root, "family", value.getFamily(), null); |
1016 | 0 | findAndReplaceSimpleElement(innerCount, root, "arch", value.getArch(), null); |
1017 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1018 | |
} |
1019 | 0 | } |
1020 | |
|
1021 | |
|
1022 | |
|
1023 | |
|
1024 | |
|
1025 | |
|
1026 | |
|
1027 | |
|
1028 | |
|
1029 | |
protected void updateActivationProperty(ActivationProperty value, String xmlTag, Counter counter, Element element) |
1030 | |
{ |
1031 | 0 | boolean shouldExist = value != null; |
1032 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1033 | 0 | if (shouldExist) { |
1034 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1035 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1036 | 0 | findAndReplaceSimpleElement(innerCount, root, "value", value.getValue(), null); |
1037 | |
} |
1038 | 0 | } |
1039 | |
|
1040 | |
|
1041 | |
|
1042 | |
|
1043 | |
|
1044 | |
|
1045 | |
|
1046 | |
|
1047 | |
|
1048 | |
protected void updateBuild(Build value, String xmlTag, Counter counter, Element element) |
1049 | |
{ |
1050 | 0 | boolean shouldExist = value != null; |
1051 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1052 | 0 | if (shouldExist) { |
1053 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1054 | 0 | findAndReplaceSimpleElement(innerCount, root, "sourceDirectory", value.getSourceDirectory(), null); |
1055 | 0 | findAndReplaceSimpleElement(innerCount, root, "scriptSourceDirectory", value.getScriptSourceDirectory(), null); |
1056 | 0 | findAndReplaceSimpleElement(innerCount, root, "testSourceDirectory", value.getTestSourceDirectory(), null); |
1057 | 0 | findAndReplaceSimpleElement(innerCount, root, "outputDirectory", value.getOutputDirectory(), null); |
1058 | 0 | findAndReplaceSimpleElement(innerCount, root, "testOutputDirectory", value.getTestOutputDirectory(), null); |
1059 | 0 | iterateExtension(innerCount, root, value.getExtensions(),"extensions","extension"); |
1060 | 0 | findAndReplaceSimpleElement(innerCount, root, "defaultGoal", value.getDefaultGoal(), null); |
1061 | 0 | iterateResource(innerCount, root, value.getResources(),"resources","resource"); |
1062 | 0 | iterateResource(innerCount, root, value.getTestResources(),"testResources","testResource"); |
1063 | 0 | findAndReplaceSimpleElement(innerCount, root, "directory", value.getDirectory(), null); |
1064 | 0 | findAndReplaceSimpleElement(innerCount, root, "finalName", value.getFinalName(), null); |
1065 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getFilters(), "filters", "filter"); |
1066 | 0 | updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root); |
1067 | 0 | iteratePlugin(innerCount, root, value.getPlugins(),"plugins","plugin"); |
1068 | |
} |
1069 | 0 | } |
1070 | |
|
1071 | |
|
1072 | |
|
1073 | |
|
1074 | |
|
1075 | |
|
1076 | |
|
1077 | |
|
1078 | |
|
1079 | |
protected void updateBuildBase(BuildBase value, String xmlTag, Counter counter, Element element) |
1080 | |
{ |
1081 | 0 | boolean shouldExist = value != null; |
1082 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1083 | 0 | if (shouldExist) { |
1084 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1085 | 0 | findAndReplaceSimpleElement(innerCount, root, "defaultGoal", value.getDefaultGoal(), null); |
1086 | 0 | iterateResource(innerCount, root, value.getResources(),"resources","resource"); |
1087 | 0 | iterateResource(innerCount, root, value.getTestResources(),"testResources","testResource"); |
1088 | 0 | findAndReplaceSimpleElement(innerCount, root, "directory", value.getDirectory(), null); |
1089 | 0 | findAndReplaceSimpleElement(innerCount, root, "finalName", value.getFinalName(), null); |
1090 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getFilters(), "filters", "filter"); |
1091 | 0 | updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root); |
1092 | 0 | iteratePlugin(innerCount, root, value.getPlugins(),"plugins","plugin"); |
1093 | |
} |
1094 | 0 | } |
1095 | |
|
1096 | |
|
1097 | |
|
1098 | |
|
1099 | |
|
1100 | |
|
1101 | |
|
1102 | |
|
1103 | |
|
1104 | |
protected void updateCiManagement(CiManagement value, String xmlTag, Counter counter, Element element) |
1105 | |
{ |
1106 | 0 | boolean shouldExist = value != null; |
1107 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1108 | 0 | if (shouldExist) { |
1109 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1110 | 0 | findAndReplaceSimpleElement(innerCount, root, "system", value.getSystem(), null); |
1111 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1112 | 0 | iterateNotifier(innerCount, root, value.getNotifiers(),"notifiers","notifier"); |
1113 | |
} |
1114 | 0 | } |
1115 | |
|
1116 | |
|
1117 | |
|
1118 | |
|
1119 | |
|
1120 | |
|
1121 | |
|
1122 | |
|
1123 | |
|
1124 | |
protected void updateConfigurationContainer(ConfigurationContainer value, String xmlTag, Counter counter, Element element) |
1125 | |
{ |
1126 | 0 | boolean shouldExist = value != null; |
1127 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1128 | 0 | if (shouldExist) { |
1129 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1130 | 0 | findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null); |
1131 | 0 | findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom)value.getConfiguration()); |
1132 | |
} |
1133 | 0 | } |
1134 | |
|
1135 | |
|
1136 | |
|
1137 | |
|
1138 | |
|
1139 | |
|
1140 | |
|
1141 | |
|
1142 | |
|
1143 | |
protected void updateContributor(Contributor value, String xmlTag, Counter counter, Element element) |
1144 | |
{ |
1145 | 0 | Element root = element; |
1146 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1147 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1148 | 0 | findAndReplaceSimpleElement(innerCount, root, "email", value.getEmail(), null); |
1149 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1150 | 0 | findAndReplaceSimpleElement(innerCount, root, "organization", value.getOrganization(), null); |
1151 | 0 | findAndReplaceSimpleElement(innerCount, root, "organizationUrl", value.getOrganizationUrl(), null); |
1152 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getRoles(), "roles", "role"); |
1153 | 0 | findAndReplaceSimpleElement(innerCount, root, "timezone", value.getTimezone(), null); |
1154 | 0 | findAndReplaceProperties(innerCount, root, "properties", value.getProperties()); |
1155 | 0 | } |
1156 | |
|
1157 | |
|
1158 | |
|
1159 | |
|
1160 | |
|
1161 | |
|
1162 | |
|
1163 | |
|
1164 | |
|
1165 | |
protected void updateDependency(Dependency value, String xmlTag, Counter counter, Element element) |
1166 | |
{ |
1167 | 0 | Element root = element; |
1168 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1169 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null); |
1170 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1171 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1172 | 0 | findAndReplaceSimpleElement(innerCount, root, "type", value.getType(), "jar"); |
1173 | 0 | findAndReplaceSimpleElement(innerCount, root, "classifier", value.getClassifier(), null); |
1174 | 0 | findAndReplaceSimpleElement(innerCount, root, "scope", value.getScope(), null); |
1175 | 0 | findAndReplaceSimpleElement(innerCount, root, "systemPath", value.getSystemPath(), null); |
1176 | 0 | iterateExclusion(innerCount, root, value.getExclusions(),"exclusions","exclusion"); |
1177 | 0 | findAndReplaceSimpleElement(innerCount, root, "optional", value.isOptional() == false ? null : String.valueOf( value.isOptional() ), "false"); |
1178 | 0 | } |
1179 | |
|
1180 | |
|
1181 | |
|
1182 | |
|
1183 | |
|
1184 | |
|
1185 | |
|
1186 | |
|
1187 | |
|
1188 | |
protected void updateDependencyManagement(DependencyManagement value, String xmlTag, Counter counter, Element element) |
1189 | |
{ |
1190 | 0 | boolean shouldExist = value != null; |
1191 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1192 | 0 | if (shouldExist) { |
1193 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1194 | 0 | iterateDependency(innerCount, root, value.getDependencies(),"dependencies","dependency"); |
1195 | |
} |
1196 | 0 | } |
1197 | |
|
1198 | |
|
1199 | |
|
1200 | |
|
1201 | |
|
1202 | |
|
1203 | |
|
1204 | |
|
1205 | |
|
1206 | |
protected void updateDeploymentRepository(DeploymentRepository value, String xmlTag, Counter counter, Element element) |
1207 | |
{ |
1208 | 0 | boolean shouldExist = value != null; |
1209 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1210 | 0 | if (shouldExist) { |
1211 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1212 | 0 | findAndReplaceSimpleElement(innerCount, root, "uniqueVersion", value.isUniqueVersion() == true ? null : String.valueOf( value.isUniqueVersion() ), "true"); |
1213 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); |
1214 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1215 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1216 | 0 | findAndReplaceSimpleElement(innerCount, root, "layout", value.getLayout(), "default"); |
1217 | |
} |
1218 | 0 | } |
1219 | |
|
1220 | |
|
1221 | |
|
1222 | |
|
1223 | |
|
1224 | |
|
1225 | |
|
1226 | |
|
1227 | |
|
1228 | |
protected void updateDeveloper(Developer value, String xmlTag, Counter counter, Element element) |
1229 | |
{ |
1230 | 0 | Element root = element; |
1231 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1232 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); |
1233 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1234 | 0 | findAndReplaceSimpleElement(innerCount, root, "email", value.getEmail(), null); |
1235 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1236 | 0 | findAndReplaceSimpleElement(innerCount, root, "organization", value.getOrganization(), null); |
1237 | 0 | findAndReplaceSimpleElement(innerCount, root, "organizationUrl", value.getOrganizationUrl(), null); |
1238 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getRoles(), "roles", "role"); |
1239 | 0 | findAndReplaceSimpleElement(innerCount, root, "timezone", value.getTimezone(), null); |
1240 | 0 | findAndReplaceProperties(innerCount, root, "properties", value.getProperties()); |
1241 | 0 | } |
1242 | |
|
1243 | |
|
1244 | |
|
1245 | |
|
1246 | |
|
1247 | |
|
1248 | |
|
1249 | |
|
1250 | |
|
1251 | |
protected void updateDistributionManagement(DistributionManagement value, String xmlTag, Counter counter, Element element) |
1252 | |
{ |
1253 | 0 | boolean shouldExist = value != null; |
1254 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1255 | 0 | if (shouldExist) { |
1256 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1257 | 0 | updateDeploymentRepository( value.getRepository(), "repository", innerCount, root); |
1258 | 0 | updateDeploymentRepository( value.getSnapshotRepository(), "snapshotRepository", innerCount, root); |
1259 | 0 | updateSite( value.getSite(), "site", innerCount, root); |
1260 | 0 | findAndReplaceSimpleElement(innerCount, root, "downloadUrl", value.getDownloadUrl(), null); |
1261 | 0 | updateRelocation( value.getRelocation(), "relocation", innerCount, root); |
1262 | 0 | findAndReplaceSimpleElement(innerCount, root, "status", value.getStatus(), null); |
1263 | |
} |
1264 | 0 | } |
1265 | |
|
1266 | |
|
1267 | |
|
1268 | |
|
1269 | |
|
1270 | |
|
1271 | |
|
1272 | |
|
1273 | |
|
1274 | |
protected Element updateElement(Counter counter, Element parent, String name, boolean shouldExist) |
1275 | |
{ |
1276 | 0 | Element element = parent.getChild(name, parent.getNamespace()); |
1277 | 0 | if (element != null && shouldExist) { |
1278 | 0 | counter.increaseCount(); |
1279 | |
} |
1280 | 0 | if (element == null && shouldExist) { |
1281 | 0 | element = factory.element(name, parent.getNamespace()); |
1282 | 0 | insertAtPreferredLocation(parent, element, counter); |
1283 | 0 | counter.increaseCount(); |
1284 | |
} |
1285 | 0 | if (!shouldExist && element != null) { |
1286 | 0 | int index = parent.indexOf(element); |
1287 | 0 | if (index > 0) { |
1288 | 0 | Content previous = parent.getContent(index - 1); |
1289 | 0 | if (previous instanceof Text) { |
1290 | 0 | Text txt = (Text)previous; |
1291 | 0 | if (txt.getTextTrim().length() == 0) { |
1292 | 0 | parent.removeContent(txt); |
1293 | |
} |
1294 | |
} |
1295 | |
} |
1296 | 0 | parent.removeContent(element); |
1297 | |
} |
1298 | 0 | return element; |
1299 | |
} |
1300 | |
|
1301 | |
|
1302 | |
|
1303 | |
|
1304 | |
|
1305 | |
|
1306 | |
|
1307 | |
|
1308 | |
|
1309 | |
protected void updateExclusion(Exclusion value, String xmlTag, Counter counter, Element element) |
1310 | |
{ |
1311 | 0 | Element root = element; |
1312 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1313 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1314 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null); |
1315 | 0 | } |
1316 | |
|
1317 | |
|
1318 | |
|
1319 | |
|
1320 | |
|
1321 | |
|
1322 | |
|
1323 | |
|
1324 | |
|
1325 | |
protected void updateExtension(Extension value, String xmlTag, Counter counter, Element element) |
1326 | |
{ |
1327 | 0 | Element root = element; |
1328 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1329 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null); |
1330 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1331 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1332 | 0 | } |
1333 | |
|
1334 | |
|
1335 | |
|
1336 | |
|
1337 | |
|
1338 | |
|
1339 | |
|
1340 | |
|
1341 | |
|
1342 | |
protected void updateFileSet(FileSet value, String xmlTag, Counter counter, Element element) |
1343 | |
{ |
1344 | 0 | boolean shouldExist = value != null; |
1345 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1346 | 0 | if (shouldExist) { |
1347 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1348 | 0 | findAndReplaceSimpleElement(innerCount, root, "directory", value.getDirectory(), null); |
1349 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getIncludes(), "includes", "include"); |
1350 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getExcludes(), "excludes", "exclude"); |
1351 | |
} |
1352 | 0 | } |
1353 | |
|
1354 | |
|
1355 | |
|
1356 | |
|
1357 | |
|
1358 | |
|
1359 | |
|
1360 | |
|
1361 | |
|
1362 | |
protected void updateIssueManagement(IssueManagement value, String xmlTag, Counter counter, Element element) |
1363 | |
{ |
1364 | 0 | boolean shouldExist = value != null; |
1365 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1366 | 0 | if (shouldExist) { |
1367 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1368 | 0 | findAndReplaceSimpleElement(innerCount, root, "system", value.getSystem(), null); |
1369 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1370 | |
} |
1371 | 0 | } |
1372 | |
|
1373 | |
|
1374 | |
|
1375 | |
|
1376 | |
|
1377 | |
|
1378 | |
|
1379 | |
|
1380 | |
|
1381 | |
protected void updateLicense(License value, String xmlTag, Counter counter, Element element) |
1382 | |
{ |
1383 | 0 | Element root = element; |
1384 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1385 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1386 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1387 | 0 | findAndReplaceSimpleElement(innerCount, root, "distribution", value.getDistribution(), null); |
1388 | 0 | findAndReplaceSimpleElement(innerCount, root, "comments", value.getComments(), null); |
1389 | 0 | } |
1390 | |
|
1391 | |
|
1392 | |
|
1393 | |
|
1394 | |
|
1395 | |
|
1396 | |
|
1397 | |
|
1398 | |
|
1399 | |
protected void updateMailingList(MailingList value, String xmlTag, Counter counter, Element element) |
1400 | |
{ |
1401 | 0 | Element root = element; |
1402 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1403 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1404 | 0 | findAndReplaceSimpleElement(innerCount, root, "subscribe", value.getSubscribe(), null); |
1405 | 0 | findAndReplaceSimpleElement(innerCount, root, "unsubscribe", value.getUnsubscribe(), null); |
1406 | 0 | findAndReplaceSimpleElement(innerCount, root, "post", value.getPost(), null); |
1407 | 0 | findAndReplaceSimpleElement(innerCount, root, "archive", value.getArchive(), null); |
1408 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getOtherArchives(), "otherArchives", "otherArchive"); |
1409 | 0 | } |
1410 | |
|
1411 | |
|
1412 | |
|
1413 | |
|
1414 | |
|
1415 | |
|
1416 | |
|
1417 | |
|
1418 | |
|
1419 | |
protected void updateModel(Model value, String xmlTag, Counter counter, Element element) |
1420 | |
{ |
1421 | 0 | Element root = element; |
1422 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1423 | 0 | updateParent( value.getParent(), "parent", innerCount, root); |
1424 | 0 | findAndReplaceSimpleElement(innerCount, root, "modelVersion", value.getModelVersion(), null); |
1425 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null); |
1426 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1427 | 0 | findAndReplaceSimpleElement(innerCount, root, "packaging", value.getPackaging(), "jar"); |
1428 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1429 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1430 | 0 | findAndReplaceSimpleElement(innerCount, root, "description", value.getDescription(), null); |
1431 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1432 | 0 | updatePrerequisites( value.getPrerequisites(), "prerequisites", innerCount, root); |
1433 | 0 | updateIssueManagement( value.getIssueManagement(), "issueManagement", innerCount, root); |
1434 | 0 | updateCiManagement( value.getCiManagement(), "ciManagement", innerCount, root); |
1435 | 0 | findAndReplaceSimpleElement(innerCount, root, "inceptionYear", value.getInceptionYear(), null); |
1436 | 0 | iterateMailingList(innerCount, root, value.getMailingLists(),"mailingLists","mailingList"); |
1437 | 0 | iterateDeveloper(innerCount, root, value.getDevelopers(),"developers","developer"); |
1438 | 0 | iterateContributor(innerCount, root, value.getContributors(),"contributors","contributor"); |
1439 | 0 | iterateLicense(innerCount, root, value.getLicenses(),"licenses","license"); |
1440 | 0 | updateScm( value.getScm(), "scm", innerCount, root); |
1441 | 0 | updateOrganization( value.getOrganization(), "organization", innerCount, root); |
1442 | 0 | updateBuild( value.getBuild(), "build", innerCount, root); |
1443 | 0 | iterateProfile(innerCount, root, value.getProfiles(),"profiles","profile"); |
1444 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getModules(), "modules", "module"); |
1445 | 0 | iterateRepository(innerCount, root, value.getRepositories(),"repositories","repository"); |
1446 | 0 | iterateRepository(innerCount, root, value.getPluginRepositories(),"pluginRepositories","pluginRepository"); |
1447 | 0 | iterateDependency(innerCount, root, value.getDependencies(),"dependencies","dependency"); |
1448 | 0 | findAndReplaceXpp3DOM(innerCount, root, "reports", (Xpp3Dom)value.getReports()); |
1449 | 0 | updateReporting( value.getReporting(), "reporting", innerCount, root); |
1450 | 0 | updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root); |
1451 | 0 | updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root); |
1452 | 0 | findAndReplaceProperties(innerCount, root, "properties", value.getProperties()); |
1453 | 0 | } |
1454 | |
|
1455 | |
|
1456 | |
|
1457 | |
|
1458 | |
|
1459 | |
|
1460 | |
|
1461 | |
|
1462 | |
|
1463 | |
protected void updateModelBase(ModelBase value, String xmlTag, Counter counter, Element element) |
1464 | |
{ |
1465 | 0 | boolean shouldExist = value != null; |
1466 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1467 | 0 | if (shouldExist) { |
1468 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1469 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getModules(), "modules", "module"); |
1470 | 0 | iterateRepository(innerCount, root, value.getRepositories(),"repositories","repository"); |
1471 | 0 | iterateRepository(innerCount, root, value.getPluginRepositories(),"pluginRepositories","pluginRepository"); |
1472 | 0 | iterateDependency(innerCount, root, value.getDependencies(),"dependencies","dependency"); |
1473 | 0 | findAndReplaceXpp3DOM(innerCount, root, "reports", (Xpp3Dom)value.getReports()); |
1474 | 0 | updateReporting( value.getReporting(), "reporting", innerCount, root); |
1475 | 0 | updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root); |
1476 | 0 | updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root); |
1477 | 0 | findAndReplaceProperties(innerCount, root, "properties", value.getProperties()); |
1478 | |
} |
1479 | 0 | } |
1480 | |
|
1481 | |
|
1482 | |
|
1483 | |
|
1484 | |
|
1485 | |
|
1486 | |
|
1487 | |
|
1488 | |
|
1489 | |
protected void updateNotifier(Notifier value, String xmlTag, Counter counter, Element element) |
1490 | |
{ |
1491 | 0 | Element root = element; |
1492 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1493 | 0 | findAndReplaceSimpleElement(innerCount, root, "type", value.getType(), "mail"); |
1494 | 0 | findAndReplaceSimpleElement(innerCount, root, "sendOnError", value.isSendOnError() == true ? null : String.valueOf( value.isSendOnError() ), "true"); |
1495 | 0 | findAndReplaceSimpleElement(innerCount, root, "sendOnFailure", value.isSendOnFailure() == true ? null : String.valueOf( value.isSendOnFailure() ), "true"); |
1496 | 0 | findAndReplaceSimpleElement(innerCount, root, "sendOnSuccess", value.isSendOnSuccess() == true ? null : String.valueOf( value.isSendOnSuccess() ), "true"); |
1497 | 0 | findAndReplaceSimpleElement(innerCount, root, "sendOnWarning", value.isSendOnWarning() == true ? null : String.valueOf( value.isSendOnWarning() ), "true"); |
1498 | 0 | findAndReplaceSimpleElement(innerCount, root, "address", value.getAddress(), null); |
1499 | 0 | findAndReplaceProperties(innerCount, root, "configuration", value.getConfiguration()); |
1500 | 0 | } |
1501 | |
|
1502 | |
|
1503 | |
|
1504 | |
|
1505 | |
|
1506 | |
|
1507 | |
|
1508 | |
|
1509 | |
|
1510 | |
protected void updateOrganization(Organization value, String xmlTag, Counter counter, Element element) |
1511 | |
{ |
1512 | 0 | boolean shouldExist = value != null; |
1513 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1514 | 0 | if (shouldExist) { |
1515 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1516 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1517 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1518 | |
} |
1519 | 0 | } |
1520 | |
|
1521 | |
|
1522 | |
|
1523 | |
|
1524 | |
|
1525 | |
|
1526 | |
|
1527 | |
|
1528 | |
|
1529 | |
protected void updateParent(Parent value, String xmlTag, Counter counter, Element element) |
1530 | |
{ |
1531 | 0 | boolean shouldExist = value != null; |
1532 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1533 | 0 | if (shouldExist) { |
1534 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1535 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1536 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null); |
1537 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1538 | 0 | findAndReplaceSimpleElement(innerCount, root, "relativePath", value.getRelativePath(), "../pom.xml"); |
1539 | |
} |
1540 | 0 | } |
1541 | |
|
1542 | |
|
1543 | |
|
1544 | |
|
1545 | |
|
1546 | |
|
1547 | |
|
1548 | |
|
1549 | |
|
1550 | |
protected void updatePatternSet(PatternSet value, String xmlTag, Counter counter, Element element) |
1551 | |
{ |
1552 | 0 | boolean shouldExist = value != null; |
1553 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1554 | 0 | if (shouldExist) { |
1555 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1556 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getIncludes(), "includes", "include"); |
1557 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getExcludes(), "excludes", "exclude"); |
1558 | |
} |
1559 | 0 | } |
1560 | |
|
1561 | |
|
1562 | |
|
1563 | |
|
1564 | |
|
1565 | |
|
1566 | |
|
1567 | |
|
1568 | |
|
1569 | |
protected void updatePlugin(Plugin value, String xmlTag, Counter counter, Element element) |
1570 | |
{ |
1571 | 0 | Element root = element; |
1572 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1573 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins"); |
1574 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1575 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1576 | 0 | findAndReplaceSimpleElement(innerCount, root, "extensions", value.isExtensions() == false ? null : String.valueOf( value.isExtensions() ), "false"); |
1577 | 0 | iteratePluginExecution(innerCount, root, value.getExecutions(),"executions","execution"); |
1578 | 0 | iterateDependency(innerCount, root, value.getDependencies(),"dependencies","dependency"); |
1579 | 0 | findAndReplaceXpp3DOM(innerCount, root, "goals", (Xpp3Dom)value.getGoals()); |
1580 | 0 | findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null); |
1581 | 0 | findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom)value.getConfiguration()); |
1582 | 0 | } |
1583 | |
|
1584 | |
|
1585 | |
|
1586 | |
|
1587 | |
|
1588 | |
|
1589 | |
|
1590 | |
|
1591 | |
|
1592 | |
protected void updatePluginConfiguration(PluginConfiguration value, String xmlTag, Counter counter, Element element) |
1593 | |
{ |
1594 | 0 | boolean shouldExist = value != null; |
1595 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1596 | 0 | if (shouldExist) { |
1597 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1598 | 0 | updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root); |
1599 | 0 | iteratePlugin(innerCount, root, value.getPlugins(),"plugins","plugin"); |
1600 | |
} |
1601 | 0 | } |
1602 | |
|
1603 | |
|
1604 | |
|
1605 | |
|
1606 | |
|
1607 | |
|
1608 | |
|
1609 | |
|
1610 | |
|
1611 | |
protected void updatePluginContainer(PluginContainer value, String xmlTag, Counter counter, Element element) |
1612 | |
{ |
1613 | 0 | boolean shouldExist = value != null; |
1614 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1615 | 0 | if (shouldExist) { |
1616 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1617 | 0 | iteratePlugin(innerCount, root, value.getPlugins(),"plugins","plugin"); |
1618 | |
} |
1619 | 0 | } |
1620 | |
|
1621 | |
|
1622 | |
|
1623 | |
|
1624 | |
|
1625 | |
|
1626 | |
|
1627 | |
|
1628 | |
|
1629 | |
protected void updatePluginExecution(PluginExecution value, String xmlTag, Counter counter, Element element) |
1630 | |
{ |
1631 | 0 | Element root = element; |
1632 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1633 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), "default"); |
1634 | 0 | findAndReplaceSimpleElement(innerCount, root, "phase", value.getPhase(), null); |
1635 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getGoals(), "goals", "goal"); |
1636 | 0 | findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null); |
1637 | 0 | findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom)value.getConfiguration()); |
1638 | 0 | } |
1639 | |
|
1640 | |
|
1641 | |
|
1642 | |
|
1643 | |
|
1644 | |
|
1645 | |
|
1646 | |
|
1647 | |
|
1648 | |
protected void updatePluginManagement(PluginManagement value, String xmlTag, Counter counter, Element element) |
1649 | |
{ |
1650 | 0 | boolean shouldExist = value != null; |
1651 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1652 | 0 | if (shouldExist) { |
1653 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1654 | 0 | iteratePlugin(innerCount, root, value.getPlugins(),"plugins","plugin"); |
1655 | |
} |
1656 | 0 | } |
1657 | |
|
1658 | |
|
1659 | |
|
1660 | |
|
1661 | |
|
1662 | |
|
1663 | |
|
1664 | |
|
1665 | |
|
1666 | |
protected void updatePrerequisites(Prerequisites value, String xmlTag, Counter counter, Element element) |
1667 | |
{ |
1668 | 0 | boolean shouldExist = value != null; |
1669 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1670 | 0 | if (shouldExist) { |
1671 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1672 | 0 | findAndReplaceSimpleElement(innerCount, root, "maven", value.getMaven(), "2.0"); |
1673 | |
} |
1674 | 0 | } |
1675 | |
|
1676 | |
|
1677 | |
|
1678 | |
|
1679 | |
|
1680 | |
|
1681 | |
|
1682 | |
|
1683 | |
|
1684 | |
protected void updateProfile(Profile value, String xmlTag, Counter counter, Element element) |
1685 | |
{ |
1686 | 0 | Element root = element; |
1687 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1688 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), "default"); |
1689 | |
|
1690 | 0 | updateBuildBase( value.getBuild(), "build", innerCount, root); |
1691 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getModules(), "modules", "module"); |
1692 | 0 | iterateRepository(innerCount, root, value.getRepositories(),"repositories","repository"); |
1693 | 0 | iterateRepository(innerCount, root, value.getPluginRepositories(),"pluginRepositories","pluginRepository"); |
1694 | 0 | iterateDependency(innerCount, root, value.getDependencies(),"dependencies","dependency"); |
1695 | 0 | findAndReplaceXpp3DOM(innerCount, root, "reports", (Xpp3Dom)value.getReports()); |
1696 | 0 | updateReporting( value.getReporting(), "reporting", innerCount, root); |
1697 | 0 | updateDependencyManagement( value.getDependencyManagement(), "dependencyManagement", innerCount, root); |
1698 | 0 | updateDistributionManagement( value.getDistributionManagement(), "distributionManagement", innerCount, root); |
1699 | 0 | findAndReplaceProperties(innerCount, root, "properties", value.getProperties()); |
1700 | 0 | } |
1701 | |
|
1702 | |
|
1703 | |
|
1704 | |
|
1705 | |
|
1706 | |
|
1707 | |
|
1708 | |
|
1709 | |
|
1710 | |
protected void updateRelocation(Relocation value, String xmlTag, Counter counter, Element element) |
1711 | |
{ |
1712 | 0 | boolean shouldExist = value != null; |
1713 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1714 | 0 | if (shouldExist) { |
1715 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1716 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), null); |
1717 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1718 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1719 | 0 | findAndReplaceSimpleElement(innerCount, root, "message", value.getMessage(), null); |
1720 | |
} |
1721 | 0 | } |
1722 | |
|
1723 | |
|
1724 | |
|
1725 | |
|
1726 | |
|
1727 | |
|
1728 | |
|
1729 | |
|
1730 | |
|
1731 | |
protected void updateReportPlugin(ReportPlugin value, String xmlTag, Counter counter, Element element) |
1732 | |
{ |
1733 | 0 | Element root = element; |
1734 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1735 | 0 | findAndReplaceSimpleElement(innerCount, root, "groupId", value.getGroupId(), "org.apache.maven.plugins"); |
1736 | 0 | findAndReplaceSimpleElement(innerCount, root, "artifactId", value.getArtifactId(), null); |
1737 | 0 | findAndReplaceSimpleElement(innerCount, root, "version", value.getVersion(), null); |
1738 | 0 | findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null); |
1739 | 0 | findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom)value.getConfiguration()); |
1740 | 0 | iterateReportSet(innerCount, root, value.getReportSets(),"reportSets","reportSet"); |
1741 | 0 | } |
1742 | |
|
1743 | |
|
1744 | |
|
1745 | |
|
1746 | |
|
1747 | |
|
1748 | |
|
1749 | |
|
1750 | |
|
1751 | |
protected void updateReportSet(ReportSet value, String xmlTag, Counter counter, Element element) |
1752 | |
{ |
1753 | 0 | Element root = element; |
1754 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1755 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), "default"); |
1756 | 0 | findAndReplaceXpp3DOM(innerCount, root, "configuration", (Xpp3Dom)value.getConfiguration()); |
1757 | 0 | findAndReplaceSimpleElement(innerCount, root, "inherited", value.getInherited(), null); |
1758 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getReports(), "reports", "report"); |
1759 | 0 | } |
1760 | |
|
1761 | |
|
1762 | |
|
1763 | |
|
1764 | |
|
1765 | |
|
1766 | |
|
1767 | |
|
1768 | |
|
1769 | |
protected void updateReporting(Reporting value, String xmlTag, Counter counter, Element element) |
1770 | |
{ |
1771 | 0 | boolean shouldExist = value != null; |
1772 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1773 | 0 | if (shouldExist) { |
1774 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1775 | 0 | findAndReplaceSimpleElement(innerCount, root, "excludeDefaults", value.isExcludeDefaults() == false ? null : String.valueOf( value.isExcludeDefaults() ), "false"); |
1776 | 0 | findAndReplaceSimpleElement(innerCount, root, "outputDirectory", value.getOutputDirectory(), null); |
1777 | 0 | iterateReportPlugin(innerCount, root, value.getPlugins(),"plugins","plugin"); |
1778 | |
} |
1779 | 0 | } |
1780 | |
|
1781 | |
|
1782 | |
|
1783 | |
|
1784 | |
|
1785 | |
|
1786 | |
|
1787 | |
|
1788 | |
|
1789 | |
protected void updateRepository(Repository value, String xmlTag, Counter counter, Element element) |
1790 | |
{ |
1791 | 0 | Element root = element; |
1792 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1793 | 0 | updateRepositoryPolicy( value.getReleases(), "releases", innerCount, root); |
1794 | 0 | updateRepositoryPolicy( value.getSnapshots(), "snapshots", innerCount, root); |
1795 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); |
1796 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1797 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1798 | 0 | findAndReplaceSimpleElement(innerCount, root, "layout", value.getLayout(), "default"); |
1799 | 0 | } |
1800 | |
|
1801 | |
|
1802 | |
|
1803 | |
|
1804 | |
|
1805 | |
|
1806 | |
|
1807 | |
|
1808 | |
|
1809 | |
protected void updateRepositoryBase(RepositoryBase value, String xmlTag, Counter counter, Element element) |
1810 | |
{ |
1811 | 0 | boolean shouldExist = value != null; |
1812 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1813 | 0 | if (shouldExist) { |
1814 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1815 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); |
1816 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1817 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1818 | 0 | findAndReplaceSimpleElement(innerCount, root, "layout", value.getLayout(), "default"); |
1819 | |
} |
1820 | 0 | } |
1821 | |
|
1822 | |
|
1823 | |
|
1824 | |
|
1825 | |
|
1826 | |
|
1827 | |
|
1828 | |
|
1829 | |
|
1830 | |
protected void updateRepositoryPolicy(RepositoryPolicy value, String xmlTag, Counter counter, Element element) |
1831 | |
{ |
1832 | 0 | boolean shouldExist = value != null; |
1833 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1834 | 0 | if (shouldExist) { |
1835 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1836 | 0 | findAndReplaceSimpleElement(innerCount, root, "enabled", value.isEnabled() == true ? null : String.valueOf( value.isEnabled() ), "true"); |
1837 | 0 | findAndReplaceSimpleElement(innerCount, root, "updatePolicy", value.getUpdatePolicy(), null); |
1838 | 0 | findAndReplaceSimpleElement(innerCount, root, "checksumPolicy", value.getChecksumPolicy(), null); |
1839 | |
} |
1840 | 0 | } |
1841 | |
|
1842 | |
|
1843 | |
|
1844 | |
|
1845 | |
|
1846 | |
|
1847 | |
|
1848 | |
|
1849 | |
|
1850 | |
protected void updateResource(Resource value, String xmlTag, Counter counter, Element element) |
1851 | |
{ |
1852 | 0 | Element root = element; |
1853 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1854 | 0 | findAndReplaceSimpleElement(innerCount, root, "targetPath", value.getTargetPath(), null); |
1855 | 0 | findAndReplaceSimpleElement(innerCount, root, "filtering", value.isFiltering() == false ? null : String.valueOf( value.isFiltering() ), "false"); |
1856 | 0 | findAndReplaceSimpleElement(innerCount, root, "directory", value.getDirectory(), null); |
1857 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getIncludes(), "includes", "include"); |
1858 | 0 | findAndReplaceSimpleLists(innerCount, root, value.getExcludes(), "excludes", "exclude"); |
1859 | 0 | } |
1860 | |
|
1861 | |
|
1862 | |
|
1863 | |
|
1864 | |
|
1865 | |
|
1866 | |
|
1867 | |
|
1868 | |
|
1869 | |
protected void updateScm(Scm value, String xmlTag, Counter counter, Element element) |
1870 | |
{ |
1871 | 0 | boolean shouldExist = value != null; |
1872 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1873 | 0 | if (shouldExist) { |
1874 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1875 | 0 | findAndReplaceSimpleElement(innerCount, root, "connection", value.getConnection(), null); |
1876 | 0 | findAndReplaceSimpleElement(innerCount, root, "developerConnection", value.getDeveloperConnection(), null); |
1877 | 0 | findAndReplaceSimpleElement(innerCount, root, "tag", value.getTag(), "HEAD"); |
1878 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1879 | |
} |
1880 | 0 | } |
1881 | |
|
1882 | |
|
1883 | |
|
1884 | |
|
1885 | |
|
1886 | |
|
1887 | |
|
1888 | |
|
1889 | |
|
1890 | |
protected void updateSite(Site value, String xmlTag, Counter counter, Element element) |
1891 | |
{ |
1892 | 0 | boolean shouldExist = value != null; |
1893 | 0 | Element root = updateElement(counter, element, xmlTag, shouldExist); |
1894 | 0 | if (shouldExist) { |
1895 | 0 | Counter innerCount = new Counter(counter.getDepth() + 1); |
1896 | 0 | findAndReplaceSimpleElement(innerCount, root, "id", value.getId(), null); |
1897 | 0 | findAndReplaceSimpleElement(innerCount, root, "name", value.getName(), null); |
1898 | 0 | findAndReplaceSimpleElement(innerCount, root, "url", value.getUrl(), null); |
1899 | |
} |
1900 | 0 | } |
1901 | |
|
1902 | |
|
1903 | |
|
1904 | |
|
1905 | |
|
1906 | |
|
1907 | |
|
1908 | |
|
1909 | |
|
1910 | |
public void write(Model project, Document document, OutputStream stream) |
1911 | |
throws java.io.IOException |
1912 | |
{ |
1913 | 0 | updateModel(project, "project", new Counter(0), document.getRootElement()); |
1914 | 0 | XMLOutputter outputter = new XMLOutputter(); |
1915 | 0 | outputter.setFormat(Format.getPrettyFormat() |
1916 | |
.setIndent(" ") |
1917 | |
.setLineSeparator(System.getProperty("line.separator"))); |
1918 | 0 | outputter.output(document, stream); |
1919 | 0 | } |
1920 | |
|
1921 | |
|
1922 | |
|
1923 | |
|
1924 | |
|
1925 | |
|
1926 | |
|
1927 | |
|
1928 | |
public void write(Model project, Document document, OutputStreamWriter writer) |
1929 | |
throws java.io.IOException |
1930 | |
{ |
1931 | 0 | Format format = Format.getRawFormat() |
1932 | |
.setEncoding(writer.getEncoding()) |
1933 | |
.setLineSeparator(System.getProperty("line.separator")); |
1934 | 0 | write(project, document, writer, format); |
1935 | 0 | } |
1936 | |
|
1937 | |
|
1938 | |
|
1939 | |
|
1940 | |
|
1941 | |
|
1942 | |
|
1943 | |
|
1944 | |
|
1945 | |
public void write(Model project, Document document, Writer writer, Format jdomFormat) |
1946 | |
throws java.io.IOException |
1947 | |
{ |
1948 | 0 | updateModel(project, "project", new Counter(0), document.getRootElement()); |
1949 | 0 | XMLOutputter outputter = new XMLOutputter(); |
1950 | 0 | outputter.setFormat(jdomFormat); |
1951 | 0 | outputter.output(document, writer); |
1952 | 0 | } |
1953 | |
|
1954 | |
|
1955 | |
|
1956 | |
|
1957 | |
|
1958 | |
|
1959 | |
|
1960 | |
|
1961 | |
|
1962 | |
|
1963 | |
|
1964 | |
public class Counter { |
1965 | |
|
1966 | |
|
1967 | |
|
1968 | |
|
1969 | |
|
1970 | |
|
1971 | |
|
1972 | |
|
1973 | |
|
1974 | 0 | private int currentIndex = 0; |
1975 | |
|
1976 | |
|
1977 | |
|
1978 | |
|
1979 | |
private int level; |
1980 | |
|
1981 | |
|
1982 | |
|
1983 | |
|
1984 | |
|
1985 | |
|
1986 | 0 | public Counter(int depthLevel) { |
1987 | 0 | level = depthLevel; |
1988 | 0 | } |
1989 | |
|
1990 | |
|
1991 | |
|
1992 | |
|
1993 | |
|
1994 | |
|
1995 | |
|
1996 | |
|
1997 | |
|
1998 | |
public int getCurrentIndex() |
1999 | |
{ |
2000 | 0 | return currentIndex; |
2001 | |
} |
2002 | |
|
2003 | |
|
2004 | |
|
2005 | |
|
2006 | |
public int getDepth() |
2007 | |
{ |
2008 | 0 | return level; |
2009 | |
} |
2010 | |
|
2011 | |
|
2012 | |
|
2013 | |
|
2014 | |
public void increaseCount() |
2015 | |
{ |
2016 | 0 | currentIndex = currentIndex + 1; |
2017 | 0 | } |
2018 | |
|
2019 | |
} |
2020 | |
|
2021 | |
} |