1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.impl.cxf.interceptors;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.log4j.Logger;
20 import org.kuali.rice.core.api.config.property.Config;
21 import org.kuali.rice.core.api.config.property.ConfigContext;
22
23 import java.util.Collections;
24 import java.util.List;
25 import java.util.Map;
26
27
28
29
30 public class ServiceCallVersioningHelper {
31 private static final Logger LOG = Logger.getLogger(ServiceCallVersioningOutInterceptor.class);
32
33 public static final String KUALI_RICE_ENVIRONMENT_HEADER = "X-Kuali-Env";
34 public static final String KUALI_RICE_VERSION_HEADER = "X-Kuali-Rice-Ver";
35 public static final String KUALI_APP_NAME_HEADER = "X-Kuali-App-Name";
36 public static final String KUALI_APP_VERSION_HEADER = "X-Kuali-App-Ver";
37
38 private ServiceCallVersioningHelper() {
39
40
41
42
43
44
45
46 public static void populateVersionHeaders(Map<String, List<String>> headers) {
47 Config config = ConfigContext.getCurrentContextConfig();
48 if (config == null) {
49 LOG.error("No configuration context found when handling outbound message");
50
51
52 return;
53 }
54
55 String riceEnvironment = config.getEnvironment();
56 assert StringUtils.isNotBlank(riceEnvironment) : "Rice environment should never be blank";
57 if (StringUtils.isNotBlank(riceEnvironment)) {
58 headers.put(KUALI_RICE_ENVIRONMENT_HEADER, Collections.singletonList(riceEnvironment));
59 }
60
61 String riceVersion = config.getRiceVersion();
62 assert StringUtils.isNotBlank(riceVersion) : "Rice version should never be blank";
63 if (StringUtils.isNotBlank(riceVersion)) {
64 headers.put(KUALI_RICE_VERSION_HEADER, Collections.singletonList(riceVersion));
65 }
66
67 String appName = config.getApplicationName();
68 if (StringUtils.isNotBlank(appName)) {
69 headers.put(KUALI_APP_NAME_HEADER, Collections.singletonList(appName));
70 }
71
72 String appVersion = config.getApplicationVersion();
73 if (StringUtils.isNotBlank(appVersion)) {
74 headers.put(KUALI_APP_VERSION_HEADER, Collections.singletonList(appVersion));
75 }
76 }
77 }