View Javadoc

1   /*
2    * Copyright 2012 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  package org.kuali.ole.sec.service.impl;
17  
18  import org.kuali.ole.sec.document.validation.impl.AccessSecurityAccountingDocumentRuleBase;
19  import org.kuali.ole.sec.service.AccessSecurityService;
20  import org.kuali.ole.sys.context.SpringContext;
21  import org.kuali.rice.krad.document.Document;
22  import org.kuali.rice.krad.rules.rule.BusinessRule;
23  import org.kuali.rice.krad.service.impl.DocumentDictionaryServiceImpl;
24  
25  public class SecDocumentDictionaryServiceImpl extends DocumentDictionaryServiceImpl {
26      private AccessSecurityService accessSecurityService;
27  
28      protected AccessSecurityService getAccessSecurityService() {
29          if ( accessSecurityService == null ) {
30              accessSecurityService = SpringContext.getBean(AccessSecurityService.class);
31          }
32          return accessSecurityService;
33      }
34  
35      /**
36       * @see org.kuali.rice.krad.service.DocumentDictionaryService#getBusinessRulesClass
37       */
38      @Override
39      public Class<? extends BusinessRule> getBusinessRulesClass(Document document) {
40          String documentType = document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName();
41  
42          if (getAccessSecurityService().isAccessSecurityControlledDocumentType(documentType)) {
43              return AccessSecurityAccountingDocumentRuleBase.class;
44          }
45  
46          return super.getBusinessRulesClass(document);
47      }
48  }