Coverage Report - org.kuali.rice.krad.rules.DocumentRuleBase
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentRuleBase
0%
0/140
0%
0/58
2.032
 
 1  
 /*
 2  
  * Copyright 2006-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.rice.krad.rules;
 18  
 
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.kuali.rice.core.api.config.property.ConfigurationService;
 21  
 import org.kuali.rice.core.framework.parameter.ParameterConstants;
 22  
 import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator;
 23  
 import org.kuali.rice.core.util.RiceKeyConstants;
 24  
 import org.kuali.rice.kim.api.group.Group;
 25  
 import org.kuali.rice.kim.api.group.GroupService;
 26  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 27  
 import org.kuali.rice.kim.bo.Person;
 28  
 import org.kuali.rice.kim.service.PermissionService;
 29  
 import org.kuali.rice.kim.service.PersonService;
 30  
 import org.kuali.rice.kim.util.KimConstants;
 31  
 import org.kuali.rice.krad.bo.AdHocRoutePerson;
 32  
 import org.kuali.rice.krad.bo.AdHocRouteWorkgroup;
 33  
 import org.kuali.rice.krad.bo.DocumentHeader;
 34  
 import org.kuali.rice.krad.bo.Note;
 35  
 import org.kuali.rice.krad.document.Document;
 36  
 import org.kuali.rice.krad.document.MaintenanceDocument;
 37  
 import org.kuali.rice.krad.document.TransactionalDocument;
 38  
 import org.kuali.rice.krad.rule.AddAdHocRoutePersonRule;
 39  
 import org.kuali.rice.krad.rule.AddAdHocRouteWorkgroupRule;
 40  
 import org.kuali.rice.krad.rule.AddNoteRule;
 41  
 import org.kuali.rice.krad.rule.ApproveDocumentRule;
 42  
 import org.kuali.rice.krad.rule.RouteDocumentRule;
 43  
 import org.kuali.rice.krad.rule.SaveDocumentRule;
 44  
 import org.kuali.rice.krad.rule.SendAdHocRequestsRule;
 45  
 import org.kuali.rice.krad.rule.event.ApproveDocumentEvent;
 46  
 import org.kuali.rice.krad.service.DataDictionaryService;
 47  
 import org.kuali.rice.krad.service.DictionaryValidationService;
 48  
 import org.kuali.rice.krad.service.DocumentHelperService;
 49  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 50  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 51  
 import org.kuali.rice.krad.util.GlobalVariables;
 52  
 import org.kuali.rice.krad.util.KRADConstants;
 53  
 import org.kuali.rice.krad.util.KRADPropertyConstants;
 54  
 import org.kuali.rice.krad.util.KRADUtils;
 55  
 import org.kuali.rice.krad.util.MessageMap;
 56  
 import org.kuali.rice.krad.workflow.service.KualiWorkflowInfo;
 57  
 
 58  
 
 59  
 /**
 60  
  * This class contains all of the business rules that are common to all documents.
 61  
  */
 62  0
 public abstract class DocumentRuleBase implements SaveDocumentRule, RouteDocumentRule, ApproveDocumentRule, AddNoteRule, AddAdHocRoutePersonRule, AddAdHocRouteWorkgroupRule, SendAdHocRequestsRule {
 63  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentRuleBase.class);
 64  
 
 65  
     private static PersonService personService;
 66  
     private static DictionaryValidationService dictionaryValidationService;
 67  
     private static KualiWorkflowInfo workflowInfoService;
 68  
     private static ConfigurationService kualiConfigurationService;
 69  
     private static DocumentHelperService documentHelperService;
 70  
     private static GroupService groupService;
 71  
     private static PermissionService permissionService;
 72  
     private static DataDictionaryService dataDictionaryService;
 73  
     
 74  
     /**
 75  
      * Just some arbitrarily high max depth that's unlikely to occur in real life to prevent recursion problems
 76  
      */
 77  0
     private int maxDictionaryValidationDepth = 100;
 78  
 
 79  
     protected PersonService getPersonService() {
 80  0
         if ( personService == null ) {
 81  0
             personService = KimApiServiceLocator.getPersonService();
 82  
         }
 83  0
         return personService;
 84  
     }
 85  
 
 86  
     public static GroupService getGroupService() {
 87  0
         if ( groupService == null ) {
 88  0
             groupService = KimApiServiceLocator.getGroupService();
 89  
         }
 90  0
         return groupService;
 91  
     }
 92  
 
 93  
     public static PermissionService getPermissionService() {
 94  0
         if ( permissionService == null ) {
 95  0
             permissionService = KimApiServiceLocator.getPermissionService();
 96  
         }
 97  0
         return permissionService;
 98  
     }
 99  
 
 100  
     protected DocumentHelperService getDocumentHelperService() {
 101  0
         if ( documentHelperService == null ) {
 102  0
             documentHelperService = KRADServiceLocatorWeb.getDocumentHelperService();
 103  
         }
 104  0
         return documentHelperService;
 105  
     }
 106  
 
 107  
     protected DictionaryValidationService getDictionaryValidationService() {
 108  0
         if ( dictionaryValidationService == null ) {
 109  0
             dictionaryValidationService = KRADServiceLocatorWeb.getDictionaryValidationService();
 110  
         }
 111  0
         return dictionaryValidationService;
 112  
     }
 113  
 
 114  
     protected KualiWorkflowInfo getWorkflowInfoService() {
 115  0
         if ( workflowInfoService == null ) {
 116  0
             workflowInfoService = KRADServiceLocatorWeb.getWorkflowInfoService();
 117  
         }
 118  0
         return workflowInfoService;
 119  
     }
 120  
 
 121  
     protected ConfigurationService getKualiConfigurationService() {
 122  0
         if ( kualiConfigurationService == null ) {
 123  0
             kualiConfigurationService = KRADServiceLocator.getKualiConfigurationService();
 124  
         }
 125  0
         return kualiConfigurationService;
 126  
     }
 127  
 
 128  
     /**
 129  
      * Verifies that the document's overview fields are valid - it does required and format checks.
 130  
      * 
 131  
      * @param document
 132  
      * @return boolean True if the document description is valid, false otherwise.
 133  
      */
 134  
     public boolean isDocumentOverviewValid(Document document) {
 135  
         // add in the documentHeader path
 136  0
         GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME);
 137  0
         GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME);
 138  
 
 139  
         // check the document header for fields like the description
 140  0
         getDictionaryValidationService().validateBusinessObject(document.getDocumentHeader());
 141  0
         validateSensitiveDataValue(KRADPropertyConstants.EXPLANATION, document.getDocumentHeader().getExplanation(),
 142  
                         getDataDictionaryService().getAttributeLabel(DocumentHeader.class, KRADPropertyConstants.EXPLANATION));
 143  
 
 144  
         // drop the error path keys off now
 145  0
         GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME);
 146  0
         GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME);
 147  
 
 148  0
         return GlobalVariables.getMessageMap().hasNoErrors();
 149  
     }
 150  
 
 151  
     /**
 152  
      * Validates the document attributes against the data dictionary.
 153  
      * 
 154  
      * @param document
 155  
      * @param validateRequired if true, then an error will be retruned if a DD required field is empty. if false, no required
 156  
      *        checking is done
 157  
      * @return True if the document attributes are valid, false otherwise.
 158  
      */
 159  
     public boolean isDocumentAttributesValid(Document document, boolean validateRequired) {
 160  
         // start updating the error path name
 161  0
         GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME);
 162  
 
 163  
         // check the document for fields like explanation and org doc #
 164  0
         getDictionaryValidationService().validateDocumentAndUpdatableReferencesRecursively(document, getMaxDictionaryValidationDepth(), validateRequired);
 165  
 
 166  
         // drop the error path keys off now
 167  0
         GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME);
 168  
 
 169  0
         return GlobalVariables.getMessageMap().hasNoErrors();
 170  
     }
 171  
 
 172  
     /**
 173  
      * Runs all business rules needed prior to saving. This includes both common rules for all documents, plus class-specific
 174  
      * business rules. This method will only return false if it fails the isValidForSave() test. Otherwise, it will always return
 175  
      * positive regardless of the outcome of the business rules. However, any error messages resulting from the business rules will
 176  
      * still be populated, for display to the consumer of this service.
 177  
      * 
 178  
      * @see org.kuali.rice.krad.rule.SaveDocumentRule#processSaveDocument(org.kuali.rice.krad.document.Document)
 179  
      */
 180  
     public boolean processSaveDocument(Document document) {
 181  0
         boolean isValid = true;
 182  0
         isValid = isDocumentOverviewValid(document);
 183  0
         GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME);
 184  0
         getDictionaryValidationService().validateDocumentAndUpdatableReferencesRecursively(document, getMaxDictionaryValidationDepth(), false);
 185  0
         getDictionaryValidationService().validateDefaultExistenceChecksForTransDoc((TransactionalDocument) document);
 186  0
         GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME);
 187  0
         isValid &= GlobalVariables.getMessageMap().hasNoErrors();
 188  0
         isValid &= processCustomSaveDocumentBusinessRules(document);
 189  
 
 190  0
         return isValid;
 191  
     }
 192  
 
 193  
     /**
 194  
      * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
 195  
      * the "save document" event.
 196  
      * 
 197  
      * @param document
 198  
      * @return boolean True if the rules checks passed, false otherwise.
 199  
      */
 200  
     protected boolean processCustomSaveDocumentBusinessRules(Document document) {
 201  0
         return true;
 202  
     }
 203  
 
 204  
     /**
 205  
      * Runs all business rules needed prior to routing. This includes both common rules for all maintenance documents, plus
 206  
      * class-specific business rules. This method will return false if any business rule fails, or if the document is in an invalid
 207  
      * state, and not routable (see isDocumentValidForRouting()).
 208  
      * 
 209  
      * @see org.kuali.rice.krad.rule.RouteDocumentRule#processRouteDocument(org.kuali.rice.krad.document.Document)
 210  
      */
 211  
     public boolean processRouteDocument(Document document) {
 212  0
         boolean isValid = true;
 213  
 
 214  0
         isValid = isDocumentAttributesValid(document, true);
 215  
 
 216  
         // don't validate the document if the header is invalid
 217  0
         if (isValid) {
 218  0
             isValid &= processCustomRouteDocumentBusinessRules(document);
 219  
         }
 220  0
         return isValid;
 221  
     }
 222  
 
 223  
     /**
 224  
      * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
 225  
      * the "route document" event.
 226  
      * 
 227  
      * @param document
 228  
      * @return boolean True if the rules checks passed, false otherwise.
 229  
      */
 230  
     protected boolean processCustomRouteDocumentBusinessRules(Document document) {
 231  0
         return true;
 232  
     }
 233  
 
 234  
     /**
 235  
      * Runs all business rules needed prior to approving. This includes both common rules for all documents, plus class-specific
 236  
      * business rules. This method will return false if any business rule fails, or if the document is in an invalid state, and not
 237  
      * approveble.
 238  
      * 
 239  
      * @see org.kuali.rice.krad.rule.ApproveDocumentRule#processApproveDocument(org.kuali.rice.krad.rule.event.ApproveDocumentEvent)
 240  
      */
 241  
     public boolean processApproveDocument(ApproveDocumentEvent approveEvent) {
 242  0
         boolean isValid = true;
 243  
 
 244  0
         isValid = processCustomApproveDocumentBusinessRules(approveEvent);
 245  
 
 246  0
         return isValid;
 247  
     }
 248  
 
 249  
     /**
 250  
      * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
 251  
      * the "approve document" event.
 252  
      * 
 253  
      * @param approveEvent
 254  
      * @return boolean True if the rules checks passed, false otherwise.
 255  
      */
 256  
     protected boolean processCustomApproveDocumentBusinessRules(ApproveDocumentEvent approveEvent) {
 257  0
         return true;
 258  
     }
 259  
 
 260  
     /**
 261  
      * Runs all business rules needed prior to adding a document note. This method will return false if any business rule fails.
 262  
      * 
 263  
      * @see org.kuali.rice.krad.rule.AddDocumentNoteRule#processAddDocumentNote(org.kuali.rice.krad.document.Document,
 264  
      *      org.kuali.rice.krad.document.DocumentNote)
 265  
      */
 266  
     public boolean processAddNote(Document document, Note note) {
 267  0
         boolean isValid = true;
 268  
 
 269  0
         isValid &= isNoteValid(note);
 270  0
         isValid &= processCustomAddNoteBusinessRules(document, note);
 271  
 
 272  0
         return isValid;
 273  
     }
 274  
 
 275  
     /**
 276  
      * Verifies that the note's fields are valid - it does required and format checks.
 277  
      * 
 278  
      * @param note
 279  
      * @return boolean True if the document description is valid, false otherwise.
 280  
      */
 281  
     public boolean isNoteValid(Note note) {
 282  
         // add the error path keys on the stack
 283  0
         GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME);
 284  
 
 285  
         // check the document header for fields like the description
 286  0
         getDictionaryValidationService().validateBusinessObject(note);
 287  
 
 288  0
         validateSensitiveDataValue(KRADConstants.NOTE_TEXT_PROPERTY_NAME, note.getNoteText(),
 289  
                         getDataDictionaryService().getAttributeLabel(Note.class, KRADConstants.NOTE_TEXT_PROPERTY_NAME));
 290  
         
 291  
         // drop the error path keys off now
 292  0
         GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME);
 293  
 
 294  0
         return GlobalVariables.getMessageMap().hasNoErrors();
 295  
     }
 296  
 
 297  
     /**
 298  
      * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
 299  
      * the "add document note" event.
 300  
      * 
 301  
      * @param document
 302  
      * @param note
 303  
      * @return boolean True if the rules checks passed, false otherwise.
 304  
      */
 305  
     protected boolean processCustomAddNoteBusinessRules(Document document, Note note) {
 306  0
         return true;
 307  
     }
 308  
 
 309  
     /**
 310  
      * @see org.kuali.rice.krad.rule.AddAdHocRoutePersonRule#processAddAdHocRoutePerson(org.kuali.rice.krad.document.Document,
 311  
      *      org.kuali.rice.krad.bo.AdHocRoutePerson)
 312  
      */
 313  
     public boolean processAddAdHocRoutePerson(Document document, AdHocRoutePerson adHocRoutePerson) {
 314  0
         boolean isValid = true;
 315  
 
 316  0
         isValid &= isAddHocRoutePersonValid(document, adHocRoutePerson);
 317  
 
 318  0
         isValid &= processCustomAddAdHocRoutePersonBusinessRules(document, adHocRoutePerson);
 319  0
         return isValid;
 320  
     }
 321  
 
 322  
     
 323  
     /**
 324  
          * @see org.kuali.rice.krad.rule.SendAdHocRequestsRule#processSendAdHocRequests(org.kuali.rice.krad.document.Document)
 325  
          */
 326  
         public boolean processSendAdHocRequests(Document document) {
 327  0
                 boolean isValid = true;
 328  
 
 329  0
                 isValid &= isAdHocRouteRecipientsValid(document);
 330  0
                 isValid &= processCustomSendAdHocRequests(document);
 331  
                 
 332  0
                 return isValid;
 333  
         }
 334  
 
 335  
         protected boolean processCustomSendAdHocRequests(Document document) {
 336  0
                 return true;
 337  
         }
 338  
 
 339  
         /**
 340  
          * Checks the adhoc route recipient list to ensure there are recipients or
 341  
          * else throws an error that at least one recipient is required.
 342  
          * 
 343  
          * @param document
 344  
          * @return
 345  
          */
 346  
         protected boolean isAdHocRouteRecipientsValid(Document document) {
 347  0
                 boolean isValid = true;
 348  0
                 MessageMap errorMap = GlobalVariables.getMessageMap();
 349  
 
 350  0
                 if (errorMap.getErrorPath().size() == 0) {
 351  
                         // add the error path keys on the stack
 352  0
                         errorMap.addToErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME);
 353  
                 }
 354  
 
 355  0
                 if ((document.getAdHocRoutePersons() == null || document
 356  
                                 .getAdHocRoutePersons().isEmpty())
 357  
                                 && (document.getAdHocRouteWorkgroups() == null || document
 358  
                                                 .getAdHocRouteWorkgroups().isEmpty())) {
 359  
 
 360  0
                         GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, "error.adhoc.missing.recipients");
 361  0
                         isValid = false;
 362  
                 }
 363  
 
 364  
                 // drop the error path keys off now
 365  0
                 errorMap.removeFromErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME);
 366  
 
 367  0
                 return isValid;
 368  
         }        
 369  
         /**
 370  
      * Verifies that the adHocRoutePerson's fields are valid - it does required and format checks.
 371  
      * 
 372  
      * @param person
 373  
      * @return boolean True if valid, false otherwise.
 374  
      */
 375  
     public boolean isAddHocRoutePersonValid(Document document, AdHocRoutePerson person) {
 376  0
         MessageMap errorMap = GlobalVariables.getMessageMap();
 377  
 
 378  
         // new recipients are not embedded in the error path; existing lines should be
 379  0
         if (errorMap.getErrorPath().size() == 0) {
 380  
             // add the error path keys on the stack
 381  0
             errorMap.addToErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME);
 382  
         }
 383  
         
 384  0
         if (StringUtils.isNotBlank(person.getId())) {
 385  0
             Person user = getPersonService().getPersonByPrincipalName(person.getId());
 386  
             
 387  0
             if (user == null) {
 388  0
                 GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_INVALID_ADHOC_PERSON_ID);
 389  
             }
 390  0
             else if ( !getPermissionService().hasPermission(user.getPrincipalId(), KimConstants.KIM_TYPE_DEFAULT_NAMESPACE,
 391  
                     KimConstants.PermissionNames.LOG_IN, null) ) {
 392  0
                 GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_INACTIVE_ADHOC_PERSON_ID);
 393  
             }
 394  
             else {
 395  0
                 Class docOrBoClass = null;
 396  0
                 if (document instanceof MaintenanceDocument) {
 397  0
                     docOrBoClass = ((MaintenanceDocument) document).getNewMaintainableObject().getDataObjectClass();
 398  
                 }
 399  
                 else {
 400  0
                     docOrBoClass = document.getClass();
 401  
                 }
 402  0
                 if (!getDocumentHelperService().getDocumentAuthorizer(document).canReceiveAdHoc(document, user, person.getActionRequested())) {
 403  0
                     GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_UNAUTHORIZED_ADHOC_PERSON_ID);
 404  
                 }
 405  
             }
 406  0
         }
 407  
         else {
 408  0
             GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_MISSING_ADHOC_PERSON_ID);
 409  
         }
 410  
 
 411  
         // drop the error path keys off now
 412  0
         errorMap.removeFromErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME);
 413  
 
 414  0
         return GlobalVariables.getMessageMap().hasNoErrors();
 415  
     }
 416  
 
 417  
     /**
 418  
      * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
 419  
      * the "add ad hoc route person" event.
 420  
      * 
 421  
      * @param document
 422  
      * @param person
 423  
      * @return boolean True if the rules checks passed, false otherwise.
 424  
      */
 425  
     protected boolean processCustomAddAdHocRoutePersonBusinessRules(Document document, AdHocRoutePerson person) {
 426  0
         return true;
 427  
     }
 428  
 
 429  
     /**
 430  
      * @see org.kuali.rice.krad.rule.AddAdHocRouteWorkgroupRule#processAddAdHocRouteWorkgroup(org.kuali.rice.krad.document.Document,
 431  
      *      org.kuali.rice.krad.bo.AdHocRouteWorkgroup)
 432  
      */
 433  
     public boolean processAddAdHocRouteWorkgroup(Document document, AdHocRouteWorkgroup adHocRouteWorkgroup) {
 434  0
         boolean isValid = true;
 435  
 
 436  0
         isValid &= isAddHocRouteWorkgroupValid(adHocRouteWorkgroup);
 437  
 
 438  0
         isValid &= processCustomAddAdHocRouteWorkgroupBusinessRules(document, adHocRouteWorkgroup);
 439  0
         return isValid;
 440  
     }
 441  
 
 442  
     /**
 443  
      * Verifies that the adHocRouteWorkgroup's fields are valid - it does required and format checks.
 444  
      * 
 445  
      * @param workgroup
 446  
      * @return boolean True if valid, false otherwise.
 447  
      */
 448  
     public boolean isAddHocRouteWorkgroupValid(AdHocRouteWorkgroup workgroup) {
 449  0
         MessageMap errorMap = GlobalVariables.getMessageMap();
 450  
 
 451  
         // new recipients are not embedded in the error path; existing lines should be
 452  0
         if (errorMap.getErrorPath().size() == 0) {
 453  
             // add the error path keys on the stack
 454  0
             GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_WORKGROUP_PROPERTY_NAME);
 455  
         }
 456  
 
 457  0
         if (workgroup.getRecipientName() != null && workgroup.getRecipientNamespaceCode() != null) {
 458  
             // validate that they are a workgroup from the workgroup service by looking them up
 459  
             try {
 460  0
                 Group group = getGroupService().getGroupByName(workgroup.getRecipientNamespaceCode(), workgroup.getRecipientName());
 461  0
                 if (group == null || !group.isActive()) {
 462  0
                     GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_INVALID_ADHOC_WORKGROUP_ID);
 463  
                 }
 464  
             }
 465  0
             catch (Exception e) {
 466  0
                 LOG.error("isAddHocRouteWorkgroupValid(AdHocRouteWorkgroup)", e);
 467  
 
 468  0
                 GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_INVALID_ADHOC_WORKGROUP_ID);
 469  0
             }
 470  
         }
 471  
         else {
 472  0
             GlobalVariables.getMessageMap().putError(KRADPropertyConstants.ID, RiceKeyConstants.ERROR_MISSING_ADHOC_WORKGROUP_ID);
 473  
         }
 474  
 
 475  
         // drop the error path keys off now
 476  0
         GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_WORKGROUP_PROPERTY_NAME);
 477  
 
 478  0
         return GlobalVariables.getMessageMap().hasNoErrors();
 479  
     }
 480  
 
 481  
     /**
 482  
      * This method should be overridden by children rule classes as a hook to implement document specific business rule checks for
 483  
      * the "add ad hoc route workgroup" event.
 484  
      * 
 485  
      * @param document
 486  
      * @param workgroup
 487  
      * @return boolean True if the rules checks passed, false otherwise.
 488  
      */
 489  
     protected boolean processCustomAddAdHocRouteWorkgroupBusinessRules(Document document, AdHocRouteWorkgroup workgroup) {
 490  0
         return true;
 491  
     }
 492  
 
 493  
     /**
 494  
      * Gets the maximum number of levels the data-dictionary based validation will recurse for the document
 495  
      */
 496  
     public int getMaxDictionaryValidationDepth() {
 497  0
         return this.maxDictionaryValidationDepth;
 498  
     }
 499  
 
 500  
     /**
 501  
      * Gets the maximum number of levels the data-dictionary based validation will recurse for the document
 502  
      */
 503  
     public void setMaxDictionaryValidationDepth(int maxDictionaryValidationDepth) {
 504  0
         if (maxDictionaryValidationDepth < 0) {
 505  0
             LOG.error("Dictionary validation depth should be greater than or equal to 0.  Value received was: " + maxDictionaryValidationDepth);
 506  0
             throw new RuntimeException("Dictionary validation depth should be greater than or equal to 0.  Value received was: " + maxDictionaryValidationDepth);
 507  
         }
 508  0
         this.maxDictionaryValidationDepth = maxDictionaryValidationDepth;
 509  0
     }
 510  
 
 511  
     protected boolean validateSensitiveDataValue(String fieldName, String fieldValue, String fieldLabel) {
 512  0
             boolean dataValid = true;
 513  
             
 514  0
             if (fieldValue == null) {
 515  0
                     return dataValid;
 516  
             }
 517  
             
 518  0
             boolean patternFound = KRADUtils.containsSensitiveDataPatternMatch(fieldValue);
 519  0
                 boolean warnForSensitiveData = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsBoolean(
 520  
                 KRADConstants.KRAD_NAMESPACE, ParameterConstants.ALL_COMPONENT,
 521  
                 KRADConstants.SystemGroupParameterNames.SENSITIVE_DATA_PATTERNS_WARNING_IND);
 522  0
             if (patternFound && !warnForSensitiveData) {
 523  0
                     dataValid = false;
 524  0
                     GlobalVariables.getMessageMap().putError(fieldName,
 525  
                                             RiceKeyConstants.ERROR_DOCUMENT_FIELD_CONTAINS_POSSIBLE_SENSITIVE_DATA, fieldLabel);
 526  
             }
 527  
             
 528  0
             return dataValid;
 529  
     }
 530  
     
 531  
     protected DataDictionaryService getDataDictionaryService() {
 532  0
             if (dataDictionaryService == null) {
 533  0
                     dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
 534  
             }
 535  0
             return dataDictionaryService;
 536  
     }
 537  
 }