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