public String saveGroup()
throws Exception
{
boolean found = false;
ConfigurationService configuration = getContinuum().getConfiguration();
selectedbuildAgents = getBuildAgentsFromSelectedBuildAgents();
if ( buildAgentGroup.getName() != null )
{
if ( buildAgentGroup.getName().equals( "" ) )
{
addActionError( getResourceBundle().getString( "buildAgentGroup.error.name.required" ) );
return INPUT;
}
else if ( buildAgentGroup.getName().trim().equals( "" ) )
{
addActionError( getText( "buildAgentGroup.error.name.cannot.be.spaces" ) );
return INPUT;
}
}
if ( configuration.getBuildAgentGroups() != null )
{
for ( BuildAgentGroupConfiguration group : configuration.getBuildAgentGroups() )
{
if ( buildAgentGroup.getName().equals( group.getName() ) )
{
group.setName( buildAgentGroup.getName() );
configuration.updateBuildAgentGroup( group );
found = true;
break;
}
}
}
AuditLog event = new AuditLog( "Build Agent Group=" + buildAgentGroup.getName(), AuditLogConstants.MODIFY_BUILD_AGENT_GROUP );
event.setCategory( AuditLogConstants.BUILD_AGENT );
event.setCurrentUser( getPrincipal() );
if ( !found )
{
buildAgentGroup.setBuildAgents( selectedbuildAgents );
configuration.addBuildAgentGroup( buildAgentGroup );
event.setAction( AuditLogConstants.ADD_BUILD_AGENT_GROUP );
}
else
// found
{
if ( typeGroup.equals( "new" ) )
{
addActionError( getResourceBundle().getString( "buildAgentGroup.error.duplicate" ) );
return INPUT;
}
else if ( typeGroup.equals( "edit" ) )
{
buildAgentGroup.setBuildAgents( selectedbuildAgents );
configuration.updateBuildAgentGroup( buildAgentGroup );
}
}
getContinuum().getDistributedBuildManager().reload();
event.log();