Coverage Report - org.kuali.rice.core.cxf.interceptors.ServiceCallVersioningHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
ServiceCallVersioningHelper
0%
0/22
0%
0/18
4
 
 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.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  
  * Helps populate service call protocol headers with Rice version information.
 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() { /* static utility class */ }
 39  
 
 40  
     /**
 41  
      * Populates protocol headers represented by a map of list of strings with Kuali/Rice
 42  
      * versioning information, including Rice environment and version, and Rice application
 43  
      * name and version.
 44  
      * @param headers the protocol headers. let's be honest, they are just HTTP headers.
 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  
             // commented for the sake of tests
 51  
             // assert config != null : "No configuration context found when handling outbound message";
 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  
 }