{
List<BuildDefinition> selectedBuildDefinitions = getBuildDefinitionsFromSelectedBuildDefinitions();
BuildDefinitionTemplate result;
AuditLog event = new AuditLog( buildDefinitionTemplate.getName(), AuditLogConstants.ADD_TEMPLATE );
event.setCategory( AuditLogConstants.TEMPLATE );
event.setCurrentUser( getPrincipal() );
if ( this.buildDefinitionTemplate.getId() > 0 )
{
buildDefinitionTemplate.setBuildDefinitions( selectedBuildDefinitions );
result = this.getContinuum().getBuildDefinitionService().updateBuildDefinitionTemplate( buildDefinitionTemplate );
event.setAction( AuditLogConstants.MODIFY_TEMPLATE );
}
else
{
buildDefinitionTemplate.setBuildDefinitions( selectedBuildDefinitions );
this.buildDefinitionTemplate =
this.getContinuum().getBuildDefinitionService().addBuildDefinitionTemplate( buildDefinitionTemplate );
result = this.buildDefinitionTemplate;
}
if ( result == null )
{
addActionError( getText( "buildDefintionTemplate.name.exists" ) );
return INPUT;
}
else
{
event.log();
}
return SUCCESS;
}