if (errorBuffer.length() > 0) {
errorBuffer.insert(0, "\r\n");
errorBuffer.insert(errorBuffer.length(), "\r\n");
}
throw new DemoiselleException(bundle.getString(
"management-validation-constraint-violation", managedType.getType()
.getCanonicalName(), propertyName, errorBuffer.toString()));
}
} else {
logger.warn(bundle.getString("management-validation-validator-not-found"));
}
Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();
Object oldValue;
try {
oldValue = getterMethod.invoke(delegate, (Object[]) null);
} catch (Exception e) {
oldValue = null;
}
method.invoke(delegate, new Object[] { newValue });
// Manda uma notificação de mudança de atributo
NotificationManager notificationManager = Beans.getReference(NotificationManager.class);
Class<? extends Object> attributeType = newValue != null ? newValue.getClass() : null;
AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString(
"management-notification-attribute-changed", propertyName, managedType.getType()
.getCanonicalName()), propertyName, attributeType, oldValue, newValue);
notificationManager.sendNotification(notification);
} catch (DemoiselleException de) {
throw de;
} catch (Exception e) {
throw new DemoiselleException(bundle.getString("management-invoke-error", method.getName()), e);
} finally {
deactivateContexts(managedType.getType());
}
} else {
throw new DemoiselleException(bundle.getString("management-write-value-error", propertyName));
}
} else {
throw new DemoiselleException(bundle.getString("management-type-not-found"));
}
}