public String modifyRegistration()
{
if (getConsumer() != null)
{
ProducerInfo info = getProducerInfo();
if (isModified())
{
// get updated registration info
RegistrationInfo newReg = getExpectedRegistrationInfo();
// make sure we save any modified registration properties
saveToRegistry(info);
// save old info in case something goes wrong
RegistrationInfo oldReg = getProducerInfo().getRegistrationInfo();
// check that we have the proper state
if (newReg == null)
{
// if we want to change an existing registration property (for example, to upgrade service) then there are
// no expected information, we're just using the modified local version
newReg = new RegistrationInfo(oldReg);
if (!isRegistrationLocallyModified())
{
IllegalStateException e =
new IllegalStateException("Registration not locally modified: there should be expected registration from producer!");
log.debug("Couldn't modify registration", e);
throw e;
}
}
try
{
// todo: this should be done better cf regPropListener
newReg.setModifiedSinceLastRefresh(true); // mark as modified to force refresh of RegistrationData
// attempt to modify the registration using new registration info
info.setRegistrationInfo(newReg);
info.modifyRegistration();
newReg.setModifiedSinceLastRefresh(false);
beanContext.createInfoMessage(MODIFY_REG_SUCCESS);
}
catch (Exception e)
{
// restore old info
info.setRegistrationInfo(oldReg);
beanContext.createErrorMessageFrom(e);
return null;
}