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.openehealth.ipf.commons.ihe.xds.core.responses.ErrorCode;
22 import org.openehealth.ipf.commons.ihe.xds.core.responses.QueryResponse;
23 import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
24 import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryResponse;
25 import org.openehealth.ipf.platform.camel.core.util.Exchanges;
26 import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWebService;
27 import org.openehealth.ipf.platform.camel.ihe.xds.core.converters.EbXML30Converters;
28
29
30
31
32
33
34
35 @Slf4j
36 public abstract class XdsAdhocQueryService extends AbstractWebService {
37
38 private final String homeCommunityId;
39
40
41
42
43 public XdsAdhocQueryService(String homeCommunityId) {
44 this.homeCommunityId = homeCommunityId;
45 }
46
47 protected AdhocQueryResponse processRequest(AdhocQueryRequest body) {
48 Exchange result = process(body);
49 Exception exception = Exchanges.extractException(result);
50 if (exception != null) {
51 log.debug(getClass().getSimpleName() + " service failed", exception);
52 QueryResponse errorResponse = new QueryResponse(
53 exception,
54 ErrorCode.REGISTRY_METADATA_ERROR,
55 ErrorCode.REGISTRY_ERROR,
56 homeCommunityId);
57 errorResponse.getErrors().get(0).setLocation(homeCommunityId);
58 return EbXML30Converters.convert(errorResponse);
59 }
60 return Exchanges.resultMessage(result).getBody(AdhocQueryResponse.class);
61 }
62 }