|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
     | 
  |  121 |     | 
     | 
  |  122 |     | 
     | 
  |  123 |     | 
     | 
  |  124 |     | 
     | 
  |  125 |     | 
       public boolean isDocumentOverviewValid(Document document) { | 
  |  126 |     | 
             | 
  |  127 |    0 |            GlobalVariables.getMessageMap().addToErrorPath(KNSConstants.DOCUMENT_PROPERTY_NAME);  | 
  |  128 |    0 |            GlobalVariables.getMessageMap().addToErrorPath(KNSConstants.DOCUMENT_HEADER_PROPERTY_NAME);  | 
  |  129 |     | 
     | 
  |  130 |     | 
             | 
  |  131 |    0 |            getDictionaryValidationService().validateBusinessObject(document.getDocumentHeader());  | 
  |  132 |    0 |            validateSensitiveDataValue(KNSPropertyConstants.EXPLANATION, document.getDocumentHeader().getExplanation(),  | 
  |  133 |     | 
                           getDataDictionaryService().getAttributeLabel(DocumentHeader.class, KNSPropertyConstants.EXPLANATION));  | 
  |  134 |     | 
     | 
  |  135 |     | 
             | 
  |  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 |     | 
     | 
  |  144 |     | 
     | 
  |  145 |     | 
     | 
  |  146 |     | 
     | 
  |  147 |     | 
     | 
  |  148 |     | 
     | 
  |  149 |     | 
     | 
  |  150 |     | 
       public boolean isDocumentAttributesValid(Document document, boolean validateRequired) { | 
  |  151 |     | 
             | 
  |  152 |    0 |            GlobalVariables.getMessageMap().addToErrorPath(KNSConstants.DOCUMENT_PROPERTY_NAME);  | 
  |  153 |     | 
     | 
  |  154 |     | 
             | 
  |  155 |    0 |            getDictionaryValidationService().validateDocumentAndUpdatableReferencesRecursively(document, getMaxDictionaryValidationDepth(), validateRequired);  | 
  |  156 |     | 
     | 
  |  157 |     | 
             | 
  |  158 |    0 |            GlobalVariables.getMessageMap().removeFromErrorPath(KNSConstants.DOCUMENT_PROPERTY_NAME);  | 
  |  159 |     | 
     | 
  |  160 |    0 |            return GlobalVariables.getMessageMap().hasNoErrors();  | 
  |  161 |     | 
       }  | 
  |  162 |     | 
     | 
  |  163 |     | 
         | 
  |  164 |     | 
     | 
  |  165 |     | 
     | 
  |  166 |     | 
     | 
  |  167 |     | 
     | 
  |  168 |     | 
     | 
  |  169 |     | 
     | 
  |  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 |     | 
     | 
  |  186 |     | 
     | 
  |  187 |     | 
     | 
  |  188 |     | 
     | 
  |  189 |     | 
     | 
  |  190 |     | 
     | 
  |  191 |     | 
       protected boolean processCustomSaveDocumentBusinessRules(Document document) { | 
  |  192 |    0 |            return true;  | 
  |  193 |     | 
       }  | 
  |  194 |     | 
     | 
  |  195 |     | 
         | 
  |  196 |     | 
     | 
  |  197 |     | 
     | 
  |  198 |     | 
     | 
  |  199 |     | 
     | 
  |  200 |     | 
     | 
  |  201 |     | 
     | 
  |  202 |     | 
       public boolean processRouteDocument(Document document) { | 
  |  203 |    0 |            boolean isValid = true;  | 
  |  204 |     | 
     | 
  |  205 |    0 |            isValid = isDocumentAttributesValid(document, true);  | 
  |  206 |     | 
     | 
  |  207 |     | 
             | 
  |  208 |    0 |            if (isValid) { | 
  |  209 |    0 |                isValid &= processCustomRouteDocumentBusinessRules(document);  | 
  |  210 |     | 
           }  | 
  |  211 |    0 |            return isValid;  | 
  |  212 |     | 
       }  | 
  |  213 |     | 
     | 
  |  214 |     | 
         | 
  |  215 |     | 
     | 
  |  216 |     | 
     | 
  |  217 |     | 
     | 
  |  218 |     | 
     | 
  |  219 |     | 
     | 
  |  220 |     | 
     | 
  |  221 |     | 
       protected boolean processCustomRouteDocumentBusinessRules(Document document) { | 
  |  222 |    0 |            return true;  | 
  |  223 |     | 
       }  | 
  |  224 |     | 
     | 
  |  225 |     | 
         | 
  |  226 |     | 
     | 
  |  227 |     | 
     | 
  |  228 |     | 
     | 
  |  229 |     | 
     | 
  |  230 |     | 
     | 
  |  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 |     | 
     | 
  |  242 |     | 
     | 
  |  243 |     | 
     | 
  |  244 |     | 
     | 
  |  245 |     | 
     | 
  |  246 |     | 
     | 
  |  247 |     | 
       protected boolean processCustomApproveDocumentBusinessRules(ApproveDocumentEvent approveEvent) { | 
  |  248 |    0 |            return true;  | 
  |  249 |     | 
       }  | 
  |  250 |     | 
     | 
  |  251 |     | 
         | 
  |  252 |     | 
     | 
  |  253 |     | 
     | 
  |  254 |     | 
     | 
  |  255 |     | 
     | 
  |  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 |     | 
     | 
  |  268 |     | 
     | 
  |  269 |     | 
     | 
  |  270 |     | 
     | 
  |  271 |     | 
     | 
  |  272 |     | 
       public boolean isNoteValid(Note note) { | 
  |  273 |     | 
             | 
  |  274 |    0 |            GlobalVariables.getMessageMap().addToErrorPath(KNSConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME);  | 
  |  275 |     | 
     | 
  |  276 |     | 
             | 
  |  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 |     | 
             | 
  |  283 |    0 |            GlobalVariables.getMessageMap().removeFromErrorPath(KNSConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME);  | 
  |  284 |     | 
     | 
  |  285 |    0 |            return GlobalVariables.getMessageMap().hasNoErrors();  | 
  |  286 |     | 
       }  | 
  |  287 |     | 
     | 
  |  288 |     | 
         | 
  |  289 |     | 
     | 
  |  290 |     | 
     | 
  |  291 |     | 
     | 
  |  292 |     | 
     | 
  |  293 |     | 
     | 
  |  294 |     | 
     | 
  |  295 |     | 
     | 
  |  296 |     | 
       protected boolean processCustomAddNoteBusinessRules(Document document, Note note) { | 
  |  297 |    0 |            return true;  | 
  |  298 |     | 
       }  | 
  |  299 |     | 
     | 
  |  300 |     | 
         | 
  |  301 |     | 
     | 
  |  302 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
     | 
  |  332 |     | 
     | 
  |  333 |     | 
     | 
  |  334 |     | 
     | 
  |  335 |     | 
     | 
  |  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 |     | 
                             | 
  |  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 |     | 
                     | 
  |  356 |    0 |                    errorMap.removeFromErrorPath(KNSConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME);  | 
  |  357 |     | 
     | 
  |  358 |    0 |                    return isValid;  | 
  |  359 |     | 
           }          | 
  |  360 |     | 
             | 
  |  361 |     | 
     | 
  |  362 |     | 
     | 
  |  363 |     | 
     | 
  |  364 |     | 
     | 
  |  365 |     | 
     | 
  |  366 |     | 
       public boolean isAddHocRoutePersonValid(Document document, AdHocRoutePerson person) { | 
  |  367 |    0 |            MessageMap errorMap = GlobalVariables.getMessageMap();  | 
  |  368 |     | 
     | 
  |  369 |     | 
             | 
  |  370 |    0 |            if (errorMap.getErrorPath().size() == 0) { | 
  |  371 |     | 
                 | 
  |  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 |     | 
             | 
  |  403 |    0 |            errorMap.removeFromErrorPath(KNSConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME);  | 
  |  404 |     | 
     | 
  |  405 |    0 |            return GlobalVariables.getMessageMap().hasNoErrors();  | 
  |  406 |     | 
       }  | 
  |  407 |     | 
     | 
  |  408 |     | 
         | 
  |  409 |     | 
     | 
  |  410 |     | 
     | 
  |  411 |     | 
     | 
  |  412 |     | 
     | 
  |  413 |     | 
     | 
  |  414 |     | 
     | 
  |  415 |     | 
     | 
  |  416 |     | 
       protected boolean processCustomAddAdHocRoutePersonBusinessRules(Document document, AdHocRoutePerson person) { | 
  |  417 |    0 |            return true;  | 
  |  418 |     | 
       }  | 
  |  419 |     | 
     | 
  |  420 |     | 
         | 
  |  421 |     | 
     | 
  |  422 |     | 
     | 
  |  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 |     | 
     | 
  |  435 |     | 
     | 
  |  436 |     | 
     | 
  |  437 |     | 
     | 
  |  438 |     | 
     | 
  |  439 |     | 
       public boolean isAddHocRouteWorkgroupValid(AdHocRouteWorkgroup workgroup) { | 
  |  440 |    0 |            MessageMap errorMap = GlobalVariables.getMessageMap();  | 
  |  441 |     | 
     | 
  |  442 |     | 
             | 
  |  443 |    0 |            if (errorMap.getErrorPath().size() == 0) { | 
  |  444 |     | 
                 | 
  |  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 |     | 
                 | 
  |  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 |     | 
             | 
  |  467 |    0 |            GlobalVariables.getMessageMap().removeFromErrorPath(KNSConstants.NEW_AD_HOC_ROUTE_WORKGROUP_PROPERTY_NAME);  | 
  |  468 |     | 
     | 
  |  469 |    0 |            return GlobalVariables.getMessageMap().hasNoErrors();  | 
  |  470 |     | 
       }  | 
  |  471 |     | 
     | 
  |  472 |     | 
         | 
  |  473 |     | 
     | 
  |  474 |     | 
     | 
  |  475 |     | 
     | 
  |  476 |     | 
     | 
  |  477 |     | 
     | 
  |  478 |     | 
     | 
  |  479 |     | 
     | 
  |  480 |     | 
       protected boolean processCustomAddAdHocRouteWorkgroupBusinessRules(Document document, AdHocRouteWorkgroup workgroup) { | 
  |  481 |    0 |            return true;  | 
  |  482 |     | 
       }  | 
  |  483 |     | 
     | 
  |  484 |     | 
         | 
  |  485 |     | 
     | 
  |  486 |     | 
     | 
  |  487 |     | 
       public int getMaxDictionaryValidationDepth() { | 
  |  488 |    0 |            return this.maxDictionaryValidationDepth;  | 
  |  489 |     | 
       }  | 
  |  490 |     | 
     | 
  |  491 |     | 
         | 
  |  492 |     | 
     | 
  |  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 |     | 
   }  |