* when registration could not be found.
*/
private void pauseResumeRegistration(DatabusRequest request, boolean doPause) throws IOException,
RequestProcessingException
{
DatabusRegistration r = null;
DatabusV3Registration r2 = null;
boolean found = true;
boolean isRunning = false;
boolean isPaused = false;
boolean isSuspended = false;
RegistrationId regId = null;
RequestProcessingException rEx = null;
RegStatePair regStatePair = null;
try
{
r = findV2Registration(request, PAUSE_REGISTRATION);
isRunning = r.getState().isRunning();
isPaused = (r.getState() == DatabusRegistration.RegistrationState.PAUSED);
isSuspended =
(r.getState() == DatabusRegistration.RegistrationState.SUSPENDED_ON_ERROR);
regId = r.getRegistrationId();
}
catch (RequestProcessingException ex)
{
found = false;
rEx = ex;
}
if (!found)
{
try
{
r2 = findV3Registration(request, PAUSE_REGISTRATION);
found = true;
isRunning = r2.getState().isRunning();
isPaused = (r2.getState() == RegistrationState.PAUSED);
isSuspended = (r2.getState() == RegistrationState.SUSPENDED_ON_ERROR);
regId = r.getRegistrationId();
}
catch (RequestProcessingException ex)
{
found = false;
rEx = ex;
}
}
if (!found)
throw rEx;
LOG.info("REST call to pause registration : " + regId);
if (isRunning)
{
if (doPause)
{
if (!isPaused)
{
if (null != r)
{
r.pause();
regStatePair = new RegStatePair(r.getState(), r.getRegistrationId());
}
else
{
r2.pause();
regStatePair = new RegStatePair(r2.getState().name(), r2.getRegistrationId());
}
}
}
else
{
if (isPaused || isSuspended)
{
if (null != r)
{
r.resume();
regStatePair = new RegStatePair(r.getState(), r.getRegistrationId());
}
else
{
r2.resume();
regStatePair = new RegStatePair(r2.getState().name(), r2.getRegistrationId());