1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.ihe.xds.dispatch;
17
18 import org.apache.camel.Exchange;
19 import org.apache.camel.Expression;
20 import org.apache.camel.builder.RouteBuilder;
21 import org.apache.camel.component.cxf.common.message.CxfConstants;
22 import org.openehealth.ipf.commons.ihe.xds.core.SampleData;
23 import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryResponse;
24 import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryResponseType;
25 import org.openehealth.ipf.platform.camel.ihe.xds.XdsCamelValidators;
26
27 import javax.xml.namespace.QName;
28 import javax.xml.soap.SOAPFactory;
29 import javax.xml.ws.soap.SOAPFaultException;
30
31
32
33
34 public class DispatchRouteBuilder extends RouteBuilder {
35 @Override
36 public void configure() throws Exception {
37 from("cxf:bean:xdsRegistryEndpoint")
38 .choice()
39 .when(header(CxfConstants.OPERATION_NAME).isEqualTo("DocumentRegistry_RegistryStoredQuery"))
40 .to("direct:handle-iti18")
41 .when(header(CxfConstants.OPERATION_NAME).isEqualTo("DocumentRegistry_RegisterDocumentSet-b"))
42 .to("direct:handle-iti42")
43 .otherwise()
44 .to("direct:unsupportedOperation");
45
46 from("direct:handle-iti18")
47 .process(XdsCamelValidators.iti18RequestValidator())
48 .transform(new Expression() {
49 @Override
50 public <T> T evaluate(Exchange exchange, Class<T> type) {
51 return (T) SampleData.createQueryResponseWithObjRef();
52 }
53 })
54 .convertBodyTo(AdhocQueryResponse.class)
55 .process(XdsCamelValidators.iti18ResponseValidator());
56
57 from("direct:handle-iti42")
58 .process(XdsCamelValidators.iti42RequestValidator())
59 .transform(new Expression() {
60 @Override
61 public <T> T evaluate(Exchange exchange, Class<T> type) {
62 return (T) SampleData.createResponse();
63 }
64 })
65 .convertBodyTo(RegistryResponseType.class)
66 .process(XdsCamelValidators.iti42ResponseValidator());
67
68 from("direct:unsupportedOperation")
69 .throwException(new SOAPFaultException(SOAPFactory.newInstance().createFault(
70 "Unknown WSDL operation",
71 new QName("http://www.openehealth.org/ipf", "UNK"))));
72
73 }
74 }