// Retrieve the policies element.
ODOMElement policies = (ODOMElement) deviceElement.getChild(
DeviceRepositorySchemaConstants.POLICIES_ELEMENT_NAME,
deviceElement.getNamespace());
DeviceODOMElement currentPolicy =
(DeviceODOMElement) context.
getDeviceRepositoryAccessorManager().
retrievePolicy(deviceName, policyName);
UndoRedoManager undoRedoManager = context.getUndoRedoManager();
undoRedoManager.demarcateUOW();
try {
// It may be the case that the user has chosen to override when
// override was previously selected in which case the resolved policy
// will come from the current device and we must do some special
// processing to handle the standard element that should be present
if (currentPolicy != null) {
currentPolicy.override((DeviceODOMElement) policy);
} else {
// This is an override. Where there is no existing policy so nothing to
// remove, only something to add.
policies.addContent(policy);
}