This project has retired. For details please refer to its Attic page.
SoapActionRemoveInterceptor xref
View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.server.impl.webservices;
20  
21  import java.util.Iterator;
22  
23  import org.apache.cxf.binding.soap.SoapMessage;
24  import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
25  import org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor;
26  import org.apache.cxf.interceptor.Interceptor;
27  import org.apache.cxf.message.Message;
28  import org.apache.cxf.phase.Phase;
29  
30  /**
31   * Removes the CXF SOAP Action handling to be backwards compatible with the
32   * OpenCMIS server framework 0.13.0 and earlier.
33   */
34  public class SoapActionRemoveInterceptor extends AbstractSoapInterceptor {
35  
36      public SoapActionRemoveInterceptor() {
37          super(Phase.READ);
38          addBefore(SoapActionInInterceptor.class.getName());
39      }
40  
41      @Override
42      public void handleMessage(SoapMessage message) {
43          Interceptor<? extends Message> soapActionInInterceptor = null;
44          Iterator<Interceptor<? extends Message>> iterator = message.getInterceptorChain().getIterator();
45          while (iterator.hasNext()) {
46              Interceptor<? extends Message> interceptor = iterator.next();
47              if (interceptor instanceof SoapActionInInterceptor) {
48                  soapActionInInterceptor = interceptor;
49                  break;
50              }
51          }
52  
53          if (soapActionInInterceptor != null) {
54              message.getInterceptorChain().remove(soapActionInInterceptor);
55          }
56      }
57  }