Coverage Report - org.kuali.rice.core.cxf.interceptors.ImmutableCollectionsInInterceptor
 
Classes in this File Line Coverage Branch Coverage Complexity
ImmutableCollectionsInInterceptor
0%
0/9
0%
0/2
2.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.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  
 import org.kuali.rice.core.api.util.collect.CollectionUtils;
 23  
 
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * A CXF Interceptor that binds itself to the USER_LOGICAL phase to be used on inbound
 28  
  * messages.  This interceptor is invoked in the interceptor chain after unmarshalling
 29  
  * from XML to Java has occurred.  The role of this interceptor is to ensure that any
 30  
  * Collection (and specifically List, Set, or Map) used in a @WebMethod is ultimately of the
 31  
  * expected immutable type returned from the local service.
 32  
  */
 33  
 @SuppressWarnings("unused")
 34  
 public class ImmutableCollectionsInInterceptor extends AbstractPhaseInterceptor<Message> {
 35  
 
 36  
     /**
 37  
      * Instantiates an ImmutableCollectionsInInterceptor and adds it to the USER_LOGICAL phase.
 38  
      */
 39  
     public ImmutableCollectionsInInterceptor() {
 40  0
         super(Phase.USER_LOGICAL);
 41  0
     }
 42  
 
 43  
     @Override
 44  
     public void handleMessage(final Message message) throws Fault {
 45  
         try {
 46  0
             List contents = message.getContent(List.class);
 47  0
             for (Object o : contents) {
 48  0
                 CollectionUtils.makeUnmodifiableAndNullSafe(o);
 49  
             }
 50  0
         } catch (IllegalAccessException e) {
 51  0
             throw new Fault(e);
 52  0
         }
 53  0
     }
 54  
 }