Skip to content

Commit

Permalink
Merge pull request #19 from progress/develop
Browse files Browse the repository at this point in the history
Merge with Develop
  • Loading branch information
DustinGrau-PSC authored Dec 23, 2019
2 parents 0e45313 + 56b0b8e commit 63410de
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 61 deletions.
Binary file modified dist/oe11/Spark.pl
Binary file not shown.
Binary file modified dist/oe12/Spark.pl
Binary file not shown.
16 changes: 11 additions & 5 deletions src/Spark/Core/Handler/DOHEventHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,23 @@ class Spark.Core.Handler.DOHEventHandler use-widget-pool final:
/* Register all known services for this application. */
oCatalogManager:registerAllServices(ServiceRegistry:Registry).

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

/* Discover any file-based DOH services if ROOT.map exists. */
define variable cServiceMapPath as character no-undo.
file-info:file-name = "ROOT.map". /* Look for a ROOT.map file on disk. */
if file-info:full-pathname ne ? then /* File is present, so obtain the base path of the file. */
assign cServiceMapPath = replace(substring(file-info:full-pathname, 1, length(file-info:full-pathname) - 8), "~\", "/").

file-info:file-name = "ROOT.map". /* Look initially for a ROOT.map file on disk. */

if file-info:full-pathname eq ? then /* File is not present, so try a different common file. */
file-info:file-name = "catalog.map". /* Try looking for a catalog.map file on disk. */

if file-info:full-pathname ne ? then /* When file is present, obtain the base path of the file. */
assign cServiceMapPath = replace(substring(file-info:full-pathname, 1, length(file-info:full-pathname) - length(file-info:file-name)), "~\", "/").

if (cServiceMapPath gt "") eq true then do:
/* Use the base path of the ROOT.map file to know where to look for similar .MAP files. */
/* Use the base path of the ROOT.map file to know where to look for other available .MAP files. */
oLoggingManager:logMessage(substitute("Loading Service Registry data from &1", cServiceMapPath), "SPARK-STRT", 3).
OpenEdge.Web.DataObject.ServiceRegistry:RegisterAllFromFolder(cServiceMapPath).
end. /* cServiceMapPath */
Expand Down
121 changes: 79 additions & 42 deletions src/Spark/Core/Manager/CatalogManager.cls

Large diffs are not rendered by default.

77 changes: 75 additions & 2 deletions src/Spark/Core/Service/Catalog.cls
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,74 @@ using Spark.Core.Manager.ICatalogManager from propath.

block-level on error undo, throw.

class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
class Spark.Core.Service.Catalog inherits Spark.Diagnostic.Util.OSPath implements Spark.Core.Service.ICatalog use-widget-pool:

/* Tracks the last time the CB props file was loaded from the file system. */
define protected variable dCBPropsLastLoaded as datetime no-undo initial ?.

/* Find a better default port in use with this instance. */
define protected variable iPort as integer no-undo.

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

method public void dispose ( ):
end method. /* dispose */

method protected void Discovery ( ):
define variable cLine as character no-undo.
define variable cAppName as character no-undo.
define variable cAppNames as character no-undo.
define variable cWebApp as character no-undo.
define variable cTransport as character no-undo.
define variable lcConfigTemp as longchar no-undo.
define variable iLines as integer no-undo.
define variable iLine as integer no-undo.
define variable iX as integer no-undo.
define variable iHttpPort as integer no-undo.
define variable iHttpsPort as integer no-undo.
define variable lFound as logical no-undo.
define variable dLastDate as datetime no-undo.
define variable oWebAppList as JsonArray no-undo.

/* Examine the catalina.properties for info about the available ports. */
file-info:file-name = substitute("&1/conf/catalina.properties", this-object:CatalinaBase).
if file-info:full-pathname ne ? then do:
/* Get the current date/time that the file was last modified. */
assign dLastDate = datetime(file-info:file-mod-date, file-info:file-mod-time * 1000).

if dLastDate ne dCBPropsLastLoaded then do:
/* Mark down the current modified date/time for this file. */
assign dCBPropsLastLoaded = dLastDate.

/* Read the file into a longchar value (avoids keeping the file open). */
copy-lob from file file-info:full-pathname to lcConfigTemp no-error.

assign iLines = num-entries(lcConfigTemp, "~n").
if iLines ge 1 then cfgblk:
do iLine = 1 to iLines:
assign cLine = trim(entry(iLine, lcConfigTemp, "~n")).

case true:
when cLine begins "psc.as.http.port=" then
assign iHttpPort = integer(trim(entry(2, cLine, "="))).
when cLine begins "psc.as.https.port=" then
assign iHttpsPort = integer(trim(entry(2, cLine, "="))).
end case.
end. /* do iLines */

/* Look to the same server at either the HTTP or HTTPS port for OEManager. */
if iHttpPort gt 0 then
this-object:iPort = iHttpPort.
else if iHttpsPort gt 0 then
this-object:iPort = iHttpsPort.

assign lcConfigTemp = ?. /* Reset the variable. */
end. /* file updated */
end. /* catalina.properties */
end method. /* Discovery */

method protected JsonObject getDataObjectServiceCatalogs ( ):
define variable oServices as DataObjectService no-undo extent.
define variable oOperation as MappedOperation no-undo.
Expand All @@ -46,9 +106,10 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
assign oOperation = oServices[iX]:GetOperation("/", MethodEnum:Get).
if valid-object(oOperation) and oOperation:TargetName matches "*.json" then do:
assign
cFilename = replace(oOperation:TargetName, "$CATALINA_BASE", os-getenv("CATALINA_BASE"))
cFilename = replace(oOperation:TargetName, "$CATALINA_BASE", this-object:CatalinaBase)
cFilename = replace(cFilename, "$oepas-webapp", trim(web-context:get-cgi-value("env", "CONTEXT_PATH"), "/"))
.

file-info:file-name = cFilename.
if file-info:full-pathname ne ? then do:
define variable oParser as ObjectModelParser no-undo.
Expand All @@ -64,6 +125,7 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
end. /* Operation Not Available */
end. /* No Catalog */
else if oServices[iX]:Catalog:Has("services") then
/* Each service should only have one defined catalog for that service. */
oSvcArray:Add(oServices[iX]:Catalog:GetJsonArray("services"):GetJsonObject(1)).
end. /* do ix */

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

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

assign catalog = cast(oServiceWriter:Value, JsonObject).
if valid-object(catalog) then do:
define variable oVars as JsonObject no-undo.

assign oVars = catalog:GetJsonArray("servers"):GetJsonObject(1):GetJsonObject("variables").
oVars:GetJsonObject("port"):Set("default", string(iPort)). /* Use the discovered port for the instance. */
oVars:GetJsonObject("basePath"):Set("default", "/api"). /* Use the default typically set for a Spark-based application. */

assign oVars = catalog:GetJsonArray("servers"):GetJsonObject(2):GetJsonObject("variables").
oVars:GetJsonObject("basePath"):Set("default", "/api"). /* Use the default typically set for a Spark-based application. */
end.
delete object oServiceWriter no-error.
end.

Expand Down
20 changes: 9 additions & 11 deletions src/Spark/Core/Util/Reflection.cls
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ class Spark.Core.Util.Reflection final:

assign oParamSig = new Progress.Json.ObjectModel.JsonObject().
oParamSig:Add("mode", oParamInt:Mode:toString()).
oParamSig:Add("type", cDataType).
oParamSig:Add("name", oParamInt:Name).
if oParamInt:Extent gt 0 then
oParamSig:Add("extent", oParamInt:Extent).
oParamSig:Add("type", cDataType).
oParamSig:Add("extent", oParamInt:Extent).

oParamArr:Add(oParamSig).
end. /* oParamExt */
Expand Down Expand Up @@ -109,8 +108,7 @@ class Spark.Core.Util.Reflection final:
oElementSig:Add("readable", oPropsInt:CanRead).
oElementSig:Add("writable", oPropsInt:CanWrite).
oElementSig:Add("type", cDataType).
if oPropsInt:Extent gt 0 then
oElementSig:Add("extent", oPropsInt:Extent).
oElementSig:Add("extent", oPropsInt:Extent).

oProperties:Add(oPropsInt:Name, oElementSig).
end. /* oPropsExt */
Expand Down Expand Up @@ -154,8 +152,8 @@ class Spark.Core.Util.Reflection final:
oElementSig:Add("mode", oVarsInt:AccessMode:toString()).
oElementSig:Add("static", oVarsInt:IsStatic).
oElementSig:Add("type", cDataType).
if oVarsInt:Extent gt 0 then
oElementSig:Add("extent", oVarsInt:Extent).
oElementSig:Add("extent", oVarsInt:Extent).

oVariables:Add(oVarsInt:Name, oElementSig).
end. /* oVarsExt */

Expand Down Expand Up @@ -229,8 +227,7 @@ class Spark.Core.Util.Reflection final:
oParamSig:Add("mode", oParamInt:Mode:toString()).
oParamSig:Add("name", oParamInt:Name).
oParamSig:Add("type", cDataType).
if oParamInt:Extent gt 0 then
oParamSig:Add("extent", oParamInt:Extent).
oParamSig:Add("extent", oParamInt:Extent).

oParamArr:Add(oParamSig).
end. /* oParamExt */
Expand All @@ -239,9 +236,10 @@ class Spark.Core.Util.Reflection final:
oElementSig:Add("origin", oMethodInt:OriginatingClass:TypeName).
oElementSig:Add("defined", oMethodInt:DeclaringClass:TypeName).
oElementSig:Add("return", cReturnType).
oElementSig:Add("params", oParamArr).
if oMethodInt:ReturnExtent gt 0 then
if cReturnType ne "void" then
oElementSig:Add("extent", oMethodInt:ReturnExtent).
oElementSig:Add("params", oParamArr).

oMethods:Add(oMethodInt:name, oElementSig).
end. /* oMethodExt */

Expand Down
2 changes: 1 addition & 1 deletion src/Spark/version.i
Original file line number Diff line number Diff line change
@@ -1 +1 @@
&GLOBAL-DEFINE SPARK_VERSION 5.0.0-2019.11.22.042345 (12.1.0)
&GLOBAL-DEFINE SPARK_VERSION 5.0.1-2019.12.19.032446 (11.7.5)

0 comments on commit 63410de

Please sign in to comment.