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