001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sec.service.impl; 017 018 import java.util.List; 019 020 import org.kuali.kfs.sec.SecConstants; 021 import org.kuali.kfs.sec.document.validation.impl.AccessSecurityAccountingDocumentRuleBase; 022 import org.kuali.rice.kns.document.TransactionalDocument; 023 import org.kuali.rice.kns.service.ParameterService; 024 import org.kuali.rice.kns.service.impl.TransactionalDocumentDictionaryServiceImpl; 025 026 027 /** 028 * Overrides of transaction dictionary service to return the access security business rule class for certain doc types 029 */ 030 public class SecTransactionalDocumentDictionaryServiceImpl extends TransactionalDocumentDictionaryServiceImpl { 031 protected ParameterService parameterService; 032 033 /** 034 * Checks system parameter defining document types implementing access security and if type of given document is in list returns the access security rule base for the rules 035 * class 036 * 037 * @see org.kuali.rice.kns.service.impl.TransactionalDocumentDictionaryServiceImpl#getBusinessRulesClass(org.kuali.rice.kns.document.TransactionalDocument) 038 */ 039 @Override 040 public Class getBusinessRulesClass(TransactionalDocument document) { 041 String documentType = document.getDocumentHeader().getWorkflowDocument().getDocumentType(); 042 043 // list of document types configured for access security 044 List<String> documentTypes = parameterService.getParameterValues(SecConstants.ACCESS_SECURITY_NAMESPACE_CODE, SecConstants.ALL_PARAMETER_DETAIL_COMPONENT, SecConstants.SecurityParameterNames.ACCESS_SECURITY_DOCUMENT_TYPES); 045 if (documentTypes.contains(documentType)) { 046 return AccessSecurityAccountingDocumentRuleBase.class; 047 } 048 049 return super.getBusinessRulesClass(document); 050 } 051 052 /** 053 * Sets the parameterService attribute value. 054 * 055 * @param parameterService The parameterService to set. 056 */ 057 public void setParameterService(ParameterService parameterService) { 058 this.parameterService = parameterService; 059 } 060 061 062 }