diff --git a/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java b/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java
index efe4f822..a8ec5d2e 100644
--- a/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java
+++ b/xdoc/src/main/org/apache/maven/xdoc/util/ScmUtil.java
@@ -21,386 +21,377 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
-
-import org.apache.maven.scm.manager.NoSuchScmProviderException;
-import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.clearcase.ClearCaseScmProvider;
import org.apache.maven.scm.provider.clearcase.repository.ClearCaseScmProviderRepository;
import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
import org.apache.maven.scm.provider.starteam.StarteamScmProvider;
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
-import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
-
import org.apache.maven.util.EnhancedStringTokenizer;
/**
- * Utility class to manage SCM informations.
- * NOTE: This is very CVS specific, but I would like to try additional SCM
- * package like subversion ASAP.
- *
+ * Utility class to manage SCM informations. NOTE: This is very CVS specific,
+ * but I would like to try additional SCM package like subversion ASAP.
+ *
* @author Jason van Zyl
* @author Arnaud Heritier
* @version $Id$
*/
-public final class ScmUtil
-{
- /**
- * Get the SCM type.
- *
- * @param scmConnection the scm connection to analyse.
- * @return the scm type : cvs, svn , ...
- */
- public String getScmType( final String scmConnection )
- {
- if ( isValid( scmConnection ) )
- {
- return splitSCMConnection( scmConnection )[1];
- }
+public final class ScmUtil {
+ /**
+ * Get the SCM type.
+ *
+ * @param scmConnection
+ * the scm connection to analyse.
+ * @return the scm type : cvs, svn , ...
+ */
+ public String getScmType(final String scmConnection) {
+ if (isValid(scmConnection)) {
+ return splitSCMConnection(scmConnection)[1];
+ }
- return null;
- }
+ return null;
+ }
- /**
- * Get cvs connection string.
- * Used in xdocs/src/plugin-resources/templates/scm/cvs.xml.
- * If username == "", assumes anonymous (pserver) connection. In this case,
- * inserts a separator (':' or '|') between the username and '@' to indicate
- * that there is a password and that it is empty.
- * If username != "" it replaces username in conn.
- *
- * @param conn six token connection string
- * @param username username override if non-empty.
- * @return CVS root.
- */
- public String getCvsConnection( String conn, String username )
- {
- String[] tokens = splitSCMConnection( conn );
+ /**
+ * Get cvs connection string. Used in
+ * xdocs/src/plugin-resources/templates/scm/cvs.xml. If username == "",
+ * assumes anonymous (pserver) connection. In this case, inserts a separator
+ * (':' or '|') between the username and '@' to indicate that there is a
+ * password and that it is empty. If username != "" it replaces username in
+ * conn.
+ *
+ * @param conn
+ * six token connection string
+ * @param username
+ * username override if non-empty.
+ * @return CVS root.
+ */
+ public String getCvsConnection(String conn, String username) {
+ String[] tokens = splitSCMConnection(conn);
- if ( !tokens[1].equals( "cvs" ) )
- {
- return "";
- }
+ if (!tokens[1].equals("cvs")) {
+ return "";
+ }
- String separator = getSCMConnectionSeparator( conn );
+ String separator = getSCMConnectionSeparator(conn);
- if ( tokens[3].indexOf( '@' ) >= 0 )
- {
- if ( username.length() == 0 )
- {
- username =
- tokens[3].substring( 0, tokens[3].indexOf( '@' ) )
- + separator;
- }
+ if (tokens[3].indexOf('@') >= 0) {
+ if (username.length() == 0) {
+ username = tokens[3].substring(0, tokens[3].indexOf('@'))
+ + separator;
+ }
- tokens[3] =
- username + "@"
- + tokens[3].substring( tokens[3].indexOf( '@' ) + 1 );
- }
+ tokens[3] = username + "@"
+ + tokens[3].substring(tokens[3].indexOf('@') + 1);
+ }
- String result =
- tokens[0] + ":" + tokens[1] + separator + tokens[2]
- + separator + tokens[3] + separator + tokens[4] + separator
- + tokens[5];
+ String result = tokens[0] + ":" + tokens[1] + separator + tokens[2]
+ + separator + tokens[3] + separator + tokens[4] + separator
+ + tokens[5];
- return result;
- }
+ return result;
+ }
- /**
- * Get cvs module. Used in
- * xdocs/src/plugin-resources/templates/scm/cvs.xml.
- *
- * @param conn six token connection string
- * @return CVS module.
- */
- public String getCvsModule( String conn )
- {
- if ( isValid( conn ) )
- {
- String[] tokens = splitSCMConnection( conn );
+ /**
+ * Get cvs module. Used in xdocs/src/plugin-resources/templates/scm/cvs.xml.
+ *
+ * @param conn
+ * six token connection string
+ * @return CVS module.
+ */
+ public String getCvsModule(String conn) {
+ if (isValid(conn)) {
+ String[] tokens = splitSCMConnection(conn);
- if ( !tokens[1].equals( "cvs" ) )
- {
- return "";
- }
+ if (!tokens[1].equals("cvs")) {
+ return "";
+ }
- return tokens[5];
- }
+ return tokens[5];
+ }
- return null;
- }
+ return null;
+ }
- /**
- * Create the documentation to provide an developer access with a Perforce SCM.
- * For example, generate the following command line:
- *
p4 -H hostname -p port -u username -P password path
- *p4 -H hostname -p port -u username -P password path submit -c changement
- * - * @param perforceRepo - * @see http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html> - */ - public String developerAccessPerforce( String devConnection ) - { - StringBuffer command = new StringBuffer(); - char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 ); + /** + * Get svn connection string. Used in + * xdocs/src/plugin-resources/templates/scm/svn.xml. It removes the first + * two elements (scm:svn:) + * + * @param conn + * the repository connection + * @return CVS root. + */ + public String getSvnConnection(String conn) { + if (conn != null && conn.length() > 8 + && "svn".equals(conn.substring(4, 7))) + return conn.substring(8); + else { + System.err + .println("Your subversion connection does not seem to be valid: " + + conn); + return ""; + } + } - PerforceScmProvider perforceProvider= new PerforceScmProvider(); - PerforceScmProviderRepository perforceRepo; + /** + * Create the documentation to provide an developer access with a + *Perforce SCM. For example, generate the following command
+ * line:
+ * + * p4 -H hostname -p port -u username -P password path + *
+ *+ * p4 -H hostname -p port -u username -P password path submit -c changement + *
+ * + * @param devConnection + * @see http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html> + */ + public String developerAccessPerforce(String devConnection) { + StringBuffer command = new StringBuffer(); + char delim = getSCMConnectionSeparator(devConnection).charAt(0); - String scmSpecificUrl = devConnection.substring( 13 ); + PerforceScmProvider perforceProvider = new PerforceScmProvider(); + PerforceScmProviderRepository perforceRepo; - try - { - perforceRepo = (PerforceScmProviderRepository) - perforceProvider.makeProviderScmRepository( scmSpecificUrl, delim ); - } - catch (ScmRepositoryException e) - { - System.err.println( "Your developerConnection does not seem to be valid: " + e.getMessage() ); - return ""; - } + String scmSpecificUrl = devConnection.substring(13); + try { + perforceRepo = (PerforceScmProviderRepository) perforceProvider + .makeProviderScmRepository(scmSpecificUrl, delim); + } catch (ScmRepositoryException e) { + System.err + .println("Your developerConnection does not seem to be valid: " + + e.getMessage()); + return ""; + } - command.append( "p4" ); - if ( !StringUtils.isEmpty( perforceRepo.getHost() ) ) - { - command.append( " -H " ).append( perforceRepo.getHost() ); - } - if ( perforceRepo.getPort() > 0 ) - { - command.append( " -p " + perforceRepo.getPort() ); - } - command.append( " -u username" ); - command.append( " -P password" ); - command.append( " " ); - command.append( perforceRepo.getPath() ); - command.append( "\n" ); - command.append( "p4 submit -c \"A comment\"" ); + command.append("p4"); + if (!StringUtils.isEmpty(perforceRepo.getHost())) { + command.append(" -H ").append(perforceRepo.getHost()); + } + if (perforceRepo.getPort() > 0) { + command.append(" -p " + perforceRepo.getPort()); + } + command.append(" -u username"); + command.append(" -P password"); + command.append(" "); + command.append(perforceRepo.getPath()); + command.append("\n"); + command.append("p4 submit -c \"A comment\""); - return command.toString(); - } + return command.toString(); + } - // Starteam + // Starteam - /** - * Create the documentation to provide an developer access with aStarteam SCM.
- * For example, generate the following command line:
- * stcmd co -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl -is
- *stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl -f NCI -is
- * - * @param starteamRepo - */ - public String developerAccessStarteam( String devConnection ) - { + /** + * Create the documentation to provide an developer access with a + *Starteam SCM. For example, generate the following command
+ * line:
+ * + * stcmd co -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl + * -is + *
+ *+ * stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl + * -f NCI -is + *
+ * + * @param devConnection + */ + public String developerAccessStarteam(String devConnection) { - StringBuffer command = new StringBuffer(); - char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 ); + StringBuffer command = new StringBuffer(); + char delim = getSCMConnectionSeparator(devConnection).charAt(0); - StarteamScmProvider starteamProvider= new StarteamScmProvider(); - StarteamScmProviderRepository starteamRepo; + StarteamScmProvider starteamProvider = new StarteamScmProvider(); + StarteamScmProviderRepository starteamRepo; - String scmSpecificUrl = devConnection.substring( 13 ); + String scmSpecificUrl = devConnection.substring(13); - try - { - starteamRepo = (StarteamScmProviderRepository) - starteamProvider.makeProviderScmRepository( scmSpecificUrl, delim ); - } - catch (ScmRepositoryException e) - { - System.err.println( "Your developerConnection does not seem to be valid: " + e.getMessage() ); - return ""; - } + try { + starteamRepo = (StarteamScmProviderRepository) starteamProvider + .makeProviderScmRepository(scmSpecificUrl, delim); + } catch (ScmRepositoryException e) { + System.err + .println("Your developerConnection does not seem to be valid: " + + e.getMessage()); + return ""; + } - // Safety: remove the username/password if present - String fullUrl = StringUtils.replace( starteamRepo.getFullUrl(), starteamRepo.getUser(), "username" ); - fullUrl = StringUtils.replace( fullUrl, starteamRepo.getPassword(), "password" ); + // Safety: remove the username/password if present + String fullUrl = StringUtils.replace(starteamRepo.getFullUrl(), + starteamRepo.getUser(), "username"); + fullUrl = StringUtils.replace(fullUrl, starteamRepo.getPassword(), + "password"); - command.append( "stcmd co -x -nologo -stop -p " ); - command.append( fullUrl ); - command.append( " -is" ); - command.append( "\n" ); - command.append( "stcmd ci -x -nologo -stop -p " ); - command.append( fullUrl ); - command.append( " -f NCI -is" ); + command.append("stcmd co -x -nologo -stop -p "); + command.append(fullUrl); + command.append(" -is"); + command.append("\n"); + command.append("stcmd ci -x -nologo -stop -p "); + command.append(fullUrl); + command.append(" -f NCI -is"); - return command.toString(); - } + return command.toString(); + } + /** + * Create the documentation to provide an developer access with a + *Clearcase SCM. For example, generate the following command
+ * line:
+ * + * cleartool checkout module + *
+ * + * @param devConnection + */ + public String developerAccessClearCase(String devConnection) { - /** - * Create the documentation to provide an developer access with aClearcase SCM.
- * For example, generate the following command line:
- * cleartool checkout module
- * - * @param clearCaseRepo - */ - public String developerAccessClearCase( String devConnection ) - { + StringBuffer command = new StringBuffer(); + char delim = getSCMConnectionSeparator(devConnection).charAt(0); - StringBuffer command = new StringBuffer(); - char delim = getSCMConnectionSeparator( devConnection ).charAt( 0 ); + ClearCaseScmProvider clearCaseProvider = new ClearCaseScmProvider(); + ClearCaseScmProviderRepository clearCaseRepo; - ClearCaseScmProvider clearCaseProvider= new ClearCaseScmProvider(); - ClearCaseScmProviderRepository clearCaseRepo; + String scmSpecificUrl = devConnection.substring(14); - String scmSpecificUrl = devConnection.substring( 14 ); + try { + clearCaseRepo = (ClearCaseScmProviderRepository) clearCaseProvider + .makeProviderScmRepository(scmSpecificUrl, delim); + } catch (ScmRepositoryException e) { + System.err + .println("Your developerConnection does not seem to be valid: " + + e.getMessage()); + return ""; + } - try - { - clearCaseRepo = (ClearCaseScmProviderRepository) - clearCaseProvider.makeProviderScmRepository( scmSpecificUrl, delim ); - } - catch (ScmRepositoryException e) - { - System.err.println( "Your developerConnection does not seem to be valid: " + e.getMessage() ); - return ""; - } + command.append("cleartool checkout ").append( + clearCaseRepo.getViewName("id")); - command.append( "cleartool checkout " ).append( clearCaseRepo.getViewName( "id" ) ); + return command.toString(); + } - return command.toString(); - } + /** + * Splits an SCM string into parts. + * + * @param connection + * @return A string array of SCM parts + */ + public String[] splitSCMConnection(String connection) { + if (connection == null) { + throw new NullPointerException("repository connection is null"); + } + if (connection.length() < 5) { + throw new IllegalArgumentException( + "repository connection is too short"); + } - /** - * Splits an SCM string into parts. - * - * @param connection - * @return A string array of SCM parts - */ - public String[] splitSCMConnection( String connection ) - { - if ( connection == null ) - { - throw new NullPointerException( "repository connection is null" ); - } + if (!connection.startsWith("scm:")) { + throw new IllegalArgumentException( + "repository connection must start with scm:"); + } - if ( connection.length() < 5 ) - { - throw new IllegalArgumentException( - "repository connection is too short" ); - } + String delimiter = getSCMConnectionSeparator(connection); - if ( !connection.startsWith( "scm:" ) ) - { - throw new IllegalArgumentException( - "repository connection must start with scm:" ); - } + // If the tokenizer is going to work correctly then the character + // following "scm" must be the same as the delimiter, which is not + // always the case. Therefor we give it a modified connection. + String modifiedConnection = "scm" + delimiter + connection.substring(4); - String delimiter = getSCMConnectionSeparator( connection ); + EnhancedStringTokenizer tok = new EnhancedStringTokenizer( + modifiedConnection, delimiter); - // If the tokenizer is going to work correctly then the character - // following "scm" must be the same as the delimiter, which is not - // always the case. Therefor we give it a modified connection. - String modifiedConnection = - "scm" + delimiter + connection.substring( 4 ); + String[] tokens = tokenizerToArray(tok); - EnhancedStringTokenizer tok = - new EnhancedStringTokenizer( modifiedConnection, delimiter ); + // for a valid repository, it should be scm: