Author: vsiveton Date: Mon Nov 1 21:27:56 2010 New Revision: 1029846 URL: http://svn.apache.org/viewvc?rev=1029846&view=rev Log: MPIR-171: support "TimeZones" as a timezone
o improved timezone description in the M3 POM model (exactly timezone are between -12 and +14 or a valid timezone id) o support timezone ids in the teamListReport o added joda (ASF2.0) as dependency in MPIR o updated faq Modified: maven/maven-3/trunk/maven-model/src/main/mdo/maven.mdo maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml Modified: maven/maven-3/trunk/maven-model/src/main/mdo/maven.mdo URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-model/src/main/mdo/maven.mdo?rev=1029846&r1=1029845&r2=1029846&view=diff ============================================================================== --- maven/maven-3/trunk/maven-model/src/main/mdo/maven.mdo (original) +++ maven/maven-3/trunk/maven-model/src/main/mdo/maven.mdo Mon Nov 1 21:27:56 2010 @@ -1194,7 +1194,13 @@ <field> <name>timezone</name> <version>3.0.0+</version> - <description>The timezone the contributor is in. This is a number in the range -11 to 12.</description> + <description> + <![CDATA[ + The timezone the contributor is in. Typically, this is a number in the range + <a href="http://en.wikipedia.org/wiki/UTC%E2%88%9212:00">-12</a> to <a href="http://en.wikipedia.org/wiki/UTC%2B14:00">+14</a> + or a valid time zone id like "America/Montreal" (UTC-05:00) or "Europe/Paris" (UTC+01:00). + ]]> + </description> <type>String</type> </field> <field> Modified: maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml?rev=1029846&r1=1029845&r2=1029846&view=diff ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml (original) +++ maven/plugins/trunk/maven-project-info-reports-plugin/pom.xml Mon Nov 1 21:27:56 2010 @@ -88,6 +88,12 @@ under the License. <groupId>org.apache.maven.reporting</groupId> <artifactId>maven-reporting-api</artifactId> <version>3.0</version> + <exclusions> + <exclusion> + <groupId>org.apache.maven.doxia</groupId> + <artifactId>doxia-sink-api</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.apache.maven.reporting</groupId> @@ -241,17 +247,22 @@ under the License. <!-- Doxia --> <dependency> <groupId>org.apache.maven.doxia</groupId> - <artifactId>doxia-core</artifactId> + <artifactId>doxia-sink-api</artifactId> <version>${doxiaVersion}</version> </dependency> <dependency> <groupId>org.apache.maven.doxia</groupId> - <artifactId>doxia-module-xhtml</artifactId> + <artifactId>doxia-logging-api</artifactId> <version>${doxiaVersion}</version> </dependency> <dependency> <groupId>org.apache.maven.doxia</groupId> - <artifactId>doxia-sink-api</artifactId> + <artifactId>doxia-core</artifactId> + <version>${doxiaVersion}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.doxia</groupId> + <artifactId>doxia-module-xhtml</artifactId> <version>${doxiaVersion}</version> </dependency> @@ -305,6 +316,11 @@ under the License. <artifactId>commons-validator</artifactId> <version>1.2.0</version> </dependency> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> + <version>1.6.2</version> + </dependency> <!-- test --> <dependency> Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java?rev=1029846&r1=1029845&r2=1029846&view=diff ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java (original) +++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/TeamListReport.java Mon Nov 1 21:27:56 2010 @@ -20,12 +20,15 @@ package org.apache.maven.report.projecti */ import org.apache.commons.lang.SystemUtils; +import org.apache.commons.lang.math.NumberUtils; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Contributor; import org.apache.maven.model.Developer; import org.apache.maven.model.Model; +import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; +import org.joda.time.DateTimeZone; import java.util.ArrayList; import java.util.HashMap; @@ -33,6 +36,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Properties; +import java.util.TimeZone; /** * Generates the Project Team report. @@ -52,7 +56,7 @@ public class TeamListReport /** {...@inheritdoc} */ public void executeReport( Locale locale ) { - TeamListRenderer r = new TeamListRenderer( getSink(), project.getModel(), i18n, locale ); + TeamListRenderer r = new TeamListRenderer( getSink(), project.getModel(), i18n, locale, getLog() ); r.render(); } @@ -96,15 +100,18 @@ public class TeamListReport private static final String ID = "id"; - private Model model; + private final Model model; + + private final Log log; private static final String[] EMPTY_STRING_ARRAY = new String[0]; - TeamListRenderer( Sink sink, Model model, I18N i18n, Locale locale ) + TeamListRenderer( Sink sink, Model model, I18N i18n, Locale locale, Log log ) { super( sink, i18n, locale ); this.model = model; + this.log = log; } protected String getI18Nsection() @@ -159,12 +166,12 @@ public class TeamListReport tableHeader( requiredHeaders ); // To handle JS - int developersRows = 0; + int developersRowId = 0; for ( Developer developer : developers ) { - renderDeveloper( developer, developersRows, headersMap, javascript ); + renderDeveloper( developer, developersRowId, headersMap, javascript ); - developersRows++; + developersRowId++; } endTable(); @@ -194,12 +201,12 @@ public class TeamListReport tableHeader( requiredHeaders ); // To handle JS - int contributorsRows = 0; + int contributorsRowId = 0; for ( Contributor contributor : contributors ) { - renderContributor( contributor, contributorsRows, headersMap, javascript ); + renderContributor( contributor, contributorsRowId, headersMap, javascript ); - contributorsRows++; + contributorsRowId++; } endTable(); @@ -215,7 +222,7 @@ public class TeamListReport endSection(); } - private void renderDeveloper( Developer developer, int developerRow, Map<String, Boolean> headersMap, + private void renderDeveloper( Developer developer, int developerRowId, Map<String, Boolean> headersMap, StringBuffer javascript ) { // To handle JS @@ -261,18 +268,68 @@ public class TeamListReport { tableCell( developer.getTimezone() ); - // To handle JS - sink.tableCell(); - sink.rawText( "<span id=\"developer-" + developerRow + "\">" ); - text( developer.getTimezone() ); - if ( !StringUtils.isEmpty( developer.getTimezone() ) ) - { - javascript.append( " offsetDate('developer-" ).append( developerRow ).append( "', '" ); - javascript.append( developer.getTimezone() ); - javascript.append( "');" ).append( SystemUtils.LINE_SEPARATOR ); + if ( !NumberUtils.isNumber( developer.getTimezone() ) + && StringUtils.isNotEmpty( developer.getTimezone() ) ) + { + String tz = developer.getTimezone().trim(); + try + { + // check if it is a valid timeZone + DateTimeZone.forID( tz ); + + sink.tableCell(); + sink.rawText( "<span id=\"developer-" + developerRowId + "\">" ); + text( tz ); + String offSet = + String.valueOf( TimeZone.getTimeZone( tz ).getRawOffset() / 3600000 ); + javascript.append( " offsetDate('developer-" ).append( developerRowId ).append( "', '" ); + javascript.append( offSet ); + javascript.append( "');" ).append( SystemUtils.LINE_SEPARATOR ); + sink.rawText( "</span>" ); + sink.tableCell_(); + } + catch ( IllegalArgumentException e ) + { + log.warn( "The time zone '" + tz + "' for the developer '" + developer.getName() + + "' is not a recognised time zone, use a number in the range -12 to +14 instead of." ); + + sink.tableCell(); + sink.rawText( "<span id=\"developer-" + developerRowId + "\">" ); + text( null ); + sink.rawText( "</span>" ); + sink.tableCell_(); + } + } + else + { + // To handle JS + sink.tableCell(); + sink.rawText( "<span id=\"developer-" + developerRowId + "\">" ); + if ( StringUtils.isNotEmpty( developer.getTimezone() ) ) + { + // check if number is between -12 and +14 + int tz = NumberUtils.toInt( developer.getTimezone().trim(), Integer.MIN_VALUE ); + if ( tz == Integer.MIN_VALUE || !( tz >= -12 && tz <= 14 ) ) + { + text( null ); + log.warn( "The time zone '" + tz + "' for the developer '" + developer.getName() + + "' is not a recognised time zone, use a number in the range -12 to +14 instead of." ); + } + else + { + text( developer.getTimezone() ); + javascript.append( " offsetDate('developer-" ).append( developerRowId ).append( "', '" ); + javascript.append( developer.getTimezone() ); + javascript.append( "');" ).append( SystemUtils.LINE_SEPARATOR ); + } + } + else + { + text( null ); + } + sink.rawText( "</span>" ); + sink.tableCell_(); } - sink.rawText( "</span>" ); - sink.tableCell_(); } if ( headersMap.get( PROPERTIES ) == Boolean.TRUE ) @@ -291,7 +348,7 @@ public class TeamListReport sink.tableRow_(); } - private void renderContributor( Contributor contributor, int contributorRow, Map<String, Boolean> headersMap, + private void renderContributor( Contributor contributor, int contributorRowId, Map<String, Boolean> headersMap, StringBuffer javascript ) { sink.tableRow(); @@ -326,25 +383,73 @@ public class TeamListReport { tableCell( null ); } - } if ( headersMap.get( TIME_ZONE ) == Boolean.TRUE ) { tableCell( contributor.getTimezone() ); - // To handle JS - sink.tableCell(); - sink.rawText( "<span id=\"contributor-" + contributorRow + "\">" ); - text( contributor.getTimezone() ); - if ( !StringUtils.isEmpty( contributor.getTimezone() ) ) - { - javascript.append( " offsetDate('contributor-" ).append( contributorRow ) - .append( "', '" ); - javascript.append( contributor.getTimezone() ); - javascript.append( "');" ).append( SystemUtils.LINE_SEPARATOR ); + if ( !NumberUtils.isNumber( contributor.getTimezone() ) + && StringUtils.isNotEmpty( contributor.getTimezone() ) ) + { + String tz = contributor.getTimezone().trim(); + try + { + // check if it is a valid timeZone + DateTimeZone.forID( tz ); + + sink.tableCell(); + sink.rawText( "<span id=\"contributor-" + contributorRowId + "\">" ); + text( tz ); + String offSet = + String.valueOf( TimeZone.getTimeZone( tz ).getRawOffset() / 3600000 ); + javascript.append( " offsetDate('contributor-" ).append( contributorRowId ).append( "', '" ); + javascript.append( offSet ); + javascript.append( "');" ).append( SystemUtils.LINE_SEPARATOR ); + sink.rawText( "</span>" ); + sink.tableCell_(); + } + catch ( IllegalArgumentException e ) + { + log.warn( "The time zone '" + tz + "' for the contributor '" + contributor.getName() + + "' is not a recognised time zone, use a number in the range -12 and +14 instead of." ); + + sink.tableCell(); + sink.rawText( "<span id=\"contributor-" + contributorRowId + "\">" ); + text( null ); + sink.rawText( "</span>" ); + sink.tableCell_(); + } + } + else + { + // To handle JS + sink.tableCell(); + sink.rawText( "<span id=\"contributor-" + contributorRowId + "\">" ); + if ( StringUtils.isNotEmpty( contributor.getTimezone() ) ) + { + // check if number is between -12 and +14 + int tz = NumberUtils.toInt( contributor.getTimezone().trim(), Integer.MIN_VALUE ); + if ( tz == Integer.MIN_VALUE || !( tz >= -12 && tz <= 14 ) ) + { + text( null ); + log.warn( "The time zone '" + tz + "' for the contributor '" + contributor.getName() + + "' is not a recognised time zone, use a number in the range -12 to +14 instead of." ); + } + else + { + text( contributor.getTimezone() ); + javascript.append( " offsetDate('contributor-" ).append( contributorRowId ).append( "', '" ); + javascript.append( contributor.getTimezone() ); + javascript.append( "');" ).append( SystemUtils.LINE_SEPARATOR ); + } + } + else + { + text( null ); + } + sink.rawText( "</span>" ); + sink.tableCell_(); } - sink.rawText( "</span>" ); - sink.tableCell_(); } if ( headersMap.get( PROPERTIES ) == Boolean.TRUE ) Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml?rev=1029846&r1=1029845&r2=1029846&view=diff ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml (original) +++ maven/plugins/trunk/maven-project-info-reports-plugin/src/site/fml/faq.fml Mon Nov 1 21:27:56 2010 @@ -52,7 +52,7 @@ under the License. <developer> <id>foo</id> <email>http://mailhide.recaptcha.net/d?k=01ebFB9eM2hZL-T96IpUgRmA==&c=AI-pouLFNTr5xMTBVDaj8iKeIFI5dy9Wj5cxSY0Nuhw=</email> - ... + ... </developer> ... </developers> @@ -61,5 +61,17 @@ under the License. </p> </answer> </faq> + + <faq id="How to use developer/contributor time zone"> + <question>How to use developer/contributor time zone?</question> + <answer> + <p> + According the <a href="http://maven.apache.org/xsd/maven-4.0.0.xsd">Maven XSD</a>, the developer/contributor + time zone fields are string so you could use a time zone as a number in the range + <a href="http://en.wikipedia.org/wiki/UTC%E2%88%9212:00">-12</a> to <a href="http://en.wikipedia.org/wiki/UTC%2B14:00">+14</a> + or a valid time zone id like "America/Montreal" (UTC-05:00) or "Europe/Paris" (UTC+01:00). + </p> + </answer> + </faq> </part> </faqs>