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