Skip to content

Commit 63410de

Browse files
Merge pull request #19 from progress/develop
Merge with Develop
2 parents 0e45313 + 56b0b8e commit 63410de

7 files changed

Lines changed: 175 additions & 61 deletions

File tree

dist/oe11/Spark.pl

16.7 KB
Binary file not shown.

dist/oe12/Spark.pl

18.6 KB
Binary file not shown.

src/Spark/Core/Handler/DOHEventHandler.cls

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,23 @@ class Spark.Core.Handler.DOHEventHandler use-widget-pool final:
177177
/* Register all known services for this application. */
178178
oCatalogManager:registerAllServices(ServiceRegistry:Registry).
179179

180-
/* Create a master catalog for all services (caches output). */
180+
/* Create a master catalog for all services and cache the output. */
181181
oCatalogManager:getCatalog("", "").
182182
end. /* valid-object */
183183

184184
/* Discover any file-based DOH services if ROOT.map exists. */
185185
define variable cServiceMapPath as character no-undo.
186-
file-info:file-name = "ROOT.map". /* Look for a ROOT.map file on disk. */
187-
if file-info:full-pathname ne ? then /* File is present, so obtain the base path of the file. */
188-
assign cServiceMapPath = replace(substring(file-info:full-pathname, 1, length(file-info:full-pathname) - 8), "~\", "/").
186+
187+
file-info:file-name = "ROOT.map". /* Look initially for a ROOT.map file on disk. */
188+
189+
if file-info:full-pathname eq ? then /* File is not present, so try a different common file. */
190+
file-info:file-name = "catalog.map". /* Try looking for a catalog.map file on disk. */
191+
192+
if file-info:full-pathname ne ? then /* When file is present, obtain the base path of the file. */
193+
assign cServiceMapPath = replace(substring(file-info:full-pathname, 1, length(file-info:full-pathname) - length(file-info:file-name)), "~\", "/").
194+
189195
if (cServiceMapPath gt "") eq true then do:
190-
/* Use the base path of the ROOT.map file to know where to look for similar .MAP files. */
196+
/* Use the base path of the ROOT.map file to know where to look for other available .MAP files. */
191197
oLoggingManager:logMessage(substitute("Loading Service Registry data from &1", cServiceMapPath), "SPARK-STRT", 3).
192198
OpenEdge.Web.DataObject.ServiceRegistry:RegisterAllFromFolder(cServiceMapPath).
193199
end. /* cServiceMapPath */

src/Spark/Core/Manager/CatalogManager.cls

Lines changed: 79 additions & 42 deletions
Large diffs are not rendered by default.

src/Spark/Core/Service/Catalog.cls

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,74 @@ using Spark.Core.Manager.ICatalogManager from propath.
1717

1818
block-level on error undo, throw.
1919

20-
class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
20+
class Spark.Core.Service.Catalog inherits Spark.Diagnostic.Util.OSPath implements Spark.Core.Service.ICatalog use-widget-pool:
21+
22+
/* Tracks the last time the CB props file was loaded from the file system. */
23+
define protected variable dCBPropsLastLoaded as datetime no-undo initial ?.
24+
25+
/* Find a better default port in use with this instance. */
26+
define protected variable iPort as integer no-undo.
2127

2228
method public void initialize ( ):
29+
this-object:Discovery(). /* Perform local discovery of server info. */
2330
end method. /* initialize */
2431

2532
method public void dispose ( ):
2633
end method. /* dispose */
2734

35+
method protected void Discovery ( ):
36+
define variable cLine as character no-undo.
37+
define variable cAppName as character no-undo.
38+
define variable cAppNames as character no-undo.
39+
define variable cWebApp as character no-undo.
40+
define variable cTransport as character no-undo.
41+
define variable lcConfigTemp as longchar no-undo.
42+
define variable iLines as integer no-undo.
43+
define variable iLine as integer no-undo.
44+
define variable iX as integer no-undo.
45+
define variable iHttpPort as integer no-undo.
46+
define variable iHttpsPort as integer no-undo.
47+
define variable lFound as logical no-undo.
48+
define variable dLastDate as datetime no-undo.
49+
define variable oWebAppList as JsonArray no-undo.
50+
51+
/* Examine the catalina.properties for info about the available ports. */
52+
file-info:file-name = substitute("&1/conf/catalina.properties", this-object:CatalinaBase).
53+
if file-info:full-pathname ne ? then do:
54+
/* Get the current date/time that the file was last modified. */
55+
assign dLastDate = datetime(file-info:file-mod-date, file-info:file-mod-time * 1000).
56+
57+
if dLastDate ne dCBPropsLastLoaded then do:
58+
/* Mark down the current modified date/time for this file. */
59+
assign dCBPropsLastLoaded = dLastDate.
60+
61+
/* Read the file into a longchar value (avoids keeping the file open). */
62+
copy-lob from file file-info:full-pathname to lcConfigTemp no-error.
63+
64+
assign iLines = num-entries(lcConfigTemp, "~n").
65+
if iLines ge 1 then cfgblk:
66+
do iLine = 1 to iLines:
67+
assign cLine = trim(entry(iLine, lcConfigTemp, "~n")).
68+
69+
case true:
70+
when cLine begins "psc.as.http.port=" then
71+
assign iHttpPort = integer(trim(entry(2, cLine, "="))).
72+
when cLine begins "psc.as.https.port=" then
73+
assign iHttpsPort = integer(trim(entry(2, cLine, "="))).
74+
end case.
75+
end. /* do iLines */
76+
77+
/* Look to the same server at either the HTTP or HTTPS port for OEManager. */
78+
if iHttpPort gt 0 then
79+
this-object:iPort = iHttpPort.
80+
else if iHttpsPort gt 0 then
81+
this-object:iPort = iHttpsPort.
82+
83+
assign lcConfigTemp = ?. /* Reset the variable. */
84+
end. /* file updated */
85+
end. /* catalina.properties */
86+
end method. /* Discovery */
87+
2888
method protected JsonObject getDataObjectServiceCatalogs ( ):
2989
define variable oServices as DataObjectService no-undo extent.
3090
define variable oOperation as MappedOperation no-undo.
@@ -46,9 +106,10 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
46106
assign oOperation = oServices[iX]:GetOperation("/", MethodEnum:Get).
47107
if valid-object(oOperation) and oOperation:TargetName matches "*.json" then do:
48108
assign
49-
cFilename = replace(oOperation:TargetName, "$CATALINA_BASE", os-getenv("CATALINA_BASE"))
109+
cFilename = replace(oOperation:TargetName, "$CATALINA_BASE", this-object:CatalinaBase)
50110
cFilename = replace(cFilename, "$oepas-webapp", trim(web-context:get-cgi-value("env", "CONTEXT_PATH"), "/"))
51111
.
112+
52113
file-info:file-name = cFilename.
53114
if file-info:full-pathname ne ? then do:
54115
define variable oParser as ObjectModelParser no-undo.
@@ -64,6 +125,7 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
64125
end. /* Operation Not Available */
65126
end. /* No Catalog */
66127
else if oServices[iX]:Catalog:Has("services") then
128+
/* Each service should only have one defined catalog for that service. */
67129
oSvcArray:Add(oServices[iX]:Catalog:GetJsonArray("services"):GetJsonObject(1)).
68130
end. /* do ix */
69131

@@ -82,6 +144,7 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
82144
end method. /* getDataObjectServiceCatalogs */
83145

84146
method public void getOpenApiCatalog ( output catalog as JsonObject ):
147+
/* Specialized method to return an Open API v3.0 formatted description of resource endpoints. */
85148
define variable oServiceWriter as OpenAPI30ServiceWriter no-undo.
86149
assign oServiceWriter = new OpenAPI30ServiceWriter().
87150
if valid-object(oServiceWriter) then do:
@@ -90,6 +153,16 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
90153
oServiceWriter:close().
91154

92155
assign catalog = cast(oServiceWriter:Value, JsonObject).
156+
if valid-object(catalog) then do:
157+
define variable oVars as JsonObject no-undo.
158+
159+
assign oVars = catalog:GetJsonArray("servers"):GetJsonObject(1):GetJsonObject("variables").
160+
oVars:GetJsonObject("port"):Set("default", string(iPort)). /* Use the discovered port for the instance. */
161+
oVars:GetJsonObject("basePath"):Set("default", "/api"). /* Use the default typically set for a Spark-based application. */
162+
163+
assign oVars = catalog:GetJsonArray("servers"):GetJsonObject(2):GetJsonObject("variables").
164+
oVars:GetJsonObject("basePath"):Set("default", "/api"). /* Use the default typically set for a Spark-based application. */
165+
end.
93166
delete object oServiceWriter no-error.
94167
end.
95168

src/Spark/Core/Util/Reflection.cls

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ class Spark.Core.Util.Reflection final:
5454

5555
assign oParamSig = new Progress.Json.ObjectModel.JsonObject().
5656
oParamSig:Add("mode", oParamInt:Mode:toString()).
57-
oParamSig:Add("type", cDataType).
5857
oParamSig:Add("name", oParamInt:Name).
59-
if oParamInt:Extent gt 0 then
60-
oParamSig:Add("extent", oParamInt:Extent).
58+
oParamSig:Add("type", cDataType).
59+
oParamSig:Add("extent", oParamInt:Extent).
6160

6261
oParamArr:Add(oParamSig).
6362
end. /* oParamExt */
@@ -109,8 +108,7 @@ class Spark.Core.Util.Reflection final:
109108
oElementSig:Add("readable", oPropsInt:CanRead).
110109
oElementSig:Add("writable", oPropsInt:CanWrite).
111110
oElementSig:Add("type", cDataType).
112-
if oPropsInt:Extent gt 0 then
113-
oElementSig:Add("extent", oPropsInt:Extent).
111+
oElementSig:Add("extent", oPropsInt:Extent).
114112

115113
oProperties:Add(oPropsInt:Name, oElementSig).
116114
end. /* oPropsExt */
@@ -154,8 +152,8 @@ class Spark.Core.Util.Reflection final:
154152
oElementSig:Add("mode", oVarsInt:AccessMode:toString()).
155153
oElementSig:Add("static", oVarsInt:IsStatic).
156154
oElementSig:Add("type", cDataType).
157-
if oVarsInt:Extent gt 0 then
158-
oElementSig:Add("extent", oVarsInt:Extent).
155+
oElementSig:Add("extent", oVarsInt:Extent).
156+
159157
oVariables:Add(oVarsInt:Name, oElementSig).
160158
end. /* oVarsExt */
161159

@@ -229,8 +227,7 @@ class Spark.Core.Util.Reflection final:
229227
oParamSig:Add("mode", oParamInt:Mode:toString()).
230228
oParamSig:Add("name", oParamInt:Name).
231229
oParamSig:Add("type", cDataType).
232-
if oParamInt:Extent gt 0 then
233-
oParamSig:Add("extent", oParamInt:Extent).
230+
oParamSig:Add("extent", oParamInt:Extent).
234231

235232
oParamArr:Add(oParamSig).
236233
end. /* oParamExt */
@@ -239,9 +236,10 @@ class Spark.Core.Util.Reflection final:
239236
oElementSig:Add("origin", oMethodInt:OriginatingClass:TypeName).
240237
oElementSig:Add("defined", oMethodInt:DeclaringClass:TypeName).
241238
oElementSig:Add("return", cReturnType).
242-
oElementSig:Add("params", oParamArr).
243-
if oMethodInt:ReturnExtent gt 0 then
239+
if cReturnType ne "void" then
244240
oElementSig:Add("extent", oMethodInt:ReturnExtent).
241+
oElementSig:Add("params", oParamArr).
242+
245243
oMethods:Add(oMethodInt:name, oElementSig).
246244
end. /* oMethodExt */
247245

src/Spark/version.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
&GLOBAL-DEFINE SPARK_VERSION 5.0.0-2019.11.22.042345 (12.1.0)
1+
&GLOBAL-DEFINE SPARK_VERSION 5.0.1-2019.12.19.032446 (11.7.5)

0 commit comments

Comments
 (0)