/** * This method executes the DataDictionary Validation against the document. It's an exact replica * of MaintenanceDocumentRuleBase with the exception of the error path being * "document.newMaintainableObject.businessObject" instead of "document.newMaintainableObject". * TODO: Find a better solution as this duplicates code and is prone to failure if the rice * framework changes, specifically its dataDictionaryValidate method. * * @param document * @return true if it passes DD validation, false otherwise */ @Override protected boolean dataDictionaryValidate(MaintenanceDocument document) { LOG.debug("MaintenanceDocument validation beginning"); // explicitly put the errorPath that the dictionaryValidationService requires GlobalVariables.getMessageMap().addToErrorPath("document.newMaintainableObject.businessObject"); // document must have a newMaintainable object Maintainable newMaintainable = document.getNewMaintainableObject(); if (newMaintainable == null) { GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject"); throw new ValidationException( "Maintainable object from Maintenance Document '" + document.getDocumentTitle() + "' is null, unable to proceed."); } // document's newMaintainable must contain an object (ie, not null) PersistableBusinessObject businessObject = newMaintainable.getBusinessObject(); if (businessObject == null) { GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject."); throw new ValidationException("Maintainable's component business object is null."); } // run required check from maintenance data dictionary maintDocDictionaryService.validateMaintenanceRequiredFields(document); // check for duplicate entries in collections if necessary maintDocDictionaryService.validateMaintainableCollectionsForDuplicateEntries(document); // run the DD DictionaryValidation (non-recursive) dictionaryValidationService.validateBusinessObject(businessObject, false); // do default (ie, mandatory) existence checks dictionaryValidationService.validateDefaultExistenceChecks(businessObject); // explicitly remove the errorPath we've added GlobalVariables.getMessageMap() .removeFromErrorPath("document.newMaintainableObject.businessObject"); LOG.debug("MaintenanceDocument validation ending"); return true; }