-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcRESTModule.pkg
More file actions
118 lines (89 loc) · 3.57 KB
/
cRESTModule.pkg
File metadata and controls
118 lines (89 loc) · 3.57 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
Use UI
Class cRESTModule is a cObject
Procedure Construct_Object
Forward Send Construct_Object
Property String psInterfacePath
Property String psInterfaceDesc
Property Boolean pbAutoRegister True
Property Boolean pbIncludeInApiRoot True
Property String[] pasInterfacePaths
Property Handle[] pahoInterfaces
Property Integer piNestingDepth (piNestingDepth(Parent(Self)) + 1)
End_Procedure
Procedure End_Construct_Object
If (pbAutoRegister(Self)) ;
Delegate Send RegisterInterface Self
Forward Send End_Construct_Object
End_Procedure
Procedure RegisterInterface Handle hoObj
Handle[] ahoInterfaces
Integer iIdx
String sPath
String[] asPaths
Get pahoInterfaces to ahoInterfaces
Move (SearchArray(hoObj, ahoInterfaces)) to iIdx
If (iIdx <> -1) ;
Procedure_Return // Already registered
Move (SizeOfArray(ahoInterfaces)) to iIdx
Get psInterfacePath of hoObj to sPath
If (sPath = "") Begin
Error 999 ("Interface path (psInterfacePath) not set for ResourceHandlerObject" * ;
Name(hoObj))
Procedure_Return
End
Move (Lowercase(sPath)) to sPath
Get pasInterfacePaths to asPaths
Move hoObj to ahoInterfaces[iIdx]
Move sPath to asPaths[iIdx]
Set pahoInterfaces to ahoInterfaces
Set pasInterfacePaths to asPaths
End_Procedure
Procedure AddRegisteredCollections Handle hoResp
Handle[] ahoInterfaces
Integer iLast i
String sPath sDesc
Boolean bInc
Handle hoObj
Get pahoInterfaces to ahoInterfaces
Move (SizeOfArray(ahoInterfaces) - 1) to iLast
For i From 0 to iLast
Move ahoInterfaces[i] to hoObj
Get pbIncludeInAPIRoot of hoObj to bInc
If bInc Begin
Get psInterfacePath of hoObj to sPath
Get psInterfaceDesc of hoObj to sDesc
If (sDesc = "") ;
Move sPath to sDesc
Send AddCollection hoResp sDesc ;
(BaseURL(Self) + "/" + psInterfacePath(Self) + "/" + sPath)
End
Loop
End_Procedure
Procedure ModuleRoot
Handle hoResp
Get CreateJsonObject to hoResp
Send SetMemberValue of hoResp "Module Name" jsonTypeString (psInterfaceDesc(Self))
Send AddRegisteredCollections hoResp
Send OutputJson hoResp
End_Procedure
Procedure ProcessRequest
String sPart1
String[] asPaths
Integer iIdx
Handle[] ahoHandlers
Get PathPart (piNestingDepth(Self)) to sPart1
If (sPart1 = "") ;
Send ModuleRoot
Else Begin
Move (Lowercase(sPart1)) to sPart1
Get pasInterfacePaths to asPaths
Move (SearchArray(sPart1, asPaths)) to iIdx
If (iIdx = -1) Begin // Not registered
Send UnrecognisedOperation
Procedure_Return
End
Get pahoInterfaces to ahoHandlers
Send ProcessRequest of ahoHandlers[iIdx]
End
End_Procedure
End_Class