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