View Javadoc
1   /*
2    * Copyright 2015 the original author or authors.
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.openehealth.ipf.platform.camel.ihe.xds.dispatch;
17  
18  import org.apache.cxf.interceptor.Fault;
19  import org.apache.cxf.jaxws.context.WebServiceContextImpl;
20  import org.apache.cxf.jaxws.handler.logical.LogicalMessageContextImpl;
21  import org.apache.cxf.message.Message;
22  import org.apache.cxf.phase.AbstractPhaseInterceptor;
23  import org.apache.cxf.phase.Phase;
24  import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditInRequestInterceptor;
25  
26  import javax.xml.ws.handler.MessageContext;
27  
28  /**
29   * @author Dmytro Rud
30   */
31  public class DispatchInContextCreatorInterceptor extends AbstractPhaseInterceptor<Message> {
32  
33      public DispatchInContextCreatorInterceptor() {
34          super(Phase.UNMARSHAL);
35          addBefore(AuditInRequestInterceptor.class.getName());
36     }
37  
38      @Override
39      public void handleMessage(Message message) throws Fault {
40          MessageContext messageContext = new WebServiceContextImpl().getMessageContext();
41          if (messageContext == null) {
42              messageContext = new LogicalMessageContextImpl(message);
43              WebServiceContextImpl.setMessageContext(messageContext);
44          }
45          messageContext.put(MessageContext.WSDL_OPERATION, message.get(MessageContext.WSDL_OPERATION));
46      }
47  }