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