Coverage Report - org.kuali.rice.kew.web.ContextSensitiveConverter
 
Classes in this File Line Coverage Branch Coverage Complexity
ContextSensitiveConverter
0%
0/7
0%
0/2
2
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.web;
 18  
 
 19  
 import org.apache.commons.beanutils.Converter;
 20  
 
 21  
 /**
 22  
  * A BeanUtils Converter which delegates to an original convertor or a KEW converter depending on
 23  
  * what the current {@link ModuleContext} is.  This allows for the KEW struts module to run inside
 24  
  * of an ActionServlet that has the "convertNull" init-param set to null.  The KEW module
 25  
  * depends on this being set to true in order for the form processing to work properly.
 26  
  * When KEW is embedded in a web application where this is not the case, we need to work
 27  
  * around the issue by registering custom converters to convert the values properly when inside
 28  
  * the context of the KEW struts module but preserve the conversion behavior of the parent
 29  
  * struts module.
 30  
  *
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 32  
  */
 33  
 public class ContextSensitiveConverter implements Converter {
 34  
 
 35  
         private Converter originalConverter;
 36  
         private Converter kewConverter;
 37  
 
 38  0
         public ContextSensitiveConverter(Converter originalConverter, Converter kewConverter) {
 39  0
                 this.originalConverter = originalConverter;
 40  0
                 this.kewConverter = kewConverter;
 41  0
         }
 42  
 
 43  
         public Object convert(Class type, Object object) {
 44  0
                 if (ModuleContext.isKew()) {
 45  0
                         return kewConverter.convert(type, object);
 46  
                 } else {
 47  0
                         return originalConverter.convert(type, object);
 48  
                 }
 49  
         }
 50  
 
 51  
 }