1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.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 | 0 | public class ServiceCallVersioningHelper { |
31 | 0 | 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 | 0 | private ServiceCallVersioningHelper() { } |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public static void populateVersionHeaders(Map<String, List<String>> headers) { |
47 | 0 | Config config = ConfigContext.getCurrentContextConfig(); |
48 | 0 | if (config == null) { |
49 | 0 | LOG.error("No configuration context found when handling outbound message"); |
50 | |
|
51 | |
|
52 | 0 | return; |
53 | |
} |
54 | |
|
55 | 0 | String riceEnvironment = config.getEnvironment(); |
56 | 0 | assert StringUtils.isNotBlank(riceEnvironment) : "Rice environment should never be blank"; |
57 | 0 | if (StringUtils.isNotBlank(riceEnvironment)) { |
58 | 0 | headers.put(KUALI_RICE_ENVIRONMENT_HEADER, Collections.singletonList(riceEnvironment)); |
59 | |
} |
60 | |
|
61 | 0 | String riceVersion = config.getRiceVersion(); |
62 | 0 | assert StringUtils.isNotBlank(riceVersion) : "Rice version should never be blank"; |
63 | 0 | if (StringUtils.isNotBlank(riceVersion)) { |
64 | 0 | headers.put(KUALI_RICE_VERSION_HEADER, Collections.singletonList(riceVersion)); |
65 | |
} |
66 | |
|
67 | 0 | String appName = config.getApplicationName(); |
68 | 0 | if (StringUtils.isNotBlank(appName)) { |
69 | 0 | headers.put(KUALI_APP_NAME_HEADER, Collections.singletonList(appName)); |
70 | |
} |
71 | |
|
72 | 0 | String appVersion = config.getApplicationVersion(); |
73 | 0 | if (StringUtils.isNotBlank(appVersion)) { |
74 | 0 | headers.put(KUALI_APP_VERSION_HEADER, Collections.singletonList(appVersion)); |
75 | |
} |
76 | 0 | } |
77 | |
} |