URI jazzUri = URI.create( jazzUrl );
String scheme = jazzUri.getScheme();
getLogger().debug( "Scheme - " + scheme );
if ( scheme == null || !( scheme.equalsIgnoreCase( "http" ) || scheme.equalsIgnoreCase( "https" ) ) )
{
throw new ScmRepositoryException(
"Jazz Url \"" + jazzUrl + "\" is not a valid URL. The Jazz Url syntax is " + JAZZ_URL_FORMAT );
}
}
catch ( IllegalArgumentException e )
{
throw new ScmRepositoryException(
"Jazz Url \"" + jazzUrl + "\" is not a valid URL. The Jazz Url syntax is " + JAZZ_URL_FORMAT );
}
// At this point, jazzUrl is guaranteed to start with either http:// or https://
// Further process the jazzUrl to extract the server name and port.
String hostname = null;
int port = 0;
if ( havePort )
{
// jazzUrlAndWorkspace should be: http[s]://server_name:port/contextRoot:repositoryWorkspace
// jazzUrl should be : http[s]://server_name:port/contextRoot
int protocolIndex = jazzUrl.indexOf( ":" ) + 3; // The +3 accounts for the "://"
int portIndex = jazzUrl.indexOf( ":", protocolIndex + 1 );
hostname = jazzUrl.substring( protocolIndex, portIndex );
int pathIndex = jazzUrl.indexOf( "/", portIndex + 1 );
String portNo = jazzUrl.substring( portIndex + 1, pathIndex );
try
{
port = Integer.parseInt( portNo );
}
catch ( NumberFormatException nfe )
{
throw new ScmRepositoryException(
"Jazz Url \"" + jazzUrl + "\" is not a valid URL. The Jazz Url syntax is " + JAZZ_URL_FORMAT );
}
}
else
{
// jazzUrlAndWorkspace should be: http[s]://server_name/contextRoot:repositoryWorkspace
// jazzUrl should be : http[s]://server_name/contextRoot
// So we will set port to zero.
int protocolIndex = jazzUrl.indexOf( ":" ) + 3; // The +3 accounts for the "://"
int pathIndex = jazzUrl.indexOf( "/", protocolIndex + 1 );
if ( ( protocolIndex != -1 ) && ( pathIndex != -1 ) )
{
hostname = jazzUrl.substring( protocolIndex, pathIndex );
}
else
{
throw new ScmRepositoryException(
"Jazz Url \"" + jazzUrl + "\" is not a valid URL. The Jazz Url syntax is " + JAZZ_URL_FORMAT );
}
}
getLogger().debug( "Creating JazzScmProviderRepository with the following values:" );