final POM pom,
final String baseUrl ) {
final FileSystem fs = Paths.convert( repository.getRoot() ).getFileSystem();
try {
//Projects are always created in the FS root
final Path fsRoot = repository.getRoot();
final Path projectRootPath = Paths.convert( Paths.convert( fsRoot ).resolve( projectName ) );
ioService.startBatch( new FileSystem[]{fs}, makeCommentedOption( "New project [" + projectName + "]" ) );
//Create POM.xml
pomService.create( projectRootPath,
baseUrl,
pom );
//Raise an event for the new project
final Project project = resolveProject( projectRootPath );
newProjectEvent.fire( new NewProjectEvent( project, sessionInfo ) );
//Create a default workspace based on the GAV
final String legalJavaGroupId[] = IdentifierUtils.convertMavenIdentifierToJavaIdentifier( pom.getGav().getGroupId().split( "\\.",
-1 ) );
final String legalJavaArtifactId[] = IdentifierUtils.convertMavenIdentifierToJavaIdentifier( pom.getGav().getArtifactId().split( "\\.",
-1 ) );
final String defaultWorkspacePath = StringUtils.join( legalJavaGroupId,
"/" ) + "/" + StringUtils.join( legalJavaArtifactId,
"/" );
final Path defaultPackagePath = Paths.convert( Paths.convert( projectRootPath ).resolve( MAIN_RESOURCES_PATH ) );
final org.guvnor.common.services.project.model.Package defaultPackage = resolvePackage( defaultPackagePath );
final Package defaultWorkspacePackage = doNewPackage( defaultPackage,
defaultWorkspacePath,
false );