Invoke.java
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package th.co.ais.ssbsrfc.config;
import java.util.UUID;
import th.co.ais.ssbsrfc.utils.Global;
public class Invoke {
public String nodeName; // UDC, SRFC, SDF
public String key; // 6681234567
public String cmd = null; // callBackUrl, getFile
public String eventType = null; // Incoming_UDC_Response
public String unique;
public Object dev = null; // for developer
private static final String DELIMITER = ".";
public String getNodeName() {
return nodeName;
}
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getCmd() {
return cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public String getUnique() {
return unique;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public void setUnique(String unique) {
this.unique = unique;
}
public static String genUniqueId()
{
UUID uuid = UUID.randomUUID();
return uuid.toString();
}
public Object getDev() {
return dev;
}
public void setDev(Object dev) {
this.dev = dev;
}
public Invoke() {}
public Invoke(String invokeString)
{
String[] strSplit = null;
if(invokeString != null)
{
strSplit = invokeString.split("[\\"+DELIMITER+"]");
if(strSplit.length == 5)
{
this.nodeName = strSplit[0];
this.key = strSplit[1];
this.cmd = strSplit[2];
this.eventType = strSplit[3];
this.unique = strSplit[4];
} else if (strSplit.length == 6) {
this.nodeName = strSplit[0];
this.key = strSplit[1];
this.cmd = strSplit[2];
this.eventType = strSplit[3];
this.unique = strSplit[4];
this.dev = strSplit[5];
}
}
}
public Invoke(String _key, String _eventType) {
super();
String _cmd = StateConfig.getCommandFromEventType(eventType);
String _node = Global.getNodeFromEventType(eventType);
this.nodeName = _node;
this.key = _key;
this.cmd = _cmd;
this.eventType = _eventType;
UUID uuid = UUID.randomUUID();
this.unique = uuid.toString();
}
public Invoke(String _nodeName, String _key, String _cmd, String _eventType, String _unique)
{
// TODO check . in all variable (if have)
this.nodeName = _nodeName;
this.key = _key;
this.cmd = _cmd;
this.eventType = _eventType;
if(_unique == null)
{
UUID uuid = UUID.randomUUID();
this.unique = uuid.toString();
}
else
{
this.unique = _unique;
}
}
public String toString()
{
String strInvoke ="";
strInvoke = this.nodeName + DELIMITER + this.key + DELIMITER + this.cmd + DELIMITER + this.eventType + DELIMITER + this.unique;
if(this.dev != null) {
strInvoke += DELIMITER + this.dev.toString();
}
return strInvoke;
}
}