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  
 package org.kuali.rice.core.cxf.interceptors;
 2  
 
 3  
 import org.apache.cxf.interceptor.Fault;
 4  
 import org.apache.cxf.message.Message;
 5  
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 6  
 import org.apache.cxf.phase.Phase;
 7  
 import org.kuali.rice.core.api.util.CollectionUtils;
 8  
 
 9  
 import java.lang.reflect.Field;
 10  
 import java.util.Collection;
 11  
 import java.util.Collections;
 12  
 import java.util.List;
 13  
 import java.util.Map;
 14  
 import java.util.Set;
 15  
 
 16  
 /**
 17  
  * A CXF Interceptor that binds itself to the USER_LOGICAL phase to be used on inbound
 18  
  * messages.  This interceptor is invoked in the interceptor chain after unmarshalling
 19  
  * from XML to Java has occurred.  The role of this interceptor is to ensure that any
 20  
  * Collection (and specifically List, Set, or Map) used in a @WebMethod is ultimately of the
 21  
  * expected immutable type returned from the local service.
 22  
  */
 23  
 @SuppressWarnings("unused")
 24  
 public class ImmutableCollectionsInInterceptor extends AbstractPhaseInterceptor<Message> {
 25  
 
 26  
     /**
 27  
      * Instantiates an ImmutableCollectionsInInterceptor and adds it to the USER_LOGICAL phase.
 28  
      */
 29  
     public ImmutableCollectionsInInterceptor() {
 30  0
         super(Phase.USER_LOGICAL);
 31  0
     }
 32  
 
 33  
     @Override
 34  
     public void handleMessage(final Message message) throws Fault {
 35  
         try {
 36  0
             List contents = message.getContent(List.class);
 37  0
             for (Object o : contents) {
 38  0
                 CollectionUtils.makeUnmodifiableAndNullSafe(o);
 39  
             }
 40  0
         } catch (IllegalAccessException e) {
 41  0
             throw new Fault(e);
 42  0
         }
 43  0
     }
 44  
 }