listenerSummary = new ReleaseListenerSummary();
if ( getContinuum().getConfiguration().isDistributedBuildEnabled() )
{
DistributedReleaseManager releaseManager = getContinuum().getDistributedReleaseManager();
Map map;
try
{
map = releaseManager.getListener( releaseId );
}
catch ( BuildAgentConfigurationException e )
{
List<String> args = new ArrayList<String>();
args.add( e.getMessage() );
addActionError( getText( "releaseInProgress.error", args ) );
return ERROR;
}
if ( map != null && !map.isEmpty() )
{
int state = DistributedReleaseUtil.getReleaseState( map );
if ( state == ContinuumReleaseManagerListener.LISTENING )
{
status = "inProgress";
}
else if ( state == ContinuumReleaseManagerListener.FINISHED )
{
status = SUCCESS;
}
else
{
status = "initialized";
}
if ( status.equals( SUCCESS ) )
{
ReleaseResult result = releaseManager.getReleaseResult( releaseId );
if ( result != null && getContinuum().getContinuumReleaseResult( projectId, releaseGoal, result.getStartTime(), result.getEndTime() ) == null )
{
ContinuumReleaseResult releaseResult = createContinuumReleaseResult( result );
getContinuum().addContinuumReleaseResult( releaseResult );
}
}
listenerSummary.setPhases( DistributedReleaseUtil.getReleasePhases( map ) );
listenerSummary.setCompletedPhases( DistributedReleaseUtil.getCompletedReleasePhases( map ) );
listenerSummary.setInProgress( DistributedReleaseUtil.getReleaseInProgress( map ) );
listenerSummary.setError( DistributedReleaseUtil.getReleaseError( map ) );
}
else
{
throw new Exception( "There is no on-going or finished release operation with id " + releaseId );
}
}
else
{
ContinuumReleaseManager releaseManager = getContinuum().getReleaseManager();
listener = (ContinuumReleaseManagerListener) releaseManager.getListeners().get( releaseId );
if ( listener != null )
{
if ( listener.getState() == ContinuumReleaseManagerListener.LISTENING )
{
status = "inProgress";
}
else if ( listener.getState() == ContinuumReleaseManagerListener.FINISHED )
{
status = SUCCESS;
}
else
{
status = "initialized";
}
listenerSummary.setPhases( listener.getPhases() );
listenerSummary.setCompletedPhases( listener.getCompletedPhases() );
listenerSummary.setInProgress( listener.getInProgress() );
listenerSummary.setError( listener.getError() );
}
else
{
throw new Exception( "There is no on-going or finished release operation with id " + releaseId );
}
if ( status.equals( SUCCESS ) )
{
ReleaseResult result = (ReleaseResult) releaseManager.getReleaseResults().get( releaseId );
if ( result != null && getContinuum().getContinuumReleaseResult( projectId, releaseGoal, result.getStartTime(), result.getEndTime() ) == null )
{
ContinuumReleaseResult releaseResult = createContinuumReleaseResult( result );
getContinuum().addContinuumReleaseResult( releaseResult );