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