ProjectVersionMetadata versionMetadata )
throws MetadataRepositoryException
{
String namespaceKey =
new Namespace.KeyBuilder().withRepositoryId( repositoryId ).withNamespace( namespaceId ).build();
Namespace namespace = getNamespaceEntityManager().get( namespaceKey );
if ( namespace == null )
{
namespace = updateOrAddNamespace( repositoryId, namespaceId );
}
String key = new Project.KeyBuilder().withNamespace( namespace ).withProjectId( projectId ).build();
Project project = getProjectEntityManager().get( key );
if ( project == null )
{
project = new Project( key, projectId, namespace );
getProjectEntityManager().put( project );
}
// we don't test of repository and namespace really exist !
key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( repositoryId ).withNamespace(
namespaceId ).withProjectId( projectId ).withId( versionMetadata.getId() ).build();
ProjectVersionMetadataModel projectVersionMetadataModel =
getProjectVersionMetadataModelEntityManager().get( key );
if ( projectVersionMetadataModel == null )
{
projectVersionMetadataModel =
getModelMapper().map( versionMetadata, ProjectVersionMetadataModel.class );
projectVersionMetadataModel.setRowId( key );
}
projectVersionMetadataModel.setProjectId( projectId );
projectVersionMetadataModel.setNamespace( new Namespace( namespaceId, new Repository( repositoryId ) ) );
projectVersionMetadataModel.setCiManagement( versionMetadata.getCiManagement() );
projectVersionMetadataModel.setIssueManagement( versionMetadata.getIssueManagement() );
projectVersionMetadataModel.setOrganization( versionMetadata.getOrganization() );
projectVersionMetadataModel.setScm( versionMetadata.getScm() );