1
2
3
4
5
6
7
8
9
10
11
12
13
14 package uk.nhs.interoperability.client.samples.cda;
15
16 import uk.nhs.interoperability.consumer.AbstractRoutedMessageServlet;
17 import uk.nhs.interoperability.consumer.ITKMessageConsumer;
18 import uk.nhs.interoperability.infrastructure.ITKMessagingException;
19 import uk.nhs.interoperability.payload.ITKMessage;
20 import uk.nhs.interoperability.util.Logger;
21
22
23
24
25
26
27
28
29 public class CDARepository extends AbstractRoutedMessageServlet implements ITKMessageConsumer{
30
31
32 private static final long serialVersionUID = -541728545823668074L;
33
34
35
36
37 public void onMessage(ITKMessage request) {
38 Logger.trace("This is CDA Repository receiving a message:onMessage()");
39 String docId = request.getMessageProperties().getBusinessPayloadId();
40 if (docId.substring(0,5).equals("uuid_")){
41 docId = docId.substring(5);
42 }
43 DocStore.putDocument(docId, request.getBusinessPayload());
44 Logger.trace("added document "+docId+" to repository.");
45
46
47 }
48
49
50
51
52 public ITKMessage onSyncMessage(ITKMessage request) throws ITKMessagingException {
53 throw new ITKMessagingException(ITKMessagingException.INVALID_MESSAGE_CODE, "Synchronous execution not supported");
54 }
55
56
57
58
59 @Override
60 public ITKMessageConsumer getMessageConsumer() {
61 return this;
62 }
63
64 }