HttpResponseDecorator.java
/*
** Module : HttpRequestDecorator.java
** Abstract : Implementation of the builtin class.
**
** Copyright (c) 2019-2023, Golden Code Development Corporation.
**
** -#- -I- --Date-- ---------------------------------------Description----------------------------------------
** 001 ME 20200511 First version.
** 20201123 Implement all methods as pass-through.
** CA 20210219 OO input parameter definitions for functions/procedures must not register with ObjectOps
** - TypeFactory.initInput will take care of this.
** 002 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy
** signature.
** CA 20210609 Updated INPUT/INPUT-OUTPUT parameters to the new approach, where they are explicitly
** initialized at the method's execution, and not at the caller's arguments.
** 003 CA 20231113 The 'execute' method must be annotated with LegacySignature Type.Execute, and also can be
** dropped if is a no-op.
*/
/*
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Affero General Public License for more details.
**
** You may find a copy of the GNU Affero GPL version 3 at the following
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
**
** Additional terms under GNU Affero GPL version 3 section 7:
**
** Under Section 7 of the GNU Affero GPL version 3, the following additional
** terms apply to the works covered under the License. These additional terms
** are non-permissive additional terms allowed under Section 7 of the GNU
** Affero GPL version 3 and may not be removed by you.
**
** 0. Attribution Requirement.
**
** You must preserve all legal notices or author attributions in the covered
** work or Appropriate Legal Notices displayed by works containing the covered
** work. You may not remove from the covered work any author or developer
** credit already included within the covered work.
**
** 1. No License To Use Trademarks.
**
** This license does not grant any license or rights to use the trademarks
** Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
** of Golden Code Development Corporation. You are not authorized to use the
** name Golden Code, FWD, or the names of any author or contributor, for
** publicity purposes without written authorization.
**
** 2. No Misrepresentation of Affiliation.
**
** You may not represent yourself as Golden Code Development Corporation or FWD.
**
** You may not represent yourself for publicity purposes as associated with
** Golden Code Development Corporation, FWD, or any author or contributor to
** the covered work, without written authorization.
**
** 3. No Misrepresentation of Source or Origin.
**
** You may not represent the covered work as solely your work. All modified
** versions of the covered work must be marked in a reasonable way to make it
** clear that the modified work is not originating from Golden Code Development
** Corporation or FWD. All modified versions must contain the notices of
** attribution required in this license.
*/
package com.goldencode.p2j.oo.net.http;
import com.goldencode.p2j.util.*;
import com.goldencode.p2j.util.BlockManager.Action;
import com.goldencode.p2j.util.BlockManager.Condition;
import com.goldencode.p2j.oo.net.http.IhttpResponse;
import com.goldencode.p2j.oo.core.Assert;
import com.goldencode.p2j.oo.core.IAdaptable;
import com.goldencode.p2j.oo.lang.*;
import com.goldencode.p2j.oo.lang._BaseObject_;
import com.goldencode.p2j.oo.lang.LegacyClass;
import static com.goldencode.p2j.report.ReportConstants.*;
import static com.goldencode.p2j.util.BlockManager.*;
import static com.goldencode.p2j.util.InternalEntry.Type;
/**
* Business logic (converted to Java from the 4GL source code
* in OpenEdge/Net/HTTP/HttpResponseDecorator.cls).
*/
@LegacyResource(resource = "OpenEdge.Net.HTTP.HttpResponseDecorator")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public class HttpResponseDecorator
extends BaseObject
implements IhttpResponse,
IAdaptable
{
@LegacySignature(type = Type.PROPERTY, name = "DecoratedHttpResponse")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
private object<? extends IhttpResponse> decoratedHttpResponse = TypeFactory.object(IhttpResponse.class);
@LegacySignature(type = Type.EXECUTE)
public void __net_http_HttpResponseDecorator_execute__()
{
onBlockLevel(Condition.ERROR, Action.THROW);
}
@LegacySignature(returns = "OBJECT", qualified = "OpenEdge.Net.HTTP.IHttpResponse", type = Type.GETTER, name = "DecoratedHttpResponse")
protected object<? extends IhttpResponse> getDecoratedHttpResponse()
{
return function(HttpResponseDecorator.class, this, "DecoratedHttpResponse", object.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse);
}));
}
@LegacySignature(returns = "INTEGER", type = Type.GETTER, name = "StatusCode")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public integer getStatusCode()
{
return function(HttpResponseDecorator.class, this, "StatusCode", integer.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getStatusCode());
}));
}
@LegacySignature(type = Type.SETTER, name = "StatusCode", parameters =
{
@LegacyParameter(name = "var", type = "INTEGER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setStatusCode(final integer var)
{
internalProcedure(HttpResponseDecorator.class, this, "StatusCode", new Block((Body) () ->
{
decoratedHttpResponse.ref().setStatusCode(var);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "StatusReason")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public character getStatusReason()
{
return function(HttpResponseDecorator.class, this, "StatusReason", character.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getStatusReason());
}));
}
@LegacySignature(type = Type.SETTER, name = "StatusReason", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setStatusReason(final character var)
{
internalProcedure(HttpResponseDecorator.class, this, "StatusReason", new Block((Body) () ->
{
decoratedHttpResponse.ref().setStatusReason(var);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "Version")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public character getVersion()
{
return function(HttpResponseDecorator.class, this, "Version", character.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getVersion());
}));
}
@LegacySignature(type = Type.SETTER, name = "Version", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setVersion(final character var)
{
internalProcedure(HttpResponseDecorator.class, this, "Version", new Block((Body) () ->
{
decoratedHttpResponse.ref().setVersion(var);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "ContentType")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public character getContentType()
{
return function(HttpResponseDecorator.class, this, "ContentType", character.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getContentType());
}));
}
@LegacySignature(type = Type.SETTER, name = "ContentType", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setContentType(final character var)
{
internalProcedure(HttpResponseDecorator.class, this, "ContentType", new Block((Body) () ->
{
decoratedHttpResponse.ref().setContentType(var);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "CharacterEncoding")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public character getCharacterEncoding()
{
return function(HttpResponseDecorator.class, this, "CharacterEncoding", character.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getCharacterEncoding());
}));
}
@LegacySignature(type = Type.SETTER, name = "CharacterEncoding", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setCharacterEncoding(final character var)
{
internalProcedure(HttpResponseDecorator.class, this, "CharacterEncoding", new Block((Body) () ->
{
decoratedHttpResponse.ref().setCharacterEncoding(var);
}));
}
@LegacySignature(returns = "RAW", type = Type.GETTER, name = "ContentMD5")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public raw getContentMd5()
{
return function(HttpResponseDecorator.class, this, "ContentMD5", raw.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getContentMd5());
}));
}
@LegacySignature(type = Type.SETTER, name = "ContentMD5", parameters =
{
@LegacyParameter(name = "var", type = "RAW", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setContentMd5(final raw var)
{
internalProcedure(HttpResponseDecorator.class, this, "ContentMD5", new Block((Body) () ->
{
decoratedHttpResponse.ref().setContentMd5(var);
}));
}
@LegacySignature(returns = "OBJECT", qualified = "Progress.Lang.Object", type = Type.GETTER, name = "Entity")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public object<? extends _BaseObject_> getEntity()
{
return function(HttpResponseDecorator.class, this, "Entity", object.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getEntity());
}));
}
@LegacySignature(type = Type.SETTER, name = "Entity", parameters =
{
@LegacyParameter(qualified = "Progress.Lang.Object", name = "var", type = "OBJECT", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setEntity(final object<? extends _BaseObject_> var)
{
internalProcedure(HttpResponseDecorator.class, this, "Entity", new Block((Body) () ->
{
decoratedHttpResponse.ref().setEntity(var);
}));
}
@LegacySignature(returns = "INTEGER", type = Type.GETTER, name = "ContentLength")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public integer getContentLength()
{
return function(HttpResponseDecorator.class, this, "ContentLength", integer.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getContentLength());
}));
}
@LegacySignature(type = Type.SETTER, name = "ContentLength", parameters =
{
@LegacyParameter(name = "var", type = "INTEGER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setContentLength(final integer var)
{
internalProcedure(HttpResponseDecorator.class, this, "ContentLength", new Block((Body) () ->
{
decoratedHttpResponse.ref().setContentLength(var);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "TransferEncoding")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public character getTransferEncoding()
{
return function(HttpResponseDecorator.class, this, "TransferEncoding", character.class, new Block((Body) () ->
{
returnNormal(decoratedHttpResponse.ref().getTransferEncoding());
}));
}
@LegacySignature(type = Type.SETTER, name = "TransferEncoding", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setTransferEncoding(final character var)
{
internalProcedure(HttpResponseDecorator.class, this, "TransferEncoding", new Block((Body) () ->
{
decoratedHttpResponse.ref().setTransferEncoding(var);
}));
}
@LegacySignature(type = Type.CONSTRUCTOR, parameters =
{
@LegacyParameter(name = "poHttpResponse", type = "OBJECT", qualified = "openedge.net.http.ihttpresponse", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void __net_http_HttpResponseDecorator_constructor__(final object<? extends IhttpResponse> _poHttpResponse)
{
object<? extends IhttpResponse> poHttpResponse = TypeFactory.initInput(_poHttpResponse);
internalProcedure(HttpResponseDecorator.class, this, "__net_http_HttpResponseDecorator_constructor__", new Block((Body) () ->
{
__lang_BaseObject_constructor__();
Assert.notNull(poHttpResponse, new character("HttpResponse"));
decoratedHttpResponse.assign(poHttpResponse);
}));
}
@LegacySignature(type = Type.METHOD, name = "SetHeader", parameters =
{
@LegacyParameter(name = "poHeader", type = "OBJECT", qualified = "openedge.net.http.httpheader", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setHeader(final object<? extends HttpHeader> poHeader)
{
internalProcedure(HttpResponseDecorator.class, this, "SetHeader", new Block((Body) () -> {
decoratedHttpResponse.ref().setHeader(poHeader);
}));
}
@LegacySignature(type = Type.METHOD, name = "SetHeaders", parameters =
{
@LegacyParameter(name = "poHeaders", type = "OBJECT", extent = -1, qualified = "openedge.net.http.httpheader", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setHeaders(final object<? extends HttpHeader>[] poHeaders)
{
internalProcedure(HttpResponseDecorator.class, this, "SetHeaders", new Block((Body) () -> {
decoratedHttpResponse.ref().setHeaders(poHeaders);
}));
}
@LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetHeader", qualified = "openedge.net.http.httpheader", parameters =
{
@LegacyParameter(name = "pcName", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public object<? extends com.goldencode.p2j.oo.net.http.HttpHeader> getHeader(final character pcName)
{
return function(HttpResponseDecorator.class, this, "GetHeader", object.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().getHeader(pcName));
}));
}
@LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "GetHeaders", parameters =
{
@LegacyParameter(name = "extpoHeader", type = "OBJECT", extent = -1, qualified = "openedge.net.http.httpheader", mode = "OUTPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public integer getHeaders(final OutputExtentParameter<object<? extends HttpHeader>> _extpoHeader)
{
object[][] extpoHeader = { TypeFactory.initOutput(_extpoHeader) };
return function(HttpResponseDecorator.class, this, "GetHeaders", integer.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().getHeaders(new OutputExtentParameter<object<? extends HttpHeader>>()
{
@Override
public object<? extends HttpHeader>[] getVariable()
{
return extpoHeader[0];
}
@Override
public void setVariable(object<? extends HttpHeader>[] reference)
{
extpoHeader[0] = reference;
}
}));
}));
}
@LegacySignature(type = Type.METHOD, name = "RemoveHeader", parameters =
{
@LegacyParameter(name = "pcName", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void removeHeader(final character pcName)
{
internalProcedure(HttpResponseDecorator.class, this, "RemoveHeader", new Block((Body) () -> {
decoratedHttpResponse.ref().removeHeader(pcName);
}));
}
@LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "HasHeader", parameters =
{
@LegacyParameter(name = "pcName", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public logical hasHeader(final character pcName)
{
return function(HttpResponseDecorator.class, this, "HasHeader", logical.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().hasHeader(pcName));
}));
}
@LegacySignature(type = Type.METHOD, name = "ClearHeaders")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void clearHeaders()
{
internalProcedure(HttpResponseDecorator.class, this, "ClearHeaders", new Block((Body) () -> {
decoratedHttpResponse.ref().clearHeaders();
}));
}
@LegacySignature(type = Type.METHOD, name = "SetCookie", parameters =
{
@LegacyParameter(name = "poCookie", type = "OBJECT", qualified = "openedge.net.http.cookie", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setCookie(final object<? extends Cookie> poCookie)
{
internalProcedure(HttpResponseDecorator.class, this, "SetCookie", new Block((Body) () -> {
decoratedHttpResponse.ref().setCookie(poCookie);
}));
}
@LegacySignature(type = Type.METHOD, name = "SetCookies", parameters =
{
@LegacyParameter(name = "poCookies", type = "OBJECT", extent = -1, qualified = "openedge.net.http.cookie", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void setCookies(final object<? extends Cookie>[] poCookies)
{
internalProcedure(HttpResponseDecorator.class, this, "SetCookies", new Block((Body) () -> {
decoratedHttpResponse.ref().setCookies(poCookies);
}));
}
@LegacySignature(returns = "INTEGER", type = Type.METHOD, name = "GetCookies", parameters =
{
@LegacyParameter(name = "extpoCookies", type = "OBJECT", extent = -1, qualified = "openedge.net.http.cookie", mode = "OUTPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public integer getCookies(final OutputExtentParameter<object<? extends Cookie>> _extpoCookies)
{
object[][] extpoCookies = { TypeFactory.initOutput(_extpoCookies) };
return function(HttpResponseDecorator.class, this, "GetCookies", integer.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().getCookies(new OutputExtentParameter<object<? extends Cookie>>()
{
@Override
public object<? extends Cookie>[] getVariable()
{
return extpoCookies[0];
}
@Override
public void setVariable(object<? extends Cookie>[] reference)
{
extpoCookies[0] = reference;
}
}));
}));
}
@LegacySignature(type = Type.METHOD, name = "RemoveCookie", parameters =
{
@LegacyParameter(name = "poCookie", type = "OBJECT", qualified = "openedge.net.http.cookie", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void removeCookie(final object<? extends Cookie> poCookie)
{
internalProcedure(HttpResponseDecorator.class, this, "RemoveCookie", new Block((Body) () -> {
decoratedHttpResponse.ref().removeCookie(poCookie);
}));
}
@LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "HasCookie", parameters =
{
@LegacyParameter(name = "poCookie", type = "OBJECT", qualified = "openedge.net.http.cookie", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public logical hasCookie(final object<? extends Cookie> poCookie)
{
return function(HttpResponseDecorator.class, this, "HasCookie", logical.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().hasCookie(poCookie));
}));
}
@LegacySignature(type = Type.METHOD, name = "ClearCookies")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void clearCookies()
{
internalProcedure(HttpResponseDecorator.class, this, "ClearCookies", new Block((Body) () -> {
decoratedHttpResponse.ref().clearCookies();
}));
}
@LegacySignature(type = Type.METHOD, name = "RemoveCookie", parameters =
{
@LegacyParameter(name = "pcName", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public void removeCookie(final character pcName)
{
internalProcedure(HttpResponseDecorator.class, this, "RemoveCookie", new Block((Body) () -> {
decoratedHttpResponse.ref().removeCookie(pcName);
}));
}
@LegacySignature(returns = "LOGICAL", type = Type.METHOD, name = "HasCookie", parameters =
{
@LegacyParameter(name = "pcName", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public logical hasCookie(final character pcName)
{
return function(HttpResponseDecorator.class, this, "HasCookie", logical.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().hasCookie(pcName));
}));
}
@LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetCookie", qualified = "openedge.net.http.cookie", parameters =
{
@LegacyParameter(name = "pcName", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public object<? extends com.goldencode.p2j.oo.net.http.Cookie> getCookie(final character pcName)
{
return function(HttpResponseDecorator.class, this, "GetCookie", object.class, new Block((Body) () -> {
returnNormal(decoratedHttpResponse.ref().getCookie(pcName));
}));
}
@LegacySignature(returns = "OBJECT", type = Type.METHOD, name = "GetAdapter", qualified = "progress.lang.object", parameters = {
@LegacyParameter(name = "poAdaptTo", type = "OBJECT", qualified = "progress.lang.class", mode = "INPUT") })
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL | RT_LVL_FULL)
public object<? extends com.goldencode.p2j.oo.lang._BaseObject_> getAdapter(
final object<? extends LegacyClass> _poAdaptTo)
{
object<? extends LegacyClass> poAdaptTo = TypeFactory.initInput(_poAdaptTo);
return function(HttpResponseDecorator.class, this, "GetAdapter", object.class,
new Block((Body) () -> {
Assert.notNull(poAdaptTo, new character("Adapter"));
if (getLegacyClass().ref()._isA(poAdaptTo))
returnNormal(ObjectOps.thisObject());
if (ObjectOps.typeOf(decoratedHttpResponse, IAdaptable.class).booleanValue())
returnNormal(ObjectOps.cast(decoratedHttpResponse, IAdaptable.class).ref().getAdapter(poAdaptTo));
returnNormal(new object());
}));
}
}