1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.util;
17
18 import org.apache.commons.beanutils.PropertyUtils;
19 import org.kuali.rice.core.api.CoreApiServiceLocator;
20 import org.kuali.rice.kim.api.KimConstants;
21
22
23
24
25
26
27
28
29 public final class KimCommonUtilsInternal {
30 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KimCommonUtilsInternal.class);
31
32 private KimCommonUtilsInternal() {
33 throw new UnsupportedOperationException("do not call");
34 }
35
36 public static void copyProperties(Object targetToCopyTo, Object sourceToCopyFrom){
37 if(targetToCopyTo!=null && sourceToCopyFrom!=null)
38 try{
39 PropertyUtils.copyProperties(targetToCopyTo, sourceToCopyFrom);
40 } catch(Exception ex){
41 throw new RuntimeException("Failed to copy from source object: "+sourceToCopyFrom.getClass()+" to target object: "+targetToCopyTo,ex);
42 }
43 }
44
45 public static String getKimBasePath(){
46 String kimBaseUrl = CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(
47 KimConstants.KimUIConstants.KIM_URL_KEY);
48 if (!kimBaseUrl.endsWith(KimConstants.KimUIConstants.URL_SEPARATOR)) {
49 kimBaseUrl = kimBaseUrl + KimConstants.KimUIConstants.URL_SEPARATOR;
50 }
51 return kimBaseUrl;
52 }
53
54 public static String getPathWithKimContext(String path, String kimActionName){
55 String kimContext = KimConstants.KimUIConstants.KIM_APPLICATION+KimConstants.KimUIConstants.URL_SEPARATOR;
56 String kimContextParameterized = KimConstants.KimUIConstants.KIM_APPLICATION+KimConstants.KimUIConstants.PARAMETERIZED_URL_SEPARATOR;
57 if(path.contains(kimActionName) && !path.contains(kimContext + kimActionName)
58 && !path.contains(kimContextParameterized + kimActionName))
59 path = path.replace(kimActionName, kimContext+kimActionName);
60 return path;
61 }
62 }