1 /**
2 * Copyright 2005-2012 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.ksb.impl.cxf.interceptors;
17
18 import org.apache.cxf.interceptor.Fault;
19 import org.apache.cxf.message.Message;
20 import org.apache.cxf.phase.AbstractPhaseInterceptor;
21 import org.apache.cxf.phase.Phase;
22
23 import java.util.List;
24 import java.util.Map;
25
26 /**
27 * A CXF Interceptor that binds itself to the USER_PROTOCOL phase to be used on outbound
28 * messages. The role of this interceptor is to populate outgoing protocol headers
29 * (for all intents and purposes, HTTP headers) with Kuali Rice and application version
30 * information.
31 * @see <a href="http://cxf.apache.org/docs/interceptors.html">CXF interceptors</a>
32 */
33 public class ServiceCallVersioningOutInterceptor extends AbstractPhaseInterceptor<Message> {
34 /**
35 * Instantiates an ServiceCallVersioningOutInterceptor and adds it to the USER_PROTOCOL phase.
36 */
37 public ServiceCallVersioningOutInterceptor() {
38 super(Phase.USER_PROTOCOL);
39 }
40
41 /**
42 * Publishes the Kuali Rice Environment, Rice Version, Application Name and Application Version
43 * in outbound protocol headers
44 */
45 @Override
46 public void handleMessage(final Message message) throws Fault {
47 Map<String, List<String>> headers = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS);
48 if (headers != null) {
49 ServiceCallVersioningHelper.populateVersionHeaders(headers);
50 }
51 }
52 }