1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.openehealth.ipf.platform.camel.ihe.xds;
18
19 import lombok.extern.slf4j.Slf4j;
20 import org.apache.camel.Exchange;
21 import org.apache.camel.ExchangePattern;
22 import org.openehealth.ipf.commons.ihe.xds.core.XdsJaxbDataBinding;
23 import org.openehealth.ipf.commons.ihe.xds.core.responses.ErrorCode;
24 import org.openehealth.ipf.commons.ihe.xds.core.responses.Response;
25 import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryResponseType;
26 import org.openehealth.ipf.platform.camel.core.util.Exchanges;
27 import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWebService;
28 import org.openehealth.ipf.platform.camel.ihe.xds.core.converters.EbXML30Converters;
29
30
31
32
33
34
35 @Slf4j
36 public abstract class XdsRegistryRequestService<T> extends AbstractWebService {
37
38 protected RegistryResponseType processRequest(T body) {
39 Exchange result = process(body, XdsJaxbDataBinding.getCamelHeaders(body), ExchangePattern.InOut);
40 Exception exception = Exchanges.extractException(result);
41 if (exception != null) {
42 log.debug(getClass().getSimpleName() + " service failed", exception);
43 Response errorResponse = new Response(
44 exception,
45 ErrorCode.REGISTRY_METADATA_ERROR,
46 ErrorCode.REGISTRY_ERROR, null);
47 return EbXML30Converters.convert(errorResponse);
48 }
49
50 return Exchanges.resultMessage(result).getBody(RegistryResponseType.class);
51 }
52 }