Coverage Report - org.kuali.rice.kim.util.KimCommonUtilsInternal
 
Classes in this File Line Coverage Branch Coverage Complexity
KimCommonUtilsInternal
0%
0/18
0%
0/12
3.25
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.rice.kim.util;
 17  
 
 18  
 import org.apache.commons.beanutils.PropertyUtils;
 19  
 import org.kuali.rice.kim.api.KimConstants;
 20  
 import org.kuali.rice.krad.service.KRADServiceLocator;
 21  
 
 22  
 /**
 23  
  * This is a description of what this class does - bhargavp don't forget to fill
 24  
  * this in.
 25  
  *
 26  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 27  
  *
 28  
  */
 29  
 public final class KimCommonUtilsInternal {
 30  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KimCommonUtilsInternal.class);
 31  
 
 32  0
         private KimCommonUtilsInternal() {
 33  0
                 throw new UnsupportedOperationException("do not call");
 34  
         }
 35  
 
 36  
     public static void copyProperties(Object targetToCopyTo, Object sourceToCopyFrom){
 37  0
                 if(targetToCopyTo!=null && sourceToCopyFrom!=null)
 38  
                 try{
 39  0
                         PropertyUtils.copyProperties(targetToCopyTo, sourceToCopyFrom);
 40  0
                 } catch(Exception ex){
 41  0
                         throw new RuntimeException("Failed to copy from source object: "+sourceToCopyFrom.getClass()+" to target object: "+targetToCopyTo,ex);
 42  0
                 }
 43  0
         }
 44  
 
 45  
         public static String getKimBasePath(){
 46  0
                 String kimBaseUrl = KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
 47  
                 KimConstants.KimUIConstants.KIM_URL_KEY);
 48  0
                 if (!kimBaseUrl.endsWith(KimConstants.KimUIConstants.URL_SEPARATOR)) {
 49  0
                         kimBaseUrl = kimBaseUrl + KimConstants.KimUIConstants.URL_SEPARATOR;
 50  
                 }
 51  0
                 return kimBaseUrl;
 52  
         }
 53  
 
 54  
         public static String getPathWithKimContext(String path, String kimActionName){
 55  0
                 String kimContext = KimConstants.KimUIConstants.KIM_APPLICATION+KimConstants.KimUIConstants.URL_SEPARATOR;
 56  0
                 String kimContextParameterized = KimConstants.KimUIConstants.KIM_APPLICATION+KimConstants.KimUIConstants.PARAMETERIZED_URL_SEPARATOR;
 57  0
             if(path.contains(kimActionName) && !path.contains(kimContext + kimActionName)
 58  
                             && !path.contains(kimContextParameterized + kimActionName))
 59  0
                     path = path.replace(kimActionName, kimContext+kimActionName);
 60  0
             return path;
 61  
         }
 62  
 }