1- Include MDX2JSON .MDX2JSON
2-
3- /// All logic related to the proceccing of http requests.
4- Class MDX2JSON .AbstractREST Extends %CSP .REST
5- {
6-
7- Parameter UseSession As Integer = 1 ;
8-
9- /// This method gets called prior to dispatch of the request. Put any common code here
10- /// that you want to be executed for EVERY request. If pContinue is set to 0, the
11- /// request will NOT be dispatched according to the UrlMap. In this case it's the
12- /// responsibility of the user to return a response.
13- ClassMethod OnPreDispatch (pUrl As %String , pMethod As %String , ByRef pContinue As %Boolean ) As %Status
14- {
1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <Export generator =" Cache" version =" 25" >
3+ <Class name =" MDX2JSON.AbstractREST" >
4+ <Description >
5+ All logic related to the proceccing of http requests.</Description >
6+ <IncludeCode >MDX2JSON.MDX2JSON</IncludeCode >
7+ <Super >%CSP.REST</Super >
8+ <TimeCreated >63572,78432.426689</TimeCreated >
9+
10+ <Parameter name =" UseSession" >
11+ <Type >Integer</Type >
12+ <Default >1</Default >
13+ </Parameter >
14+
15+ <Method name =" OnPreDispatch" >
16+ <Description >
17+ This method gets called prior to dispatch of the request. Put any common code here
18+ that you want to be executed for EVERY request. If pContinue is set to 0, the
19+ request will NOT be dispatched according to the UrlMap. In this case it's the
20+ responsibility of the user to return a response.</Description >
21+ <ClassMethod >1</ClassMethod >
22+ <FormalSpec ><![CDATA[ pUrl:%String,pMethod:%String,&pContinue:%Boolean]]> </FormalSpec >
23+ <ReturnType >%Status</ReturnType >
24+ <Implementation ><![CDATA[
1525 Set pContinue = 1
1626 #dim request As %CSP.Request
1727 Do %response.SetHeader("Access-Control-Allow-Origin",..GetOrigins())
@@ -48,11 +58,15 @@ ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue A
4858 }
4959
5060 Quit $$$OK
51- }
52-
53- /// Converts request into UTF8. Converts request into proxyObject.
54- ClassMethod ConvertRequestBody () As %Status
55- {
61+ ]]> </Implementation >
62+ </Method >
63+
64+ <Method name =" ConvertRequestBody" >
65+ <Description >
66+ Converts request into UTF8. Converts request into proxyObject. </Description >
67+ <ClassMethod >1</ClassMethod >
68+ <ReturnType >%Status</ReturnType >
69+ <Implementation ><![CDATA[
5670 #dim %request As %CSP.Request
5771 #dim obj As %ZEN.proxyObject
5872
@@ -67,18 +81,27 @@ ClassMethod ConvertRequestBody() As %Status
6781
6882 set %request.Content = obj // obj here is a valid UTF8 proxyObject with required property
6983 return $$$OK
70- }
71-
72- /// Get Origin from %request object
73- ClassMethod GetOrigins () As %String
74- {
84+ ]]> </Implementation >
85+ </Method >
86+
87+ <Method name =" GetOrigins" >
88+ <Description >
89+ Get Origin from %request object </Description >
90+ <ClassMethod >1</ClassMethod >
91+ <ReturnType >%String</ReturnType >
92+ <Implementation ><![CDATA[
7593 set url = %request.GetCgiEnv("HTTP_REFERER")
7694 return $p(url,"/",1,3) // get http(s)://origin.com:port
77- }
78-
79- /// Called for a REST page in the event of a login being required
80- ClassMethod Login (skipheader As %Boolean = 1 ) As %Status
81- {
95+ ]]> </Implementation >
96+ </Method >
97+
98+ <Method name =" Login" >
99+ <Description >
100+ Called for a REST page in the event of a login being required</Description >
101+ <ClassMethod >1</ClassMethod >
102+ <FormalSpec >skipheader:%Boolean=1</FormalSpec >
103+ <ReturnType >%Status</ReturnType >
104+ <Implementation ><![CDATA[
82105 Do %response.SetHeader("Access-Control-Allow-Origin",..GetOrigins())
83106 Do %response.SetHeader("Access-Control-Allow-Credentials","true")
84107 Do %response.SetHeader("Access-Control-Allow-Methods","GET, PUT, POST, DELETE, OPTIONS")
@@ -104,12 +127,17 @@ ClassMethod Login(skipheader As %Boolean = 1) As %Status
104127 Do %response.WriteHTTPHeader()
105128
106129 Return $$$OK
107- }
108-
109- /// Issue an '500' error and give some indication as to what occurred.<br>
110- /// <b>pStatus</b> - %status, not %Exception.AbstractException.
111- ClassMethod Http500 (pStatus As %Exception .AbstractException ) As %Status
112- {
130+ ]]> </Implementation >
131+ </Method >
132+
133+ <Method name =" Http500" >
134+ <Description ><![CDATA[
135+ Issue an '500' error and give some indication as to what occurred.<br>
136+ <b>pStatus</b> - %status, not %Exception.AbstractException.]]> </Description >
137+ <ClassMethod >1</ClassMethod >
138+ <FormalSpec >pStatus:%Exception.AbstractException</FormalSpec >
139+ <ReturnType >%Status</ReturnType >
140+ <Implementation ><![CDATA[
113141 // we are expecting status
114142 #; Set the response Http status
115143 Set %response.Status="500 Internal Server Error"
@@ -121,11 +149,15 @@ ClassMethod Http500(pStatus As %Exception.AbstractException) As %Status
121149 Write "{""Error"":"_$$$ZENJSSTR($System.Status.GetErrorText(pStatus,%session.Language))_"}"
122150
123151 Quit $$$OK
124- }
125-
126- /// Returns info about MDX2JSON package mapping
127- ClassMethod GetMappings () As %ArrayOfObjects
128- {
152+ ]]> </Implementation >
153+ </Method >
154+
155+ <Method name =" GetMappings" >
156+ <Description >
157+ Returns info about MDX2JSON package mapping</Description >
158+ <ClassMethod >1</ClassMethod >
159+ <ReturnType >%ArrayOfObjects</ReturnType >
160+ <Implementation ><![CDATA[
129161 Set result = ##class(%ArrayOfObjects).%New()
130162 Set mapped = ##class(%ListOfDataTypes).%New()
131163 Set unmapped = ##class(%ListOfDataTypes).%New()
@@ -147,12 +179,17 @@ ClassMethod GetMappings() As %ArrayOfObjects
147179 do result.SetAt(mapped,"Mapped")
148180 do result.SetAt(unmapped,"Unmapped")
149181 return result
150- }
151-
152- /// Returns OK if namespace both exists and contains MDX2JSON package.<br>
153- /// <b>Namespace</b> - name of namespace. Sets namespace variable to current namespace if empty or missing.
154- ClassMethod CheckNamespace (ByRef Namespace As %String = {$Namespace }) As %Status
155- {
182+ ]]> </Implementation >
183+ </Method >
184+
185+ <Method name =" CheckNamespace" >
186+ <Description ><![CDATA[
187+ Returns OK if namespace both exists and contains MDX2JSON package.<br>
188+ <b>Namespace</b> - name of namespace. Sets namespace variable to current namespace if empty or missing.]]> </Description >
189+ <ClassMethod >1</ClassMethod >
190+ <FormalSpec ><![CDATA[ &Namespace:%String=$Namespace]]> </FormalSpec >
191+ <ReturnType >%Status</ReturnType >
192+ <Implementation ><![CDATA[
156193 if (Namespace = "") {
157194 set Namespace = $Namespace
158195 return $$$OK
@@ -175,14 +212,20 @@ ClassMethod CheckNamespace(ByRef Namespace As %String = {$Namespace}) As %Status
175212 return:(exists=$$$NO) $$$ERROR($$$GeneralError, "No dashboards exist in " _ Namespace)
176213
177214 return $$$OK
178- }
179-
180- /// Executes actions and returns device output <br>
181- /// pObj - OREF or class<br>
182- /// pMethod - instance or class method to execute respectively<br>
183- /// pArgs - additional arguments
184- ClassMethod OutputToStr (pObj , pMethod , pArgs ...) As %String [ ProcedureBlock = 0 ]
185- {
215+ ]]> </Implementation >
216+ </Method >
217+
218+ <Method name =" OutputToStr" >
219+ <Description ><![CDATA[
220+ Executes actions and returns device output <br>
221+ pObj - OREF or class<br>
222+ pMethod - instance or class method to execute respectively<br>
223+ pArgs - additional arguments]]> </Description >
224+ <ClassMethod >1</ClassMethod >
225+ <FormalSpec >pObj,pMethod,pArgs...</FormalSpec >
226+ <ProcedureBlock >0</ProcedureBlock >
227+ <ReturnType >%String</ReturnType >
228+ <Implementation ><![CDATA[
186229 set tOldIORedirected = ##class(%Device).ReDirectIO()
187230 set tOldMnemonic = ##class(%Device).GetMnemonicRoutine()
188231 set tOldIO = $io
@@ -232,7 +275,7 @@ wtab(s) do output($char(9)) quit
232275 //Output label - this is where you would handle what you actually want to do.
233276 // in our case, we want to write to str
234277output(s) set str=str_s quit
235- }
236-
237- }
238-
278+ ]]> </ Implementation >
279+ </ Method >
280+ </ Class >
281+ </ Export >
0 commit comments