001 /** 002 * Copyright 2005-2014 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.rice.kim.util; 017 018 import org.apache.commons.beanutils.PropertyUtils; 019 import org.kuali.rice.kim.api.KimConstants; 020 import org.kuali.rice.krad.service.KRADServiceLocator; 021 022 /** 023 * This is a description of what this class does - bhargavp don't forget to fill 024 * this in. 025 * 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 * 028 */ 029 public final class KimCommonUtilsInternal { 030 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KimCommonUtilsInternal.class); 031 032 private KimCommonUtilsInternal() { 033 throw new UnsupportedOperationException("do not call"); 034 } 035 036 public static void copyProperties(Object targetToCopyTo, Object sourceToCopyFrom){ 037 if(targetToCopyTo!=null && sourceToCopyFrom!=null) 038 try{ 039 PropertyUtils.copyProperties(targetToCopyTo, sourceToCopyFrom); 040 } catch(Exception ex){ 041 throw new RuntimeException("Failed to copy from source object: "+sourceToCopyFrom.getClass()+" to target object: "+targetToCopyTo,ex); 042 } 043 } 044 045 public static String getKimBasePath(){ 046 String kimBaseUrl = KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString( 047 KimConstants.KimUIConstants.KIM_URL_KEY); 048 if (!kimBaseUrl.endsWith(KimConstants.KimUIConstants.URL_SEPARATOR)) { 049 kimBaseUrl = kimBaseUrl + KimConstants.KimUIConstants.URL_SEPARATOR; 050 } 051 return kimBaseUrl; 052 } 053 054 public static String getPathWithKimContext(String path, String kimActionName){ 055 String kimContext = KimConstants.KimUIConstants.KIM_APPLICATION+KimConstants.KimUIConstants.URL_SEPARATOR; 056 String kimContextParameterized = KimConstants.KimUIConstants.KIM_APPLICATION+KimConstants.KimUIConstants.PARAMETERIZED_URL_SEPARATOR; 057 if(path.contains(kimActionName) && !path.contains(kimContext + kimActionName) 058 && !path.contains(kimContextParameterized + kimActionName)) 059 path = path.replace(kimActionName, kimContext+kimActionName); 060 return path; 061 } 062 }