1 package org.apache.maven.report.projectinfo;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.doxia.sink.Sink;
23 import org.apache.maven.model.CiManagement;
24 import org.apache.maven.model.Model;
25 import org.apache.maven.model.Notifier;
26 import org.codehaus.plexus.i18n.I18N;
27 import org.codehaus.plexus.util.StringUtils;
28
29 import java.util.Iterator;
30 import java.util.List;
31 import java.util.Locale;
32
33
34
35
36
37
38
39
40
41 public class CimReport
42 extends AbstractProjectInfoReport
43 {
44
45
46
47
48
49 public void executeReport( Locale locale )
50 {
51 CimRenderer r = new CimRenderer( getSink(), getProject().getModel(), i18n, locale );
52
53 r.render();
54 }
55
56
57 public String getOutputName()
58 {
59 return "integration";
60 }
61
62 protected String getI18Nsection()
63 {
64 return "cim";
65 }
66
67
68
69
70
71
72
73
74 private static class CimRenderer
75 extends AbstractProjectInfoRenderer
76 {
77 private Model model;
78
79 CimRenderer( Sink sink, Model model, I18N i18n, Locale locale )
80 {
81 super( sink, i18n, locale );
82
83 this.model = model;
84 }
85
86 protected String getI18Nsection()
87 {
88 return "cim";
89 }
90
91
92 public void renderBody()
93 {
94 CiManagement cim = model.getCiManagement();
95 if ( cim == null )
96 {
97 startSection( getTitle() );
98
99 paragraph( getI18nString( "nocim" ) );
100
101 endSection();
102
103 return;
104 }
105
106 String system = cim.getSystem();
107 String url = cim.getUrl();
108 List notifiers = cim.getNotifiers();
109
110
111 startSection( getI18nString( "overview.title" ) );
112
113 sink.paragraph();
114 if ( isCimSystem( system, "anthill" ) )
115 {
116 linkPatternedText( getI18nString( "anthill.intro" ) );
117 }
118 else if ( isCimSystem( system, "buildforge" ) )
119 {
120 linkPatternedText( getI18nString( "buildforge.intro" ) );
121 }
122 else if ( isCimSystem( system, "continuum" ) )
123 {
124 linkPatternedText( getI18nString( "continuum.intro" ) );
125 }
126 else if ( isCimSystem( system, "cruisecontrol" ) )
127 {
128 linkPatternedText( getI18nString( "cruisecontrol.intro" ) );
129 }
130 else if ( isCimSystem( system, "hudson" ) )
131 {
132 linkPatternedText( getI18nString( "hudson.intro" ) );
133 }
134 else if ( isCimSystem( system, "luntbuild" ) )
135 {
136 linkPatternedText( getI18nString( "luntbuild.intro" ) );
137 }
138 else
139 {
140 linkPatternedText( getI18nString( "general.intro" ) );
141 }
142 sink.paragraph_();
143
144 endSection();
145
146
147 startSection( getI18nString( "access" ) );
148
149 if ( !StringUtils.isEmpty( url ) )
150 {
151 paragraph( getI18nString( "url" ) );
152
153 verbatimLink( url, url );
154 }
155 else
156 {
157 paragraph( getI18nString( "nourl" ) );
158 }
159
160 endSection();
161
162
163 startSection( getI18nString( "notifiers.title" ) );
164
165 if ( notifiers == null || notifiers.isEmpty() )
166 {
167 paragraph( getI18nString( "notifiers.nolist" ) );
168 }
169 else
170 {
171 sink.paragraph();
172 sink.text( getI18nString( "notifiers.intro" ) );
173 sink.paragraph_();
174
175 startTable();
176
177 String type = getI18nString( "notifiers.column.type" );
178 String address = getI18nString( "notifiers.column.address" );
179 String configuration = getI18nString( "notifiers.column.configuration" );
180
181 tableHeader( new String[]{type, address, configuration} );
182
183 for ( Iterator i = notifiers.iterator(); i.hasNext(); )
184 {
185 Notifier notifier = (Notifier) i.next();
186
187 tableRow( new String[]{notifier.getType(),
188 createLinkPatternedText( notifier.getAddress(), notifier.getAddress() ),
189 propertiesToString( notifier.getConfiguration() )} );
190 }
191
192 endTable();
193 }
194
195 endSection();
196 }
197
198
199
200
201
202
203
204
205 private boolean isCimSystem( String connection, String cim )
206 {
207 if ( StringUtils.isEmpty( connection ) )
208 {
209 return false;
210 }
211
212 if ( StringUtils.isEmpty( cim ) )
213 {
214 return false;
215 }
216
217 return connection.toLowerCase( Locale.ENGLISH ).startsWith( cim.toLowerCase( Locale.ENGLISH ) );
218 }
219 }
220 }