| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 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 | |
|
| 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 | |
|
| 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 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
public boolean isDocumentOverviewValid(Document document) { |
| 135 | |
|
| 136 | 0 | GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME); |
| 137 | 0 | GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME); |
| 138 | |
|
| 139 | |
|
| 140 | 0 | getDictionaryValidationService().validateBusinessObject(document.getDocumentHeader()); |
| 141 | 0 | validateSensitiveDataValue(KRADPropertyConstants.EXPLANATION, document.getDocumentHeader().getExplanation(), |
| 142 | |
getDataDictionaryService().getAttributeLabel(DocumentHeader.class, KRADPropertyConstants.EXPLANATION)); |
| 143 | |
|
| 144 | |
|
| 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 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
public boolean isDocumentAttributesValid(Document document, boolean validateRequired) { |
| 160 | |
|
| 161 | 0 | GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME); |
| 162 | |
|
| 163 | |
|
| 164 | 0 | getDictionaryValidationService().validateDocumentAndUpdatableReferencesRecursively(document, getMaxDictionaryValidationDepth(), validateRequired); |
| 165 | |
|
| 166 | |
|
| 167 | 0 | GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.DOCUMENT_PROPERTY_NAME); |
| 168 | |
|
| 169 | 0 | return GlobalVariables.getMessageMap().hasNoErrors(); |
| 170 | |
} |
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 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 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
protected boolean processCustomSaveDocumentBusinessRules(Document document) { |
| 201 | 0 | return true; |
| 202 | |
} |
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | |
|
| 211 | |
public boolean processRouteDocument(Document document) { |
| 212 | 0 | boolean isValid = true; |
| 213 | |
|
| 214 | 0 | isValid = isDocumentAttributesValid(document, true); |
| 215 | |
|
| 216 | |
|
| 217 | 0 | if (isValid) { |
| 218 | 0 | isValid &= processCustomRouteDocumentBusinessRules(document); |
| 219 | |
} |
| 220 | 0 | return isValid; |
| 221 | |
} |
| 222 | |
|
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
protected boolean processCustomRouteDocumentBusinessRules(Document document) { |
| 231 | 0 | return true; |
| 232 | |
} |
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 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 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | |
|
| 256 | |
protected boolean processCustomApproveDocumentBusinessRules(ApproveDocumentEvent approveEvent) { |
| 257 | 0 | return true; |
| 258 | |
} |
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 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 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
public boolean isNoteValid(Note note) { |
| 282 | |
|
| 283 | 0 | GlobalVariables.getMessageMap().addToErrorPath(KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME); |
| 284 | |
|
| 285 | |
|
| 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 | |
|
| 292 | 0 | GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME); |
| 293 | |
|
| 294 | 0 | return GlobalVariables.getMessageMap().hasNoErrors(); |
| 295 | |
} |
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
protected boolean processCustomAddNoteBusinessRules(Document document, Note note) { |
| 306 | 0 | return true; |
| 307 | |
} |
| 308 | |
|
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 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 | |
|
| 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 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 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 | |
|
| 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 | |
|
| 365 | 0 | errorMap.removeFromErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME); |
| 366 | |
|
| 367 | 0 | return isValid; |
| 368 | |
} |
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
|
| 374 | |
|
| 375 | |
public boolean isAddHocRoutePersonValid(Document document, AdHocRoutePerson person) { |
| 376 | 0 | MessageMap errorMap = GlobalVariables.getMessageMap(); |
| 377 | |
|
| 378 | |
|
| 379 | 0 | if (errorMap.getErrorPath().size() == 0) { |
| 380 | |
|
| 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 | |
|
| 412 | 0 | errorMap.removeFromErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_PERSON_PROPERTY_NAME); |
| 413 | |
|
| 414 | 0 | return GlobalVariables.getMessageMap().hasNoErrors(); |
| 415 | |
} |
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | |
|
| 420 | |
|
| 421 | |
|
| 422 | |
|
| 423 | |
|
| 424 | |
|
| 425 | |
protected boolean processCustomAddAdHocRoutePersonBusinessRules(Document document, AdHocRoutePerson person) { |
| 426 | 0 | return true; |
| 427 | |
} |
| 428 | |
|
| 429 | |
|
| 430 | |
|
| 431 | |
|
| 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 | |
|
| 444 | |
|
| 445 | |
|
| 446 | |
|
| 447 | |
|
| 448 | |
public boolean isAddHocRouteWorkgroupValid(AdHocRouteWorkgroup workgroup) { |
| 449 | 0 | MessageMap errorMap = GlobalVariables.getMessageMap(); |
| 450 | |
|
| 451 | |
|
| 452 | 0 | if (errorMap.getErrorPath().size() == 0) { |
| 453 | |
|
| 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 | |
|
| 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 | |
|
| 476 | 0 | GlobalVariables.getMessageMap().removeFromErrorPath(KRADConstants.NEW_AD_HOC_ROUTE_WORKGROUP_PROPERTY_NAME); |
| 477 | |
|
| 478 | 0 | return GlobalVariables.getMessageMap().hasNoErrors(); |
| 479 | |
} |
| 480 | |
|
| 481 | |
|
| 482 | |
|
| 483 | |
|
| 484 | |
|
| 485 | |
|
| 486 | |
|
| 487 | |
|
| 488 | |
|
| 489 | |
protected boolean processCustomAddAdHocRouteWorkgroupBusinessRules(Document document, AdHocRouteWorkgroup workgroup) { |
| 490 | 0 | return true; |
| 491 | |
} |
| 492 | |
|
| 493 | |
|
| 494 | |
|
| 495 | |
|
| 496 | |
public int getMaxDictionaryValidationDepth() { |
| 497 | 0 | return this.maxDictionaryValidationDepth; |
| 498 | |
} |
| 499 | |
|
| 500 | |
|
| 501 | |
|
| 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 | |
} |