1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.onehippo.forge.camel.component.hippo;
17
18 import org.apache.camel.CamelContext;
19 import org.apache.camel.Exchange;
20 import org.apache.camel.support.DefaultMessage;
21 import org.apache.camel.util.ObjectHelper;
22
23 import net.sf.json.JSONObject;
24
25 public class HippoEventMessage extends DefaultMessage {
26
27 public HippoEventMessage(final Exchange exchange) {
28 super(exchange);
29 }
30
31 public HippoEventMessage(final CamelContext camelContext) {
32 super(camelContext);
33 }
34
35 @Override
36 public String toString() {
37 if (getBody() != null) {
38 return "HippoEventMessage[event: " + getBody() + "]";
39 }
40
41 return "HippoEventMessage@" + ObjectHelper.getIdentityHashCode(this);
42 }
43
44 @Override
45 public void copyFrom(org.apache.camel.Message that) {
46 if (that == this) {
47
48 return;
49 }
50
51
52
53 getHeaders().clear();
54
55
56
57 Object body = that.getBody();
58
59 if (body != null && body instanceof JSONObject) {
60 setBody(JSONObject.fromObject((JSONObject) body));
61 } else {
62 setBody(body);
63 }
64
65
66 if (that.hasHeaders()) {
67 getHeaders().putAll(that.getHeaders());
68 }
69
70 }
71 }