{
String[] tokens = StringUtils.split( scmSpecificUrl, Character.toString( delimiter ) );
if ( tokens.length != 2 )
{
throw new ScmRepositoryException( "The connection string didn't contain the expected number of tokens. "
+ "Expected 2 tokens but got " + tokens.length + " tokens." );
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
String root = tokens[0];
File rootFile = new File( root );
if ( !rootFile.isAbsolute() )
{
String basedir = System.getProperty( "basedir", new File( "" ).getAbsolutePath() );
rootFile = new File( basedir, root );
}
if ( !rootFile.exists() )
{
throw new ScmRepositoryException( "The root doesn't exists (" + rootFile.getAbsolutePath() + ")." );
}
if ( !rootFile.isDirectory() )
{
throw new ScmRepositoryException( "The root isn't a directory (" + rootFile.getAbsolutePath() + ")." );
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
String module = tokens[1];
File moduleFile = new File( rootFile, module );
if ( !moduleFile.exists() )
{
throw new ScmRepositoryException(
"The module doesn't exist (root: " + rootFile.getAbsolutePath() + ", module: " + module + ")." );
}
if ( !moduleFile.isDirectory() )
{
throw new ScmRepositoryException( "The module isn't a directory." );
}
return new LocalScmProviderRepository( rootFile.getAbsolutePath(), module );
}