 
/*------------------------------------------------------------------------
   File        : adresse_dict
   Purpose     : 
   Syntax      : 
   Description : 
   Author(s)   : walter.riechsteiner
   Created     : Thu Jun 26 13:56:20 CEST 2025
   Notes       : 
 ----------------------------------------------------------------------*/
 
BLOCK-LEVEL ON ERROR UNDO, THROW.

USING OpenEdge.Core.String FROM PROPATH.
USING OpenEdge.Net.HTTP.IHttpResponse FROM PROPATH.
USING OpenEdge.Net.HTTP.StatusCodeEnum FROM PROPATH.
USING OpenEdge.Web.IWebRequest FROM PROPATH.
USING OpenEdge.Web.WebHandler FROM PROPATH.
USING OpenEdge.Web.WebResponseWriter FROM PROPATH.
USING Progress.Json.ObjectModel.JsonObject FROM PROPATH.
USING Progress.Json.ObjectModel.JsonArray FROM PROPATH.
USING src.ch.adprime.gemis.WebHandlerUtilities FROM PROPATH.
USING src.ch.adprime.gemis.ErrorMessage FROM PROPATH.

CLASS isWorkingImpl INHERITS WebHandler: 

    DEFINE TEMP-TABLE tFileDIct
        SERIALIZE-NAME 'fields'
        FIELD cName   AS CHARACTER SERIALIZE-NAME 'name' 
        FIELD cType   AS CHARACTER SERIALIZE-NAME 'type'
        FIELD iLaenge AS INTEGER   SERIALIZE-NAME 'width'
        .
        
    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/

    METHOD OVERRIDE PROTECTED INTEGER HandleGet (INPUT poRequest AS IWebRequest ):
        DEFINE VARIABLE oResponse       AS IHttpResponse     NO-UNDO.         
        DEFINE VARIABLE oWriter         AS WebResponseWriter NO-UNDO.
        DEFINE VARIABLE oError          AS ErrorMessage      NO-UNDO.
        DEFINE VARIABLE oBody           AS String            NO-UNDO.
        DEFINE VARIABLE oJsonResponse   AS JsonObject        NO-UNDO.
        DEFINE VARIABLE lDebug          AS LOGICAL           NO-UNDO.
        DEFINE VARIABLE cDefautlCharSet AS CHARACTER         NO-UNDO INIT 'UTF-8'.
           
        DEFINE VARIABLE cCorralationID  AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cContent-Type   AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE htFileDIct      AS HANDLE            NO-UNDO.
        DEFINE VARIABLE oJsonArray      AS JsonArray         NO-UNDO.
        DEFINE VARIABLE lcJsonInhalt    AS LONGCHAR          NO-UNDO.
        DEFINE VARIABLE ii              AS INTEGER           NO-UNDO.
        DEFINE VARIABLE cFileName       AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cFelder         AS CHARACTER         NO-UNDO.
        
        MESSAGE 'start get'.
        
        oBody           = NEW String('GET is working').
        cContent-Type   = 'plain/text'.
        cDefautlCharSet = 'utf-8'.

        WebHandlerUtilities:createHttpResponse(INPUT INTEGER(StatusCodeEnum:OK), INPUT oBody, INPUT cContent-Type, INPUT cDefautlCharSet, INPUT cCorralationID, OUTPUT oResponse).
//        oResponse:SetHeader(HttpHeaderBuilder:Build(cHeaderCorralationID):Value(cCorralationID):Header).
        
        oWriter = NEW WebResponseWriter(oResponse).
        oWriter:Open(). 
        oWriter:Close(). 
            
        RETURN 0.
        
        CATCH e AS Progress.Lang.Error:

        END CATCH.

        FINALLY:

        END FINALLY.

    END METHOD.

    METHOD OVERRIDE PROTECTED INTEGER HandlePost(INPUT poRequest AS IWebRequest):
        DEFINE VARIABLE oResponse    AS IHttpResponse     NO-UNDO.
        DEFINE VARIABLE oWriter      AS WebResponseWriter NO-UNDO.
        DEFINE VARIABLE oJsonData    AS JsonObject        NO-UNDO.
        DEFINE VARIABLE lcJsonString AS LONGCHAR          NO-UNDO.
        
        DEFINE VARIABLE lRetVal      AS LOGICAL           NO-UNDO.
        
        DEFINE VARIABLE hbttMandant  AS HANDLE            NO-UNDO.
        DEFINE VARIABLE cGetHtml     AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE lcHTML       AS LONGCHAR          NO-UNDO.
        DEFINE VARIABLE cDatei       AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE ii           AS INTEGER           NO-UNDO.
        DEFINE VARIABLE lAdmin       AS LOGICAL           NO-UNDO.
        DEFINE VARIABLE oInput       AS JsonObject        NO-UNDO.

        MESSAGE "Entering HandlePost" VIEW-AS ALERT-BOX.
        
        oResponse = NEW OpenEdge.Web.WebResponse().
        oResponse:StatusCode = INTEGER(StatusCodeEnum:OK).
        oResponse:ContentType = "plain/text;charset=utf-8".
        oWriter = NEW WebResponseWriter(oResponse).
        oWriter:Open().
        MESSAGE 'POST is working'.
        oWriter:Write('POST is working').
        oWriter:Close().

        MESSAGE "Exiting HandlePost" VIEW-AS ALERT-BOX.

        CATCH e AS Progress.Lang.Error:
            MESSAGE "Exception occurred: " + e:GetMessage(1) VIEW-AS ALERT-BOX ERROR BUTTONS OK.
            RETURN -1.
        END CATCH.
        
    END METHOD.

    METHOD OVERRIDE PROTECTED INTEGER HandleNotAllowedMethod(INPUT poRequest AS IWebRequest):
        DEFINE VARIABLE result AS INTEGER NO-UNDO.
        MESSAGE "HandleNotAllowedMethod called" VIEW-AS ALERT-BOX.
        RETURN result.
    END METHOD.

    METHOD OVERRIDE PROTECTED INTEGER HandleNotImplemented(INPUT poRequest AS IWebRequest):
        DEFINE VARIABLE result AS INTEGER NO-UNDO.
        MESSAGE "HandleNotImplemented called" VIEW-AS ALERT-BOX.
        RETURN result.
    END METHOD.

END CLASS.