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.List;
30 import java.util.Locale;
31
32
33
34
35
36
37
38
39
40 public class CimReport
41 extends AbstractProjectInfoReport
42 {
43
44
45
46
47 @Override
48 public void executeReport( Locale locale )
49 {
50 CimRenderer r = new CimRenderer( getSink(), getProject().getModel(), getI18N( locale ), locale );
51
52 r.render();
53 }
54
55
56 public String getOutputName()
57 {
58 return "integration";
59 }
60
61 @Override
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 @Override
87 protected String getI18Nsection()
88 {
89 return "cim";
90 }
91
92 @Override
93 public void renderBody()
94 {
95 CiManagement cim = model.getCiManagement();
96 if ( cim == null )
97 {
98 startSection( getTitle() );
99
100 paragraph( getI18nString( "nocim" ) );
101
102 endSection();
103
104 return;
105 }
106
107 String system = cim.getSystem();
108 String url = cim.getUrl();
109 List<Notifier> notifiers = cim.getNotifiers();
110
111
112 startSection( getI18nString( "overview.title" ) );
113
114 sink.paragraph();
115 if ( isCimSystem( system, "anthill" ) )
116 {
117 linkPatternedText( getI18nString( "anthill.intro" ) );
118 }
119 else if ( isCimSystem( system, "buildforge" ) )
120 {
121 linkPatternedText( getI18nString( "buildforge.intro" ) );
122 }
123 else if ( isCimSystem( system, "continuum" ) )
124 {
125 linkPatternedText( getI18nString( "continuum.intro" ) );
126 }
127 else if ( isCimSystem( system, "cruisecontrol" ) )
128 {
129 linkPatternedText( getI18nString( "cruisecontrol.intro" ) );
130 }
131 else if ( isCimSystem( system, "hudson" ) )
132 {
133 linkPatternedText( getI18nString( "hudson.intro" ) );
134 }
135 else if ( isCimSystem( system, "luntbuild" ) )
136 {
137 linkPatternedText( getI18nString( "luntbuild.intro" ) );
138 }
139 else
140 {
141 linkPatternedText( getI18nString( "general.intro" ) );
142 }
143 sink.paragraph_();
144
145 endSection();
146
147
148 startSection( getI18nString( "access" ) );
149
150 if ( !StringUtils.isEmpty( url ) )
151 {
152 paragraph( getI18nString( "url" ) );
153
154 verbatimLink( url, url );
155 }
156 else
157 {
158 paragraph( getI18nString( "nourl" ) );
159 }
160
161 endSection();
162
163
164 startSection( getI18nString( "notifiers.title" ) );
165
166 if ( notifiers == null || notifiers.isEmpty() )
167 {
168 paragraph( getI18nString( "notifiers.nolist" ) );
169 }
170 else
171 {
172 sink.paragraph();
173 sink.text( getI18nString( "notifiers.intro" ) );
174 sink.paragraph_();
175
176 startTable();
177
178 String type = getI18nString( "notifiers.column.type" );
179 String address = getI18nString( "notifiers.column.address" );
180 String configuration = getI18nString( "notifiers.column.configuration" );
181
182 tableHeader( new String[]{type, address, configuration} );
183
184 for ( Notifier notifier : notifiers )
185 {
186 tableRow( new String[]{notifier.getType(),
187 createLinkPatternedText( notifier.getAddress(), notifier.getAddress() ),
188 propertiesToString( notifier.getConfiguration() )} );
189 }
190
191 endTable();
192 }
193
194 endSection();
195 }
196
197
198
199
200
201
202
203
204 private boolean isCimSystem( String connection, String cim )
205 {
206 if ( StringUtils.isEmpty( connection ) )
207 {
208 return false;
209 }
210
211 if ( StringUtils.isEmpty( cim ) )
212 {
213 return false;
214 }
215
216 return connection.toLowerCase( Locale.ENGLISH ).startsWith( cim.toLowerCase( Locale.ENGLISH ) );
217 }
218 }
219 }