From 7aabd35a00127aa565bb1997fd0f3658c3e2944f Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Fri, 6 May 2022 17:14:38 -0300 Subject: [PATCH 01/12] Initial bits for lambda trigger events --- .../cloud/serverless/EventMessage.java | 13 +++++ .../serverless/EventMessageResponse.java | 2 + .../serverless/EventMessageSourceType.java | 7 +++ .../cloud/serverless/EventMessages.java | 2 + .../com/genexus/cloud/serverless/Helper.java | 2 + .../serverless/aws/EventMessageProperty.java | 4 ++ .../{ => handler}/AwsGxServletResponse.java | 0 .../aws/handler/LambdaBaseHandler.java | 51 +++++++++++++++++++ .../aws/handler/LambdaSQSHandler.java | 44 ++++++++++++++++ .../aws/events/TestLambdaBaseHandler.java | 2 + 10 files changed, 127 insertions(+) create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/{ => handler}/AwsGxServletResponse.java (100%) create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java create mode 100644 gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java new file mode 100644 index 000000000..3603f948f --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java @@ -0,0 +1,13 @@ +package com.genexus.cloud.serverless; + +import java.util.Date; + +public class EventMessage { + private String messageId; + private Date messageDate; + private String messageSourceType; + private String messageData; + private String messageCustomPlayload; + private String messageVersion = "1.0"; +} + diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java new file mode 100644 index 000000000..a507001d5 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java @@ -0,0 +1,2 @@ +package com.genexus.cloud.serverless;public class EventMessageResponse { +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java new file mode 100644 index 000000000..0835ad5c8 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java @@ -0,0 +1,7 @@ +package com.genexus.cloud.serverless; + +public class EventMessageSourceType { + public static String QueueMessage = "QueueMessage"; + public static String ServiceBusMessage = "ServiceBusMessage"; + public static String Timer = "Timer"; +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java new file mode 100644 index 000000000..4a815f196 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java @@ -0,0 +1,2 @@ +package com.genexus.cloud.serverless;public class EventMessages { +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java new file mode 100644 index 000000000..0947b0593 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java @@ -0,0 +1,2 @@ +package com.genexus.cloud.serverless;public class Helper { +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java new file mode 100644 index 000000000..5cd108239 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java @@ -0,0 +1,4 @@ +package com.genexus.cloud.serverless.aws; + +public class EventMessageAttribute { +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/AwsGxServletResponse.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/AwsGxServletResponse.java similarity index 100% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/AwsGxServletResponse.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/AwsGxServletResponse.java diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java new file mode 100644 index 000000000..a2dc347ce --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java @@ -0,0 +1,51 @@ +package com.genexus.cloud.serverless.aws; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.SQSEvent; +import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.specific.java.Connect; +import com.genexus.specific.java.LogManager; +import com.genexus.util.IniFile; + + +public class LambdaBaseHandler { + protected static ILogger logger = null; + protected static Class entryPointClass = null; + private static final String GX_APPLICATION_CLASS = "GXcfg"; + private static String ENTRY_POINT_CLASS_NAME_VAR = "GX_MAIN_CLASS_NAME"; + private static String packageName = null; + protected static final String MESSAGE_INPUT_CLASS_NAME = "com.genexusserverlessapi.genexusserverlessapi.SdtEventMessages"; + protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexusserverlessapi.genexusserverlessapi.SdtEventMessageResponse"; + + + public LambdaBaseHandler() throws Exception { + initialize(); + } + + private static void initialize() throws Exception { + logger = LogManager.initialize(".", LambdaBaseHandler.class); + Connect.init(); + + String entryPointClassName = System.getenv(ENTRY_POINT_CLASS_NAME_VAR); + if (entryPointClassName == null) { + throw new Exception(String.format("'%s' Environment Variable must be defined", ENTRY_POINT_CLASS_NAME_VAR)); + } + + IniFile config = com.genexus.ConfigFileFinder.getConfigFile(null, "client.cfg", null); + packageName = config.getProperty("Client", "PACKAGE", null); + Class cfgClass; + try { + cfgClass = Class.forName(packageName.isEmpty() ? GX_APPLICATION_CLASS: String.format("%s.%s", packageName, GX_APPLICATION_CLASS)); + com.genexus.Application.init(cfgClass); + entryPointClassName = packageName.isEmpty() ? entryPointClassName: String.format("%s.%s", packageName, entryPointClassName); + logger.debug("Initializing entry Point ClassName: " + entryPointClassName); + entryPointClass = Class.forName(entryPointClassName); + } catch (Exception e) { + logger.error(String.format("Failed to initialize Application for className: %s", entryPointClassName), e); + throw e; + } + } +} + diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java new file mode 100644 index 000000000..1249f6a8a --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java @@ -0,0 +1,44 @@ +package com.genexus.cloud.serverless.aws; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.SQSEvent; +import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage; +import com.genexus.GxUserType; +import com.genexus.ModelContext; + +import java.lang.reflect.Constructor; + + +public class LambdaSQSHandler extends LambdaBaseHandler implements RequestHandler { + + public LambdaSQSHandler() throws Exception { + super(); + } + + @Override + public Void handleRequest(SQSEvent sqsEvent, Context context) { + logger.debug("handleRequest start"); + + for(SQSMessage msg : sqsEvent.getRecords()){ + logger.debug(String.format("Processing sqsEvent Message: %s", msg.getMessageId())); + + try { + ModelContext modelContext = new ModelContext( entryPointClass ); + Object[] parameters = new Object[2]; + + Class eventMessagesClass = Class.forName(MESSAGE_INPUT_CLASS_NAME); + Constructor constructor = eventMessagesClass.getConstructor(ModelContext.class); + GxUserType inputMessage = (GxUserType) constructor.newInstance(modelContext); + + com.genexus.db.DynamicExecute.dynamicExecute(modelContext, -1, entryPointClass, entryPointClass.getName(), parameters); + } + catch (Exception e) { + logger.error("HandleRequest failed: " + entryPointClass.getName(), e); + } + + } + return null; + } +} + diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java new file mode 100644 index 000000000..2be2d68a4 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java @@ -0,0 +1,2 @@ +package com.genexus.cloud.aws.events;public class TestLambdaBaseHandler { +} From c184a01101896fc12f3c0a7335e5e1557ce2838a Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Thu, 12 May 2022 09:50:28 -0300 Subject: [PATCH 02/12] Add UnitTests --- .../java/com/genexus/db/DynamicExecute.java | 5 +- gxawsserverless/pom.xml | 7 + .../cloud/serverless/EventMessage.java | 63 +- .../serverless/EventMessageResponse.java | 27 +- .../serverless/EventMessageSourceType.java | 1 + .../cloud/serverless/EventMessages.java | 15 +- .../GXProcedureDynamicExecuteStrategy.java | 96 +++ .../com/genexus/cloud/serverless/Helper.java | 12 +- .../serverless/aws/EventMessageProperty.java | 15 +- .../cloud/serverless/aws/LambdaHandler.java | 3 +- .../aws/handler/AwsGxServletResponse.java | 2 +- .../aws/handler/LambdaBaseHandler.java | 100 ++- .../aws/handler/LambdaSQSHandler.java | 81 ++- .../genexus/cloud/aws/events/MockContext.java | 65 ++ .../aws/events/TestLambdaBaseHandler.java | 4 +- .../aws/events/TestLambdaSQSHandler.java | 95 +++ ...EventCustomPayload_CustomPayloadItem.class | Bin 0 -> 5728 bytes ...tEventCustomPayload_CustomPayloadItem.java | 218 ++++++ .../genexusserverlessapi/SdtEventMessage.java | 477 +++++++++++++ .../SdtEventMessageResponse.java | 221 ++++++ .../SdtEventMessages.java | 250 +++++++ .../StructSdtEventCustomPayload.java | 45 ++ ...tEventCustomPayload_CustomPayloadItem.java | 54 ++ .../StructSdtEventMessage.java | 114 +++ .../StructSdtEventMessageResponse.java | 53 ++ .../StructSdtEventMessages.java | 43 ++ .../com/unittest/eventdriven/SdtUser.java | 664 ++++++++++++++++++ .../unittest/eventdriven/StructSdtUser.java | 147 ++++ .../queue/handlesimplerawsqsevent.java | 66 ++ .../queue/handlesimpleuserqueueevent.java | 109 +++ gxawsserverless/src/test/java/log4j2.xml | 4 +- 31 files changed, 3013 insertions(+), 43 deletions(-) create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java create mode 100644 gxawsserverless/src/test/java/com/genexus/cloud/aws/events/MockContext.java create mode 100644 gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.class create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java create mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java diff --git a/common/src/main/java/com/genexus/db/DynamicExecute.java b/common/src/main/java/com/genexus/db/DynamicExecute.java index ed72237c7..3e09e97ad 100644 --- a/common/src/main/java/com/genexus/db/DynamicExecute.java +++ b/common/src/main/java/com/genexus/db/DynamicExecute.java @@ -189,7 +189,8 @@ private static boolean dynamicExecute2(ModelContext context, int handle, Class c return true; } - private final static String METHOD_EXECUTE = "execute"; // El m�todo a ejecutar en la clase + public final static String METHOD_EXECUTE = "execute"; // Method to Execute for entry points in GXWebProcedure. + public static boolean dynamicExecute(ModelContext context, int handle, Class caller, String sPackage, String sPgmName, Object[] params) { String pgmName = getDynamicPgmName(caller, sPackage, sPgmName); @@ -198,7 +199,7 @@ public static boolean dynamicExecute(ModelContext context, int handle, Class cal public static boolean dynamicExecute(ModelContext context, int handle, Class caller, String className, Object[] params) { - Object [] callingParams = new Object[params.length]; // Contiene el verdadero array a pasarle a la clase + Object [] callingParams = new Object[params.length]; boolean [] needToUpdateParams = new boolean[params.length]; // Indica si hay que actualizar el array de parametros(params) al terminar la invocaci�n del m�todo. Solo se deben actualizar los parametros que en destino son 'arrays', que son los que pueden sufrir modificaci�n // Primero obtengo la clase a ejecutar diff --git a/gxawsserverless/pom.xml b/gxawsserverless/pom.xml index 24d28aa20..52155cb42 100644 --- a/gxawsserverless/pom.xml +++ b/gxawsserverless/pom.xml @@ -37,6 +37,13 @@ 1.2.1 + + com.amazonaws + aws-lambda-java-events + 3.11.0 + + + org.glassfish.jersey.media jersey-media-json-jackson diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java index 3603f948f..d58508b66 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java @@ -1,13 +1,72 @@ package com.genexus.cloud.serverless; -import java.util.Date; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.genexus.cloud.serverless.aws.EventMessageProperty; + +import java.util.*; public class EventMessage { + @JsonProperty("EventMessageId") private String messageId; + + @JsonProperty("EventMessageDate") private Date messageDate; + + @JsonProperty("EventMessageSourceType") private String messageSourceType; + + @JsonProperty("EventMessageData") private String messageData; - private String messageCustomPlayload; + + @JsonProperty("EventMessageVersion") private String messageVersion = "1.0"; + + @JsonProperty("EventMessageCustomPayload") + private List messageProperties = new ArrayList<>(); + + public String getMessageId() { + return messageId; + } + + public void setMessageId(String messageId) { + this.messageId = messageId; + } + + public Date getMessageDate() { + return messageDate; + } + + public void setMessageDate(Date messageDate) { + this.messageDate = messageDate; + } + + public String getMessageSourceType() { + return messageSourceType; + } + + public void setMessageSourceType(String messageSourceType) { + this.messageSourceType = messageSourceType; + } + + public String getMessageData() { + return messageData; + } + + public void setMessageData(String messageData) { + this.messageData = messageData; + } + + public String getMessageVersion() { + return messageVersion; + } + + public void setMessageVersion(String messageVersion) { + this.messageVersion = messageVersion; + } + + public List getMessageProperties() { + return messageProperties; + } + } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java index a507001d5..68b701088 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java @@ -1,2 +1,27 @@ -package com.genexus.cloud.serverless;public class EventMessageResponse { +package com.genexus.cloud.serverless; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class EventMessageResponse { + @JsonProperty("Handled") + private boolean handled; + + @JsonProperty("ErrorMessage") + private String errorMessage; + + public boolean isHandled() { + return handled; + } + + public void setHandled(boolean handled) { + this.handled = handled; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java index 0835ad5c8..d340af98e 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java @@ -4,4 +4,5 @@ public class EventMessageSourceType { public static String QueueMessage = "QueueMessage"; public static String ServiceBusMessage = "ServiceBusMessage"; public static String Timer = "Timer"; + public static String StreamMessage = "StreamMessage"; } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java index 4a815f196..0bf1c6cad 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java @@ -1,2 +1,15 @@ -package com.genexus.cloud.serverless;public class EventMessages { +package com.genexus.cloud.serverless; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.ArrayList; +import java.util.List; + +public class EventMessages { + @JsonProperty("EventMessage") + List eventMessages = new ArrayList<>(); + + public void add(EventMessage msg) { + eventMessages.add(msg); + } } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java new file mode 100644 index 000000000..54ddb75fb --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java @@ -0,0 +1,96 @@ +package com.genexus.cloud.serverless; + +import com.genexus.GXProcedure; +import com.genexus.GxUserType; +import com.genexus.ModelContext; +import com.genexus.db.DynamicExecute; + +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; + +public class GXProcedureDynamicExecuteStrategy { + private int id; + protected Class entryPointClass; + protected List> classParameters = new ArrayList<>(); + protected Class outputClassParameter; + private Boolean isValid = null; + + public GXProcedureDynamicExecuteStrategy(int id, String procedureClassName) throws ClassNotFoundException { + this.setId(id); + entryPointClass = (Class) Class.forName(procedureClassName); + } + + public void addInputParameter(String className) throws ClassNotFoundException { + classParameters.add((Class)Class.forName(className)); + } + + public void addOutputParameter(String className) throws ClassNotFoundException { + this.outputClassParameter = (Class)Class.forName(className); + } + + public boolean isValid() { + if (isValid != null) { + return isValid; + } + + List> classMethodParameters = new ArrayList<>(); + classMethodParameters.addAll(classParameters); + classMethodParameters.add(Array.newInstance(outputClassParameter, 0).getClass()); + + Class[] classMethodParametersArray = new Class[classMethodParameters.size()]; + for (int i = 0; i < classMethodParameters.size(); i++) { + classMethodParametersArray[i] = classMethodParameters.get(i); + } + + try { + this.entryPointClass.getMethod(DynamicExecute.METHOD_EXECUTE, classMethodParametersArray); + isValid = true; + } + catch (Exception e) { + isValid = false; + } + return isValid; + + } + + public Object[] execute(ModelContext m, String[] parmsStringSerializedValue) throws Exception { + int methodParameterSize = classParameters.size() + 1; + + if (parmsStringSerializedValue.length != classParameters.size()) { + throw new Exception("Signature method does not match"); + } + + Object[] parameters = new Object[methodParameterSize]; + int idx = 0; + for (String objString : parmsStringSerializedValue) { + Class classParameter = classParameters.get(idx); + parameters[idx] = classParameter.getConstructor().newInstance(); + + if (GxUserType.class.isAssignableFrom(classParameter)) { + GxUserType sdt = (GxUserType) parameters[idx]; + sdt.fromJSonString(objString); + } else if (classParameter == String.class) { + parameters[idx] = objString; + } else { + throw new Exception("Parameter cannot be handled"); + } + idx++; + } + + Object [] outputArray = (Object[]) Array.newInstance(outputClassParameter, 1); + outputArray[0] = outputClassParameter.getConstructor(int.class, ModelContext.class).newInstance(-1 , m);; + parameters[idx] = outputArray; + + com.genexus.db.DynamicExecute.dynamicExecute(m, -1, entryPointClass, "", entryPointClass.getName(), parameters); + return outputArray; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java index 0947b0593..04bae7c1d 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java @@ -1,2 +1,12 @@ -package com.genexus.cloud.serverless;public class Helper { +package com.genexus.cloud.serverless; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class Helper { + + public static String toJSONString(Object dtoObject) throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(dtoObject); + } } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java index 5cd108239..b33a38dff 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java @@ -1,4 +1,17 @@ package com.genexus.cloud.serverless.aws; -public class EventMessageAttribute { +import com.fasterxml.jackson.annotation.JsonProperty; + +public class EventMessageProperty { + + public EventMessageProperty(String pId, String pValue) { + propertyId = pId; + propertyValue = pValue; + } + + @JsonProperty("PropertyId") + private String propertyId; + + @JsonProperty("PropertyValue") + private String propertyValue; } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/LambdaHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/LambdaHandler.java index c782c76d4..16a53717f 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/LambdaHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/LambdaHandler.java @@ -9,6 +9,7 @@ import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest; import com.amazonaws.serverless.proxy.internal.servlet.AwsServletContext; import com.amazonaws.serverless.proxy.model.MultiValuedTreeMap; +import com.genexus.cloud.serverless.aws.handler.AwsGxServletResponse; import com.genexus.specific.java.Connect; import com.genexus.specific.java.LogManager; import com.genexus.webpanels.GXWebObjectStub; @@ -35,7 +36,7 @@ public class LambdaHandler implements RequestHandler handler = null; private static ResourceConfig jerseyApplication = null; private static final String BASE_REST_PATH = "/rest/"; - private static final String GX_APPLICATION_CLASS = "GXApplication"; + private static final String GX_APPLICATION_CLASS = "GXApplication"; public LambdaHandler() throws Exception { if (LambdaHandler.jerseyApplication == null) { diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/AwsGxServletResponse.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/AwsGxServletResponse.java index 1a043d986..ed1f17691 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/AwsGxServletResponse.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/AwsGxServletResponse.java @@ -1,4 +1,4 @@ -package com.genexus.cloud.serverless.aws; +package com.genexus.cloud.serverless.aws.handler; import com.amazonaws.serverless.proxy.model.AwsProxyResponse; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java index a2dc347ce..db78186ed 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java @@ -1,34 +1,46 @@ -package com.genexus.cloud.serverless.aws; +package com.genexus.cloud.serverless.aws.handler; -import com.amazonaws.services.lambda.runtime.Context; -import com.amazonaws.services.lambda.runtime.RequestHandler; -import com.amazonaws.services.lambda.runtime.events.SQSEvent; -import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.genexus.GxUserType; +import com.genexus.ModelContext; +import com.genexus.cloud.serverless.*; import com.genexus.diagnostics.core.ILogger; import com.genexus.specific.java.Connect; import com.genexus.specific.java.LogManager; import com.genexus.util.IniFile; +import java.util.ArrayList; +import java.util.List; + public class LambdaBaseHandler { protected static ILogger logger = null; protected static Class entryPointClass = null; + private static String entryPointClassName; private static final String GX_APPLICATION_CLASS = "GXcfg"; - private static String ENTRY_POINT_CLASS_NAME_VAR = "GX_MAIN_CLASS_NAME"; + public static String ENTRY_POINT_CLASS_NAME_VAR = "GX_MAIN_CLASS_NAME"; private static String packageName = null; - protected static final String MESSAGE_INPUT_CLASS_NAME = "com.genexusserverlessapi.genexusserverlessapi.SdtEventMessages"; - protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexusserverlessapi.genexusserverlessapi.SdtEventMessageResponse"; + protected static final String MESSAGE_COLLECTION_INPUT_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessages"; + protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessageResponse"; + private static List strategies = new ArrayList<>(); public LambdaBaseHandler() throws Exception { initialize(); } - private static void initialize() throws Exception { + public LambdaBaseHandler(String className) throws Exception { + entryPointClassName = className; + initialize(); + } + + private void initialize() throws Exception { logger = LogManager.initialize(".", LambdaBaseHandler.class); Connect.init(); - String entryPointClassName = System.getenv(ENTRY_POINT_CLASS_NAME_VAR); + if (entryPointClassName == null) { + entryPointClassName = System.getenv(ENTRY_POINT_CLASS_NAME_VAR); + } if (entryPointClassName == null) { throw new Exception(String.format("'%s' Environment Variable must be defined", ENTRY_POINT_CLASS_NAME_VAR)); } @@ -37,15 +49,79 @@ private static void initialize() throws Exception { packageName = config.getProperty("Client", "PACKAGE", null); Class cfgClass; try { - cfgClass = Class.forName(packageName.isEmpty() ? GX_APPLICATION_CLASS: String.format("%s.%s", packageName, GX_APPLICATION_CLASS)); + cfgClass = Class.forName(packageName.isEmpty() ? GX_APPLICATION_CLASS : String.format("%s.%s", packageName, GX_APPLICATION_CLASS)); com.genexus.Application.init(cfgClass); - entryPointClassName = packageName.isEmpty() ? entryPointClassName: String.format("%s.%s", packageName, entryPointClassName); + entryPointClassName = entryPointClassName; logger.debug("Initializing entry Point ClassName: " + entryPointClassName); entryPointClass = Class.forName(entryPointClassName); } catch (Exception e) { logger.error(String.format("Failed to initialize Application for className: %s", entryPointClassName), e); throw e; } + + if (entryPointClass == null) { + throw new Exception(String.format("GeneXus Procedure '%s' was not found. Check deployment package ", entryPointClassName)); + } + loadStrategies(); + + } + + + protected EventMessageResponse dispatchEventMessages(EventMessages eventMessages, String lambdaRawMessageBody) throws Exception { + try { + Object[] outResponse = null; + boolean handled = false; + + String jsonStringMessages = Helper.toJSONString(eventMessages); + ModelContext modelContext = new ModelContext(entryPointClass); + + logger.debug(String.format("dispatchEventMessages (%s) - serialized messages: %s", entryPointClassName, jsonStringMessages)); + for (GXProcedureDynamicExecuteStrategy stg: strategies) { + if (outResponse == null && stg.isValid()) { + handled = true; + switch (stg.getId()){ + case 1: + outResponse = stg.execute(modelContext, new String[]{ jsonStringMessages }); + break; + case 2: + outResponse = stg.execute(modelContext, new String[]{ lambdaRawMessageBody }); + break; + } + } + } + + if (!handled) { + throw new Exception(String.format("GeneXus Procedure '%s' does not comply with the required method signature required by Event Handlers. ", entryPointClassName)); + } + + GxUserType handlerOutput = (GxUserType) outResponse[0]; + String jsonResponse = handlerOutput.toJSonString(false); + EventMessageResponse response = new ObjectMapper().readValue(jsonResponse, EventMessageResponse.class); + + if (!response.isHandled()) { + logger.info("dispatchEventmessages - messages not handled with success: " + response.getErrorMessage()); + } else { + logger.debug("dispatchEventmessages - message handled with success"); + } + return response; + + } catch (Exception e) { + logger.error("HandleRequest failed: " + entryPointClass.getName(), e); + throw e; + } + } + + + private void loadStrategies() throws ClassNotFoundException { + GXProcedureDynamicExecuteStrategy strategy = new GXProcedureDynamicExecuteStrategy(1 ,entryPointClassName); + strategy.addInputParameter(MESSAGE_COLLECTION_INPUT_CLASS_NAME); + strategy.addOutputParameter(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME); + strategies.add(strategy); + + strategy = new GXProcedureDynamicExecuteStrategy(2, entryPointClassName); + strategy.addInputParameter(String.class.getName()); + strategy.addOutputParameter(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME); + strategies.add(strategy); } } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java index 1249f6a8a..a58c5e8f4 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java @@ -1,43 +1,88 @@ -package com.genexus.cloud.serverless.aws; +package com.genexus.cloud.serverless.aws.handler; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse; import com.amazonaws.services.lambda.runtime.events.SQSEvent; import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage; -import com.genexus.GxUserType; -import com.genexus.ModelContext; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.genexus.cloud.serverless.*; +import com.genexus.cloud.serverless.aws.EventMessageProperty; -import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; -public class LambdaSQSHandler extends LambdaBaseHandler implements RequestHandler { +public class LambdaSQSHandler extends LambdaBaseHandler implements RequestHandler { public LambdaSQSHandler() throws Exception { super(); } + public LambdaSQSHandler(String className) throws Exception { + super(className); + } + + //https://docs.aws.amazon.com/en_gb/lambda/latest/dg/with-sqs.html @Override - public Void handleRequest(SQSEvent sqsEvent, Context context) { - logger.debug("handleRequest start"); + public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) { + int msgCount = (int) sqsEvent.getRecords().stream().count(); - for(SQSMessage msg : sqsEvent.getRecords()){ - logger.debug(String.format("Processing sqsEvent Message: %s", msg.getMessageId())); + logger.debug("handleRequest started with #sqsItems: " + msgCount); - try { - ModelContext modelContext = new ModelContext( entryPointClass ); - Object[] parameters = new Object[2]; + EventMessages msgs = new EventMessages(); - Class eventMessagesClass = Class.forName(MESSAGE_INPUT_CLASS_NAME); - Constructor constructor = eventMessagesClass.getConstructor(ModelContext.class); - GxUserType inputMessage = (GxUserType) constructor.newInstance(modelContext); + for (SQSMessage sqsItem : sqsEvent.getRecords()) { + logger.debug(String.format("Processing sqsEvent Message: %s", sqsItem.getMessageId())); + EventMessage msg = new EventMessage(); + msg.setMessageId(sqsItem.getMessageId()); + msg.setMessageSourceType(EventMessageSourceType.QueueMessage); + msg.setMessageDate(new Date()); + msg.setMessageData(sqsItem.getBody()); + List msgAtts = msg.getMessageProperties(); - com.genexus.db.DynamicExecute.dynamicExecute(modelContext, -1, entryPointClass, entryPointClass.getName(), parameters); + for (Map.Entry entry : sqsItem.getAttributes().entrySet()) { + msgAtts.add(new EventMessageProperty(entry.getKey(), entry.getValue())); } - catch (Exception e) { - logger.error("HandleRequest failed: " + entryPointClass.getName(), e); + for (Map.Entry entry : sqsItem.getMessageAttributes().entrySet()) { + msgAtts.add(new EventMessageProperty(entry.getKey(), entry.getValue().getStringValue())); } + msgAtts.add(new EventMessageProperty("eventSource", sqsItem.getEventSource())); + msgAtts.add(new EventMessageProperty("eventSourceARN", sqsItem.getEventSourceArn())); + msgAtts.add(new EventMessageProperty("awsRegion", sqsItem.getAwsRegion())); + msgAtts.add(new EventMessageProperty("receiptHandle", sqsItem.getReceiptHandle())); + msgAtts.add(new EventMessageProperty("md5Body", sqsItem.getMd5OfBody())); + + msgs.add(msg); + } + + boolean wasHandled = false; + String errorMessage; + try { + EventMessageResponse response = dispatchEventMessages(msgs, Helper.toJSONString(sqsEvent)); + wasHandled = response.isHandled(); + errorMessage = response.getErrorMessage(); + } catch (Exception e) { + errorMessage = "HandleRequest execution error"; + logger.error(errorMessage, e); } + + if (!wasHandled) { + logger.error(String.format("Messages were not handled. Marking all SQS Events as failed: %s", errorMessage)); + List failures = new ArrayList<>(); + //Assume all batch failed + for (SQSMessage sqsItem : sqsEvent.getRecords()) { + failures.add(new SQSBatchResponse.BatchItemFailure(sqsItem.getMessageId())); + } + return new SQSBatchResponse(failures); + } else { + logger.info("Event Message processed successfully"); + } + return null; } } diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/MockContext.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/MockContext.java new file mode 100644 index 000000000..8d642b9f8 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/MockContext.java @@ -0,0 +1,65 @@ +package com.genexus.cloud.aws.events; + +import com.amazonaws.services.lambda.runtime.ClientContext; +import com.amazonaws.services.lambda.runtime.CognitoIdentity; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.LambdaLogger; + +public class MockContext implements Context { + @Override + public String getAwsRequestId() { + return "1"; + } + + @Override + public String getLogGroupName() { + return ""; + } + + @Override + public String getLogStreamName() { + return ""; + } + + @Override + public String getFunctionName() { + return ""; + } + + @Override + public String getFunctionVersion() { + return ""; + } + + @Override + public String getInvokedFunctionArn() { + return ""; + } + + @Override + public CognitoIdentity getIdentity() { + return null; + } + + @Override + public ClientContext getClientContext() { + return null; + } + + @Override + public int getRemainingTimeInMillis() { + return 200; + } + + @Override + public int getMemoryLimitInMB() { + return 100; + } + + @Override + public LambdaLogger getLogger() { + return null; + } + +} + diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java index 2be2d68a4..b03df7ad3 100644 --- a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java @@ -1,2 +1,4 @@ -package com.genexus.cloud.aws.events;public class TestLambdaBaseHandler { +package com.genexus.cloud.aws.events; + +public class TestLambdaBaseHandler { } diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java new file mode 100644 index 000000000..7f1bcedfa --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java @@ -0,0 +1,95 @@ +package com.genexus.cloud.aws.events; + +import com.amazonaws.services.lambda.runtime.ClientContext; +import com.amazonaws.services.lambda.runtime.CognitoIdentity; +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.LambdaLogger; +import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse; +import com.amazonaws.services.lambda.runtime.events.SQSEvent; +import com.genexus.cloud.serverless.aws.handler.LambdaBaseHandler; +import com.genexus.cloud.serverless.aws.handler.LambdaSQSHandler; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + +import java.util.*; + + +public class TestLambdaSQSHandler { + private static String SIMPLE_HANDLER = "com.unittest.eventdriven.queue.handlesimpleuserqueueevent"; + private static String SIMPLE_RAW_HANDLER = "com.unittest.eventdriven.queue.handlesimplerawsqsevent"; + + @Test + public void TestSQSSimpleEvent() throws Exception { + LambdaSQSHandler sqsHandler = new LambdaSQSHandler(SIMPLE_HANDLER); + SQSEvent sqsEvent = new SQSEvent(); + createSqsEvent("1", "{\"UserId\":\"d2376a4c-86c3-461f-93cc-1c2e0174222b\", \"UserName\":\"John\"}", sqsEvent); + SQSBatchResponse response = sqsHandler.handleRequest(sqsEvent, new MockContext()); + Assert.assertNull(response); + } + + @Test + public void TestSQSSimpleMultipleEvent() throws Exception { + LambdaSQSHandler sqsHandler = new LambdaSQSHandler(SIMPLE_HANDLER); + SQSEvent sqsEvent = new SQSEvent(); + createSqsEvent("1", "{\"UserId\":\"d2376a4c-86c3-461f-93cc-1c2e0174222b\", \"UserName\":\"John\"}", sqsEvent); + createSqsEvent("2", "{\"UserId\":\"d2996a4c-86c3-461f-93cc-1c2e0174222b\", \"UserName\":\"John2\"}", sqsEvent); + SQSBatchResponse response = sqsHandler.handleRequest(sqsEvent, new MockContext()); + Assert.assertNull(response); + } + + @Test + public void TestSQSRAWEvent() throws Exception { + LambdaSQSHandler sqsHandler = new LambdaSQSHandler(SIMPLE_RAW_HANDLER); + SQSEvent sqsEvent = new SQSEvent(); + createSqsEvent("1", "{\"UserId\":\"d2376a4c-86c3-461f-93cc-1c2e0174222b\", \"UserName\":\"John\"}", sqsEvent); + SQSBatchResponse response = sqsHandler.handleRequest(sqsEvent, new MockContext()); + Assert.assertNull(response); + } + + @Test + public void TestSQSSimpleEventError() throws Exception { + LambdaSQSHandler sqsHandler = new LambdaSQSHandler(SIMPLE_HANDLER); + String msgId = "1"; + SQSEvent sqsEvent = new SQSEvent(); + createSqsEvent(msgId, "{sadadsa}", sqsEvent); + SQSBatchResponse response = sqsHandler.handleRequest(sqsEvent, new MockContext()); + Assert.assertNotNull(response); + Assert.assertEquals(1, response.getBatchItemFailures().size()); + Assert.assertEquals(msgId, response.getBatchItemFailures().get(0).getItemIdentifier()); + } + + @Test + public void TestSQSSimpleMultipleEventError() throws Exception { + LambdaSQSHandler sqsHandler = new LambdaSQSHandler(SIMPLE_HANDLER); + + SQSEvent sqsEvent = new SQSEvent(); + createSqsEvent("1", "{aa}", sqsEvent); + createSqsEvent("2", "{aaaa}", sqsEvent); + createSqsEvent("3", "{aaaaaaa}", sqsEvent); + SQSBatchResponse response = sqsHandler.handleRequest(sqsEvent, new MockContext()); + Assert.assertNotNull(response); + Assert.assertEquals(3, response.getBatchItemFailures().size()); + Assert.assertEquals("1", response.getBatchItemFailures().get(0).getItemIdentifier()); + Assert.assertEquals("2", response.getBatchItemFailures().get(1).getItemIdentifier()); + Assert.assertEquals("3", response.getBatchItemFailures().get(2).getItemIdentifier()); + } + + private void createSqsEvent(String msgId, String body, SQSEvent sqsEvent) { + if (sqsEvent.getRecords() == null) { + sqsEvent.setRecords(new ArrayList<>()); + } + List sqsMessagesList = sqsEvent.getRecords(); + SQSEvent.SQSMessage sqsMessage = new SQSEvent.SQSMessage(); + sqsMessage.setMessageId(msgId); + sqsMessage.setEventSource("aws:sqs"); + sqsMessage.setAwsRegion("us-east-1"); + sqsMessage.setBody(body); + sqsMessage.setEventSourceArn("arn:test"); + sqsMessage.setReceiptHandle("123123"); + sqsMessage.setAttributes(new HashMap<>()); + sqsMessage.setMessageAttributes(new HashMap()); + sqsMessagesList.add(sqsMessage); + } +} diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.class b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.class new file mode 100644 index 0000000000000000000000000000000000000000..d6dfff6086e62b45fe69f61f10c238d63f57eba6 GIT binary patch literal 5728 zcmbtY34Bxa9sfR>Hfj23OSsBW1i4B=DIN@Hp$e6wtSucy$}xto$)gQT@=Eg37UnUX zQ#W;+uuWmgoNhxmWeROz;1oA;o7dds?t9E#?mnDzvhVM`*EVS*tMJL^^FM$0|98DS z^TzSV0W8EBH@e*D_CmofFGgUu2k-Xc3S2G2HF9#T4ALyv;EW<6beZLnUz^$^qO}4ko@Il#r$b%2d-5s*oBgcC^_=wCOmEmLgl;O^N+=YDt zwckhi4hZNce7yLiNO7MB_j~XuFFuXW2+Tnb9`N8n*?(5{pOfJs**@&SA(=lfXphM7 zs0@dN(Ggko$k6M>5~O5xR944i^#wPM%f?dsgsdKu<1fnUaW|e28(izgNdM^q>nJ|rLqqZwzXrXNxyINC^ zZfj7WEGNylu7%dNbJL_?WNdBHY}De>8Y3Aq6;!?@ij8rD(wVzDwMbG|;IoB{XtCCc zCNmz6wNge;V!hVdphbCKAe>i3^eBZT`^`MrZp5RSxgs7nsN}+PVjd1rrzPQ7*sNBN zQ#NOV0#}U@BEO=#a7=GVMqBjwdaWhGlhU%fpb@QT)nj^hGEq@aut<#&Gxct>N)V@% z)t()oDU*OhD51wY^>{>2B(#pOsGba(!+aHst+!P-*CdP>Usb`ZvY}?2GxSJ-Tg=%V zjVPF(DHYEuHrCgzj+?(-?R9SL013VrK! z!(#K6LWoIbNigDM0B@6#j0g3VVTt#-!;Hdtl3f*)r0bua92Bfhzd9e&sA$5IGBhig zJxuWg{7W)?S%&p0c4Cu?6gC8Ud0P?Qj0Yz)}m3x*RfrJw=c2RhE%+WZ>adDkXeU%CXT+l4U+U#)Cuix z;oB;{gO}X+u8Qx;$@hg$@p8j36J}iNsMpOlBa|r0!w)?8p^6{j$0~k;?H>G8Ha}Cb z4SWDr;Tc0~*}NgO%#EL`_yvBc;#W9LdAIm0V@5)cg|^b4nZ#lV6~D&IDt?3Cs`wpF ztN1-$maNyGsh2g@s`vw9Dq0YffvUcOKdM-T)hgP>%74P2Rs2OXZ$+DmzshO{+7vYW ze`k0r4y-~K(ti^sVOjlMn2Z`y@fD0qXS}NWN*12=yE^FTW76|aO+-s1tin=}nT69` zI$K>}!kT}!3Yb0B=P#(9METme1MgmSED6E+kD1=VVSTn-5{e4#2jc%3Yli)FL*2 zw@vTjVH0FG;~@zvDyT@%?kW^a%t)#kFCh9xj211DP%t(FY?Xb?G&(v%**@rkMAO=3 zjcl9h6Ro5Y)4QbA@!}u&Cmlzz`l+d6EowhiQ51}iYVA5ZouFnmhs`#w5~db2$#~7M z?3KlWLys7U!gHP0#qNXlRqCZ9YSk+#0u~L6PrAoAPnF$c>~@68T73(fnYh{CS!ON9 ztaPr3zMY<$%|mLlGA^`;FEi;yElHDpm<@HP9i*z}M0B<-StX(C<;KIUZ4^bd81xHX zWN%{wP4cK^p^zOpeQ8(0oU>cf2{gM=$_?7ZJ+tTOkHwMn*gnG2M;E8v#r8 z+TH?j<6n}(|HIThP=>;>PNQ9Sz5;B&Td4(2BfiUx|1w(Z45K~CXjN-tF+FZ2ES=7H zSGsBr4ZC!#)?y(x*fVUzED@dd3>k})@W;Hd9`MiaBF6fwr19MYi3R6JdTBv zjRD6ix$~1AYbgr-C!lQdjW~*&qi{XS69pSM%Eu-!lD|R=ui3$yfgJ0`;}7_9k0Ng{ zh7WFxwlFq27&FN!hqUtjljaJFdoW4~JeXjiY;sWiWFhRm{-YqH6!Hgf3N2!#Bszu0 zxquj(vBklg?%)+1hL>0cC!sz_ri$ z;{7;S<`!GcaP3*-azl#?H z^T=W>4@Xs7V3RYzO0$5G+qnIds2|VI6QAptuVbn*w!$^dRa{cV7utra?03RU5rK*rd@yLwod_UFi+1sUoNiiaHzV_EYJ3gaXu+Mh9-X+svWpwJ>Xd@X zlc`rrfB0TV;^NMEep=(=!PdBmn%``}i%lflr#oTm_D>?hC4&)eMILUm5JC>ZVv>-k zo#40akdu?brG8s&Ydt{1j>tQx+#Zx*FA16?cv@V@MNx$`_Fe%~x73oNjfrPf$9Kw%u&0f%Y-BPc)*Mlo*3 zBSmUa`ijjwUBLwsu;~fyIClm*9MGwp#oivux$q=L3^vCTyyb_X11&{Hv>GMpYEcS{ zWv)!2YCt~wai3y%okB65CSn{32ff-spLhaGHXX&%x&XOWr*N6fm#45SFu>kt#qYDE z^Bn0sPe*xyYqQ^>XIp~s^-o|qY1JHocR&c+%+vTPQht(@cm%`aHO}&f@vC?p|7HdG QIQNCTxtnMASmV9_15HlnGynhq literal 0 HcmV?d00001 diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java new file mode 100644 index 000000000..ca405bc72 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java @@ -0,0 +1,218 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; +import com.genexus.*; +import com.genexus.xml.*; +import com.genexus.search.*; +import com.genexus.webpanels.*; +import java.util.*; + +public final class SdtEventCustomPayload_CustomPayloadItem extends GxUserType +{ + public SdtEventCustomPayload_CustomPayloadItem( ) + { + this( new ModelContext(SdtEventCustomPayload_CustomPayloadItem.class)); + } + + public SdtEventCustomPayload_CustomPayloadItem( ModelContext context ) + { + super( context, "SdtEventCustomPayload_CustomPayloadItem"); + } + + public SdtEventCustomPayload_CustomPayloadItem( int remoteHandle , + ModelContext context ) + { + super( remoteHandle, context, "SdtEventCustomPayload_CustomPayloadItem"); + } + + public SdtEventCustomPayload_CustomPayloadItem( StructSdtEventCustomPayload_CustomPayloadItem struct ) + { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + static + { + } + + public String getJsonMap( String value ) + { + return (String) mapper.get(value); + } + + public short readxml( com.genexus.xml.XMLReader oReader , + String sName ) + { + short GXSoapError = 1; + formatError = false ; + sTagName = oReader.getName() ; + if ( oReader.getIsSimple() == 0 ) + { + GXSoapError = oReader.read() ; + nOutParmCount = (short)(0) ; + while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) + { + readOk = (short)(0) ; + readElement = false ; + if ( GXutil.strcmp2( oReader.getLocalName(), "PropertyId") ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "PropertyValue") ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( ! readElement ) + { + readOk = (short)(1) ; + GXSoapError = oReader.read() ; + } + nOutParmCount = (short)(nOutParmCount+1) ; + if ( ( readOk == 0 ) || formatError ) + { + context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; + context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; + GXSoapError = (short)(nOutParmCount*-1) ; + } + } + } + return GXSoapError ; + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace ) + { + writexml(oWriter, sName, sNameSpace, true); + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace , + boolean sIncludeState ) + { + if ( (GXutil.strcmp("", sName)==0) ) + { + sName = "EventCustomPayload.CustomPayloadItem" ; + } + oWriter.writeStartElement(sName); + if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) + { + oWriter.writeAttribute("xmlns", sNameSpace); + } + else + { + sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; + } + oWriter.writeElement("PropertyId", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + oWriter.writeElement("PropertyValue", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + oWriter.writeEndElement(); + } + + public void tojson( ) + { + tojson( true) ; + } + + public void tojson( boolean includeState ) + { + tojson( includeState, true) ; + } + + public void tojson( boolean includeState , + boolean includeNonInitialized ) + { + AddObjectProperty("PropertyId", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid, false, false); + AddObjectProperty("PropertyValue", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue, false, false); + } + + public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid( ) + { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; + } + + public void setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid( String value ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = value ; + } + + public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue( ) + { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; + } + + public void setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue( String value ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = value ; + } + + public void initialize( int remoteHandle ) + { + initialize( ) ; + } + + public void initialize( ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = "" ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(1) ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = "" ; + sTagName = "" ; + } + + public byte isNull( ) + { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_N ; + } + + public com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem Clone( ) + { + return (com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem)(clone()) ; + } + + public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem struct ) + { + setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid(struct.getPropertyid()); + setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue(struct.getPropertyvalue()); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem getStruct( ) + { + com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem struct = new com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem (); + struct.setPropertyid(getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid()); + struct.setPropertyvalue(getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue()); + return struct ; + } + + protected byte gxTv_SdtEventCustomPayload_CustomPayloadItem_N ; + protected short readOk ; + protected short nOutParmCount ; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; + protected String sTagName ; + protected boolean readElement ; + protected boolean formatError ; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java new file mode 100644 index 000000000..bc9d43502 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java @@ -0,0 +1,477 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; +import com.genexus.*; +import com.genexus.xml.*; +import com.genexus.search.*; +import com.genexus.webpanels.*; +import java.util.*; + +public final class SdtEventMessage extends GxUserType +{ + public SdtEventMessage( ) + { + this( new ModelContext(SdtEventMessage.class)); + } + + public SdtEventMessage( ModelContext context ) + { + super( context, "SdtEventMessage"); + } + + public SdtEventMessage( int remoteHandle , + ModelContext context ) + { + super( remoteHandle, context, "SdtEventMessage"); + } + + public SdtEventMessage( StructSdtEventMessage struct ) + { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + static + { + } + + public String getJsonMap( String value ) + { + return (String) mapper.get(value); + } + + public short readxml( com.genexus.xml.XMLReader oReader , + String sName ) + { + short GXSoapError = 1; + formatError = false ; + sTagName = oReader.getName() ; + if ( oReader.getIsSimple() == 0 ) + { + GXSoapError = oReader.read() ; + nOutParmCount = (short)(0) ; + while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) + { + readOk = (short)(0) ; + readElement = false ; + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageId") ) + { + gxTv_SdtEventMessage_Eventmessageid = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageDate") ) + { + if ( ( GXutil.strcmp(oReader.getValue(), "") == 0 ) || ( oReader.existsAttribute("xsi:nil") == 1 ) ) + { + gxTv_SdtEventMessage_Eventmessagedate = GXutil.resetTime( GXutil.nullDate() ); + gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(1) ; + } + else + { + gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagedate = localUtil.ymdhmsToT( (short)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 1, 4), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 6, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 9, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 12, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 15, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 18, 2), ".")))) ; + } + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageSourceType") ) + { + gxTv_SdtEventMessage_Eventmessagesourcetype = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageData") ) + { + gxTv_SdtEventMessage_Eventmessagedata = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageVersion") ) + { + gxTv_SdtEventMessage_Eventmessageversion = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageCustomPayload") ) + { + if ( gxTv_SdtEventMessage_Eventmessagecustompayload == null ) + { + gxTv_SdtEventMessage_Eventmessagecustompayload = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); + } + if ( ( oReader.getIsSimple() == 0 ) || ( oReader.getAttributeCount() > 0 ) ) + { + GXSoapError = gxTv_SdtEventMessage_Eventmessagecustompayload.readxml(oReader, "EventMessageCustomPayload") ; + } + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageCustomPayload") ) + { + GXSoapError = oReader.read() ; + } + } + if ( ! readElement ) + { + readOk = (short)(1) ; + GXSoapError = oReader.read() ; + } + nOutParmCount = (short)(nOutParmCount+1) ; + if ( ( readOk == 0 ) || formatError ) + { + context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; + context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; + GXSoapError = (short)(nOutParmCount*-1) ; + } + } + } + return GXSoapError ; + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace ) + { + writexml(oWriter, sName, sNameSpace, true); + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace , + boolean sIncludeState ) + { + if ( (GXutil.strcmp("", sName)==0) ) + { + sName = "EventMessage" ; + } + if ( (GXutil.strcmp("", sNameSpace)==0) ) + { + sNameSpace = "ServerlessAPI" ; + } + oWriter.writeStartElement(sName); + if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) + { + oWriter.writeAttribute("xmlns", sNameSpace); + } + else + { + sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; + } + oWriter.writeElement("EventMessageId", gxTv_SdtEventMessage_Eventmessageid); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + if ( GXutil.dateCompare(GXutil.nullDate(), gxTv_SdtEventMessage_Eventmessagedate) && ( gxTv_SdtEventMessage_Eventmessagedate_N == 1 ) ) + { + oWriter.writeElement("EventMessageDate", ""); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + } + else + { + sDateCnv = "" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.year( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; + sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.month( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.day( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "T" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.second( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + oWriter.writeElement("EventMessageDate", sDateCnv); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + } + oWriter.writeElement("EventMessageSourceType", gxTv_SdtEventMessage_Eventmessagesourcetype); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + oWriter.writeElement("EventMessageData", gxTv_SdtEventMessage_Eventmessagedata); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + oWriter.writeElement("EventMessageVersion", gxTv_SdtEventMessage_Eventmessageversion); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + if ( gxTv_SdtEventMessage_Eventmessagecustompayload != null ) + { + String sNameSpace1; + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") == 0 ) + { + sNameSpace1 = "[*:nosend]" + "ServerlessAPI" ; + } + else + { + sNameSpace1 = "ServerlessAPI" ; + } + gxTv_SdtEventMessage_Eventmessagecustompayload.writexml(oWriter, "EventMessageCustomPayload", sNameSpace1, sIncludeState); + } + oWriter.writeEndElement(); + } + + public void tojson( ) + { + tojson( true) ; + } + + public void tojson( boolean includeState ) + { + tojson( includeState, true) ; + } + + public void tojson( boolean includeState , + boolean includeNonInitialized ) + { + AddObjectProperty("EventMessageId", gxTv_SdtEventMessage_Eventmessageid, false, false); + datetime_STZ = gxTv_SdtEventMessage_Eventmessagedate ; + sDateCnv = "" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.year( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.month( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.day( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "T" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.second( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + AddObjectProperty("EventMessageDate", sDateCnv, false, false); + AddObjectProperty("EventMessageSourceType", gxTv_SdtEventMessage_Eventmessagesourcetype, false, false); + AddObjectProperty("EventMessageData", gxTv_SdtEventMessage_Eventmessagedata, false, false); + AddObjectProperty("EventMessageVersion", gxTv_SdtEventMessage_Eventmessageversion, false, false); + if ( gxTv_SdtEventMessage_Eventmessagecustompayload != null ) + { + AddObjectProperty("EventMessageCustomPayload", gxTv_SdtEventMessage_Eventmessagecustompayload, false, false); + } + } + + public String getgxTv_SdtEventMessage_Eventmessageid( ) + { + return gxTv_SdtEventMessage_Eventmessageid ; + } + + public void setgxTv_SdtEventMessage_Eventmessageid( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessageid = value ; + } + + public java.util.Date getgxTv_SdtEventMessage_Eventmessagedate( ) + { + return gxTv_SdtEventMessage_Eventmessagedate ; + } + + public void setgxTv_SdtEventMessage_Eventmessagedate( java.util.Date value ) + { + gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(0) ; + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagedate = value ; + } + + public String getgxTv_SdtEventMessage_Eventmessagesourcetype( ) + { + return gxTv_SdtEventMessage_Eventmessagesourcetype ; + } + + public void setgxTv_SdtEventMessage_Eventmessagesourcetype( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagesourcetype = value ; + } + + public String getgxTv_SdtEventMessage_Eventmessagedata( ) + { + return gxTv_SdtEventMessage_Eventmessagedata ; + } + + public void setgxTv_SdtEventMessage_Eventmessagedata( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagedata = value ; + } + + public String getgxTv_SdtEventMessage_Eventmessageversion( ) + { + return gxTv_SdtEventMessage_Eventmessageversion ; + } + + public void setgxTv_SdtEventMessage_Eventmessageversion( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessageversion = value ; + } + + public GXBaseCollection getgxTv_SdtEventMessage_Eventmessagecustompayload( ) + { + if ( gxTv_SdtEventMessage_Eventmessagecustompayload == null ) + { + gxTv_SdtEventMessage_Eventmessagecustompayload = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); + } + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(0) ; + gxTv_SdtEventMessage_N = (byte)(0) ; + return gxTv_SdtEventMessage_Eventmessagecustompayload ; + } + + public void setgxTv_SdtEventMessage_Eventmessagecustompayload( GXBaseCollection value ) + { + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(0) ; + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagecustompayload = value ; + } + + public void setgxTv_SdtEventMessage_Eventmessagecustompayload_SetNull( ) + { + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(1) ; + gxTv_SdtEventMessage_Eventmessagecustompayload = null ; + } + + public boolean getgxTv_SdtEventMessage_Eventmessagecustompayload_IsNull( ) + { + if ( gxTv_SdtEventMessage_Eventmessagecustompayload == null ) + { + return true ; + } + return false ; + } + + public byte getgxTv_SdtEventMessage_Eventmessagecustompayload_N( ) + { + return gxTv_SdtEventMessage_Eventmessagecustompayload_N ; + } + + public void initialize( int remoteHandle ) + { + initialize( ) ; + } + + public void initialize( ) + { + gxTv_SdtEventMessage_Eventmessageid = "" ; + gxTv_SdtEventMessage_N = (byte)(1) ; + gxTv_SdtEventMessage_Eventmessagedate = GXutil.resetTime( GXutil.nullDate() ); + gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(1) ; + gxTv_SdtEventMessage_Eventmessagesourcetype = "" ; + gxTv_SdtEventMessage_Eventmessagedata = "" ; + gxTv_SdtEventMessage_Eventmessageversion = "" ; + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(1) ; + sTagName = "" ; + sDateCnv = "" ; + sNumToPad = "" ; + datetime_STZ = GXutil.resetTime( GXutil.nullDate() ); + } + + public byte isNull( ) + { + return gxTv_SdtEventMessage_N ; + } + + public com.genexus.genexusserverlessapi.SdtEventMessage Clone( ) + { + return (com.genexus.genexusserverlessapi.SdtEventMessage)(clone()) ; + } + + public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventMessage struct ) + { + setgxTv_SdtEventMessage_Eventmessageid(struct.getEventmessageid()); + if ( struct.gxTv_SdtEventMessage_Eventmessagedate_N == 0 ) + { + setgxTv_SdtEventMessage_Eventmessagedate(struct.getEventmessagedate()); + } + setgxTv_SdtEventMessage_Eventmessagesourcetype(struct.getEventmessagesourcetype()); + setgxTv_SdtEventMessage_Eventmessagedata(struct.getEventmessagedata()); + setgxTv_SdtEventMessage_Eventmessageversion(struct.getEventmessageversion()); + GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload_aux = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); + Vector gxTv_SdtEventMessage_Eventmessagecustompayload_aux1 = struct.getEventmessagecustompayload(); + if (gxTv_SdtEventMessage_Eventmessagecustompayload_aux1 != null) + { + for (int i = 0; i < gxTv_SdtEventMessage_Eventmessagecustompayload_aux1.size(); i++) + { + gxTv_SdtEventMessage_Eventmessagecustompayload_aux.add(new com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem(gxTv_SdtEventMessage_Eventmessagecustompayload_aux1.elementAt(i))); + } + } + setgxTv_SdtEventMessage_Eventmessagecustompayload(gxTv_SdtEventMessage_Eventmessagecustompayload_aux); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventMessage getStruct( ) + { + com.genexus.genexusserverlessapi.StructSdtEventMessage struct = new com.genexus.genexusserverlessapi.StructSdtEventMessage (); + struct.setEventmessageid(getgxTv_SdtEventMessage_Eventmessageid()); + if ( gxTv_SdtEventMessage_Eventmessagedate_N == 0 ) + { + struct.setEventmessagedate(getgxTv_SdtEventMessage_Eventmessagedate()); + } + struct.setEventmessagesourcetype(getgxTv_SdtEventMessage_Eventmessagesourcetype()); + struct.setEventmessagedata(getgxTv_SdtEventMessage_Eventmessagedata()); + struct.setEventmessageversion(getgxTv_SdtEventMessage_Eventmessageversion()); + struct.setEventmessagecustompayload(getgxTv_SdtEventMessage_Eventmessagecustompayload().getStruct()); + return struct ; + } + + protected byte gxTv_SdtEventMessage_N ; + protected byte gxTv_SdtEventMessage_Eventmessagedate_N ; + protected byte gxTv_SdtEventMessage_Eventmessagecustompayload_N ; + protected short readOk ; + protected short nOutParmCount ; + protected String sTagName ; + protected String sDateCnv ; + protected String sNumToPad ; + protected java.util.Date gxTv_SdtEventMessage_Eventmessagedate ; + protected java.util.Date datetime_STZ ; + protected boolean readElement ; + protected boolean formatError ; + protected String gxTv_SdtEventMessage_Eventmessagedata ; + protected String gxTv_SdtEventMessage_Eventmessageid ; + protected String gxTv_SdtEventMessage_Eventmessagesourcetype ; + protected String gxTv_SdtEventMessage_Eventmessageversion ; + protected GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload_aux ; + protected GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload=null ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java new file mode 100644 index 000000000..cbb5d1e79 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java @@ -0,0 +1,221 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; +import com.genexus.*; +import com.genexus.xml.*; +import com.genexus.search.*; +import com.genexus.webpanels.*; +import java.util.*; + +public final class SdtEventMessageResponse extends GxUserType +{ + public SdtEventMessageResponse( ) + { + this( new ModelContext(SdtEventMessageResponse.class)); + } + + public SdtEventMessageResponse( ModelContext context ) + { + super( context, "SdtEventMessageResponse"); + } + + public SdtEventMessageResponse( int remoteHandle , + ModelContext context ) + { + super( remoteHandle, context, "SdtEventMessageResponse"); + } + + public SdtEventMessageResponse( StructSdtEventMessageResponse struct ) + { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + static + { + } + + public String getJsonMap( String value ) + { + return (String) mapper.get(value); + } + + public short readxml( com.genexus.xml.XMLReader oReader , + String sName ) + { + short GXSoapError = 1; + formatError = false ; + sTagName = oReader.getName() ; + if ( oReader.getIsSimple() == 0 ) + { + GXSoapError = oReader.read() ; + nOutParmCount = (short)(0) ; + while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) + { + readOk = (short)(0) ; + readElement = false ; + if ( GXutil.strcmp2( oReader.getLocalName(), "Handled") ) + { + gxTv_SdtEventMessageResponse_Handled = (boolean)((((GXutil.strcmp(oReader.getValue(), "true")==0)||(GXutil.strcmp(oReader.getValue(), "1")==0) ? 1 : 0)==0)?false:true) ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "ErrorMessage") ) + { + gxTv_SdtEventMessageResponse_Errormessage = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( ! readElement ) + { + readOk = (short)(1) ; + GXSoapError = oReader.read() ; + } + nOutParmCount = (short)(nOutParmCount+1) ; + if ( ( readOk == 0 ) || formatError ) + { + context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; + context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; + GXSoapError = (short)(nOutParmCount*-1) ; + } + } + } + return GXSoapError ; + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace ) + { + writexml(oWriter, sName, sNameSpace, true); + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace , + boolean sIncludeState ) + { + if ( (GXutil.strcmp("", sName)==0) ) + { + sName = "EventMessageResponse" ; + } + if ( (GXutil.strcmp("", sNameSpace)==0) ) + { + sNameSpace = "ServerlessAPI" ; + } + oWriter.writeStartElement(sName); + if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) + { + oWriter.writeAttribute("xmlns", sNameSpace); + } + else + { + sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; + } + oWriter.writeElement("Handled", GXutil.booltostr( gxTv_SdtEventMessageResponse_Handled)); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + oWriter.writeElement("ErrorMessage", gxTv_SdtEventMessageResponse_Errormessage); + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) + { + oWriter.writeAttribute("xmlns", "ServerlessAPI"); + } + oWriter.writeEndElement(); + } + + public void tojson( ) + { + tojson( true) ; + } + + public void tojson( boolean includeState ) + { + tojson( includeState, true) ; + } + + public void tojson( boolean includeState , + boolean includeNonInitialized ) + { + AddObjectProperty("Handled", gxTv_SdtEventMessageResponse_Handled, false, false); + AddObjectProperty("ErrorMessage", gxTv_SdtEventMessageResponse_Errormessage, false, false); + } + + public boolean getgxTv_SdtEventMessageResponse_Handled( ) + { + return gxTv_SdtEventMessageResponse_Handled ; + } + + public void setgxTv_SdtEventMessageResponse_Handled( boolean value ) + { + gxTv_SdtEventMessageResponse_N = (byte)(0) ; + gxTv_SdtEventMessageResponse_Handled = value ; + } + + public String getgxTv_SdtEventMessageResponse_Errormessage( ) + { + return gxTv_SdtEventMessageResponse_Errormessage ; + } + + public void setgxTv_SdtEventMessageResponse_Errormessage( String value ) + { + gxTv_SdtEventMessageResponse_N = (byte)(0) ; + gxTv_SdtEventMessageResponse_Errormessage = value ; + } + + public void initialize( int remoteHandle ) + { + initialize( ) ; + } + + public void initialize( ) + { + gxTv_SdtEventMessageResponse_N = (byte)(1) ; + gxTv_SdtEventMessageResponse_Errormessage = "" ; + sTagName = "" ; + } + + public byte isNull( ) + { + return gxTv_SdtEventMessageResponse_N ; + } + + public com.genexus.genexusserverlessapi.SdtEventMessageResponse Clone( ) + { + return (com.genexus.genexusserverlessapi.SdtEventMessageResponse)(clone()) ; + } + + public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventMessageResponse struct ) + { + setgxTv_SdtEventMessageResponse_Handled(struct.getHandled()); + setgxTv_SdtEventMessageResponse_Errormessage(struct.getErrormessage()); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventMessageResponse getStruct( ) + { + com.genexus.genexusserverlessapi.StructSdtEventMessageResponse struct = new com.genexus.genexusserverlessapi.StructSdtEventMessageResponse (); + struct.setHandled(getgxTv_SdtEventMessageResponse_Handled()); + struct.setErrormessage(getgxTv_SdtEventMessageResponse_Errormessage()); + return struct ; + } + + protected byte gxTv_SdtEventMessageResponse_N ; + protected short readOk ; + protected short nOutParmCount ; + protected String sTagName ; + protected boolean gxTv_SdtEventMessageResponse_Handled ; + protected boolean readElement ; + protected boolean formatError ; + protected String gxTv_SdtEventMessageResponse_Errormessage ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java new file mode 100644 index 000000000..378086405 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java @@ -0,0 +1,250 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; +import com.genexus.*; +import com.genexus.xml.*; +import com.genexus.search.*; +import com.genexus.webpanels.*; +import java.util.*; + +public final class SdtEventMessages extends GxUserType +{ + public SdtEventMessages( ) + { + this( new ModelContext(SdtEventMessages.class)); + } + + public SdtEventMessages( ModelContext context ) + { + super( context, "SdtEventMessages"); + } + + public SdtEventMessages( int remoteHandle , + ModelContext context ) + { + super( remoteHandle, context, "SdtEventMessages"); + } + + public SdtEventMessages( StructSdtEventMessages struct ) + { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + static + { + } + + public String getJsonMap( String value ) + { + return (String) mapper.get(value); + } + + public short readxml( com.genexus.xml.XMLReader oReader , + String sName ) + { + short GXSoapError = 1; + formatError = false ; + sTagName = oReader.getName() ; + if ( oReader.getIsSimple() == 0 ) + { + GXSoapError = oReader.read() ; + nOutParmCount = (short)(0) ; + while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) + { + readOk = (short)(0) ; + readElement = false ; + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessage") ) + { + if ( gxTv_SdtEventMessages_Eventmessage == null ) + { + gxTv_SdtEventMessages_Eventmessage = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); + } + if ( oReader.getIsSimple() == 0 ) + { + GXSoapError = gxTv_SdtEventMessages_Eventmessage.readxmlcollection(oReader, "EventMessage", "EventMessage") ; + } + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessage") ) + { + GXSoapError = oReader.read() ; + } + } + if ( ! readElement ) + { + readOk = (short)(1) ; + GXSoapError = oReader.read() ; + } + nOutParmCount = (short)(nOutParmCount+1) ; + if ( ( readOk == 0 ) || formatError ) + { + context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; + context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; + GXSoapError = (short)(nOutParmCount*-1) ; + } + } + } + return GXSoapError ; + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace ) + { + writexml(oWriter, sName, sNameSpace, true); + } + + public void writexml( com.genexus.xml.XMLWriter oWriter , + String sName , + String sNameSpace , + boolean sIncludeState ) + { + if ( (GXutil.strcmp("", sName)==0) ) + { + sName = "EventMessages" ; + } + if ( (GXutil.strcmp("", sNameSpace)==0) ) + { + sNameSpace = "ServerlessAPI" ; + } + oWriter.writeStartElement(sName); + if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) + { + oWriter.writeAttribute("xmlns", sNameSpace); + } + else + { + sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; + } + if ( gxTv_SdtEventMessages_Eventmessage != null ) + { + String sNameSpace1; + if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") == 0 ) + { + sNameSpace1 = "[*:nosend]" + "ServerlessAPI" ; + } + else + { + sNameSpace1 = "ServerlessAPI" ; + } + gxTv_SdtEventMessages_Eventmessage.writexmlcollection(oWriter, "EventMessage", sNameSpace1, "EventMessage", sNameSpace1); + } + oWriter.writeEndElement(); + } + + public void tojson( ) + { + tojson( true) ; + } + + public void tojson( boolean includeState ) + { + tojson( includeState, true) ; + } + + public void tojson( boolean includeState , + boolean includeNonInitialized ) + { + if ( gxTv_SdtEventMessages_Eventmessage != null ) + { + AddObjectProperty("EventMessage", gxTv_SdtEventMessages_Eventmessage, false, false); + } + } + + public GXBaseCollection getgxTv_SdtEventMessages_Eventmessage( ) + { + if ( gxTv_SdtEventMessages_Eventmessage == null ) + { + gxTv_SdtEventMessages_Eventmessage = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); + } + gxTv_SdtEventMessages_Eventmessage_N = (byte)(0) ; + gxTv_SdtEventMessages_N = (byte)(0) ; + return gxTv_SdtEventMessages_Eventmessage ; + } + + public void setgxTv_SdtEventMessages_Eventmessage( GXBaseCollection value ) + { + gxTv_SdtEventMessages_Eventmessage_N = (byte)(0) ; + gxTv_SdtEventMessages_N = (byte)(0) ; + gxTv_SdtEventMessages_Eventmessage = value ; + } + + public void setgxTv_SdtEventMessages_Eventmessage_SetNull( ) + { + gxTv_SdtEventMessages_Eventmessage_N = (byte)(1) ; + gxTv_SdtEventMessages_Eventmessage = null ; + } + + public boolean getgxTv_SdtEventMessages_Eventmessage_IsNull( ) + { + if ( gxTv_SdtEventMessages_Eventmessage == null ) + { + return true ; + } + return false ; + } + + public byte getgxTv_SdtEventMessages_Eventmessage_N( ) + { + return gxTv_SdtEventMessages_Eventmessage_N ; + } + + public void initialize( int remoteHandle ) + { + initialize( ) ; + } + + public void initialize( ) + { + gxTv_SdtEventMessages_Eventmessage_N = (byte)(1) ; + gxTv_SdtEventMessages_N = (byte)(1) ; + sTagName = "" ; + } + + public byte isNull( ) + { + return gxTv_SdtEventMessages_N ; + } + + public com.genexus.genexusserverlessapi.SdtEventMessages Clone( ) + { + return (com.genexus.genexusserverlessapi.SdtEventMessages)(clone()) ; + } + + public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventMessages struct ) + { + GXBaseCollection gxTv_SdtEventMessages_Eventmessage_aux = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); + Vector gxTv_SdtEventMessages_Eventmessage_aux1 = struct.getEventmessage(); + if (gxTv_SdtEventMessages_Eventmessage_aux1 != null) + { + for (int i = 0; i < gxTv_SdtEventMessages_Eventmessage_aux1.size(); i++) + { + gxTv_SdtEventMessages_Eventmessage_aux.add(new com.genexus.genexusserverlessapi.SdtEventMessage(gxTv_SdtEventMessages_Eventmessage_aux1.elementAt(i))); + } + } + setgxTv_SdtEventMessages_Eventmessage(gxTv_SdtEventMessages_Eventmessage_aux); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventMessages getStruct( ) + { + com.genexus.genexusserverlessapi.StructSdtEventMessages struct = new com.genexus.genexusserverlessapi.StructSdtEventMessages (); + struct.setEventmessage(getgxTv_SdtEventMessages_Eventmessage().getStruct()); + return struct ; + } + + protected byte gxTv_SdtEventMessages_Eventmessage_N ; + protected byte gxTv_SdtEventMessages_N ; + protected short readOk ; + protected short nOutParmCount ; + protected String sTagName ; + protected boolean readElement ; + protected boolean formatError ; + protected GXBaseCollection gxTv_SdtEventMessages_Eventmessage_aux ; + protected GXBaseCollection gxTv_SdtEventMessages_Eventmessage=null ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java new file mode 100644 index 000000000..faae24709 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java @@ -0,0 +1,45 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; + +@javax.xml.bind.annotation.XmlType(name = "EventCustomPayload", namespace ="ServerlessAPI") +public final class StructSdtEventCustomPayload implements Cloneable, java.io.Serializable +{ + public StructSdtEventCustomPayload( ) + { + this( -1, new ModelContext( StructSdtEventCustomPayload.class )); + } + + public StructSdtEventCustomPayload( int remoteHandle , + ModelContext context ) + { + } + + public StructSdtEventCustomPayload( java.util.Vector value ) + { + item = value; + } + + public Object clone() + { + Object cloned = null; + try + { + cloned = super.clone(); + }catch (CloneNotSupportedException e){ ; } + return cloned; + } + + @javax.xml.bind.annotation.XmlElement(name="CustomPayloadItem",namespace="ServerlessAPI") + public java.util.Vector getItem( ) + { + return item; + } + + public void setItem( java.util.Vector value ) + { + item = value; + } + + protected java.util.Vector item = new java.util.Vector<>(); +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java new file mode 100644 index 000000000..56ee75554 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java @@ -0,0 +1,54 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; + +public final class StructSdtEventCustomPayload_CustomPayloadItem implements Cloneable, java.io.Serializable +{ + public StructSdtEventCustomPayload_CustomPayloadItem( ) + { + this( -1, new ModelContext( StructSdtEventCustomPayload_CustomPayloadItem.class )); + } + + public StructSdtEventCustomPayload_CustomPayloadItem( int remoteHandle , + ModelContext context ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = "" ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = "" ; + } + + public Object clone() + { + Object cloned = null; + try + { + cloned = super.clone(); + }catch (CloneNotSupportedException e){ ; } + return cloned; + } + + public String getPropertyid( ) + { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; + } + + public void setPropertyid( String value ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = value ; + } + + public String getPropertyvalue( ) + { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; + } + + public void setPropertyvalue( String value ) + { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = value ; + } + + protected byte gxTv_SdtEventCustomPayload_CustomPayloadItem_N ; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java new file mode 100644 index 000000000..24155e5d4 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java @@ -0,0 +1,114 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; + +public final class StructSdtEventMessage implements Cloneable, java.io.Serializable +{ + public StructSdtEventMessage( ) + { + this( -1, new ModelContext( StructSdtEventMessage.class )); + } + + public StructSdtEventMessage( int remoteHandle , + ModelContext context ) + { + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.set(1, 0, 1, 0, 0, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + gxTv_SdtEventMessage_Eventmessageid = "" ; + gxTv_SdtEventMessage_Eventmessagedate = cal.getTime() ; + gxTv_SdtEventMessage_Eventmessagesourcetype = "" ; + gxTv_SdtEventMessage_Eventmessagedata = "" ; + gxTv_SdtEventMessage_Eventmessageversion = "" ; + gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(1) ; + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(1) ; + } + + public Object clone() + { + Object cloned = null; + try + { + cloned = super.clone(); + }catch (CloneNotSupportedException e){ ; } + return cloned; + } + + public String getEventmessageid( ) + { + return gxTv_SdtEventMessage_Eventmessageid ; + } + + public void setEventmessageid( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessageid = value ; + } + + public java.util.Date getEventmessagedate( ) + { + return gxTv_SdtEventMessage_Eventmessagedate ; + } + + public void setEventmessagedate( java.util.Date value ) + { + gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(0) ; + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagedate = value ; + } + + public String getEventmessagesourcetype( ) + { + return gxTv_SdtEventMessage_Eventmessagesourcetype ; + } + + public void setEventmessagesourcetype( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagesourcetype = value ; + } + + public String getEventmessagedata( ) + { + return gxTv_SdtEventMessage_Eventmessagedata ; + } + + public void setEventmessagedata( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagedata = value ; + } + + public String getEventmessageversion( ) + { + return gxTv_SdtEventMessage_Eventmessageversion ; + } + + public void setEventmessageversion( String value ) + { + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessageversion = value ; + } + + public java.util.Vector getEventmessagecustompayload( ) + { + return gxTv_SdtEventMessage_Eventmessagecustompayload ; + } + + public void setEventmessagecustompayload( java.util.Vector value ) + { + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(0) ; + gxTv_SdtEventMessage_N = (byte)(0) ; + gxTv_SdtEventMessage_Eventmessagecustompayload = value ; + } + + protected byte gxTv_SdtEventMessage_Eventmessagedate_N ; + protected byte gxTv_SdtEventMessage_Eventmessagecustompayload_N ; + protected byte gxTv_SdtEventMessage_N ; + protected String gxTv_SdtEventMessage_Eventmessagedata ; + protected String gxTv_SdtEventMessage_Eventmessageid ; + protected String gxTv_SdtEventMessage_Eventmessagesourcetype ; + protected String gxTv_SdtEventMessage_Eventmessageversion ; + protected java.util.Date gxTv_SdtEventMessage_Eventmessagedate ; + protected java.util.Vector gxTv_SdtEventMessage_Eventmessagecustompayload=null ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java new file mode 100644 index 000000000..35db65564 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java @@ -0,0 +1,53 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; + +public final class StructSdtEventMessageResponse implements Cloneable, java.io.Serializable +{ + public StructSdtEventMessageResponse( ) + { + this( -1, new ModelContext( StructSdtEventMessageResponse.class )); + } + + public StructSdtEventMessageResponse( int remoteHandle , + ModelContext context ) + { + gxTv_SdtEventMessageResponse_Errormessage = "" ; + } + + public Object clone() + { + Object cloned = null; + try + { + cloned = super.clone(); + }catch (CloneNotSupportedException e){ ; } + return cloned; + } + + public boolean getHandled( ) + { + return gxTv_SdtEventMessageResponse_Handled ; + } + + public void setHandled( boolean value ) + { + gxTv_SdtEventMessageResponse_N = (byte)(0) ; + gxTv_SdtEventMessageResponse_Handled = value ; + } + + public String getErrormessage( ) + { + return gxTv_SdtEventMessageResponse_Errormessage ; + } + + public void setErrormessage( String value ) + { + gxTv_SdtEventMessageResponse_N = (byte)(0) ; + gxTv_SdtEventMessageResponse_Errormessage = value ; + } + + protected byte gxTv_SdtEventMessageResponse_N ; + protected boolean gxTv_SdtEventMessageResponse_Handled ; + protected String gxTv_SdtEventMessageResponse_Errormessage ; +} + diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java new file mode 100644 index 000000000..7152ae550 --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java @@ -0,0 +1,43 @@ +package com.genexus.genexusserverlessapi; +import com.genexus.*; + +public final class StructSdtEventMessages implements Cloneable, java.io.Serializable +{ + public StructSdtEventMessages( ) + { + this( -1, new ModelContext( StructSdtEventMessages.class )); + } + + public StructSdtEventMessages( int remoteHandle , + ModelContext context ) + { + gxTv_SdtEventMessages_Eventmessage_N = (byte)(1) ; + } + + public Object clone() + { + Object cloned = null; + try + { + cloned = super.clone(); + }catch (CloneNotSupportedException e){ ; } + return cloned; + } + + public java.util.Vector getEventmessage( ) + { + return gxTv_SdtEventMessages_Eventmessage ; + } + + public void setEventmessage( java.util.Vector value ) + { + gxTv_SdtEventMessages_Eventmessage_N = (byte)(0) ; + gxTv_SdtEventMessages_N = (byte)(0) ; + gxTv_SdtEventMessages_Eventmessage = value ; + } + + protected byte gxTv_SdtEventMessages_Eventmessage_N ; + protected byte gxTv_SdtEventMessages_N ; + protected java.util.Vector gxTv_SdtEventMessages_Eventmessage=null ; +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java new file mode 100644 index 000000000..ce29d5c1c --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java @@ -0,0 +1,664 @@ +package com.unittest.eventdriven; +import com.unittest.*; +import com.genexus.*; +import com.genexus.xml.*; +import com.genexus.search.*; +import com.genexus.webpanels.*; +import java.util.*; + +public final class SdtUser extends GxSilentTrnSdt +{ + public SdtUser( int remoteHandle ) + { + this( remoteHandle, new ModelContext(SdtUser.class)); + } + + public SdtUser( int remoteHandle , + ModelContext context ) + { + super( remoteHandle, context, "SdtUser"); + initialize() ; + } + + public SdtUser( int remoteHandle , + StructSdtUser struct ) + { + this(remoteHandle); + setStruct(struct); + } + + private static HashMap mapper = new HashMap(); + static + { + } + + public String getJsonMap( String value ) + { + return (String) mapper.get(value); + } + + public void Load( UUID AV4UserId ) + { + IGxSilentTrn obj; + obj = getTransaction() ; + obj.LoadKey(new Object[] {AV4UserId}); + } + + public void LoadStrParms( String sAV4UserId ) + { + UUID AV4UserId; + AV4UserId = GXutil.strToGuid(sAV4UserId) ; + Load( AV4UserId) ; + } + + public Object[][] GetBCKey( ) + { + return (Object[][])(new Object[][]{new Object[]{"UserId", UUID.class}}) ; + } + + public com.genexus.util.GXProperties getMetadata( ) + { + com.genexus.util.GXProperties metadata = new com.genexus.util.GXProperties(); + metadata.set("Name", "EventDriven\\User"); + metadata.set("BT", "User"); + metadata.set("PK", "[ \"UserId\" ]"); + metadata.set("PKAssigned", "[ \"UserId\" ]"); + metadata.set("AllowInsert", "True"); + metadata.set("AllowUpdate", "True"); + metadata.set("AllowDelete", "True"); + return metadata ; + } + + public short readxml( XMLReader oReader , + String sName ) + { + short GXSoapError = 1; + formatError = false ; + sTagName = oReader.getName() ; + if ( oReader.getIsSimple() == 0 ) + { + GXSoapError = oReader.read() ; + nOutParmCount = (short)(0) ; + while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) + { + readOk = (short)(0) ; + readElement = false ; + if ( GXutil.strcmp2( oReader.getLocalName(), "UserId") ) + { + gxTv_SdtUser_Userid = GXutil.strToGuid(oReader.getValue()) ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "UserName") ) + { + gxTv_SdtUser_Username = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "UserRegisteredDateTime") ) + { + if ( ( GXutil.strcmp(oReader.getValue(), "") == 0 ) || ( oReader.existsAttribute("xsi:nil") == 1 ) ) + { + gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime( GXutil.nullDate() ); + } + else + { + gxTv_SdtUser_Userregistereddatetime = localUtil.ymdhmsToT( (short)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 1, 4), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 6, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 9, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 12, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 15, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 18, 2), ".")))) ; + } + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "UserEventMessageData") ) + { + gxTv_SdtUser_Usereventmessagedata = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "Mode") ) + { + gxTv_SdtUser_Mode = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "Initialized") ) + { + gxTv_SdtUser_Initialized = (short)(getnumericvalue(oReader.getValue())) ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "UserId_Z") ) + { + gxTv_SdtUser_Userid_Z = GXutil.strToGuid(oReader.getValue()) ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "UserName_Z") ) + { + gxTv_SdtUser_Username_Z = oReader.getValue() ; + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( GXutil.strcmp2( oReader.getLocalName(), "UserRegisteredDateTime_Z") ) + { + if ( ( GXutil.strcmp(oReader.getValue(), "") == 0 ) || ( oReader.existsAttribute("xsi:nil") == 1 ) ) + { + gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime( GXutil.nullDate() ); + } + else + { + gxTv_SdtUser_Userregistereddatetime_Z = localUtil.ymdhmsToT( (short)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 1, 4), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 6, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 9, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 12, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 15, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 18, 2), ".")))) ; + } + readElement = true ; + if ( GXSoapError > 0 ) + { + readOk = (short)(1) ; + } + GXSoapError = oReader.read() ; + } + if ( ! readElement ) + { + readOk = (short)(1) ; + GXSoapError = oReader.read() ; + } + nOutParmCount = (short)(nOutParmCount+1) ; + if ( ( readOk == 0 ) || formatError ) + { + context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; + context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; + GXSoapError = (short)(nOutParmCount*-1) ; + } + } + } + return GXSoapError ; + } + + public void writexml( XMLWriter oWriter , + String sName , + String sNameSpace ) + { + writexml(oWriter, sName, sNameSpace, true); + } + + public void writexml( XMLWriter oWriter , + String sName , + String sNameSpace , + boolean sIncludeState ) + { + if ( (GXutil.strcmp("", sName)==0) ) + { + sName = "User" ; + } + if ( (GXutil.strcmp("", sNameSpace)==0) ) + { + sNameSpace = "Issue95858" ; + } + oWriter.writeStartElement(sName); + if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) + { + oWriter.writeAttribute("xmlns", sNameSpace); + } + else + { + sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; + } + oWriter.writeElement("UserId", gxTv_SdtUser_Userid.toString()); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserName", gxTv_SdtUser_Username); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + sDateCnv = "" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.year( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; + sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.month( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.day( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "T" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.second( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + oWriter.writeElement("UserRegisteredDateTime", sDateCnv); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + if ( sIncludeState ) + { + oWriter.writeElement("Mode", gxTv_SdtUser_Mode); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("Initialized", GXutil.trim( GXutil.str( gxTv_SdtUser_Initialized, 4, 0))); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserId_Z", gxTv_SdtUser_Userid_Z.toString()); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserName_Z", gxTv_SdtUser_Username_Z); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + sDateCnv = "" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.year( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; + sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.month( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.day( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "T" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.second( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + oWriter.writeElement("UserRegisteredDateTime_Z", sDateCnv); + if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) + { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + } + oWriter.writeEndElement(); + } + + public long getnumericvalue( String value ) + { + if ( GXutil.notNumeric( value) ) + { + formatError = true ; + } + return GXutil.lval( value) ; + } + + public void tojson( ) + { + tojson( true) ; + } + + public void tojson( boolean includeState ) + { + tojson( includeState, true) ; + } + + public void tojson( boolean includeState , + boolean includeNonInitialized ) + { + AddObjectProperty("UserId", gxTv_SdtUser_Userid, false, includeNonInitialized); + AddObjectProperty("UserName", gxTv_SdtUser_Username, false, includeNonInitialized); + datetime_STZ = gxTv_SdtUser_Userregistereddatetime ; + sDateCnv = "" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.year( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.month( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.day( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "T" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.second( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + AddObjectProperty("UserRegisteredDateTime", sDateCnv, false, includeNonInitialized); + AddObjectProperty("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata, false, includeNonInitialized); + if ( includeState ) + { + AddObjectProperty("Mode", gxTv_SdtUser_Mode, false, includeNonInitialized); + AddObjectProperty("Initialized", gxTv_SdtUser_Initialized, false, includeNonInitialized); + AddObjectProperty("UserId_Z", gxTv_SdtUser_Userid_Z, false, includeNonInitialized); + AddObjectProperty("UserName_Z", gxTv_SdtUser_Username_Z, false, includeNonInitialized); + datetime_STZ = gxTv_SdtUser_Userregistereddatetime_Z ; + sDateCnv = "" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.year( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.month( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "-" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.day( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += "T" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + sDateCnv += ":" ; + sNumToPad = GXutil.trim( GXutil.str( GXutil.second( datetime_STZ), 10, 0)) ; + sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; + AddObjectProperty("UserRegisteredDateTime_Z", sDateCnv, false, includeNonInitialized); + } + } + + public void updateDirties( SdtUser sdt ) + { + if ( sdt.IsDirty("UserId") ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Userid = sdt.getgxTv_SdtUser_Userid() ; + } + if ( sdt.IsDirty("UserName") ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Username = sdt.getgxTv_SdtUser_Username() ; + } + if ( sdt.IsDirty("UserRegisteredDateTime") ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Userregistereddatetime = sdt.getgxTv_SdtUser_Userregistereddatetime() ; + } + if ( sdt.IsDirty("UserEventMessageData") ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Usereventmessagedata = sdt.getgxTv_SdtUser_Usereventmessagedata() ; + } + } + + public UUID getgxTv_SdtUser_Userid( ) + { + return gxTv_SdtUser_Userid ; + } + + public void setgxTv_SdtUser_Userid( UUID value ) + { + gxTv_SdtUser_N = (byte)(0) ; + if ( !( gxTv_SdtUser_Userid.equals( value ) ) ) + { + gxTv_SdtUser_Mode = "INS" ; + this.setgxTv_SdtUser_Userid_Z_SetNull( ); + this.setgxTv_SdtUser_Username_Z_SetNull( ); + this.setgxTv_SdtUser_Userregistereddatetime_Z_SetNull( ); + } + SetDirty("Userid"); + gxTv_SdtUser_Userid = value ; + } + + public String getgxTv_SdtUser_Username( ) + { + return gxTv_SdtUser_Username ; + } + + public void setgxTv_SdtUser_Username( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Username"); + gxTv_SdtUser_Username = value ; + } + + public Date getgxTv_SdtUser_Userregistereddatetime( ) + { + return gxTv_SdtUser_Userregistereddatetime ; + } + + public void setgxTv_SdtUser_Userregistereddatetime( Date value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Userregistereddatetime"); + gxTv_SdtUser_Userregistereddatetime = value ; + } + + public String getgxTv_SdtUser_Usereventmessagedata( ) + { + return gxTv_SdtUser_Usereventmessagedata ; + } + + public void setgxTv_SdtUser_Usereventmessagedata( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Usereventmessagedata"); + gxTv_SdtUser_Usereventmessagedata = value ; + } + + public String getgxTv_SdtUser_Mode( ) + { + return gxTv_SdtUser_Mode ; + } + + public void setgxTv_SdtUser_Mode( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Mode"); + gxTv_SdtUser_Mode = value ; + } + + public void setgxTv_SdtUser_Mode_SetNull( ) + { + gxTv_SdtUser_Mode = "" ; + SetDirty("Mode"); + } + + public boolean getgxTv_SdtUser_Mode_IsNull( ) + { + return false ; + } + + public short getgxTv_SdtUser_Initialized( ) + { + return gxTv_SdtUser_Initialized ; + } + + public void setgxTv_SdtUser_Initialized( short value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Initialized"); + gxTv_SdtUser_Initialized = value ; + } + + public void setgxTv_SdtUser_Initialized_SetNull( ) + { + gxTv_SdtUser_Initialized = (short)(0) ; + SetDirty("Initialized"); + } + + public boolean getgxTv_SdtUser_Initialized_IsNull( ) + { + return false ; + } + + public UUID getgxTv_SdtUser_Userid_Z( ) + { + return gxTv_SdtUser_Userid_Z ; + } + + public void setgxTv_SdtUser_Userid_Z( UUID value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Userid_Z"); + gxTv_SdtUser_Userid_Z = value ; + } + + public void setgxTv_SdtUser_Userid_Z_SetNull( ) + { + gxTv_SdtUser_Userid_Z = UUID.fromString("00000000-0000-0000-0000-000000000000") ; + SetDirty("Userid_Z"); + } + + public boolean getgxTv_SdtUser_Userid_Z_IsNull( ) + { + return false ; + } + + public String getgxTv_SdtUser_Username_Z( ) + { + return gxTv_SdtUser_Username_Z ; + } + + public void setgxTv_SdtUser_Username_Z( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Username_Z"); + gxTv_SdtUser_Username_Z = value ; + } + + public void setgxTv_SdtUser_Username_Z_SetNull( ) + { + gxTv_SdtUser_Username_Z = "" ; + SetDirty("Username_Z"); + } + + public boolean getgxTv_SdtUser_Username_Z_IsNull( ) + { + return false ; + } + + public Date getgxTv_SdtUser_Userregistereddatetime_Z( ) + { + return gxTv_SdtUser_Userregistereddatetime_Z ; + } + + public void setgxTv_SdtUser_Userregistereddatetime_Z( Date value ) + { + gxTv_SdtUser_N = (byte)(0) ; + SetDirty("Userregistereddatetime_Z"); + gxTv_SdtUser_Userregistereddatetime_Z = value ; + } + + public void setgxTv_SdtUser_Userregistereddatetime_Z_SetNull( ) + { + gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime( GXutil.nullDate() ); + SetDirty("Userregistereddatetime_Z"); + } + + public boolean getgxTv_SdtUser_Userregistereddatetime_Z_IsNull( ) + { + return false ; + } + + + public void initialize( ) + { + gxTv_SdtUser_Userid = UUID.fromString("00000000-0000-0000-0000-000000000000") ; + gxTv_SdtUser_N = (byte)(1) ; + gxTv_SdtUser_Username = "" ; + gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime( GXutil.nullDate() ); + gxTv_SdtUser_Usereventmessagedata = "" ; + gxTv_SdtUser_Mode = "" ; + gxTv_SdtUser_Userid_Z = UUID.fromString("00000000-0000-0000-0000-000000000000") ; + gxTv_SdtUser_Username_Z = "" ; + gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime( GXutil.nullDate() ); + sTagName = "" ; + sDateCnv = "" ; + sNumToPad = "" ; + datetime_STZ = GXutil.resetTime( GXutil.nullDate() ); + } + + public byte isNull( ) + { + return gxTv_SdtUser_N ; + } + + + public void setStruct( com.unittest.eventdriven.StructSdtUser struct ) + { + setgxTv_SdtUser_Userid(struct.getUserid()); + setgxTv_SdtUser_Username(struct.getUsername()); + setgxTv_SdtUser_Userregistereddatetime(struct.getUserregistereddatetime()); + setgxTv_SdtUser_Usereventmessagedata(struct.getUsereventmessagedata()); + setgxTv_SdtUser_Mode(struct.getMode()); + setgxTv_SdtUser_Initialized(struct.getInitialized()); + setgxTv_SdtUser_Userid_Z(struct.getUserid_Z()); + setgxTv_SdtUser_Username_Z(struct.getUsername_Z()); + setgxTv_SdtUser_Userregistereddatetime_Z(struct.getUserregistereddatetime_Z()); + } + + @SuppressWarnings("unchecked") + public com.unittest.eventdriven.StructSdtUser getStruct( ) + { + com.unittest.eventdriven.StructSdtUser struct = new com.unittest.eventdriven.StructSdtUser (); + struct.setUserid(getgxTv_SdtUser_Userid()); + struct.setUsername(getgxTv_SdtUser_Username()); + struct.setUserregistereddatetime(getgxTv_SdtUser_Userregistereddatetime()); + struct.setUsereventmessagedata(getgxTv_SdtUser_Usereventmessagedata()); + struct.setMode(getgxTv_SdtUser_Mode()); + struct.setInitialized(getgxTv_SdtUser_Initialized()); + struct.setUserid_Z(getgxTv_SdtUser_Userid_Z()); + struct.setUsername_Z(getgxTv_SdtUser_Username_Z()); + struct.setUserregistereddatetime_Z(getgxTv_SdtUser_Userregistereddatetime_Z()); + return struct ; + } + + private byte gxTv_SdtUser_N ; + private short gxTv_SdtUser_Initialized ; + private short readOk ; + private short nOutParmCount ; + private String gxTv_SdtUser_Username ; + private String gxTv_SdtUser_Mode ; + private String gxTv_SdtUser_Username_Z ; + private String sTagName ; + private String sDateCnv ; + private String sNumToPad ; + private Date gxTv_SdtUser_Userregistereddatetime ; + private Date gxTv_SdtUser_Userregistereddatetime_Z ; + private Date datetime_STZ ; + private boolean readElement ; + private boolean formatError ; + private String gxTv_SdtUser_Usereventmessagedata ; + private UUID AV4UserId ; + private UUID gxTv_SdtUser_Userid ; + private UUID gxTv_SdtUser_Userid_Z ; +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java new file mode 100644 index 000000000..af760aca6 --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java @@ -0,0 +1,147 @@ +package com.unittest.eventdriven; +import com.genexus.*; + +public final class StructSdtUser implements Cloneable, java.io.Serializable +{ + public StructSdtUser( ) + { + this( -1, new ModelContext( StructSdtUser.class )); + } + + public StructSdtUser( int remoteHandle , + ModelContext context ) + { + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.set(1, 0, 1, 0, 0, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + gxTv_SdtUser_Userid = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000") ; + gxTv_SdtUser_Username = "" ; + gxTv_SdtUser_Userregistereddatetime = cal.getTime() ; + gxTv_SdtUser_Usereventmessagedata = "" ; + gxTv_SdtUser_Mode = "" ; + gxTv_SdtUser_Userid_Z = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000") ; + gxTv_SdtUser_Username_Z = "" ; + gxTv_SdtUser_Userregistereddatetime_Z = cal.getTime() ; + } + + public Object clone() + { + Object cloned = null; + try + { + cloned = super.clone(); + }catch (CloneNotSupportedException e){ ; } + return cloned; + } + + public java.util.UUID getUserid( ) + { + return gxTv_SdtUser_Userid ; + } + + public void setUserid( java.util.UUID value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Userid = value ; + } + + public String getUsername( ) + { + return gxTv_SdtUser_Username ; + } + + public void setUsername( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Username = value ; + } + + public java.util.Date getUserregistereddatetime( ) + { + return gxTv_SdtUser_Userregistereddatetime ; + } + + public void setUserregistereddatetime( java.util.Date value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Userregistereddatetime = value ; + } + + public String getUsereventmessagedata( ) + { + return gxTv_SdtUser_Usereventmessagedata ; + } + + public void setUsereventmessagedata( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Usereventmessagedata = value ; + } + + public String getMode( ) + { + return gxTv_SdtUser_Mode ; + } + + public void setMode( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Mode = value ; + } + + public short getInitialized( ) + { + return gxTv_SdtUser_Initialized ; + } + + public void setInitialized( short value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Initialized = value ; + } + + public java.util.UUID getUserid_Z( ) + { + return gxTv_SdtUser_Userid_Z ; + } + + public void setUserid_Z( java.util.UUID value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Userid_Z = value ; + } + + public String getUsername_Z( ) + { + return gxTv_SdtUser_Username_Z ; + } + + public void setUsername_Z( String value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Username_Z = value ; + } + + public java.util.Date getUserregistereddatetime_Z( ) + { + return gxTv_SdtUser_Userregistereddatetime_Z ; + } + + public void setUserregistereddatetime_Z( java.util.Date value ) + { + gxTv_SdtUser_N = (byte)(0) ; + gxTv_SdtUser_Userregistereddatetime_Z = value ; + } + + private byte gxTv_SdtUser_N ; + protected short gxTv_SdtUser_Initialized ; + protected String gxTv_SdtUser_Username ; + protected String gxTv_SdtUser_Mode ; + protected String gxTv_SdtUser_Username_Z ; + protected String gxTv_SdtUser_Usereventmessagedata ; + protected java.util.UUID gxTv_SdtUser_Userid ; + protected java.util.UUID gxTv_SdtUser_Userid_Z ; + protected java.util.Date gxTv_SdtUser_Userregistereddatetime ; + protected java.util.Date gxTv_SdtUser_Userregistereddatetime_Z ; +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java new file mode 100644 index 000000000..1ace6049d --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java @@ -0,0 +1,66 @@ +package com.unittest.eventdriven.queue; + +import com.genexus.*; + +public final class handlesimplerawsqsevent extends GXProcedure { + public handlesimplerawsqsevent(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimplerawsqsevent.class), ""); + } + + public handlesimplerawsqsevent(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, ""); + } + + + public void execute(String aP0, + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + execute_int(aP0, aP1); + } + + private void execute_int(String aP0, + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + handlesimplerawsqsevent.this.AV13RAWMessage = aP0; + handlesimplerawsqsevent.this.aP1 = aP1; + initialize(); + /* GeneXus formulas */ + /* Output device settings */ + privateExecute(); + } + + private void privateExecute() { + System.out.println("START Queue Event received"); + ; + System.out.println(AV13RAWMessage); + System.out.println("END Queue Event received"); + System.out.println((boolean) ((GXutil.len(AV13RAWMessage) > 0))); + AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled( AV13RAWMessage.startsWith("{\"records\":[{\"messageId\":\"1\",\"receiptHandle\":\"123123\",\"body\":\"") ); + cleanup(); + } + + protected void cleanup() { + this.aP1[0] = handlesimplerawsqsevent.this.AV9EventMessageResponse; + CloseOpenCursors(); + exitApp(); + } + + protected void CloseOpenCursors() { + } + + /* Aggregate/select formulas */ + public void initialize() { + AV9EventMessageResponse = new com.genexus.genexusserverlessapi.SdtEventMessageResponse(remoteHandle, context); + AV16Pgmname = ""; + AV16Pgmname = "EventDriven.Queue.HandleSimpleRAWSQSEvent"; + /* GeneXus formulas. */ + AV16Pgmname = "EventDriven.Queue.HandleSimpleRAWSQSEvent"; + Gx_err = (short) (0); + } + + private short Gx_err; + private String AV13RAWMessage; + private String AV16Pgmname; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse; +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java new file mode 100644 index 000000000..71a6db1b2 --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java @@ -0,0 +1,109 @@ +package com.unittest.eventdriven.queue ; +import com.unittest.*; +import java.sql.*; +import com.genexus.db.*; +import com.genexus.*; +import com.genexus.search.*; + +public final class handlesimpleuserqueueevent extends GXProcedure +{ + public handlesimpleuserqueueevent( int remoteHandle ) + { + super( remoteHandle , new ModelContext( handlesimpleuserqueueevent.class ), "" ); + } + + public handlesimpleuserqueueevent( int remoteHandle , + ModelContext context ) + { + super( remoteHandle , context, "" ); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.SdtEventMessageResponse executeUdp( com.genexus.genexusserverlessapi.SdtEventMessages aP0 ) + { + handlesimpleuserqueueevent.this.aP1 = new com.genexus.genexusserverlessapi.SdtEventMessageResponse[] {new com.genexus.genexusserverlessapi.SdtEventMessageResponse()}; + execute_int(aP0, aP1); + return aP1[0]; + } + + public void execute( com.genexus.genexusserverlessapi.SdtEventMessages aP0 , + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1 ) + { + execute_int(aP0, aP1); + } + + private void execute_int( com.genexus.genexusserverlessapi.SdtEventMessages aP0 , + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1 ) + { + handlesimpleuserqueueevent.this.AV8EventMessages = aP0; + handlesimpleuserqueueevent.this.aP1 = aP1; + initialize(); + /* GeneXus formulas */ + /* Output device settings */ + privateExecute(); + } + + private void privateExecute( ) + { + System.out.println("START Queue Event received") ; + System.out.println(AV8EventMessages.toJSonString(false, true)) ; + + AV16GXV1 = 1 ; + while ( AV16GXV1 <= AV8EventMessages.getgxTv_SdtEventMessages_Eventmessage().size() ) + { + AV10EventMessage = (com.genexus.genexusserverlessapi.SdtEventMessage)((com.genexus.genexusserverlessapi.SdtEventMessage)AV8EventMessages.getgxTv_SdtEventMessages_Eventmessage().elementAt(-1+AV16GXV1)); + System.out.println("Processing: "+AV10EventMessage.toJSonString(false, true)) ; + AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled( AV11UserSDT.fromJSonString(AV10EventMessage.getgxTv_SdtEventMessage_Eventmessagedata(), AV12OutMessages) ); + if ( ! AV9EventMessageResponse.getgxTv_SdtEventMessageResponse_Handled() ) + { + System.out.println("EventMessageData could not be parsed: "+AV10EventMessage.getgxTv_SdtEventMessage_Eventmessagedata()) ; + System.out.println(AV12OutMessages.toJSonString(false)) ; + AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Errormessage( AV12OutMessages.toJSonString(false) ); + returnInSub = true; + cleanup(); + if (true) return; + } + System.out.println("UserSDT Processed OK: "+AV11UserSDT.toJSonString(false, true)); ; + AV16GXV1 = (int)(AV16GXV1+1) ; + } + System.out.println("END Queue Event received") ; + cleanup(); + } + + protected void cleanup( ) + { + this.aP1[0] = handlesimpleuserqueueevent.this.AV9EventMessageResponse; + CloseOpenCursors(); + exitApp(); + } + + protected void CloseOpenCursors( ) + { + } + + /* Aggregate/select formulas */ + public void initialize( ) + { + AV9EventMessageResponse = new com.genexus.genexusserverlessapi.SdtEventMessageResponse(remoteHandle, context); + AV15Pgmname = "" ; + AV10EventMessage = new com.genexus.genexusserverlessapi.SdtEventMessage(remoteHandle, context); + AV12OutMessages = new GXBaseCollection(com.genexus.SdtMessages_Message.class, "Message", "GeneXus", remoteHandle); + AV11UserSDT = new com.unittest.eventdriven.SdtUser(remoteHandle); + AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent" ; + /* GeneXus formulas. */ + AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent" ; + Gx_err = (short)(0) ; + } + + private short Gx_err ; + private int AV16GXV1 ; + private String AV15Pgmname ; + private boolean returnInSub ; + private com.unittest.eventdriven.SdtUser AV11UserSDT ; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1 ; + private GXBaseCollection AV12OutMessages ; + private com.genexus.genexusserverlessapi.SdtEventMessages AV8EventMessages ; + private com.genexus.genexusserverlessapi.SdtEventMessage AV10EventMessage ; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse ; +} + diff --git a/gxawsserverless/src/test/java/log4j2.xml b/gxawsserverless/src/test/java/log4j2.xml index 6c2178224..39b9120e8 100644 --- a/gxawsserverless/src/test/java/log4j2.xml +++ b/gxawsserverless/src/test/java/log4j2.xml @@ -10,10 +10,10 @@ - + - + From ea6a33feafe98d0ab481d97b8d75a214e2ae6429 Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Wed, 18 May 2022 10:26:54 -0300 Subject: [PATCH 03/12] SDT renamed --- .../main/java/com/genexus/cloud/serverless/EventMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java index d58508b66..bc5f91fc6 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java @@ -21,7 +21,7 @@ public class EventMessage { @JsonProperty("EventMessageVersion") private String messageVersion = "1.0"; - @JsonProperty("EventMessageCustomPayload") + @JsonProperty("EventMessageProperties") private List messageProperties = new ArrayList<>(); public String getMessageId() { From 1b5928f3102385f6d2d4e55ba1e44b5e76c97c74 Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Wed, 18 May 2022 18:14:36 -0300 Subject: [PATCH 04/12] Remove class file commited by mistake --- ...SdtEventCustomPayload_CustomPayloadItem.class | Bin 5728 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.class diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.class b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.class deleted file mode 100644 index d6dfff6086e62b45fe69f61f10c238d63f57eba6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5728 zcmbtY34Bxa9sfR>Hfj23OSsBW1i4B=DIN@Hp$e6wtSucy$}xto$)gQT@=Eg37UnUX zQ#W;+uuWmgoNhxmWeROz;1oA;o7dds?t9E#?mnDzvhVM`*EVS*tMJL^^FM$0|98DS z^TzSV0W8EBH@e*D_CmofFGgUu2k-Xc3S2G2HF9#T4ALyv;EW<6beZLnUz^$^qO}4ko@Il#r$b%2d-5s*oBgcC^_=wCOmEmLgl;O^N+=YDt zwckhi4hZNce7yLiNO7MB_j~XuFFuXW2+Tnb9`N8n*?(5{pOfJs**@&SA(=lfXphM7 zs0@dN(Ggko$k6M>5~O5xR944i^#wPM%f?dsgsdKu<1fnUaW|e28(izgNdM^q>nJ|rLqqZwzXrXNxyINC^ zZfj7WEGNylu7%dNbJL_?WNdBHY}De>8Y3Aq6;!?@ij8rD(wVzDwMbG|;IoB{XtCCc zCNmz6wNge;V!hVdphbCKAe>i3^eBZT`^`MrZp5RSxgs7nsN}+PVjd1rrzPQ7*sNBN zQ#NOV0#}U@BEO=#a7=GVMqBjwdaWhGlhU%fpb@QT)nj^hGEq@aut<#&Gxct>N)V@% z)t()oDU*OhD51wY^>{>2B(#pOsGba(!+aHst+!P-*CdP>Usb`ZvY}?2GxSJ-Tg=%V zjVPF(DHYEuHrCgzj+?(-?R9SL013VrK! z!(#K6LWoIbNigDM0B@6#j0g3VVTt#-!;Hdtl3f*)r0bua92Bfhzd9e&sA$5IGBhig zJxuWg{7W)?S%&p0c4Cu?6gC8Ud0P?Qj0Yz)}m3x*RfrJw=c2RhE%+WZ>adDkXeU%CXT+l4U+U#)Cuix z;oB;{gO}X+u8Qx;$@hg$@p8j36J}iNsMpOlBa|r0!w)?8p^6{j$0~k;?H>G8Ha}Cb z4SWDr;Tc0~*}NgO%#EL`_yvBc;#W9LdAIm0V@5)cg|^b4nZ#lV6~D&IDt?3Cs`wpF ztN1-$maNyGsh2g@s`vw9Dq0YffvUcOKdM-T)hgP>%74P2Rs2OXZ$+DmzshO{+7vYW ze`k0r4y-~K(ti^sVOjlMn2Z`y@fD0qXS}NWN*12=yE^FTW76|aO+-s1tin=}nT69` zI$K>}!kT}!3Yb0B=P#(9METme1MgmSED6E+kD1=VVSTn-5{e4#2jc%3Yli)FL*2 zw@vTjVH0FG;~@zvDyT@%?kW^a%t)#kFCh9xj211DP%t(FY?Xb?G&(v%**@rkMAO=3 zjcl9h6Ro5Y)4QbA@!}u&Cmlzz`l+d6EowhiQ51}iYVA5ZouFnmhs`#w5~db2$#~7M z?3KlWLys7U!gHP0#qNXlRqCZ9YSk+#0u~L6PrAoAPnF$c>~@68T73(fnYh{CS!ON9 ztaPr3zMY<$%|mLlGA^`;FEi;yElHDpm<@HP9i*z}M0B<-StX(C<;KIUZ4^bd81xHX zWN%{wP4cK^p^zOpeQ8(0oU>cf2{gM=$_?7ZJ+tTOkHwMn*gnG2M;E8v#r8 z+TH?j<6n}(|HIThP=>;>PNQ9Sz5;B&Td4(2BfiUx|1w(Z45K~CXjN-tF+FZ2ES=7H zSGsBr4ZC!#)?y(x*fVUzED@dd3>k})@W;Hd9`MiaBF6fwr19MYi3R6JdTBv zjRD6ix$~1AYbgr-C!lQdjW~*&qi{XS69pSM%Eu-!lD|R=ui3$yfgJ0`;}7_9k0Ng{ zh7WFxwlFq27&FN!hqUtjljaJFdoW4~JeXjiY;sWiWFhRm{-YqH6!Hgf3N2!#Bszu0 zxquj(vBklg?%)+1hL>0cC!sz_ri$ z;{7;S<`!GcaP3*-azl#?H z^T=W>4@Xs7V3RYzO0$5G+qnIds2|VI6QAptuVbn*w!$^dRa{cV7utra?03RU5rK*rd@yLwod_UFi+1sUoNiiaHzV_EYJ3gaXu+Mh9-X+svWpwJ>Xd@X zlc`rrfB0TV;^NMEep=(=!PdBmn%``}i%lflr#oTm_D>?hC4&)eMILUm5JC>ZVv>-k zo#40akdu?brG8s&Ydt{1j>tQx+#Zx*FA16?cv@V@MNx$`_Fe%~x73oNjfrPf$9Kw%u&0f%Y-BPc)*Mlo*3 zBSmUa`ijjwUBLwsu;~fyIClm*9MGwp#oivux$q=L3^vCTyyb_X11&{Hv>GMpYEcS{ zWv)!2YCt~wai3y%okB65CSn{32ff-spLhaGHXX&%x&XOWr*N6fm#45SFu>kt#qYDE z^Bn0sPe*xyYqQ^>XIp~s^-o|qY1JHocR&c+%+vTPQht(@cm%`aHO}&f@vC?p|7HdG QIQNCTxtnMASmV9_15HlnGynhq From 577ae4c44aa8391ef29ef1f393bdcfa70b9566c3 Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Wed, 18 May 2022 18:22:15 -0300 Subject: [PATCH 05/12] Package refactorings --- .../handler}/GXProcedureDynamicExecuteStrategy.java | 2 +- .../cloud/serverless/aws/handler/LambdaBaseHandler.java | 2 ++ .../cloud/serverless/aws/handler/LambdaSQSHandler.java | 8 +++++--- .../cloud/serverless/{ => model}/EventMessage.java | 3 +-- .../serverless/{aws => model}/EventMessageProperty.java | 2 +- .../serverless/{ => model}/EventMessageResponse.java | 2 +- .../serverless/{ => model}/EventMessageSourceType.java | 2 +- .../cloud/serverless/{ => model}/EventMessages.java | 2 +- 8 files changed, 13 insertions(+), 10 deletions(-) rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/{ => aws/handler}/GXProcedureDynamicExecuteStrategy.java (98%) rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/{ => model}/EventMessage.java (93%) rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/{aws => model}/EventMessageProperty.java (88%) rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/{ => model}/EventMessageResponse.java (91%) rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/{ => model}/EventMessageSourceType.java (85%) rename gxawsserverless/src/main/java/com/genexus/cloud/serverless/{ => model}/EventMessages.java (86%) diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java similarity index 98% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java index 54ddb75fb..373551fe5 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureDynamicExecuteStrategy.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java @@ -1,4 +1,4 @@ -package com.genexus.cloud.serverless; +package com.genexus.cloud.serverless.aws.handler; import com.genexus.GXProcedure; import com.genexus.GxUserType; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java index db78186ed..486cc346e 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java @@ -4,6 +4,8 @@ import com.genexus.GxUserType; import com.genexus.ModelContext; import com.genexus.cloud.serverless.*; +import com.genexus.cloud.serverless.model.EventMessageResponse; +import com.genexus.cloud.serverless.model.EventMessages; import com.genexus.diagnostics.core.ILogger; import com.genexus.specific.java.Connect; import com.genexus.specific.java.LogManager; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java index a58c5e8f4..fd51bf684 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java @@ -5,10 +5,12 @@ import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse; import com.amazonaws.services.lambda.runtime.events.SQSEvent; import com.amazonaws.services.lambda.runtime.events.SQSEvent.SQSMessage; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.genexus.cloud.serverless.*; -import com.genexus.cloud.serverless.aws.EventMessageProperty; +import com.genexus.cloud.serverless.model.EventMessageProperty; +import com.genexus.cloud.serverless.model.EventMessage; +import com.genexus.cloud.serverless.model.EventMessageResponse; +import com.genexus.cloud.serverless.model.EventMessageSourceType; +import com.genexus.cloud.serverless.model.EventMessages; import java.util.ArrayList; import java.util.Date; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessage.java similarity index 93% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessage.java index bc5f91fc6..bdbdc5b84 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessage.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessage.java @@ -1,7 +1,6 @@ -package com.genexus.cloud.serverless; +package com.genexus.cloud.serverless.model; import com.fasterxml.jackson.annotation.JsonProperty; -import com.genexus.cloud.serverless.aws.EventMessageProperty; import java.util.*; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageProperty.java similarity index 88% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageProperty.java index b33a38dff..a32e16bb9 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/EventMessageProperty.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageProperty.java @@ -1,4 +1,4 @@ -package com.genexus.cloud.serverless.aws; +package com.genexus.cloud.serverless.model; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java similarity index 91% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java index 68b701088..776bb716b 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageResponse.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java @@ -1,4 +1,4 @@ -package com.genexus.cloud.serverless; +package com.genexus.cloud.serverless.model; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java similarity index 85% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java index d340af98e..cb8aa9e78 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessageSourceType.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java @@ -1,4 +1,4 @@ -package com.genexus.cloud.serverless; +package com.genexus.cloud.serverless.model; public class EventMessageSourceType { public static String QueueMessage = "QueueMessage"; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessages.java similarity index 86% rename from gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java rename to gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessages.java index 0bf1c6cad..c2d31c84e 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/EventMessages.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessages.java @@ -1,4 +1,4 @@ -package com.genexus.cloud.serverless; +package com.genexus.cloud.serverless.model; import com.fasterxml.jackson.annotation.JsonProperty; From 31c3b92be2dd353a6ed6ba1a29a9182a9437d02a Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Thu, 19 May 2022 09:55:58 -0300 Subject: [PATCH 06/12] Code refactoring --- .../aws/handler/LambdaBaseHandler.java | 59 ++++++++++--------- .../handler/LambdaFunctionConfiguration.java | 28 +++++++++ .../LambdaFunctionConfigurationHelper.java | 44 ++++++++++++++ .../FunctionConfigurationException.java | 7 +++ 4 files changed, 109 insertions(+), 29 deletions(-) create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfiguration.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionConfigurationException.java diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java index 486cc346e..de8183447 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java @@ -17,22 +17,20 @@ public class LambdaBaseHandler { protected static ILogger logger = null; - protected static Class entryPointClass = null; - private static String entryPointClassName; + protected static Class entryPointClass = null; + private static LambdaFunctionConfiguration functionConfiguration; private static final String GX_APPLICATION_CLASS = "GXcfg"; - public static String ENTRY_POINT_CLASS_NAME_VAR = "GX_MAIN_CLASS_NAME"; private static String packageName = null; protected static final String MESSAGE_COLLECTION_INPUT_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessages"; protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessageResponse"; private static List strategies = new ArrayList<>(); - public LambdaBaseHandler() throws Exception { initialize(); } public LambdaBaseHandler(String className) throws Exception { - entryPointClassName = className; + functionConfiguration = new LambdaFunctionConfiguration(className); initialize(); } @@ -40,35 +38,36 @@ private void initialize() throws Exception { logger = LogManager.initialize(".", LambdaBaseHandler.class); Connect.init(); - if (entryPointClassName == null) { - entryPointClassName = System.getenv(ENTRY_POINT_CLASS_NAME_VAR); - } - if (entryPointClassName == null) { - throw new Exception(String.format("'%s' Environment Variable must be defined", ENTRY_POINT_CLASS_NAME_VAR)); - } - IniFile config = com.genexus.ConfigFileFinder.getConfigFile(null, "client.cfg", null); packageName = config.getProperty("Client", "PACKAGE", null); - Class cfgClass; + Class cfgClass; + + String cfgClassName = packageName.isEmpty() ? GX_APPLICATION_CLASS : String.format("%s.%s", packageName, GX_APPLICATION_CLASS); try { - cfgClass = Class.forName(packageName.isEmpty() ? GX_APPLICATION_CLASS : String.format("%s.%s", packageName, GX_APPLICATION_CLASS)); + cfgClass = Class.forName(cfgClassName); com.genexus.Application.init(cfgClass); - entryPointClassName = entryPointClassName; - logger.debug("Initializing entry Point ClassName: " + entryPointClassName); - entryPointClass = Class.forName(entryPointClassName); + } catch (ClassNotFoundException e) { + logger.error(String.format("Failed to initialize GX AppConfig Class: %s", cfgClassName), e); + throw e; + } + + logger.debug("Initializing Function configuration"); + try { + if (functionConfiguration == null) { + functionConfiguration = LambdaFunctionConfigurationHelper.getFunctionConfiguration(); + } + entryPointClass = Class.forName(functionConfiguration.getEntryPointClassName()); } catch (Exception e) { - logger.error(String.format("Failed to initialize Application for className: %s", entryPointClassName), e); + logger.error(String.format("Failed to initialize Application for className: %s", functionConfiguration.getEntryPointClassName()), e); throw e; } if (entryPointClass == null) { - throw new Exception(String.format("GeneXus Procedure '%s' was not found. Check deployment package ", entryPointClassName)); + throw new ClassNotFoundException(String.format("GeneXus Procedure '%s' was not found. Check deployment package ", functionConfiguration.getEntryPointClassName())); } loadStrategies(); - } - protected EventMessageResponse dispatchEventMessages(EventMessages eventMessages, String lambdaRawMessageBody) throws Exception { try { Object[] outResponse = null; @@ -77,23 +76,25 @@ protected EventMessageResponse dispatchEventMessages(EventMessages eventMessages String jsonStringMessages = Helper.toJSONString(eventMessages); ModelContext modelContext = new ModelContext(entryPointClass); - logger.debug(String.format("dispatchEventMessages (%s) - serialized messages: %s", entryPointClassName, jsonStringMessages)); - for (GXProcedureDynamicExecuteStrategy stg: strategies) { + if (logger.isDebugEnabled()) { + logger.debug(String.format("dispatchEventMessages (%s) - serialized messages: %s", functionConfiguration.getEntryPointClassName(), jsonStringMessages)); + } + for (GXProcedureDynamicExecuteStrategy stg : strategies) { if (outResponse == null && stg.isValid()) { handled = true; - switch (stg.getId()){ + switch (stg.getId()) { case 1: - outResponse = stg.execute(modelContext, new String[]{ jsonStringMessages }); + outResponse = stg.execute(modelContext, new String[]{jsonStringMessages}); break; case 2: - outResponse = stg.execute(modelContext, new String[]{ lambdaRawMessageBody }); + outResponse = stg.execute(modelContext, new String[]{lambdaRawMessageBody}); break; } } } if (!handled) { - throw new Exception(String.format("GeneXus Procedure '%s' does not comply with the required method signature required by Event Handlers. ", entryPointClassName)); + throw new Exception(String.format("GeneXus Procedure '%s' does not comply with the required method signature required by Event Handlers. ", functionConfiguration.getEntryPointClassName())); } GxUserType handlerOutput = (GxUserType) outResponse[0]; @@ -115,12 +116,12 @@ protected EventMessageResponse dispatchEventMessages(EventMessages eventMessages private void loadStrategies() throws ClassNotFoundException { - GXProcedureDynamicExecuteStrategy strategy = new GXProcedureDynamicExecuteStrategy(1 ,entryPointClassName); + GXProcedureDynamicExecuteStrategy strategy = new GXProcedureDynamicExecuteStrategy(1, functionConfiguration.getEntryPointClassName()); strategy.addInputParameter(MESSAGE_COLLECTION_INPUT_CLASS_NAME); strategy.addOutputParameter(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME); strategies.add(strategy); - strategy = new GXProcedureDynamicExecuteStrategy(2, entryPointClassName); + strategy = new GXProcedureDynamicExecuteStrategy(2, functionConfiguration.getEntryPointClassName()); strategy.addInputParameter(String.class.getName()); strategy.addOutputParameter(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME); strategies.add(strategy); diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfiguration.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfiguration.java new file mode 100644 index 000000000..8105a142a --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfiguration.java @@ -0,0 +1,28 @@ +package com.genexus.cloud.serverless.aws.handler; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class LambdaFunctionConfiguration { + + @JsonProperty("entryPointClassName") + private String entryPointClassName = null; + + public LambdaFunctionConfiguration() { + + } + public LambdaFunctionConfiguration(String entryPointClassName) { + this.entryPointClassName = entryPointClassName; + } + + public String getEntryPointClassName() { + return entryPointClassName; + } + + public void setEntryPointClassName(String entryPointClassName) { + this.entryPointClassName = entryPointClassName; + } + + public boolean isValidConfiguration () { + return getEntryPointClassName() != null; + } +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java new file mode 100644 index 000000000..b8626d0ff --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java @@ -0,0 +1,44 @@ +package com.genexus.cloud.serverless.aws.handler; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.genexus.cloud.serverless.exception.FunctionConfigurationException; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.specific.java.LogManager; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class LambdaFunctionConfigurationHelper { + private static ILogger logger = LogManager.initialize(".", LambdaFunctionConfiguration.class); + private static String ENTRY_POINT_CLASS_NAME_VAR = "GX_MAIN_CLASS_NAME"; + private static String FUNCTION_CONFIG_PATH = "gx-awslambda-function.json"; + + public static LambdaFunctionConfiguration getFunctionConfiguration() throws FunctionConfigurationException { + File configFile = new File(FUNCTION_CONFIG_PATH); + LambdaFunctionConfiguration config = null; + + if (configFile.exists()) { + try { + String jsonConfig = new String(Files.readAllBytes(Paths.get(FUNCTION_CONFIG_PATH))); + config = new ObjectMapper().readValue(jsonConfig, LambdaFunctionConfiguration.class); + } catch (IOException e) { + logger.error(String.format("Invalid lambda function configuration file: %s. Please check json content.", FUNCTION_CONFIG_PATH), e); + } + } + if (config == null) { + config = new LambdaFunctionConfiguration(); + } + + if (System.getenv(ENTRY_POINT_CLASS_NAME_VAR) != null) { + config.setEntryPointClassName(System.getenv(ENTRY_POINT_CLASS_NAME_VAR)); + } + + if (config == null || !config.isValidConfiguration()) { + throw new FunctionConfigurationException(String.format("Please check function configuration. Either file '%s' should be present, or '%s' Environment Variable must be defined", FUNCTION_CONFIG_PATH, ENTRY_POINT_CLASS_NAME_VAR)); + } + return config; + } + +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionConfigurationException.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionConfigurationException.java new file mode 100644 index 000000000..c4e395ca2 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionConfigurationException.java @@ -0,0 +1,7 @@ +package com.genexus.cloud.serverless.exception; + +public class FunctionConfigurationException extends Exception { + public FunctionConfigurationException(String exceptionMessage) { + super(exceptionMessage); + } +} From f5ed0040eaefc0289251dfda4062054caf6f994e Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Thu, 19 May 2022 21:17:00 -0300 Subject: [PATCH 07/12] Reformat all code. Remove unneeded source code --- .../aws/handler/LambdaSQSHandler.java | 9 +- .../test/jersey/model/MapResponseModel.java | 26 +- .../aws/events/TestLambdaBaseHandler.java | 4 - .../aws/events/TestLambdaSQSHandler.java | 1 - ...tEventCustomPayload_CustomPayloadItem.java | 310 ++--- .../genexusserverlessapi/SdtEventMessage.java | 693 +++------- .../SdtEventMessageResponse.java | 312 ++--- .../SdtEventMessages.java | 361 ++--- .../StructSdtEventCustomPayload.java | 75 +- ...tEventCustomPayload_CustomPayloadItem.java | 92 +- .../StructSdtEventMessage.java | 204 ++- .../StructSdtEventMessageResponse.java | 90 +- .../StructSdtEventMessages.java | 72 +- .../proxy/test/jersey/EchoJerseyResource.java | 158 +-- .../test/jersey/GeneXusAppAwsProxyTest.java | 106 +- .../proxy/test/jersey/JerseyAwsProxyTest.java | 286 ++-- .../com/gx/serverless/test/GXApplication.java | 18 +- .../java/com/gx/serverless/test/GXcfg.java | 14 +- .../com/unittest/eventdriven/SdtUser.java | 1211 ++++++++--------- .../unittest/eventdriven/StructSdtUser.java | 264 ++-- .../queue/handlesimplerawsqsevent.java | 12 +- .../queue/handlesimpleuserqueueevent.java | 108 +- gxawsserverless/src/test/java/log4j2.xml | 36 +- .../com/genexus/webpanels/HttpContextWeb.java | 2 + 24 files changed, 1853 insertions(+), 2611 deletions(-) delete mode 100644 gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java index fd51bf684..568348f4f 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java @@ -28,12 +28,11 @@ public LambdaSQSHandler(String className) throws Exception { super(className); } - //https://docs.aws.amazon.com/en_gb/lambda/latest/dg/with-sqs.html @Override public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) { - int msgCount = (int) sqsEvent.getRecords().stream().count(); - - logger.debug("handleRequest started with #sqsItems: " + msgCount); + if (logger.isDebugEnabled()) { + logger.debug("handleRequest started with #sqsItems: " + (int) sqsEvent.getRecords().size()); + } EventMessages msgs = new EventMessages(); @@ -76,7 +75,7 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) { if (!wasHandled) { logger.error(String.format("Messages were not handled. Marking all SQS Events as failed: %s", errorMessage)); List failures = new ArrayList<>(); - //Assume all batch failed + //Assume all batch has failed. for (SQSMessage sqsItem : sqsEvent.getRecords()) { failures.add(new SQSBatchResponse.BatchItemFailure(sqsItem.getMessageId())); } diff --git a/gxawsserverless/src/test/java/com/amazonaws/serverless/proxy/test/jersey/model/MapResponseModel.java b/gxawsserverless/src/test/java/com/amazonaws/serverless/proxy/test/jersey/model/MapResponseModel.java index 48fb23fe5..7a965e076 100644 --- a/gxawsserverless/src/test/java/com/amazonaws/serverless/proxy/test/jersey/model/MapResponseModel.java +++ b/gxawsserverless/src/test/java/com/amazonaws/serverless/proxy/test/jersey/model/MapResponseModel.java @@ -19,21 +19,21 @@ * Request/response model */ public class MapResponseModel { - private Map values; + private Map values; - public MapResponseModel() { - this.values = new HashMap<>(); - } + public MapResponseModel() { + this.values = new HashMap<>(); + } - public void addValue(String key, String value) { - this.values.put(key, value); - } + public void addValue(String key, String value) { + this.values.put(key, value); + } - public Map getValues() { - return values; - } + public Map getValues() { + return values; + } - public void setValues(Map values) { - this.values = values; - } + public void setValues(Map values) { + this.values = values; + } } \ No newline at end of file diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java deleted file mode 100644 index b03df7ad3..000000000 --- a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaBaseHandler.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.genexus.cloud.aws.events; - -public class TestLambdaBaseHandler { -} diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java index 7f1bcedfa..f4b5cce4e 100644 --- a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java @@ -15,7 +15,6 @@ import java.util.*; - public class TestLambdaSQSHandler { private static String SIMPLE_HANDLER = "com.unittest.eventdriven.queue.handlesimpleuserqueueevent"; private static String SIMPLE_RAW_HANDLER = "com.unittest.eventdriven.queue.handlesimplerawsqsevent"; diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java index ca405bc72..55b44e80f 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java @@ -1,218 +1,112 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; import com.genexus.*; import com.genexus.xml.*; import com.genexus.search.*; import com.genexus.webpanels.*; + import java.util.*; -public final class SdtEventCustomPayload_CustomPayloadItem extends GxUserType -{ - public SdtEventCustomPayload_CustomPayloadItem( ) - { - this( new ModelContext(SdtEventCustomPayload_CustomPayloadItem.class)); - } - - public SdtEventCustomPayload_CustomPayloadItem( ModelContext context ) - { - super( context, "SdtEventCustomPayload_CustomPayloadItem"); - } - - public SdtEventCustomPayload_CustomPayloadItem( int remoteHandle , - ModelContext context ) - { - super( remoteHandle, context, "SdtEventCustomPayload_CustomPayloadItem"); - } - - public SdtEventCustomPayload_CustomPayloadItem( StructSdtEventCustomPayload_CustomPayloadItem struct ) - { - this(); - setStruct(struct); - } - - private static java.util.HashMap mapper = new java.util.HashMap(); - static - { - } - - public String getJsonMap( String value ) - { - return (String) mapper.get(value); - } - - public short readxml( com.genexus.xml.XMLReader oReader , - String sName ) - { - short GXSoapError = 1; - formatError = false ; - sTagName = oReader.getName() ; - if ( oReader.getIsSimple() == 0 ) - { - GXSoapError = oReader.read() ; - nOutParmCount = (short)(0) ; - while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) - { - readOk = (short)(0) ; - readElement = false ; - if ( GXutil.strcmp2( oReader.getLocalName(), "PropertyId") ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "PropertyValue") ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( ! readElement ) - { - readOk = (short)(1) ; - GXSoapError = oReader.read() ; - } - nOutParmCount = (short)(nOutParmCount+1) ; - if ( ( readOk == 0 ) || formatError ) - { - context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; - context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; - GXSoapError = (short)(nOutParmCount*-1) ; - } - } - } - return GXSoapError ; - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace ) - { - writexml(oWriter, sName, sNameSpace, true); - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace , - boolean sIncludeState ) - { - if ( (GXutil.strcmp("", sName)==0) ) - { - sName = "EventCustomPayload.CustomPayloadItem" ; - } - oWriter.writeStartElement(sName); - if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) - { - oWriter.writeAttribute("xmlns", sNameSpace); - } - else - { - sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; - } - oWriter.writeElement("PropertyId", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - oWriter.writeElement("PropertyValue", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - oWriter.writeEndElement(); - } - - public void tojson( ) - { - tojson( true) ; - } - - public void tojson( boolean includeState ) - { - tojson( includeState, true) ; - } - - public void tojson( boolean includeState , - boolean includeNonInitialized ) - { - AddObjectProperty("PropertyId", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid, false, false); - AddObjectProperty("PropertyValue", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue, false, false); - } - - public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid( ) - { - return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; - } - - public void setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid( String value ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = value ; - } - - public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue( ) - { - return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; - } - - public void setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue( String value ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = value ; - } - - public void initialize( int remoteHandle ) - { - initialize( ) ; - } - - public void initialize( ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = "" ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(1) ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = "" ; - sTagName = "" ; - } - - public byte isNull( ) - { - return gxTv_SdtEventCustomPayload_CustomPayloadItem_N ; - } - - public com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem Clone( ) - { - return (com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem)(clone()) ; - } - - public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem struct ) - { - setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid(struct.getPropertyid()); - setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue(struct.getPropertyvalue()); - } - - @SuppressWarnings("unchecked") - public com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem getStruct( ) - { - com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem struct = new com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem (); - struct.setPropertyid(getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid()); - struct.setPropertyvalue(getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue()); - return struct ; - } - - protected byte gxTv_SdtEventCustomPayload_CustomPayloadItem_N ; - protected short readOk ; - protected short nOutParmCount ; - protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; - protected String sTagName ; - protected boolean readElement ; - protected boolean formatError ; - protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; +public final class SdtEventCustomPayload_CustomPayloadItem extends GxUserType { + public SdtEventCustomPayload_CustomPayloadItem() { + this(new ModelContext(SdtEventCustomPayload_CustomPayloadItem.class)); + } + + public SdtEventCustomPayload_CustomPayloadItem(ModelContext context) { + super(context, "SdtEventCustomPayload_CustomPayloadItem"); + } + + public SdtEventCustomPayload_CustomPayloadItem(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, "SdtEventCustomPayload_CustomPayloadItem"); + } + + public SdtEventCustomPayload_CustomPayloadItem(StructSdtEventCustomPayload_CustomPayloadItem struct) { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + + static { + } + + public String getJsonMap(String value) { + return (String) mapper.get(value); + } + + public void tojson() { + tojson(true); + } + + public void tojson(boolean includeState) { + tojson(includeState, true); + } + + public void tojson(boolean includeState, + boolean includeNonInitialized) { + AddObjectProperty("PropertyId", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid, false, false); + AddObjectProperty("PropertyValue", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue, false, false); + } + + public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid() { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid; + } + + public void setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid(String value) { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte) (0); + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = value; + } + + public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue() { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue; + } + + public void setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue(String value) { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte) (0); + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = value; + } + + public void initialize(int remoteHandle) { + initialize(); + } + + public void initialize() { + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = ""; + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte) (1); + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = ""; + sTagName = ""; + } + + public byte isNull() { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_N; + } + + public com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem Clone() { + return (com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem) (clone()); + } + + public void setStruct(com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem struct) { + setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid(struct.getPropertyid()); + setgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue(struct.getPropertyvalue()); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem getStruct() { + com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem struct = new com.genexus.genexusserverlessapi.StructSdtEventCustomPayload_CustomPayloadItem(); + struct.setPropertyid(getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid()); + struct.setPropertyvalue(getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue()); + return struct; + } + + protected byte gxTv_SdtEventCustomPayload_CustomPayloadItem_N; + protected short readOk; + protected short nOutParmCount; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue; + protected String sTagName; + protected boolean readElement; + protected boolean formatError; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java index bc9d43502..515468902 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java @@ -1,477 +1,228 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; -import com.genexus.*; -import com.genexus.xml.*; -import com.genexus.search.*; -import com.genexus.webpanels.*; import java.util.*; -public final class SdtEventMessage extends GxUserType -{ - public SdtEventMessage( ) - { - this( new ModelContext(SdtEventMessage.class)); - } - - public SdtEventMessage( ModelContext context ) - { - super( context, "SdtEventMessage"); - } - - public SdtEventMessage( int remoteHandle , - ModelContext context ) - { - super( remoteHandle, context, "SdtEventMessage"); - } - - public SdtEventMessage( StructSdtEventMessage struct ) - { - this(); - setStruct(struct); - } - - private static java.util.HashMap mapper = new java.util.HashMap(); - static - { - } - - public String getJsonMap( String value ) - { - return (String) mapper.get(value); - } - - public short readxml( com.genexus.xml.XMLReader oReader , - String sName ) - { - short GXSoapError = 1; - formatError = false ; - sTagName = oReader.getName() ; - if ( oReader.getIsSimple() == 0 ) - { - GXSoapError = oReader.read() ; - nOutParmCount = (short)(0) ; - while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) - { - readOk = (short)(0) ; - readElement = false ; - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageId") ) - { - gxTv_SdtEventMessage_Eventmessageid = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageDate") ) - { - if ( ( GXutil.strcmp(oReader.getValue(), "") == 0 ) || ( oReader.existsAttribute("xsi:nil") == 1 ) ) - { - gxTv_SdtEventMessage_Eventmessagedate = GXutil.resetTime( GXutil.nullDate() ); - gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(1) ; - } - else - { - gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagedate = localUtil.ymdhmsToT( (short)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 1, 4), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 6, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 9, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 12, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 15, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 18, 2), ".")))) ; - } - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageSourceType") ) - { - gxTv_SdtEventMessage_Eventmessagesourcetype = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageData") ) - { - gxTv_SdtEventMessage_Eventmessagedata = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageVersion") ) - { - gxTv_SdtEventMessage_Eventmessageversion = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageCustomPayload") ) - { - if ( gxTv_SdtEventMessage_Eventmessagecustompayload == null ) - { - gxTv_SdtEventMessage_Eventmessagecustompayload = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); - } - if ( ( oReader.getIsSimple() == 0 ) || ( oReader.getAttributeCount() > 0 ) ) - { - GXSoapError = gxTv_SdtEventMessage_Eventmessagecustompayload.readxml(oReader, "EventMessageCustomPayload") ; - } - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessageCustomPayload") ) - { - GXSoapError = oReader.read() ; - } - } - if ( ! readElement ) - { - readOk = (short)(1) ; - GXSoapError = oReader.read() ; - } - nOutParmCount = (short)(nOutParmCount+1) ; - if ( ( readOk == 0 ) || formatError ) - { - context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; - context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; - GXSoapError = (short)(nOutParmCount*-1) ; - } - } - } - return GXSoapError ; - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace ) - { - writexml(oWriter, sName, sNameSpace, true); - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace , - boolean sIncludeState ) - { - if ( (GXutil.strcmp("", sName)==0) ) - { - sName = "EventMessage" ; - } - if ( (GXutil.strcmp("", sNameSpace)==0) ) - { - sNameSpace = "ServerlessAPI" ; - } - oWriter.writeStartElement(sName); - if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) - { - oWriter.writeAttribute("xmlns", sNameSpace); - } - else - { - sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; - } - oWriter.writeElement("EventMessageId", gxTv_SdtEventMessage_Eventmessageid); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - if ( GXutil.dateCompare(GXutil.nullDate(), gxTv_SdtEventMessage_Eventmessagedate) && ( gxTv_SdtEventMessage_Eventmessagedate_N == 1 ) ) - { - oWriter.writeElement("EventMessageDate", ""); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - } - else - { - sDateCnv = "" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.year( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; - sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.month( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.day( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "T" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.second( gxTv_SdtEventMessage_Eventmessagedate), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - oWriter.writeElement("EventMessageDate", sDateCnv); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - } - oWriter.writeElement("EventMessageSourceType", gxTv_SdtEventMessage_Eventmessagesourcetype); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - oWriter.writeElement("EventMessageData", gxTv_SdtEventMessage_Eventmessagedata); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - oWriter.writeElement("EventMessageVersion", gxTv_SdtEventMessage_Eventmessageversion); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - if ( gxTv_SdtEventMessage_Eventmessagecustompayload != null ) - { - String sNameSpace1; - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") == 0 ) - { - sNameSpace1 = "[*:nosend]" + "ServerlessAPI" ; - } - else - { - sNameSpace1 = "ServerlessAPI" ; - } - gxTv_SdtEventMessage_Eventmessagecustompayload.writexml(oWriter, "EventMessageCustomPayload", sNameSpace1, sIncludeState); - } - oWriter.writeEndElement(); - } - - public void tojson( ) - { - tojson( true) ; - } - - public void tojson( boolean includeState ) - { - tojson( includeState, true) ; - } - - public void tojson( boolean includeState , - boolean includeNonInitialized ) - { - AddObjectProperty("EventMessageId", gxTv_SdtEventMessage_Eventmessageid, false, false); - datetime_STZ = gxTv_SdtEventMessage_Eventmessagedate ; - sDateCnv = "" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.year( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.month( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.day( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "T" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.second( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - AddObjectProperty("EventMessageDate", sDateCnv, false, false); - AddObjectProperty("EventMessageSourceType", gxTv_SdtEventMessage_Eventmessagesourcetype, false, false); - AddObjectProperty("EventMessageData", gxTv_SdtEventMessage_Eventmessagedata, false, false); - AddObjectProperty("EventMessageVersion", gxTv_SdtEventMessage_Eventmessageversion, false, false); - if ( gxTv_SdtEventMessage_Eventmessagecustompayload != null ) - { - AddObjectProperty("EventMessageCustomPayload", gxTv_SdtEventMessage_Eventmessagecustompayload, false, false); - } - } - - public String getgxTv_SdtEventMessage_Eventmessageid( ) - { - return gxTv_SdtEventMessage_Eventmessageid ; - } - - public void setgxTv_SdtEventMessage_Eventmessageid( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessageid = value ; - } - - public java.util.Date getgxTv_SdtEventMessage_Eventmessagedate( ) - { - return gxTv_SdtEventMessage_Eventmessagedate ; - } - - public void setgxTv_SdtEventMessage_Eventmessagedate( java.util.Date value ) - { - gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(0) ; - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagedate = value ; - } - - public String getgxTv_SdtEventMessage_Eventmessagesourcetype( ) - { - return gxTv_SdtEventMessage_Eventmessagesourcetype ; - } - - public void setgxTv_SdtEventMessage_Eventmessagesourcetype( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagesourcetype = value ; - } - - public String getgxTv_SdtEventMessage_Eventmessagedata( ) - { - return gxTv_SdtEventMessage_Eventmessagedata ; - } - - public void setgxTv_SdtEventMessage_Eventmessagedata( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagedata = value ; - } - - public String getgxTv_SdtEventMessage_Eventmessageversion( ) - { - return gxTv_SdtEventMessage_Eventmessageversion ; - } - - public void setgxTv_SdtEventMessage_Eventmessageversion( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessageversion = value ; - } - - public GXBaseCollection getgxTv_SdtEventMessage_Eventmessagecustompayload( ) - { - if ( gxTv_SdtEventMessage_Eventmessagecustompayload == null ) - { - gxTv_SdtEventMessage_Eventmessagecustompayload = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); - } - gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(0) ; - gxTv_SdtEventMessage_N = (byte)(0) ; - return gxTv_SdtEventMessage_Eventmessagecustompayload ; - } - - public void setgxTv_SdtEventMessage_Eventmessagecustompayload( GXBaseCollection value ) - { - gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(0) ; - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagecustompayload = value ; - } - - public void setgxTv_SdtEventMessage_Eventmessagecustompayload_SetNull( ) - { - gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(1) ; - gxTv_SdtEventMessage_Eventmessagecustompayload = null ; - } - - public boolean getgxTv_SdtEventMessage_Eventmessagecustompayload_IsNull( ) - { - if ( gxTv_SdtEventMessage_Eventmessagecustompayload == null ) - { - return true ; - } - return false ; - } - - public byte getgxTv_SdtEventMessage_Eventmessagecustompayload_N( ) - { - return gxTv_SdtEventMessage_Eventmessagecustompayload_N ; - } - - public void initialize( int remoteHandle ) - { - initialize( ) ; - } - - public void initialize( ) - { - gxTv_SdtEventMessage_Eventmessageid = "" ; - gxTv_SdtEventMessage_N = (byte)(1) ; - gxTv_SdtEventMessage_Eventmessagedate = GXutil.resetTime( GXutil.nullDate() ); - gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(1) ; - gxTv_SdtEventMessage_Eventmessagesourcetype = "" ; - gxTv_SdtEventMessage_Eventmessagedata = "" ; - gxTv_SdtEventMessage_Eventmessageversion = "" ; - gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(1) ; - sTagName = "" ; - sDateCnv = "" ; - sNumToPad = "" ; - datetime_STZ = GXutil.resetTime( GXutil.nullDate() ); - } - - public byte isNull( ) - { - return gxTv_SdtEventMessage_N ; - } - - public com.genexus.genexusserverlessapi.SdtEventMessage Clone( ) - { - return (com.genexus.genexusserverlessapi.SdtEventMessage)(clone()) ; - } - - public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventMessage struct ) - { - setgxTv_SdtEventMessage_Eventmessageid(struct.getEventmessageid()); - if ( struct.gxTv_SdtEventMessage_Eventmessagedate_N == 0 ) - { - setgxTv_SdtEventMessage_Eventmessagedate(struct.getEventmessagedate()); - } - setgxTv_SdtEventMessage_Eventmessagesourcetype(struct.getEventmessagesourcetype()); - setgxTv_SdtEventMessage_Eventmessagedata(struct.getEventmessagedata()); - setgxTv_SdtEventMessage_Eventmessageversion(struct.getEventmessageversion()); - GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload_aux = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); - Vector gxTv_SdtEventMessage_Eventmessagecustompayload_aux1 = struct.getEventmessagecustompayload(); - if (gxTv_SdtEventMessage_Eventmessagecustompayload_aux1 != null) - { - for (int i = 0; i < gxTv_SdtEventMessage_Eventmessagecustompayload_aux1.size(); i++) - { - gxTv_SdtEventMessage_Eventmessagecustompayload_aux.add(new com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem(gxTv_SdtEventMessage_Eventmessagecustompayload_aux1.elementAt(i))); - } - } - setgxTv_SdtEventMessage_Eventmessagecustompayload(gxTv_SdtEventMessage_Eventmessagecustompayload_aux); - } - - @SuppressWarnings("unchecked") - public com.genexus.genexusserverlessapi.StructSdtEventMessage getStruct( ) - { - com.genexus.genexusserverlessapi.StructSdtEventMessage struct = new com.genexus.genexusserverlessapi.StructSdtEventMessage (); - struct.setEventmessageid(getgxTv_SdtEventMessage_Eventmessageid()); - if ( gxTv_SdtEventMessage_Eventmessagedate_N == 0 ) - { - struct.setEventmessagedate(getgxTv_SdtEventMessage_Eventmessagedate()); - } - struct.setEventmessagesourcetype(getgxTv_SdtEventMessage_Eventmessagesourcetype()); - struct.setEventmessagedata(getgxTv_SdtEventMessage_Eventmessagedata()); - struct.setEventmessageversion(getgxTv_SdtEventMessage_Eventmessageversion()); - struct.setEventmessagecustompayload(getgxTv_SdtEventMessage_Eventmessagecustompayload().getStruct()); - return struct ; - } - - protected byte gxTv_SdtEventMessage_N ; - protected byte gxTv_SdtEventMessage_Eventmessagedate_N ; - protected byte gxTv_SdtEventMessage_Eventmessagecustompayload_N ; - protected short readOk ; - protected short nOutParmCount ; - protected String sTagName ; - protected String sDateCnv ; - protected String sNumToPad ; - protected java.util.Date gxTv_SdtEventMessage_Eventmessagedate ; - protected java.util.Date datetime_STZ ; - protected boolean readElement ; - protected boolean formatError ; - protected String gxTv_SdtEventMessage_Eventmessagedata ; - protected String gxTv_SdtEventMessage_Eventmessageid ; - protected String gxTv_SdtEventMessage_Eventmessagesourcetype ; - protected String gxTv_SdtEventMessage_Eventmessageversion ; - protected GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload_aux ; - protected GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload=null ; +public final class SdtEventMessage extends GxUserType { + public SdtEventMessage() { + this(new ModelContext(SdtEventMessage.class)); + } + + public SdtEventMessage(ModelContext context) { + super(context, "SdtEventMessage"); + } + + public SdtEventMessage(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, "SdtEventMessage"); + } + + public SdtEventMessage(StructSdtEventMessage struct) { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + + static { + } + + public String getJsonMap(String value) { + return (String) mapper.get(value); + } + + public void tojson() { + tojson(true); + } + + public void tojson(boolean includeState) { + tojson(includeState, true); + } + + public void tojson(boolean includeState, + boolean includeNonInitialized) { + AddObjectProperty("EventMessageId", gxTv_SdtEventMessage_Eventmessageid, false, false); + datetime_STZ = gxTv_SdtEventMessage_Eventmessagedate; + sDateCnv = ""; + sNumToPad = GXutil.trim(GXutil.str(GXutil.year(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.month(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.day(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "T"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.second(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + AddObjectProperty("EventMessageDate", sDateCnv, false, false); + AddObjectProperty("EventMessageSourceType", gxTv_SdtEventMessage_Eventmessagesourcetype, false, false); + AddObjectProperty("EventMessageData", gxTv_SdtEventMessage_Eventmessagedata, false, false); + AddObjectProperty("EventMessageVersion", gxTv_SdtEventMessage_Eventmessageversion, false, false); + if (gxTv_SdtEventMessage_Eventmessagecustompayload != null) { + AddObjectProperty("EventMessageCustomPayload", gxTv_SdtEventMessage_Eventmessagecustompayload, false, false); + } + } + + public String getgxTv_SdtEventMessage_Eventmessageid() { + return gxTv_SdtEventMessage_Eventmessageid; + } + + public void setgxTv_SdtEventMessage_Eventmessageid(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessageid = value; + } + + public java.util.Date getgxTv_SdtEventMessage_Eventmessagedate() { + return gxTv_SdtEventMessage_Eventmessagedate; + } + + public void setgxTv_SdtEventMessage_Eventmessagedate(java.util.Date value) { + gxTv_SdtEventMessage_Eventmessagedate_N = (byte) (0); + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagedate = value; + } + + public String getgxTv_SdtEventMessage_Eventmessagesourcetype() { + return gxTv_SdtEventMessage_Eventmessagesourcetype; + } + + public void setgxTv_SdtEventMessage_Eventmessagesourcetype(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagesourcetype = value; + } + + public String getgxTv_SdtEventMessage_Eventmessagedata() { + return gxTv_SdtEventMessage_Eventmessagedata; + } + + public void setgxTv_SdtEventMessage_Eventmessagedata(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagedata = value; + } + + public String getgxTv_SdtEventMessage_Eventmessageversion() { + return gxTv_SdtEventMessage_Eventmessageversion; + } + + public void setgxTv_SdtEventMessage_Eventmessageversion(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessageversion = value; + } + + public GXBaseCollection getgxTv_SdtEventMessage_Eventmessagecustompayload() { + if (gxTv_SdtEventMessage_Eventmessagecustompayload == null) { + gxTv_SdtEventMessage_Eventmessagecustompayload = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); + } + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte) (0); + gxTv_SdtEventMessage_N = (byte) (0); + return gxTv_SdtEventMessage_Eventmessagecustompayload; + } + + public void setgxTv_SdtEventMessage_Eventmessagecustompayload(GXBaseCollection value) { + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte) (0); + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagecustompayload = value; + } + + public void setgxTv_SdtEventMessage_Eventmessagecustompayload_SetNull() { + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte) (1); + gxTv_SdtEventMessage_Eventmessagecustompayload = null; + } + + public boolean getgxTv_SdtEventMessage_Eventmessagecustompayload_IsNull() { + if (gxTv_SdtEventMessage_Eventmessagecustompayload == null) { + return true; + } + return false; + } + + public byte getgxTv_SdtEventMessage_Eventmessagecustompayload_N() { + return gxTv_SdtEventMessage_Eventmessagecustompayload_N; + } + + public void initialize(int remoteHandle) { + initialize(); + } + + public void initialize() { + gxTv_SdtEventMessage_Eventmessageid = ""; + gxTv_SdtEventMessage_N = (byte) (1); + gxTv_SdtEventMessage_Eventmessagedate = GXutil.resetTime(GXutil.nullDate()); + gxTv_SdtEventMessage_Eventmessagedate_N = (byte) (1); + gxTv_SdtEventMessage_Eventmessagesourcetype = ""; + gxTv_SdtEventMessage_Eventmessagedata = ""; + gxTv_SdtEventMessage_Eventmessageversion = ""; + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte) (1); + sTagName = ""; + sDateCnv = ""; + sNumToPad = ""; + datetime_STZ = GXutil.resetTime(GXutil.nullDate()); + } + + public byte isNull() { + return gxTv_SdtEventMessage_N; + } + + public com.genexus.genexusserverlessapi.SdtEventMessage Clone() { + return (com.genexus.genexusserverlessapi.SdtEventMessage) (clone()); + } + + public void setStruct(com.genexus.genexusserverlessapi.StructSdtEventMessage struct) { + setgxTv_SdtEventMessage_Eventmessageid(struct.getEventmessageid()); + if (struct.gxTv_SdtEventMessage_Eventmessagedate_N == 0) { + setgxTv_SdtEventMessage_Eventmessagedate(struct.getEventmessagedate()); + } + setgxTv_SdtEventMessage_Eventmessagesourcetype(struct.getEventmessagesourcetype()); + setgxTv_SdtEventMessage_Eventmessagedata(struct.getEventmessagedata()); + setgxTv_SdtEventMessage_Eventmessageversion(struct.getEventmessageversion()); + GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload_aux = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem.class, "CustomPayloadItem", "ServerlessAPI", remoteHandle); + Vector gxTv_SdtEventMessage_Eventmessagecustompayload_aux1 = struct.getEventmessagecustompayload(); + if (gxTv_SdtEventMessage_Eventmessagecustompayload_aux1 != null) { + for (int i = 0; i < gxTv_SdtEventMessage_Eventmessagecustompayload_aux1.size(); i++) { + gxTv_SdtEventMessage_Eventmessagecustompayload_aux.add(new com.genexus.genexusserverlessapi.SdtEventCustomPayload_CustomPayloadItem(gxTv_SdtEventMessage_Eventmessagecustompayload_aux1.elementAt(i))); + } + } + setgxTv_SdtEventMessage_Eventmessagecustompayload(gxTv_SdtEventMessage_Eventmessagecustompayload_aux); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventMessage getStruct() { + com.genexus.genexusserverlessapi.StructSdtEventMessage struct = new com.genexus.genexusserverlessapi.StructSdtEventMessage(); + struct.setEventmessageid(getgxTv_SdtEventMessage_Eventmessageid()); + if (gxTv_SdtEventMessage_Eventmessagedate_N == 0) { + struct.setEventmessagedate(getgxTv_SdtEventMessage_Eventmessagedate()); + } + struct.setEventmessagesourcetype(getgxTv_SdtEventMessage_Eventmessagesourcetype()); + struct.setEventmessagedata(getgxTv_SdtEventMessage_Eventmessagedata()); + struct.setEventmessageversion(getgxTv_SdtEventMessage_Eventmessageversion()); + struct.setEventmessagecustompayload(getgxTv_SdtEventMessage_Eventmessagecustompayload().getStruct()); + return struct; + } + + protected byte gxTv_SdtEventMessage_N; + protected byte gxTv_SdtEventMessage_Eventmessagedate_N; + protected byte gxTv_SdtEventMessage_Eventmessagecustompayload_N; + protected short readOk; + protected short nOutParmCount; + protected String sTagName; + protected String sDateCnv; + protected String sNumToPad; + protected java.util.Date gxTv_SdtEventMessage_Eventmessagedate; + protected java.util.Date datetime_STZ; + protected boolean readElement; + protected boolean formatError; + protected String gxTv_SdtEventMessage_Eventmessagedata; + protected String gxTv_SdtEventMessage_Eventmessageid; + protected String gxTv_SdtEventMessage_Eventmessagesourcetype; + protected String gxTv_SdtEventMessage_Eventmessageversion; + protected GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload_aux; + protected GXBaseCollection gxTv_SdtEventMessage_Eventmessagecustompayload = null; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java index cbb5d1e79..a1d83fcd4 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessageResponse.java @@ -1,221 +1,111 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; import com.genexus.*; import com.genexus.xml.*; import com.genexus.search.*; import com.genexus.webpanels.*; + import java.util.*; -public final class SdtEventMessageResponse extends GxUserType -{ - public SdtEventMessageResponse( ) - { - this( new ModelContext(SdtEventMessageResponse.class)); - } - - public SdtEventMessageResponse( ModelContext context ) - { - super( context, "SdtEventMessageResponse"); - } - - public SdtEventMessageResponse( int remoteHandle , - ModelContext context ) - { - super( remoteHandle, context, "SdtEventMessageResponse"); - } - - public SdtEventMessageResponse( StructSdtEventMessageResponse struct ) - { - this(); - setStruct(struct); - } - - private static java.util.HashMap mapper = new java.util.HashMap(); - static - { - } - - public String getJsonMap( String value ) - { - return (String) mapper.get(value); - } - - public short readxml( com.genexus.xml.XMLReader oReader , - String sName ) - { - short GXSoapError = 1; - formatError = false ; - sTagName = oReader.getName() ; - if ( oReader.getIsSimple() == 0 ) - { - GXSoapError = oReader.read() ; - nOutParmCount = (short)(0) ; - while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) - { - readOk = (short)(0) ; - readElement = false ; - if ( GXutil.strcmp2( oReader.getLocalName(), "Handled") ) - { - gxTv_SdtEventMessageResponse_Handled = (boolean)((((GXutil.strcmp(oReader.getValue(), "true")==0)||(GXutil.strcmp(oReader.getValue(), "1")==0) ? 1 : 0)==0)?false:true) ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "ErrorMessage") ) - { - gxTv_SdtEventMessageResponse_Errormessage = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( ! readElement ) - { - readOk = (short)(1) ; - GXSoapError = oReader.read() ; - } - nOutParmCount = (short)(nOutParmCount+1) ; - if ( ( readOk == 0 ) || formatError ) - { - context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; - context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; - GXSoapError = (short)(nOutParmCount*-1) ; - } - } - } - return GXSoapError ; - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace ) - { - writexml(oWriter, sName, sNameSpace, true); - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace , - boolean sIncludeState ) - { - if ( (GXutil.strcmp("", sName)==0) ) - { - sName = "EventMessageResponse" ; - } - if ( (GXutil.strcmp("", sNameSpace)==0) ) - { - sNameSpace = "ServerlessAPI" ; - } - oWriter.writeStartElement(sName); - if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) - { - oWriter.writeAttribute("xmlns", sNameSpace); - } - else - { - sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; - } - oWriter.writeElement("Handled", GXutil.booltostr( gxTv_SdtEventMessageResponse_Handled)); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - oWriter.writeElement("ErrorMessage", gxTv_SdtEventMessageResponse_Errormessage); - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") != 0 ) - { - oWriter.writeAttribute("xmlns", "ServerlessAPI"); - } - oWriter.writeEndElement(); - } - - public void tojson( ) - { - tojson( true) ; - } - - public void tojson( boolean includeState ) - { - tojson( includeState, true) ; - } - - public void tojson( boolean includeState , - boolean includeNonInitialized ) - { - AddObjectProperty("Handled", gxTv_SdtEventMessageResponse_Handled, false, false); - AddObjectProperty("ErrorMessage", gxTv_SdtEventMessageResponse_Errormessage, false, false); - } - - public boolean getgxTv_SdtEventMessageResponse_Handled( ) - { - return gxTv_SdtEventMessageResponse_Handled ; - } - - public void setgxTv_SdtEventMessageResponse_Handled( boolean value ) - { - gxTv_SdtEventMessageResponse_N = (byte)(0) ; - gxTv_SdtEventMessageResponse_Handled = value ; - } - - public String getgxTv_SdtEventMessageResponse_Errormessage( ) - { - return gxTv_SdtEventMessageResponse_Errormessage ; - } - - public void setgxTv_SdtEventMessageResponse_Errormessage( String value ) - { - gxTv_SdtEventMessageResponse_N = (byte)(0) ; - gxTv_SdtEventMessageResponse_Errormessage = value ; - } - - public void initialize( int remoteHandle ) - { - initialize( ) ; - } - - public void initialize( ) - { - gxTv_SdtEventMessageResponse_N = (byte)(1) ; - gxTv_SdtEventMessageResponse_Errormessage = "" ; - sTagName = "" ; - } - - public byte isNull( ) - { - return gxTv_SdtEventMessageResponse_N ; - } - - public com.genexus.genexusserverlessapi.SdtEventMessageResponse Clone( ) - { - return (com.genexus.genexusserverlessapi.SdtEventMessageResponse)(clone()) ; - } - - public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventMessageResponse struct ) - { - setgxTv_SdtEventMessageResponse_Handled(struct.getHandled()); - setgxTv_SdtEventMessageResponse_Errormessage(struct.getErrormessage()); - } - - @SuppressWarnings("unchecked") - public com.genexus.genexusserverlessapi.StructSdtEventMessageResponse getStruct( ) - { - com.genexus.genexusserverlessapi.StructSdtEventMessageResponse struct = new com.genexus.genexusserverlessapi.StructSdtEventMessageResponse (); - struct.setHandled(getgxTv_SdtEventMessageResponse_Handled()); - struct.setErrormessage(getgxTv_SdtEventMessageResponse_Errormessage()); - return struct ; - } - - protected byte gxTv_SdtEventMessageResponse_N ; - protected short readOk ; - protected short nOutParmCount ; - protected String sTagName ; - protected boolean gxTv_SdtEventMessageResponse_Handled ; - protected boolean readElement ; - protected boolean formatError ; - protected String gxTv_SdtEventMessageResponse_Errormessage ; +public final class SdtEventMessageResponse extends GxUserType { + public SdtEventMessageResponse() { + this(new ModelContext(SdtEventMessageResponse.class)); + } + + public SdtEventMessageResponse(ModelContext context) { + super(context, "SdtEventMessageResponse"); + } + + public SdtEventMessageResponse(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, "SdtEventMessageResponse"); + } + + public SdtEventMessageResponse(StructSdtEventMessageResponse struct) { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + + static { + } + + public String getJsonMap(String value) { + return (String) mapper.get(value); + } + + public void tojson() { + tojson(true); + } + + public void tojson(boolean includeState) { + tojson(includeState, true); + } + + public void tojson(boolean includeState, + boolean includeNonInitialized) { + AddObjectProperty("Handled", gxTv_SdtEventMessageResponse_Handled, false, false); + AddObjectProperty("ErrorMessage", gxTv_SdtEventMessageResponse_Errormessage, false, false); + } + + public boolean getgxTv_SdtEventMessageResponse_Handled() { + return gxTv_SdtEventMessageResponse_Handled; + } + + public void setgxTv_SdtEventMessageResponse_Handled(boolean value) { + gxTv_SdtEventMessageResponse_N = (byte) (0); + gxTv_SdtEventMessageResponse_Handled = value; + } + + public String getgxTv_SdtEventMessageResponse_Errormessage() { + return gxTv_SdtEventMessageResponse_Errormessage; + } + + public void setgxTv_SdtEventMessageResponse_Errormessage(String value) { + gxTv_SdtEventMessageResponse_N = (byte) (0); + gxTv_SdtEventMessageResponse_Errormessage = value; + } + + public void initialize(int remoteHandle) { + initialize(); + } + + public void initialize() { + gxTv_SdtEventMessageResponse_N = (byte) (1); + gxTv_SdtEventMessageResponse_Errormessage = ""; + sTagName = ""; + } + + public byte isNull() { + return gxTv_SdtEventMessageResponse_N; + } + + public com.genexus.genexusserverlessapi.SdtEventMessageResponse Clone() { + return (com.genexus.genexusserverlessapi.SdtEventMessageResponse) (clone()); + } + + public void setStruct(com.genexus.genexusserverlessapi.StructSdtEventMessageResponse struct) { + setgxTv_SdtEventMessageResponse_Handled(struct.getHandled()); + setgxTv_SdtEventMessageResponse_Errormessage(struct.getErrormessage()); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventMessageResponse getStruct() { + com.genexus.genexusserverlessapi.StructSdtEventMessageResponse struct = new com.genexus.genexusserverlessapi.StructSdtEventMessageResponse(); + struct.setHandled(getgxTv_SdtEventMessageResponse_Handled()); + struct.setErrormessage(getgxTv_SdtEventMessageResponse_Errormessage()); + return struct; + } + + protected byte gxTv_SdtEventMessageResponse_N; + protected short readOk; + protected short nOutParmCount; + protected String sTagName; + protected boolean gxTv_SdtEventMessageResponse_Handled; + protected boolean readElement; + protected boolean formatError; + protected String gxTv_SdtEventMessageResponse_Errormessage; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java index 378086405..2f95b6ef0 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java @@ -1,250 +1,131 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; import com.genexus.*; import com.genexus.xml.*; import com.genexus.search.*; import com.genexus.webpanels.*; + import java.util.*; -public final class SdtEventMessages extends GxUserType -{ - public SdtEventMessages( ) - { - this( new ModelContext(SdtEventMessages.class)); - } - - public SdtEventMessages( ModelContext context ) - { - super( context, "SdtEventMessages"); - } - - public SdtEventMessages( int remoteHandle , - ModelContext context ) - { - super( remoteHandle, context, "SdtEventMessages"); - } - - public SdtEventMessages( StructSdtEventMessages struct ) - { - this(); - setStruct(struct); - } - - private static java.util.HashMap mapper = new java.util.HashMap(); - static - { - } - - public String getJsonMap( String value ) - { - return (String) mapper.get(value); - } - - public short readxml( com.genexus.xml.XMLReader oReader , - String sName ) - { - short GXSoapError = 1; - formatError = false ; - sTagName = oReader.getName() ; - if ( oReader.getIsSimple() == 0 ) - { - GXSoapError = oReader.read() ; - nOutParmCount = (short)(0) ; - while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) - { - readOk = (short)(0) ; - readElement = false ; - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessage") ) - { - if ( gxTv_SdtEventMessages_Eventmessage == null ) - { - gxTv_SdtEventMessages_Eventmessage = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); - } - if ( oReader.getIsSimple() == 0 ) - { - GXSoapError = gxTv_SdtEventMessages_Eventmessage.readxmlcollection(oReader, "EventMessage", "EventMessage") ; - } - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "EventMessage") ) - { - GXSoapError = oReader.read() ; - } - } - if ( ! readElement ) - { - readOk = (short)(1) ; - GXSoapError = oReader.read() ; - } - nOutParmCount = (short)(nOutParmCount+1) ; - if ( ( readOk == 0 ) || formatError ) - { - context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; - context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; - GXSoapError = (short)(nOutParmCount*-1) ; - } - } - } - return GXSoapError ; - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace ) - { - writexml(oWriter, sName, sNameSpace, true); - } - - public void writexml( com.genexus.xml.XMLWriter oWriter , - String sName , - String sNameSpace , - boolean sIncludeState ) - { - if ( (GXutil.strcmp("", sName)==0) ) - { - sName = "EventMessages" ; - } - if ( (GXutil.strcmp("", sNameSpace)==0) ) - { - sNameSpace = "ServerlessAPI" ; - } - oWriter.writeStartElement(sName); - if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) - { - oWriter.writeAttribute("xmlns", sNameSpace); - } - else - { - sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; - } - if ( gxTv_SdtEventMessages_Eventmessage != null ) - { - String sNameSpace1; - if ( GXutil.strcmp(sNameSpace, "ServerlessAPI") == 0 ) - { - sNameSpace1 = "[*:nosend]" + "ServerlessAPI" ; - } - else - { - sNameSpace1 = "ServerlessAPI" ; - } - gxTv_SdtEventMessages_Eventmessage.writexmlcollection(oWriter, "EventMessage", sNameSpace1, "EventMessage", sNameSpace1); - } - oWriter.writeEndElement(); - } - - public void tojson( ) - { - tojson( true) ; - } - - public void tojson( boolean includeState ) - { - tojson( includeState, true) ; - } - - public void tojson( boolean includeState , - boolean includeNonInitialized ) - { - if ( gxTv_SdtEventMessages_Eventmessage != null ) - { - AddObjectProperty("EventMessage", gxTv_SdtEventMessages_Eventmessage, false, false); - } - } - - public GXBaseCollection getgxTv_SdtEventMessages_Eventmessage( ) - { - if ( gxTv_SdtEventMessages_Eventmessage == null ) - { - gxTv_SdtEventMessages_Eventmessage = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); - } - gxTv_SdtEventMessages_Eventmessage_N = (byte)(0) ; - gxTv_SdtEventMessages_N = (byte)(0) ; - return gxTv_SdtEventMessages_Eventmessage ; - } - - public void setgxTv_SdtEventMessages_Eventmessage( GXBaseCollection value ) - { - gxTv_SdtEventMessages_Eventmessage_N = (byte)(0) ; - gxTv_SdtEventMessages_N = (byte)(0) ; - gxTv_SdtEventMessages_Eventmessage = value ; - } - - public void setgxTv_SdtEventMessages_Eventmessage_SetNull( ) - { - gxTv_SdtEventMessages_Eventmessage_N = (byte)(1) ; - gxTv_SdtEventMessages_Eventmessage = null ; - } - - public boolean getgxTv_SdtEventMessages_Eventmessage_IsNull( ) - { - if ( gxTv_SdtEventMessages_Eventmessage == null ) - { - return true ; - } - return false ; - } - - public byte getgxTv_SdtEventMessages_Eventmessage_N( ) - { - return gxTv_SdtEventMessages_Eventmessage_N ; - } - - public void initialize( int remoteHandle ) - { - initialize( ) ; - } - - public void initialize( ) - { - gxTv_SdtEventMessages_Eventmessage_N = (byte)(1) ; - gxTv_SdtEventMessages_N = (byte)(1) ; - sTagName = "" ; - } - - public byte isNull( ) - { - return gxTv_SdtEventMessages_N ; - } - - public com.genexus.genexusserverlessapi.SdtEventMessages Clone( ) - { - return (com.genexus.genexusserverlessapi.SdtEventMessages)(clone()) ; - } - - public void setStruct( com.genexus.genexusserverlessapi.StructSdtEventMessages struct ) - { - GXBaseCollection gxTv_SdtEventMessages_Eventmessage_aux = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); - Vector gxTv_SdtEventMessages_Eventmessage_aux1 = struct.getEventmessage(); - if (gxTv_SdtEventMessages_Eventmessage_aux1 != null) - { - for (int i = 0; i < gxTv_SdtEventMessages_Eventmessage_aux1.size(); i++) - { - gxTv_SdtEventMessages_Eventmessage_aux.add(new com.genexus.genexusserverlessapi.SdtEventMessage(gxTv_SdtEventMessages_Eventmessage_aux1.elementAt(i))); - } - } - setgxTv_SdtEventMessages_Eventmessage(gxTv_SdtEventMessages_Eventmessage_aux); - } - - @SuppressWarnings("unchecked") - public com.genexus.genexusserverlessapi.StructSdtEventMessages getStruct( ) - { - com.genexus.genexusserverlessapi.StructSdtEventMessages struct = new com.genexus.genexusserverlessapi.StructSdtEventMessages (); - struct.setEventmessage(getgxTv_SdtEventMessages_Eventmessage().getStruct()); - return struct ; - } - - protected byte gxTv_SdtEventMessages_Eventmessage_N ; - protected byte gxTv_SdtEventMessages_N ; - protected short readOk ; - protected short nOutParmCount ; - protected String sTagName ; - protected boolean readElement ; - protected boolean formatError ; - protected GXBaseCollection gxTv_SdtEventMessages_Eventmessage_aux ; - protected GXBaseCollection gxTv_SdtEventMessages_Eventmessage=null ; +public final class SdtEventMessages extends GxUserType { + public SdtEventMessages() { + this(new ModelContext(SdtEventMessages.class)); + } + + public SdtEventMessages(ModelContext context) { + super(context, "SdtEventMessages"); + } + + public SdtEventMessages(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, "SdtEventMessages"); + } + + public SdtEventMessages(StructSdtEventMessages struct) { + this(); + setStruct(struct); + } + + private static java.util.HashMap mapper = new java.util.HashMap(); + + static { + } + + public String getJsonMap(String value) { + return (String) mapper.get(value); + } + + public void tojson() { + tojson(true); + } + + public void tojson(boolean includeState) { + tojson(includeState, true); + } + + public void tojson(boolean includeState, + boolean includeNonInitialized) { + if (gxTv_SdtEventMessages_Eventmessage != null) { + AddObjectProperty("EventMessage", gxTv_SdtEventMessages_Eventmessage, false, false); + } + } + + public GXBaseCollection getgxTv_SdtEventMessages_Eventmessage() { + if (gxTv_SdtEventMessages_Eventmessage == null) { + gxTv_SdtEventMessages_Eventmessage = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); + } + gxTv_SdtEventMessages_Eventmessage_N = (byte) (0); + gxTv_SdtEventMessages_N = (byte) (0); + return gxTv_SdtEventMessages_Eventmessage; + } + + public void setgxTv_SdtEventMessages_Eventmessage(GXBaseCollection value) { + gxTv_SdtEventMessages_Eventmessage_N = (byte) (0); + gxTv_SdtEventMessages_N = (byte) (0); + gxTv_SdtEventMessages_Eventmessage = value; + } + + public void setgxTv_SdtEventMessages_Eventmessage_SetNull() { + gxTv_SdtEventMessages_Eventmessage_N = (byte) (1); + gxTv_SdtEventMessages_Eventmessage = null; + } + + public boolean getgxTv_SdtEventMessages_Eventmessage_IsNull() { + if (gxTv_SdtEventMessages_Eventmessage == null) { + return true; + } + return false; + } + + public byte getgxTv_SdtEventMessages_Eventmessage_N() { + return gxTv_SdtEventMessages_Eventmessage_N; + } + + public void initialize(int remoteHandle) { + initialize(); + } + + public void initialize() { + gxTv_SdtEventMessages_Eventmessage_N = (byte) (1); + gxTv_SdtEventMessages_N = (byte) (1); + sTagName = ""; + } + + public byte isNull() { + return gxTv_SdtEventMessages_N; + } + + public com.genexus.genexusserverlessapi.SdtEventMessages Clone() { + return (com.genexus.genexusserverlessapi.SdtEventMessages) (clone()); + } + + public void setStruct(com.genexus.genexusserverlessapi.StructSdtEventMessages struct) { + GXBaseCollection gxTv_SdtEventMessages_Eventmessage_aux = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); + Vector gxTv_SdtEventMessages_Eventmessage_aux1 = struct.getEventmessage(); + if (gxTv_SdtEventMessages_Eventmessage_aux1 != null) { + for (int i = 0; i < gxTv_SdtEventMessages_Eventmessage_aux1.size(); i++) { + gxTv_SdtEventMessages_Eventmessage_aux.add(new com.genexus.genexusserverlessapi.SdtEventMessage(gxTv_SdtEventMessages_Eventmessage_aux1.elementAt(i))); + } + } + setgxTv_SdtEventMessages_Eventmessage(gxTv_SdtEventMessages_Eventmessage_aux); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.StructSdtEventMessages getStruct() { + com.genexus.genexusserverlessapi.StructSdtEventMessages struct = new com.genexus.genexusserverlessapi.StructSdtEventMessages(); + struct.setEventmessage(getgxTv_SdtEventMessages_Eventmessage().getStruct()); + return struct; + } + + protected byte gxTv_SdtEventMessages_Eventmessage_N; + protected byte gxTv_SdtEventMessages_N; + protected short readOk; + protected short nOutParmCount; + protected String sTagName; + protected boolean readElement; + protected boolean formatError; + protected GXBaseCollection gxTv_SdtEventMessages_Eventmessage_aux; + protected GXBaseCollection gxTv_SdtEventMessages_Eventmessage = null; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java index faae24709..38d73aaae 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload.java @@ -1,45 +1,40 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; -@javax.xml.bind.annotation.XmlType(name = "EventCustomPayload", namespace ="ServerlessAPI") -public final class StructSdtEventCustomPayload implements Cloneable, java.io.Serializable -{ - public StructSdtEventCustomPayload( ) - { - this( -1, new ModelContext( StructSdtEventCustomPayload.class )); - } - - public StructSdtEventCustomPayload( int remoteHandle , - ModelContext context ) - { - } - - public StructSdtEventCustomPayload( java.util.Vector value ) - { - item = value; - } - - public Object clone() - { - Object cloned = null; - try - { - cloned = super.clone(); - }catch (CloneNotSupportedException e){ ; } - return cloned; - } - - @javax.xml.bind.annotation.XmlElement(name="CustomPayloadItem",namespace="ServerlessAPI") - public java.util.Vector getItem( ) - { - return item; - } - - public void setItem( java.util.Vector value ) - { - item = value; - } - - protected java.util.Vector item = new java.util.Vector<>(); +@javax.xml.bind.annotation.XmlType(name = "EventCustomPayload", namespace = "ServerlessAPI") +public final class StructSdtEventCustomPayload implements Cloneable, java.io.Serializable { + public StructSdtEventCustomPayload() { + this(-1, new ModelContext(StructSdtEventCustomPayload.class)); + } + + public StructSdtEventCustomPayload(int remoteHandle, + ModelContext context) { + } + + public StructSdtEventCustomPayload(java.util.Vector value) { + item = value; + } + + public Object clone() { + Object cloned = null; + try { + cloned = super.clone(); + } catch (CloneNotSupportedException e) { + ; + } + return cloned; + } + + @javax.xml.bind.annotation.XmlElement(name = "CustomPayloadItem", namespace = "ServerlessAPI") + public java.util.Vector getItem() { + return item; + } + + public void setItem(java.util.Vector value) { + item = value; + } + + protected java.util.Vector item = new java.util.Vector<>(); } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java index 56ee75554..d1485d4c7 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventCustomPayload_CustomPayloadItem.java @@ -1,54 +1,48 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; -public final class StructSdtEventCustomPayload_CustomPayloadItem implements Cloneable, java.io.Serializable -{ - public StructSdtEventCustomPayload_CustomPayloadItem( ) - { - this( -1, new ModelContext( StructSdtEventCustomPayload_CustomPayloadItem.class )); - } - - public StructSdtEventCustomPayload_CustomPayloadItem( int remoteHandle , - ModelContext context ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = "" ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = "" ; - } - - public Object clone() - { - Object cloned = null; - try - { - cloned = super.clone(); - }catch (CloneNotSupportedException e){ ; } - return cloned; - } - - public String getPropertyid( ) - { - return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; - } - - public void setPropertyid( String value ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = value ; - } - - public String getPropertyvalue( ) - { - return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; - } - - public void setPropertyvalue( String value ) - { - gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte)(0) ; - gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = value ; - } - - protected byte gxTv_SdtEventCustomPayload_CustomPayloadItem_N ; - protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue ; - protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid ; +public final class StructSdtEventCustomPayload_CustomPayloadItem implements Cloneable, java.io.Serializable { + public StructSdtEventCustomPayload_CustomPayloadItem() { + this(-1, new ModelContext(StructSdtEventCustomPayload_CustomPayloadItem.class)); + } + + public StructSdtEventCustomPayload_CustomPayloadItem(int remoteHandle, + ModelContext context) { + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = ""; + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = ""; + } + + public Object clone() { + Object cloned = null; + try { + cloned = super.clone(); + } catch (CloneNotSupportedException e) { + ; + } + return cloned; + } + + public String getPropertyid() { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid; + } + + public void setPropertyid(String value) { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte) (0); + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid = value; + } + + public String getPropertyvalue() { + return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue; + } + + public void setPropertyvalue(String value) { + gxTv_SdtEventCustomPayload_CustomPayloadItem_N = (byte) (0); + gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue = value; + } + + protected byte gxTv_SdtEventCustomPayload_CustomPayloadItem_N; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue; + protected String gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java index 24155e5d4..2c5c3414e 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessage.java @@ -1,114 +1,100 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; -public final class StructSdtEventMessage implements Cloneable, java.io.Serializable -{ - public StructSdtEventMessage( ) - { - this( -1, new ModelContext( StructSdtEventMessage.class )); - } - - public StructSdtEventMessage( int remoteHandle , - ModelContext context ) - { - java.util.Calendar cal = java.util.Calendar.getInstance(); - cal.set(1, 0, 1, 0, 0, 0); - cal.set(java.util.Calendar.MILLISECOND, 0); - gxTv_SdtEventMessage_Eventmessageid = "" ; - gxTv_SdtEventMessage_Eventmessagedate = cal.getTime() ; - gxTv_SdtEventMessage_Eventmessagesourcetype = "" ; - gxTv_SdtEventMessage_Eventmessagedata = "" ; - gxTv_SdtEventMessage_Eventmessageversion = "" ; - gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(1) ; - gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(1) ; - } - - public Object clone() - { - Object cloned = null; - try - { - cloned = super.clone(); - }catch (CloneNotSupportedException e){ ; } - return cloned; - } - - public String getEventmessageid( ) - { - return gxTv_SdtEventMessage_Eventmessageid ; - } - - public void setEventmessageid( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessageid = value ; - } - - public java.util.Date getEventmessagedate( ) - { - return gxTv_SdtEventMessage_Eventmessagedate ; - } - - public void setEventmessagedate( java.util.Date value ) - { - gxTv_SdtEventMessage_Eventmessagedate_N = (byte)(0) ; - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagedate = value ; - } - - public String getEventmessagesourcetype( ) - { - return gxTv_SdtEventMessage_Eventmessagesourcetype ; - } - - public void setEventmessagesourcetype( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagesourcetype = value ; - } - - public String getEventmessagedata( ) - { - return gxTv_SdtEventMessage_Eventmessagedata ; - } - - public void setEventmessagedata( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagedata = value ; - } - - public String getEventmessageversion( ) - { - return gxTv_SdtEventMessage_Eventmessageversion ; - } - - public void setEventmessageversion( String value ) - { - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessageversion = value ; - } - - public java.util.Vector getEventmessagecustompayload( ) - { - return gxTv_SdtEventMessage_Eventmessagecustompayload ; - } - - public void setEventmessagecustompayload( java.util.Vector value ) - { - gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte)(0) ; - gxTv_SdtEventMessage_N = (byte)(0) ; - gxTv_SdtEventMessage_Eventmessagecustompayload = value ; - } - - protected byte gxTv_SdtEventMessage_Eventmessagedate_N ; - protected byte gxTv_SdtEventMessage_Eventmessagecustompayload_N ; - protected byte gxTv_SdtEventMessage_N ; - protected String gxTv_SdtEventMessage_Eventmessagedata ; - protected String gxTv_SdtEventMessage_Eventmessageid ; - protected String gxTv_SdtEventMessage_Eventmessagesourcetype ; - protected String gxTv_SdtEventMessage_Eventmessageversion ; - protected java.util.Date gxTv_SdtEventMessage_Eventmessagedate ; - protected java.util.Vector gxTv_SdtEventMessage_Eventmessagecustompayload=null ; +public final class StructSdtEventMessage implements Cloneable, java.io.Serializable { + public StructSdtEventMessage() { + this(-1, new ModelContext(StructSdtEventMessage.class)); + } + + public StructSdtEventMessage(int remoteHandle, + ModelContext context) { + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.set(1, 0, 1, 0, 0, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + gxTv_SdtEventMessage_Eventmessageid = ""; + gxTv_SdtEventMessage_Eventmessagedate = cal.getTime(); + gxTv_SdtEventMessage_Eventmessagesourcetype = ""; + gxTv_SdtEventMessage_Eventmessagedata = ""; + gxTv_SdtEventMessage_Eventmessageversion = ""; + gxTv_SdtEventMessage_Eventmessagedate_N = (byte) (1); + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte) (1); + } + + public Object clone() { + Object cloned = null; + try { + cloned = super.clone(); + } catch (CloneNotSupportedException e) { + ; + } + return cloned; + } + + public String getEventmessageid() { + return gxTv_SdtEventMessage_Eventmessageid; + } + + public void setEventmessageid(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessageid = value; + } + + public java.util.Date getEventmessagedate() { + return gxTv_SdtEventMessage_Eventmessagedate; + } + + public void setEventmessagedate(java.util.Date value) { + gxTv_SdtEventMessage_Eventmessagedate_N = (byte) (0); + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagedate = value; + } + + public String getEventmessagesourcetype() { + return gxTv_SdtEventMessage_Eventmessagesourcetype; + } + + public void setEventmessagesourcetype(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagesourcetype = value; + } + + public String getEventmessagedata() { + return gxTv_SdtEventMessage_Eventmessagedata; + } + + public void setEventmessagedata(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagedata = value; + } + + public String getEventmessageversion() { + return gxTv_SdtEventMessage_Eventmessageversion; + } + + public void setEventmessageversion(String value) { + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessageversion = value; + } + + public java.util.Vector getEventmessagecustompayload() { + return gxTv_SdtEventMessage_Eventmessagecustompayload; + } + + public void setEventmessagecustompayload(java.util.Vector value) { + gxTv_SdtEventMessage_Eventmessagecustompayload_N = (byte) (0); + gxTv_SdtEventMessage_N = (byte) (0); + gxTv_SdtEventMessage_Eventmessagecustompayload = value; + } + + protected byte gxTv_SdtEventMessage_Eventmessagedate_N; + protected byte gxTv_SdtEventMessage_Eventmessagecustompayload_N; + protected byte gxTv_SdtEventMessage_N; + protected String gxTv_SdtEventMessage_Eventmessagedata; + protected String gxTv_SdtEventMessage_Eventmessageid; + protected String gxTv_SdtEventMessage_Eventmessagesourcetype; + protected String gxTv_SdtEventMessage_Eventmessageversion; + protected java.util.Date gxTv_SdtEventMessage_Eventmessagedate; + protected java.util.Vector gxTv_SdtEventMessage_Eventmessagecustompayload = null; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java index 35db65564..382542dbf 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessageResponse.java @@ -1,53 +1,47 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; -public final class StructSdtEventMessageResponse implements Cloneable, java.io.Serializable -{ - public StructSdtEventMessageResponse( ) - { - this( -1, new ModelContext( StructSdtEventMessageResponse.class )); - } - - public StructSdtEventMessageResponse( int remoteHandle , - ModelContext context ) - { - gxTv_SdtEventMessageResponse_Errormessage = "" ; - } - - public Object clone() - { - Object cloned = null; - try - { - cloned = super.clone(); - }catch (CloneNotSupportedException e){ ; } - return cloned; - } - - public boolean getHandled( ) - { - return gxTv_SdtEventMessageResponse_Handled ; - } - - public void setHandled( boolean value ) - { - gxTv_SdtEventMessageResponse_N = (byte)(0) ; - gxTv_SdtEventMessageResponse_Handled = value ; - } - - public String getErrormessage( ) - { - return gxTv_SdtEventMessageResponse_Errormessage ; - } - - public void setErrormessage( String value ) - { - gxTv_SdtEventMessageResponse_N = (byte)(0) ; - gxTv_SdtEventMessageResponse_Errormessage = value ; - } - - protected byte gxTv_SdtEventMessageResponse_N ; - protected boolean gxTv_SdtEventMessageResponse_Handled ; - protected String gxTv_SdtEventMessageResponse_Errormessage ; +public final class StructSdtEventMessageResponse implements Cloneable, java.io.Serializable { + public StructSdtEventMessageResponse() { + this(-1, new ModelContext(StructSdtEventMessageResponse.class)); + } + + public StructSdtEventMessageResponse(int remoteHandle, + ModelContext context) { + gxTv_SdtEventMessageResponse_Errormessage = ""; + } + + public Object clone() { + Object cloned = null; + try { + cloned = super.clone(); + } catch (CloneNotSupportedException e) { + ; + } + return cloned; + } + + public boolean getHandled() { + return gxTv_SdtEventMessageResponse_Handled; + } + + public void setHandled(boolean value) { + gxTv_SdtEventMessageResponse_N = (byte) (0); + gxTv_SdtEventMessageResponse_Handled = value; + } + + public String getErrormessage() { + return gxTv_SdtEventMessageResponse_Errormessage; + } + + public void setErrormessage(String value) { + gxTv_SdtEventMessageResponse_N = (byte) (0); + gxTv_SdtEventMessageResponse_Errormessage = value; + } + + protected byte gxTv_SdtEventMessageResponse_N; + protected boolean gxTv_SdtEventMessageResponse_Handled; + protected String gxTv_SdtEventMessageResponse_Errormessage; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java index 7152ae550..18a558a2d 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/StructSdtEventMessages.java @@ -1,43 +1,39 @@ package com.genexus.genexusserverlessapi; + import com.genexus.*; -public final class StructSdtEventMessages implements Cloneable, java.io.Serializable -{ - public StructSdtEventMessages( ) - { - this( -1, new ModelContext( StructSdtEventMessages.class )); - } - - public StructSdtEventMessages( int remoteHandle , - ModelContext context ) - { - gxTv_SdtEventMessages_Eventmessage_N = (byte)(1) ; - } - - public Object clone() - { - Object cloned = null; - try - { - cloned = super.clone(); - }catch (CloneNotSupportedException e){ ; } - return cloned; - } - - public java.util.Vector getEventmessage( ) - { - return gxTv_SdtEventMessages_Eventmessage ; - } - - public void setEventmessage( java.util.Vector value ) - { - gxTv_SdtEventMessages_Eventmessage_N = (byte)(0) ; - gxTv_SdtEventMessages_N = (byte)(0) ; - gxTv_SdtEventMessages_Eventmessage = value ; - } - - protected byte gxTv_SdtEventMessages_Eventmessage_N ; - protected byte gxTv_SdtEventMessages_N ; - protected java.util.Vector gxTv_SdtEventMessages_Eventmessage=null ; +public final class StructSdtEventMessages implements Cloneable, java.io.Serializable { + public StructSdtEventMessages() { + this(-1, new ModelContext(StructSdtEventMessages.class)); + } + + public StructSdtEventMessages(int remoteHandle, + ModelContext context) { + gxTv_SdtEventMessages_Eventmessage_N = (byte) (1); + } + + public Object clone() { + Object cloned = null; + try { + cloned = super.clone(); + } catch (CloneNotSupportedException e) { + ; + } + return cloned; + } + + public java.util.Vector getEventmessage() { + return gxTv_SdtEventMessages_Eventmessage; + } + + public void setEventmessage(java.util.Vector value) { + gxTv_SdtEventMessages_Eventmessage_N = (byte) (0); + gxTv_SdtEventMessages_N = (byte) (0); + gxTv_SdtEventMessages_Eventmessage = value; + } + + protected byte gxTv_SdtEventMessages_Eventmessage_N; + protected byte gxTv_SdtEventMessages_N; + protected java.util.Vector gxTv_SdtEventMessages_Eventmessage = null; } diff --git a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/EchoJerseyResource.java b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/EchoJerseyResource.java index 94e0afd40..7508e8810 100644 --- a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/EchoJerseyResource.java +++ b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/EchoJerseyResource.java @@ -37,83 +37,83 @@ @Path("/echo") public class EchoJerseyResource { - @Path("/hola") - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response hola(@Context ContainerRequestContext context) { - MapResponseModel headers = new MapResponseModel(); - headers.addValue("key", "hola"); - - return Response.status(200).entity(headers).build(); - } - - @Path("/headers") - @GET - @Produces(MediaType.APPLICATION_JSON) - public MapResponseModel echoHeaders(@Context ContainerRequestContext context) { - MapResponseModel headers = new MapResponseModel(); - for (String key : context.getHeaders().keySet()) { - headers.addValue(key, context.getHeaderString(key)); - } - - return headers; - } - - @Path("/servlet-headers") - @GET - @Produces(MediaType.APPLICATION_JSON) - public MapResponseModel echoServletHeaders(@Context HttpServletRequest context) { - MapResponseModel headers = new MapResponseModel(); - Enumeration headerNames = context.getHeaderNames(); - while (headerNames.hasMoreElements()) { - String headerName = headerNames.nextElement(); - headers.addValue(headerName, context.getHeader(headerName)); - } - - return headers; - } - - @Path("/query-string") - @GET - @Produces(MediaType.APPLICATION_JSON) - public MapResponseModel echoQueryString(@Context UriInfo context) { - MapResponseModel queryStrings = new MapResponseModel(); - for (String key : context.getQueryParameters().keySet()) { - queryStrings.addValue(key, context.getQueryParameters().getFirst(key)); - } - - return queryStrings; - } - - - @Path("/json-body") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public SingleValueModel echoJsonValue(final SingleValueModel requestValue) { - SingleValueModel output = new SingleValueModel(); - output.setValue(requestValue.getValue()); - - return output; - } - - @Path("/status-code") - @GET - @Produces(MediaType.APPLICATION_JSON) - public Response echoCustomStatusCode(@QueryParam("status") int statusCode) { - SingleValueModel output = new SingleValueModel(); - output.setValue("" + statusCode); - - return Response.status(statusCode).entity(output).build(); - } - - @Path("/binary") - @GET - @Produces("application/octet-stream") - public Response echoBinaryData() { - byte[] b = new byte[128]; - new Random().nextBytes(b); - - return Response.ok(b).build(); - } + @Path("/hola") + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response hola(@Context ContainerRequestContext context) { + MapResponseModel headers = new MapResponseModel(); + headers.addValue("key", "hola"); + + return Response.status(200).entity(headers).build(); + } + + @Path("/headers") + @GET + @Produces(MediaType.APPLICATION_JSON) + public MapResponseModel echoHeaders(@Context ContainerRequestContext context) { + MapResponseModel headers = new MapResponseModel(); + for (String key : context.getHeaders().keySet()) { + headers.addValue(key, context.getHeaderString(key)); + } + + return headers; + } + + @Path("/servlet-headers") + @GET + @Produces(MediaType.APPLICATION_JSON) + public MapResponseModel echoServletHeaders(@Context HttpServletRequest context) { + MapResponseModel headers = new MapResponseModel(); + Enumeration headerNames = context.getHeaderNames(); + while (headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + headers.addValue(headerName, context.getHeader(headerName)); + } + + return headers; + } + + @Path("/query-string") + @GET + @Produces(MediaType.APPLICATION_JSON) + public MapResponseModel echoQueryString(@Context UriInfo context) { + MapResponseModel queryStrings = new MapResponseModel(); + for (String key : context.getQueryParameters().keySet()) { + queryStrings.addValue(key, context.getQueryParameters().getFirst(key)); + } + + return queryStrings; + } + + + @Path("/json-body") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public SingleValueModel echoJsonValue(final SingleValueModel requestValue) { + SingleValueModel output = new SingleValueModel(); + output.setValue(requestValue.getValue()); + + return output; + } + + @Path("/status-code") + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response echoCustomStatusCode(@QueryParam("status") int statusCode) { + SingleValueModel output = new SingleValueModel(); + output.setValue("" + statusCode); + + return Response.status(statusCode).entity(output).build(); + } + + @Path("/binary") + @GET + @Produces("application/octet-stream") + public Response echoBinaryData() { + byte[] b = new byte[128]; + new Random().nextBytes(b); + + return Response.ok(b).build(); + } } diff --git a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java index 7ef778507..fa5155b32 100644 --- a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java +++ b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java @@ -37,59 +37,59 @@ * Unit test class for the Jersey AWS_PROXY default implementation */ public class GeneXusAppAwsProxyTest { - private static final String CUSTOM_HEADER_KEY = "x-custom-header"; - private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; - - private ResourceConfig app; - private LambdaHandler l; - - @Before - public void setUpStreams() { - try { - System.setProperty("LAMBDA_TASK_ROOT", "."); - l = new LambdaHandler(); - handler = LambdaHandler.handler; - } catch (Exception e) { - e.printStackTrace(); - } - } + private static final String CUSTOM_HEADER_KEY = "x-custom-header"; + private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; + + private ResourceConfig app; + private LambdaHandler l; + + @Before + public void setUpStreams() { + try { + System.setProperty("LAMBDA_TASK_ROOT", "."); + l = new LambdaHandler(); + handler = LambdaHandler.handler; + } catch (Exception e) { + e.printStackTrace(); + } + } - public GeneXusAppAwsProxyTest() { + public GeneXusAppAwsProxyTest() { - } + } - private JerseyLambdaContainerHandler handler = null; + private JerseyLambdaContainerHandler handler = null; - private static ObjectMapper objectMapper = new ObjectMapper(); + private static ObjectMapper objectMapper = new ObjectMapper(); - private static Context lambdaContext = new MockLambdaContext(); + private static Context lambdaContext = new MockLambdaContext(); - @Test - public void testGXDataProvider() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/Test", "GET") - .queryString("Itemnumber", "9") - .json() - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); + @Test + public void testGXDataProvider() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/Test", "GET") + .queryString("Itemnumber", "9") + .json() + .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals("{\"ItemId\":9,\"ItemName\":\"9 Item\"}", output.getBody()); - } + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + assertEquals("{\"ItemId\":9,\"ItemName\":\"9 Item\"}", output.getBody()); + } - @Test - public void testGXDataProviderWithParams() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/Test/12", "GET") - .queryString("Itemnumber", "9") - .json() - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); + @Test + public void testGXDataProviderWithParams() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/Test/12", "GET") + .queryString("Itemnumber", "9") + .json() + .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertEquals("{\"ItemId\":12,\"ItemName\":\"12 Item\"}", output.getBody()); - } + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + assertEquals("{\"ItemId\":12,\"ItemName\":\"12 Item\"}", output.getBody()); + } @Test public void testGxMultiCall() { @@ -119,18 +119,18 @@ public void testUpload() { @Test @Ignore - public void gxTestOAuthAccessToken() { + public void gxTestOAuthAccessToken() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/oauth/access_token", "POST") - .body("client_id=b0be5400435f42e588480fa06330f5ff&grant_type=password&username=ggallotti&password=gonzalo&scope=FullControl") - .header("Content-Type", "application/x-www-form-urlencoded") - //.header("Content-Length", "116") - .build(); + AwsProxyRequest request = new AwsProxyRequestBuilder("/oauth/access_token", "POST") + .body("client_id=b0be5400435f42e588480fa06330f5ff&grant_type=password&username=ggallotti&password=gonzalo&scope=FullControl") + .header("Content-Type", "application/x-www-form-urlencoded") + //.header("Content-Length", "116") + .build(); - AwsProxyResponse output = l.handleRequest(request, lambdaContext); - System.out.println(output); - //assertEquals(200, output.getStatusCode()); + AwsProxyResponse output = l.handleRequest(request, lambdaContext); + System.out.println(output); + //assertEquals(200, output.getStatusCode()); - } + } } diff --git a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java index 5b589dbbb..cd36d037e 100644 --- a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java +++ b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java @@ -50,147 +50,147 @@ * Unit test class for the Jersey AWS_PROXY default implementation */ public class JerseyAwsProxyTest { - private static final String CUSTOM_HEADER_KEY = "x-custom-header"; - private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; - - private ResourceConfig app; - private LambdaHandler l; - - @Before - public void setUpStreams() { - try { - System.setProperty("LAMBDA_TASK_ROOT", "."); - l = new LambdaHandler(); - handler = LambdaHandler.handler; - } catch (Exception e) { - e.printStackTrace(); - } - } - - public JerseyAwsProxyTest() { - - } - - private JerseyLambdaContainerHandler handler = null; - - private static ObjectMapper objectMapper = new ObjectMapper(); - - private static Context lambdaContext = new MockLambdaContext(); - - - @Test - public void headers_getHeaders_echo() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/headers", "GET") - .json() - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - } - - @Test - public void headers_servletRequest_echo() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/servlet-headers", "GET") - .json() - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - validateMapResponseModel(output); - } - - @Test - public void queryString_uriInfo_echo() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/query-string", "GET") - .json() - .queryString(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - validateMapResponseModel(output); - } - - - @Test - public void errors_unknownRoute_expect404() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/test33", "GET").build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(404, output.getStatusCode()); - } - - @Test - public void error_contentType_invalidContentType() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") - .header("Content-Type", "application/octet-stream") - .body("asdasdasd") - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(415, output.getStatusCode()); - } - - @Test - public void error_statusCode_methodNotAllowed() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "POST") - .json() - .queryString("status", "201") - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(405, output.getStatusCode()); - } - - @Test - public void responseBody_responseWriter_validBody() throws JsonProcessingException { - SingleValueModel singleValueModel = new SingleValueModel(); - singleValueModel.setValue(CUSTOM_HEADER_VALUE); - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") - .json() - .body(objectMapper.writeValueAsString(singleValueModel)) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertNotNull(output.getBody()); - - validateSingleValueModel(output, CUSTOM_HEADER_VALUE); - } - - @Test - public void statusCode_responseStatusCode_customStatusCode() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "GET") - .json() - .queryString("status", "201") - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(201, output.getStatusCode()); - } - - - private void validateMapResponseModel(AwsProxyResponse output) { - try { - MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class); - assertNotNull(response.getValues().get(CUSTOM_HEADER_KEY)); - assertEquals(CUSTOM_HEADER_VALUE, response.getValues().get(CUSTOM_HEADER_KEY)); - } catch (IOException e) { - fail("Exception while parsing response body: " + e.getMessage()); - e.printStackTrace(); - } - } - - private void validateSingleValueModel(AwsProxyResponse output, String value) { - try { - SingleValueModel response = objectMapper.readValue(output.getBody(), SingleValueModel.class); - assertNotNull(response.getValue()); - assertEquals(value, response.getValue()); - } catch (IOException e) { - fail("Exception while parsing response body: " + e.getMessage()); - e.printStackTrace(); - } - } + private static final String CUSTOM_HEADER_KEY = "x-custom-header"; + private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; + + private ResourceConfig app; + private LambdaHandler l; + + @Before + public void setUpStreams() { + try { + System.setProperty("LAMBDA_TASK_ROOT", "."); + l = new LambdaHandler(); + handler = LambdaHandler.handler; + } catch (Exception e) { + e.printStackTrace(); + } + } + + public JerseyAwsProxyTest() { + + } + + private JerseyLambdaContainerHandler handler = null; + + private static ObjectMapper objectMapper = new ObjectMapper(); + + private static Context lambdaContext = new MockLambdaContext(); + + + @Test + public void headers_getHeaders_echo() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/headers", "GET") + .json() + .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + } + + @Test + public void headers_servletRequest_echo() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/servlet-headers", "GET") + .json() + .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + validateMapResponseModel(output); + } + + @Test + public void queryString_uriInfo_echo() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/query-string", "GET") + .json() + .queryString(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + validateMapResponseModel(output); + } + + + @Test + public void errors_unknownRoute_expect404() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/test33", "GET").build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(404, output.getStatusCode()); + } + + @Test + public void error_contentType_invalidContentType() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") + .header("Content-Type", "application/octet-stream") + .body("asdasdasd") + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(415, output.getStatusCode()); + } + + @Test + public void error_statusCode_methodNotAllowed() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "POST") + .json() + .queryString("status", "201") + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(405, output.getStatusCode()); + } + + @Test + public void responseBody_responseWriter_validBody() throws JsonProcessingException { + SingleValueModel singleValueModel = new SingleValueModel(); + singleValueModel.setValue(CUSTOM_HEADER_VALUE); + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") + .json() + .body(objectMapper.writeValueAsString(singleValueModel)) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + assertNotNull(output.getBody()); + + validateSingleValueModel(output, CUSTOM_HEADER_VALUE); + } + + @Test + public void statusCode_responseStatusCode_customStatusCode() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "GET") + .json() + .queryString("status", "201") + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(201, output.getStatusCode()); + } + + + private void validateMapResponseModel(AwsProxyResponse output) { + try { + MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class); + assertNotNull(response.getValues().get(CUSTOM_HEADER_KEY)); + assertEquals(CUSTOM_HEADER_VALUE, response.getValues().get(CUSTOM_HEADER_KEY)); + } catch (IOException e) { + fail("Exception while parsing response body: " + e.getMessage()); + e.printStackTrace(); + } + } + + private void validateSingleValueModel(AwsProxyResponse output, String value) { + try { + SingleValueModel response = objectMapper.readValue(output.getBody(), SingleValueModel.class); + assertNotNull(response.getValue()); + assertEquals(value, response.getValue()); + } catch (IOException e) { + fail("Exception while parsing response body: " + e.getMessage()); + e.printStackTrace(); + } + } } diff --git a/gxawsserverless/src/test/java/com/gx/serverless/test/GXApplication.java b/gxawsserverless/src/test/java/com/gx/serverless/test/GXApplication.java index e856392ad..854fa68d9 100644 --- a/gxawsserverless/src/test/java/com/gx/serverless/test/GXApplication.java +++ b/gxawsserverless/src/test/java/com/gx/serverless/test/GXApplication.java @@ -7,19 +7,19 @@ Main DBMS: SQL Server */ package com.gx.serverless.test; + import java.util.*; import javax.ws.rs.core.Application; + import com.genexus.webpanels.WebUtils; -public final class GXApplication extends Application -{ - public Set> getClasses( ) - { - Set> rrcs = new HashSet>(); - WebUtils.getGXApplicationClasses( getClass(), rrcs); - WebUtils.AddExternalServices( getClass(), rrcs); - return rrcs ; - } +public final class GXApplication extends Application { + public Set> getClasses() { + Set> rrcs = new HashSet>(); + WebUtils.getGXApplicationClasses(getClass(), rrcs); + WebUtils.AddExternalServices(getClass(), rrcs); + return rrcs; + } } diff --git a/gxawsserverless/src/test/java/com/gx/serverless/test/GXcfg.java b/gxawsserverless/src/test/java/com/gx/serverless/test/GXcfg.java index 4c9217142..07c1321fb 100644 --- a/gxawsserverless/src/test/java/com/gx/serverless/test/GXcfg.java +++ b/gxawsserverless/src/test/java/com/gx/serverless/test/GXcfg.java @@ -7,19 +7,19 @@ Main DBMS: SQL Server */ package com.gx.serverless.test; + import com.gx.serverless.*; import com.genexus.*; import com.genexus.db.*; import com.genexus.search.*; + import java.sql.*; -public final class GXcfg -{ - public static int strcmp( String Left , - String Right ) - { - return GXutil.rtrim(Left).compareTo(GXutil.rtrim(Right)); - } +public final class GXcfg { + public static int strcmp(String Left, + String Right) { + return GXutil.rtrim(Left).compareTo(GXutil.rtrim(Right)); + } } diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java index ce29d5c1c..a30d1e4cd 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java @@ -1,664 +1,567 @@ package com.unittest.eventdriven; + import com.unittest.*; import com.genexus.*; import com.genexus.xml.*; import com.genexus.search.*; import com.genexus.webpanels.*; + import java.util.*; -public final class SdtUser extends GxSilentTrnSdt -{ - public SdtUser( int remoteHandle ) - { - this( remoteHandle, new ModelContext(SdtUser.class)); - } - - public SdtUser( int remoteHandle , - ModelContext context ) - { - super( remoteHandle, context, "SdtUser"); - initialize() ; - } - - public SdtUser( int remoteHandle , - StructSdtUser struct ) - { - this(remoteHandle); - setStruct(struct); - } - - private static HashMap mapper = new HashMap(); - static - { - } - - public String getJsonMap( String value ) - { - return (String) mapper.get(value); - } - - public void Load( UUID AV4UserId ) - { - IGxSilentTrn obj; - obj = getTransaction() ; - obj.LoadKey(new Object[] {AV4UserId}); - } - - public void LoadStrParms( String sAV4UserId ) - { - UUID AV4UserId; - AV4UserId = GXutil.strToGuid(sAV4UserId) ; - Load( AV4UserId) ; - } - - public Object[][] GetBCKey( ) - { - return (Object[][])(new Object[][]{new Object[]{"UserId", UUID.class}}) ; - } - - public com.genexus.util.GXProperties getMetadata( ) - { - com.genexus.util.GXProperties metadata = new com.genexus.util.GXProperties(); - metadata.set("Name", "EventDriven\\User"); - metadata.set("BT", "User"); - metadata.set("PK", "[ \"UserId\" ]"); - metadata.set("PKAssigned", "[ \"UserId\" ]"); - metadata.set("AllowInsert", "True"); - metadata.set("AllowUpdate", "True"); - metadata.set("AllowDelete", "True"); - return metadata ; - } - - public short readxml( XMLReader oReader , - String sName ) - { - short GXSoapError = 1; - formatError = false ; - sTagName = oReader.getName() ; - if ( oReader.getIsSimple() == 0 ) - { - GXSoapError = oReader.read() ; - nOutParmCount = (short)(0) ; - while ( ( ( GXutil.strcmp(oReader.getName(), sTagName) != 0 ) || ( oReader.getNodeType() == 1 ) ) && ( GXSoapError > 0 ) ) - { - readOk = (short)(0) ; - readElement = false ; - if ( GXutil.strcmp2( oReader.getLocalName(), "UserId") ) - { - gxTv_SdtUser_Userid = GXutil.strToGuid(oReader.getValue()) ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "UserName") ) - { - gxTv_SdtUser_Username = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "UserRegisteredDateTime") ) - { - if ( ( GXutil.strcmp(oReader.getValue(), "") == 0 ) || ( oReader.existsAttribute("xsi:nil") == 1 ) ) - { - gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime( GXutil.nullDate() ); - } - else - { - gxTv_SdtUser_Userregistereddatetime = localUtil.ymdhmsToT( (short)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 1, 4), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 6, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 9, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 12, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 15, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 18, 2), ".")))) ; - } - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "UserEventMessageData") ) - { - gxTv_SdtUser_Usereventmessagedata = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "Mode") ) - { - gxTv_SdtUser_Mode = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "Initialized") ) - { - gxTv_SdtUser_Initialized = (short)(getnumericvalue(oReader.getValue())) ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "UserId_Z") ) - { - gxTv_SdtUser_Userid_Z = GXutil.strToGuid(oReader.getValue()) ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "UserName_Z") ) - { - gxTv_SdtUser_Username_Z = oReader.getValue() ; - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( GXutil.strcmp2( oReader.getLocalName(), "UserRegisteredDateTime_Z") ) - { - if ( ( GXutil.strcmp(oReader.getValue(), "") == 0 ) || ( oReader.existsAttribute("xsi:nil") == 1 ) ) - { - gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime( GXutil.nullDate() ); - } - else - { - gxTv_SdtUser_Userregistereddatetime_Z = localUtil.ymdhmsToT( (short)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 1, 4), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 6, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 9, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 12, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 15, 2), "."))), (byte)(DecimalUtil.decToDouble(CommonUtil.decimalVal( GXutil.substring( oReader.getValue(), 18, 2), ".")))) ; - } - readElement = true ; - if ( GXSoapError > 0 ) - { - readOk = (short)(1) ; - } - GXSoapError = oReader.read() ; - } - if ( ! readElement ) - { - readOk = (short)(1) ; - GXSoapError = oReader.read() ; - } - nOutParmCount = (short)(nOutParmCount+1) ; - if ( ( readOk == 0 ) || formatError ) - { - context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine( ) ; - context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML() ; - GXSoapError = (short)(nOutParmCount*-1) ; - } - } - } - return GXSoapError ; - } - - public void writexml( XMLWriter oWriter , - String sName , - String sNameSpace ) - { - writexml(oWriter, sName, sNameSpace, true); - } - - public void writexml( XMLWriter oWriter , - String sName , - String sNameSpace , - boolean sIncludeState ) - { - if ( (GXutil.strcmp("", sName)==0) ) - { - sName = "User" ; - } - if ( (GXutil.strcmp("", sNameSpace)==0) ) - { - sNameSpace = "Issue95858" ; - } - oWriter.writeStartElement(sName); - if ( GXutil.strcmp(GXutil.left( sNameSpace, 10), "[*:nosend]") != 0 ) - { - oWriter.writeAttribute("xmlns", sNameSpace); - } - else - { - sNameSpace = GXutil.right( sNameSpace, GXutil.len( sNameSpace)-10) ; - } - oWriter.writeElement("UserId", gxTv_SdtUser_Userid.toString()); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserName", gxTv_SdtUser_Username); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - sDateCnv = "" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.year( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; - sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.month( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.day( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "T" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.second( gxTv_SdtUser_Userregistereddatetime), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - oWriter.writeElement("UserRegisteredDateTime", sDateCnv); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - if ( sIncludeState ) - { - oWriter.writeElement("Mode", gxTv_SdtUser_Mode); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("Initialized", GXutil.trim( GXutil.str( gxTv_SdtUser_Initialized, 4, 0))); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserId_Z", gxTv_SdtUser_Userid_Z.toString()); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserName_Z", gxTv_SdtUser_Username_Z); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - sDateCnv = "" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.year( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; - sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.month( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.day( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "T" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.second( gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - oWriter.writeElement("UserRegisteredDateTime_Z", sDateCnv); - if ( GXutil.strcmp(sNameSpace, "Issue95858") != 0 ) - { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - } - oWriter.writeEndElement(); - } - - public long getnumericvalue( String value ) - { - if ( GXutil.notNumeric( value) ) - { - formatError = true ; - } - return GXutil.lval( value) ; - } - - public void tojson( ) - { - tojson( true) ; - } - - public void tojson( boolean includeState ) - { - tojson( includeState, true) ; - } - - public void tojson( boolean includeState , - boolean includeNonInitialized ) - { - AddObjectProperty("UserId", gxTv_SdtUser_Userid, false, includeNonInitialized); - AddObjectProperty("UserName", gxTv_SdtUser_Username, false, includeNonInitialized); - datetime_STZ = gxTv_SdtUser_Userregistereddatetime ; - sDateCnv = "" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.year( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.month( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.day( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "T" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.second( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - AddObjectProperty("UserRegisteredDateTime", sDateCnv, false, includeNonInitialized); - AddObjectProperty("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata, false, includeNonInitialized); - if ( includeState ) - { - AddObjectProperty("Mode", gxTv_SdtUser_Mode, false, includeNonInitialized); - AddObjectProperty("Initialized", gxTv_SdtUser_Initialized, false, includeNonInitialized); - AddObjectProperty("UserId_Z", gxTv_SdtUser_Userid_Z, false, includeNonInitialized); - AddObjectProperty("UserName_Z", gxTv_SdtUser_Username_Z, false, includeNonInitialized); - datetime_STZ = gxTv_SdtUser_Userregistereddatetime_Z ; - sDateCnv = "" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.year( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "0000", 1, 4-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.month( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "-" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.day( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += "T" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.hour( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.minute( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - sDateCnv += ":" ; - sNumToPad = GXutil.trim( GXutil.str( GXutil.second( datetime_STZ), 10, 0)) ; - sDateCnv += GXutil.substring( "00", 1, 2-GXutil.len( sNumToPad)) + sNumToPad ; - AddObjectProperty("UserRegisteredDateTime_Z", sDateCnv, false, includeNonInitialized); - } - } - - public void updateDirties( SdtUser sdt ) - { - if ( sdt.IsDirty("UserId") ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Userid = sdt.getgxTv_SdtUser_Userid() ; - } - if ( sdt.IsDirty("UserName") ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Username = sdt.getgxTv_SdtUser_Username() ; - } - if ( sdt.IsDirty("UserRegisteredDateTime") ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Userregistereddatetime = sdt.getgxTv_SdtUser_Userregistereddatetime() ; - } - if ( sdt.IsDirty("UserEventMessageData") ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Usereventmessagedata = sdt.getgxTv_SdtUser_Usereventmessagedata() ; - } - } - - public UUID getgxTv_SdtUser_Userid( ) - { - return gxTv_SdtUser_Userid ; - } - - public void setgxTv_SdtUser_Userid( UUID value ) - { - gxTv_SdtUser_N = (byte)(0) ; - if ( !( gxTv_SdtUser_Userid.equals( value ) ) ) - { - gxTv_SdtUser_Mode = "INS" ; - this.setgxTv_SdtUser_Userid_Z_SetNull( ); - this.setgxTv_SdtUser_Username_Z_SetNull( ); - this.setgxTv_SdtUser_Userregistereddatetime_Z_SetNull( ); - } - SetDirty("Userid"); - gxTv_SdtUser_Userid = value ; - } - - public String getgxTv_SdtUser_Username( ) - { - return gxTv_SdtUser_Username ; - } - - public void setgxTv_SdtUser_Username( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Username"); - gxTv_SdtUser_Username = value ; - } - - public Date getgxTv_SdtUser_Userregistereddatetime( ) - { - return gxTv_SdtUser_Userregistereddatetime ; - } - - public void setgxTv_SdtUser_Userregistereddatetime( Date value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Userregistereddatetime"); - gxTv_SdtUser_Userregistereddatetime = value ; - } - - public String getgxTv_SdtUser_Usereventmessagedata( ) - { - return gxTv_SdtUser_Usereventmessagedata ; - } - - public void setgxTv_SdtUser_Usereventmessagedata( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Usereventmessagedata"); - gxTv_SdtUser_Usereventmessagedata = value ; - } - - public String getgxTv_SdtUser_Mode( ) - { - return gxTv_SdtUser_Mode ; - } - - public void setgxTv_SdtUser_Mode( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Mode"); - gxTv_SdtUser_Mode = value ; - } - - public void setgxTv_SdtUser_Mode_SetNull( ) - { - gxTv_SdtUser_Mode = "" ; - SetDirty("Mode"); - } - - public boolean getgxTv_SdtUser_Mode_IsNull( ) - { - return false ; - } - - public short getgxTv_SdtUser_Initialized( ) - { - return gxTv_SdtUser_Initialized ; - } - - public void setgxTv_SdtUser_Initialized( short value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Initialized"); - gxTv_SdtUser_Initialized = value ; - } - - public void setgxTv_SdtUser_Initialized_SetNull( ) - { - gxTv_SdtUser_Initialized = (short)(0) ; - SetDirty("Initialized"); - } - - public boolean getgxTv_SdtUser_Initialized_IsNull( ) - { - return false ; - } - - public UUID getgxTv_SdtUser_Userid_Z( ) - { - return gxTv_SdtUser_Userid_Z ; - } - - public void setgxTv_SdtUser_Userid_Z( UUID value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Userid_Z"); - gxTv_SdtUser_Userid_Z = value ; - } - - public void setgxTv_SdtUser_Userid_Z_SetNull( ) - { - gxTv_SdtUser_Userid_Z = UUID.fromString("00000000-0000-0000-0000-000000000000") ; - SetDirty("Userid_Z"); - } - - public boolean getgxTv_SdtUser_Userid_Z_IsNull( ) - { - return false ; - } - - public String getgxTv_SdtUser_Username_Z( ) - { - return gxTv_SdtUser_Username_Z ; - } - - public void setgxTv_SdtUser_Username_Z( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Username_Z"); - gxTv_SdtUser_Username_Z = value ; - } - - public void setgxTv_SdtUser_Username_Z_SetNull( ) - { - gxTv_SdtUser_Username_Z = "" ; - SetDirty("Username_Z"); - } - - public boolean getgxTv_SdtUser_Username_Z_IsNull( ) - { - return false ; - } - - public Date getgxTv_SdtUser_Userregistereddatetime_Z( ) - { - return gxTv_SdtUser_Userregistereddatetime_Z ; - } - - public void setgxTv_SdtUser_Userregistereddatetime_Z( Date value ) - { - gxTv_SdtUser_N = (byte)(0) ; - SetDirty("Userregistereddatetime_Z"); - gxTv_SdtUser_Userregistereddatetime_Z = value ; - } - - public void setgxTv_SdtUser_Userregistereddatetime_Z_SetNull( ) - { - gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime( GXutil.nullDate() ); - SetDirty("Userregistereddatetime_Z"); - } - - public boolean getgxTv_SdtUser_Userregistereddatetime_Z_IsNull( ) - { - return false ; - } - - - public void initialize( ) - { - gxTv_SdtUser_Userid = UUID.fromString("00000000-0000-0000-0000-000000000000") ; - gxTv_SdtUser_N = (byte)(1) ; - gxTv_SdtUser_Username = "" ; - gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime( GXutil.nullDate() ); - gxTv_SdtUser_Usereventmessagedata = "" ; - gxTv_SdtUser_Mode = "" ; - gxTv_SdtUser_Userid_Z = UUID.fromString("00000000-0000-0000-0000-000000000000") ; - gxTv_SdtUser_Username_Z = "" ; - gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime( GXutil.nullDate() ); - sTagName = "" ; - sDateCnv = "" ; - sNumToPad = "" ; - datetime_STZ = GXutil.resetTime( GXutil.nullDate() ); - } - - public byte isNull( ) - { - return gxTv_SdtUser_N ; - } - - - public void setStruct( com.unittest.eventdriven.StructSdtUser struct ) - { - setgxTv_SdtUser_Userid(struct.getUserid()); - setgxTv_SdtUser_Username(struct.getUsername()); - setgxTv_SdtUser_Userregistereddatetime(struct.getUserregistereddatetime()); - setgxTv_SdtUser_Usereventmessagedata(struct.getUsereventmessagedata()); - setgxTv_SdtUser_Mode(struct.getMode()); - setgxTv_SdtUser_Initialized(struct.getInitialized()); - setgxTv_SdtUser_Userid_Z(struct.getUserid_Z()); - setgxTv_SdtUser_Username_Z(struct.getUsername_Z()); - setgxTv_SdtUser_Userregistereddatetime_Z(struct.getUserregistereddatetime_Z()); - } - - @SuppressWarnings("unchecked") - public com.unittest.eventdriven.StructSdtUser getStruct( ) - { - com.unittest.eventdriven.StructSdtUser struct = new com.unittest.eventdriven.StructSdtUser (); - struct.setUserid(getgxTv_SdtUser_Userid()); - struct.setUsername(getgxTv_SdtUser_Username()); - struct.setUserregistereddatetime(getgxTv_SdtUser_Userregistereddatetime()); - struct.setUsereventmessagedata(getgxTv_SdtUser_Usereventmessagedata()); - struct.setMode(getgxTv_SdtUser_Mode()); - struct.setInitialized(getgxTv_SdtUser_Initialized()); - struct.setUserid_Z(getgxTv_SdtUser_Userid_Z()); - struct.setUsername_Z(getgxTv_SdtUser_Username_Z()); - struct.setUserregistereddatetime_Z(getgxTv_SdtUser_Userregistereddatetime_Z()); - return struct ; - } - - private byte gxTv_SdtUser_N ; - private short gxTv_SdtUser_Initialized ; - private short readOk ; - private short nOutParmCount ; - private String gxTv_SdtUser_Username ; - private String gxTv_SdtUser_Mode ; - private String gxTv_SdtUser_Username_Z ; - private String sTagName ; - private String sDateCnv ; - private String sNumToPad ; - private Date gxTv_SdtUser_Userregistereddatetime ; - private Date gxTv_SdtUser_Userregistereddatetime_Z ; - private Date datetime_STZ ; - private boolean readElement ; - private boolean formatError ; - private String gxTv_SdtUser_Usereventmessagedata ; - private UUID AV4UserId ; - private UUID gxTv_SdtUser_Userid ; - private UUID gxTv_SdtUser_Userid_Z ; +public final class SdtUser extends GxSilentTrnSdt { + public SdtUser(int remoteHandle) { + this(remoteHandle, new ModelContext(SdtUser.class)); + } + + public SdtUser(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, "SdtUser"); + initialize(); + } + + public SdtUser(int remoteHandle, + StructSdtUser struct) { + this(remoteHandle); + setStruct(struct); + } + + private static HashMap mapper = new HashMap(); + + static { + } + + public String getJsonMap(String value) { + return (String) mapper.get(value); + } + + public void Load(UUID AV4UserId) { + IGxSilentTrn obj; + obj = getTransaction(); + obj.LoadKey(new Object[]{AV4UserId}); + } + + public void LoadStrParms(String sAV4UserId) { + UUID AV4UserId; + AV4UserId = GXutil.strToGuid(sAV4UserId); + Load(AV4UserId); + } + + public Object[][] GetBCKey() { + return (Object[][]) (new Object[][]{new Object[]{"UserId", UUID.class}}); + } + + public com.genexus.util.GXProperties getMetadata() { + com.genexus.util.GXProperties metadata = new com.genexus.util.GXProperties(); + metadata.set("Name", "EventDriven\\User"); + metadata.set("BT", "User"); + metadata.set("PK", "[ \"UserId\" ]"); + metadata.set("PKAssigned", "[ \"UserId\" ]"); + metadata.set("AllowInsert", "True"); + metadata.set("AllowUpdate", "True"); + metadata.set("AllowDelete", "True"); + return metadata; + } + + public short readxml(XMLReader oReader, + String sName) { + short GXSoapError = 1; + formatError = false; + sTagName = oReader.getName(); + if (oReader.getIsSimple() == 0) { + GXSoapError = oReader.read(); + nOutParmCount = (short) (0); + while (((GXutil.strcmp(oReader.getName(), sTagName) != 0) || (oReader.getNodeType() == 1)) && (GXSoapError > 0)) { + readOk = (short) (0); + readElement = false; + if (GXutil.strcmp2(oReader.getLocalName(), "UserId")) { + gxTv_SdtUser_Userid = GXutil.strToGuid(oReader.getValue()); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "UserName")) { + gxTv_SdtUser_Username = oReader.getValue(); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "UserRegisteredDateTime")) { + if ((GXutil.strcmp(oReader.getValue(), "") == 0) || (oReader.existsAttribute("xsi:nil") == 1)) { + gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime(GXutil.nullDate()); + } else { + gxTv_SdtUser_Userregistereddatetime = localUtil.ymdhmsToT((short) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 1, 4), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 6, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 9, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 12, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 15, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 18, 2), ".")))); + } + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "UserEventMessageData")) { + gxTv_SdtUser_Usereventmessagedata = oReader.getValue(); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "Mode")) { + gxTv_SdtUser_Mode = oReader.getValue(); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "Initialized")) { + gxTv_SdtUser_Initialized = (short) (getnumericvalue(oReader.getValue())); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "UserId_Z")) { + gxTv_SdtUser_Userid_Z = GXutil.strToGuid(oReader.getValue()); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "UserName_Z")) { + gxTv_SdtUser_Username_Z = oReader.getValue(); + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (GXutil.strcmp2(oReader.getLocalName(), "UserRegisteredDateTime_Z")) { + if ((GXutil.strcmp(oReader.getValue(), "") == 0) || (oReader.existsAttribute("xsi:nil") == 1)) { + gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime(GXutil.nullDate()); + } else { + gxTv_SdtUser_Userregistereddatetime_Z = localUtil.ymdhmsToT((short) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 1, 4), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 6, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 9, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 12, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 15, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 18, 2), ".")))); + } + readElement = true; + if (GXSoapError > 0) { + readOk = (short) (1); + } + GXSoapError = oReader.read(); + } + if (!readElement) { + readOk = (short) (1); + GXSoapError = oReader.read(); + } + nOutParmCount = (short) (nOutParmCount + 1); + if ((readOk == 0) || formatError) { + context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine(); + context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML(); + GXSoapError = (short) (nOutParmCount * -1); + } + } + } + return GXSoapError; + } + + public void writexml(XMLWriter oWriter, + String sName, + String sNameSpace) { + writexml(oWriter, sName, sNameSpace, true); + } + + public void writexml(XMLWriter oWriter, + String sName, + String sNameSpace, + boolean sIncludeState) { + if ((GXutil.strcmp("", sName) == 0)) { + sName = "User"; + } + if ((GXutil.strcmp("", sNameSpace) == 0)) { + sNameSpace = "Issue95858"; + } + oWriter.writeStartElement(sName); + if (GXutil.strcmp(GXutil.left(sNameSpace, 10), "[*:nosend]") != 0) { + oWriter.writeAttribute("xmlns", sNameSpace); + } else { + sNameSpace = GXutil.right(sNameSpace, GXutil.len(sNameSpace) - 10); + } + oWriter.writeElement("UserId", gxTv_SdtUser_Userid.toString()); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserName", gxTv_SdtUser_Username); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + sDateCnv = ""; + sNumToPad = GXutil.trim(GXutil.str(GXutil.year(gxTv_SdtUser_Userregistereddatetime), 10, 0)); + sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.month(gxTv_SdtUser_Userregistereddatetime), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.day(gxTv_SdtUser_Userregistereddatetime), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "T"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(gxTv_SdtUser_Userregistereddatetime), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(gxTv_SdtUser_Userregistereddatetime), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.second(gxTv_SdtUser_Userregistereddatetime), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + oWriter.writeElement("UserRegisteredDateTime", sDateCnv); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + if (sIncludeState) { + oWriter.writeElement("Mode", gxTv_SdtUser_Mode); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("Initialized", GXutil.trim(GXutil.str(gxTv_SdtUser_Initialized, 4, 0))); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserId_Z", gxTv_SdtUser_Userid_Z.toString()); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + oWriter.writeElement("UserName_Z", gxTv_SdtUser_Username_Z); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + sDateCnv = ""; + sNumToPad = GXutil.trim(GXutil.str(GXutil.year(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); + sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.month(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.day(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "T"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.second(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + oWriter.writeElement("UserRegisteredDateTime_Z", sDateCnv); + if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { + oWriter.writeAttribute("xmlns", "Issue95858"); + } + } + oWriter.writeEndElement(); + } + + public long getnumericvalue(String value) { + if (GXutil.notNumeric(value)) { + formatError = true; + } + return GXutil.lval(value); + } + + public void tojson() { + tojson(true); + } + + public void tojson(boolean includeState) { + tojson(includeState, true); + } + + public void tojson(boolean includeState, + boolean includeNonInitialized) { + AddObjectProperty("UserId", gxTv_SdtUser_Userid, false, includeNonInitialized); + AddObjectProperty("UserName", gxTv_SdtUser_Username, false, includeNonInitialized); + datetime_STZ = gxTv_SdtUser_Userregistereddatetime; + sDateCnv = ""; + sNumToPad = GXutil.trim(GXutil.str(GXutil.year(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.month(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.day(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "T"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.second(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + AddObjectProperty("UserRegisteredDateTime", sDateCnv, false, includeNonInitialized); + AddObjectProperty("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata, false, includeNonInitialized); + if (includeState) { + AddObjectProperty("Mode", gxTv_SdtUser_Mode, false, includeNonInitialized); + AddObjectProperty("Initialized", gxTv_SdtUser_Initialized, false, includeNonInitialized); + AddObjectProperty("UserId_Z", gxTv_SdtUser_Userid_Z, false, includeNonInitialized); + AddObjectProperty("UserName_Z", gxTv_SdtUser_Username_Z, false, includeNonInitialized); + datetime_STZ = gxTv_SdtUser_Userregistereddatetime_Z; + sDateCnv = ""; + sNumToPad = GXutil.trim(GXutil.str(GXutil.year(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.month(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "-"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.day(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += "T"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + sDateCnv += ":"; + sNumToPad = GXutil.trim(GXutil.str(GXutil.second(datetime_STZ), 10, 0)); + sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; + AddObjectProperty("UserRegisteredDateTime_Z", sDateCnv, false, includeNonInitialized); + } + } + + public void updateDirties(SdtUser sdt) { + if (sdt.IsDirty("UserId")) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Userid = sdt.getgxTv_SdtUser_Userid(); + } + if (sdt.IsDirty("UserName")) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Username = sdt.getgxTv_SdtUser_Username(); + } + if (sdt.IsDirty("UserRegisteredDateTime")) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Userregistereddatetime = sdt.getgxTv_SdtUser_Userregistereddatetime(); + } + if (sdt.IsDirty("UserEventMessageData")) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Usereventmessagedata = sdt.getgxTv_SdtUser_Usereventmessagedata(); + } + } + + public UUID getgxTv_SdtUser_Userid() { + return gxTv_SdtUser_Userid; + } + + public void setgxTv_SdtUser_Userid(UUID value) { + gxTv_SdtUser_N = (byte) (0); + if (!(gxTv_SdtUser_Userid.equals(value))) { + gxTv_SdtUser_Mode = "INS"; + this.setgxTv_SdtUser_Userid_Z_SetNull(); + this.setgxTv_SdtUser_Username_Z_SetNull(); + this.setgxTv_SdtUser_Userregistereddatetime_Z_SetNull(); + } + SetDirty("Userid"); + gxTv_SdtUser_Userid = value; + } + + public String getgxTv_SdtUser_Username() { + return gxTv_SdtUser_Username; + } + + public void setgxTv_SdtUser_Username(String value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Username"); + gxTv_SdtUser_Username = value; + } + + public Date getgxTv_SdtUser_Userregistereddatetime() { + return gxTv_SdtUser_Userregistereddatetime; + } + + public void setgxTv_SdtUser_Userregistereddatetime(Date value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Userregistereddatetime"); + gxTv_SdtUser_Userregistereddatetime = value; + } + + public String getgxTv_SdtUser_Usereventmessagedata() { + return gxTv_SdtUser_Usereventmessagedata; + } + + public void setgxTv_SdtUser_Usereventmessagedata(String value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Usereventmessagedata"); + gxTv_SdtUser_Usereventmessagedata = value; + } + + public String getgxTv_SdtUser_Mode() { + return gxTv_SdtUser_Mode; + } + + public void setgxTv_SdtUser_Mode(String value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Mode"); + gxTv_SdtUser_Mode = value; + } + + public void setgxTv_SdtUser_Mode_SetNull() { + gxTv_SdtUser_Mode = ""; + SetDirty("Mode"); + } + + public boolean getgxTv_SdtUser_Mode_IsNull() { + return false; + } + + public short getgxTv_SdtUser_Initialized() { + return gxTv_SdtUser_Initialized; + } + + public void setgxTv_SdtUser_Initialized(short value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Initialized"); + gxTv_SdtUser_Initialized = value; + } + + public void setgxTv_SdtUser_Initialized_SetNull() { + gxTv_SdtUser_Initialized = (short) (0); + SetDirty("Initialized"); + } + + public boolean getgxTv_SdtUser_Initialized_IsNull() { + return false; + } + + public UUID getgxTv_SdtUser_Userid_Z() { + return gxTv_SdtUser_Userid_Z; + } + + public void setgxTv_SdtUser_Userid_Z(UUID value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Userid_Z"); + gxTv_SdtUser_Userid_Z = value; + } + + public void setgxTv_SdtUser_Userid_Z_SetNull() { + gxTv_SdtUser_Userid_Z = UUID.fromString("00000000-0000-0000-0000-000000000000"); + SetDirty("Userid_Z"); + } + + public boolean getgxTv_SdtUser_Userid_Z_IsNull() { + return false; + } + + public String getgxTv_SdtUser_Username_Z() { + return gxTv_SdtUser_Username_Z; + } + + public void setgxTv_SdtUser_Username_Z(String value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Username_Z"); + gxTv_SdtUser_Username_Z = value; + } + + public void setgxTv_SdtUser_Username_Z_SetNull() { + gxTv_SdtUser_Username_Z = ""; + SetDirty("Username_Z"); + } + + public boolean getgxTv_SdtUser_Username_Z_IsNull() { + return false; + } + + public Date getgxTv_SdtUser_Userregistereddatetime_Z() { + return gxTv_SdtUser_Userregistereddatetime_Z; + } + + public void setgxTv_SdtUser_Userregistereddatetime_Z(Date value) { + gxTv_SdtUser_N = (byte) (0); + SetDirty("Userregistereddatetime_Z"); + gxTv_SdtUser_Userregistereddatetime_Z = value; + } + + public void setgxTv_SdtUser_Userregistereddatetime_Z_SetNull() { + gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime(GXutil.nullDate()); + SetDirty("Userregistereddatetime_Z"); + } + + public boolean getgxTv_SdtUser_Userregistereddatetime_Z_IsNull() { + return false; + } + + + public void initialize() { + gxTv_SdtUser_Userid = UUID.fromString("00000000-0000-0000-0000-000000000000"); + gxTv_SdtUser_N = (byte) (1); + gxTv_SdtUser_Username = ""; + gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime(GXutil.nullDate()); + gxTv_SdtUser_Usereventmessagedata = ""; + gxTv_SdtUser_Mode = ""; + gxTv_SdtUser_Userid_Z = UUID.fromString("00000000-0000-0000-0000-000000000000"); + gxTv_SdtUser_Username_Z = ""; + gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime(GXutil.nullDate()); + sTagName = ""; + sDateCnv = ""; + sNumToPad = ""; + datetime_STZ = GXutil.resetTime(GXutil.nullDate()); + } + + public byte isNull() { + return gxTv_SdtUser_N; + } + + + public void setStruct(com.unittest.eventdriven.StructSdtUser struct) { + setgxTv_SdtUser_Userid(struct.getUserid()); + setgxTv_SdtUser_Username(struct.getUsername()); + setgxTv_SdtUser_Userregistereddatetime(struct.getUserregistereddatetime()); + setgxTv_SdtUser_Usereventmessagedata(struct.getUsereventmessagedata()); + setgxTv_SdtUser_Mode(struct.getMode()); + setgxTv_SdtUser_Initialized(struct.getInitialized()); + setgxTv_SdtUser_Userid_Z(struct.getUserid_Z()); + setgxTv_SdtUser_Username_Z(struct.getUsername_Z()); + setgxTv_SdtUser_Userregistereddatetime_Z(struct.getUserregistereddatetime_Z()); + } + + @SuppressWarnings("unchecked") + public com.unittest.eventdriven.StructSdtUser getStruct() { + com.unittest.eventdriven.StructSdtUser struct = new com.unittest.eventdriven.StructSdtUser(); + struct.setUserid(getgxTv_SdtUser_Userid()); + struct.setUsername(getgxTv_SdtUser_Username()); + struct.setUserregistereddatetime(getgxTv_SdtUser_Userregistereddatetime()); + struct.setUsereventmessagedata(getgxTv_SdtUser_Usereventmessagedata()); + struct.setMode(getgxTv_SdtUser_Mode()); + struct.setInitialized(getgxTv_SdtUser_Initialized()); + struct.setUserid_Z(getgxTv_SdtUser_Userid_Z()); + struct.setUsername_Z(getgxTv_SdtUser_Username_Z()); + struct.setUserregistereddatetime_Z(getgxTv_SdtUser_Userregistereddatetime_Z()); + return struct; + } + + private byte gxTv_SdtUser_N; + private short gxTv_SdtUser_Initialized; + private short readOk; + private short nOutParmCount; + private String gxTv_SdtUser_Username; + private String gxTv_SdtUser_Mode; + private String gxTv_SdtUser_Username_Z; + private String sTagName; + private String sDateCnv; + private String sNumToPad; + private Date gxTv_SdtUser_Userregistereddatetime; + private Date gxTv_SdtUser_Userregistereddatetime_Z; + private Date datetime_STZ; + private boolean readElement; + private boolean formatError; + private String gxTv_SdtUser_Usereventmessagedata; + private UUID AV4UserId; + private UUID gxTv_SdtUser_Userid; + private UUID gxTv_SdtUser_Userid_Z; } diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java index af760aca6..bd2a81b20 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/StructSdtUser.java @@ -1,147 +1,127 @@ package com.unittest.eventdriven; + import com.genexus.*; -public final class StructSdtUser implements Cloneable, java.io.Serializable -{ - public StructSdtUser( ) - { - this( -1, new ModelContext( StructSdtUser.class )); - } - - public StructSdtUser( int remoteHandle , - ModelContext context ) - { - java.util.Calendar cal = java.util.Calendar.getInstance(); - cal.set(1, 0, 1, 0, 0, 0); - cal.set(java.util.Calendar.MILLISECOND, 0); - gxTv_SdtUser_Userid = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000") ; - gxTv_SdtUser_Username = "" ; - gxTv_SdtUser_Userregistereddatetime = cal.getTime() ; - gxTv_SdtUser_Usereventmessagedata = "" ; - gxTv_SdtUser_Mode = "" ; - gxTv_SdtUser_Userid_Z = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000") ; - gxTv_SdtUser_Username_Z = "" ; - gxTv_SdtUser_Userregistereddatetime_Z = cal.getTime() ; - } - - public Object clone() - { - Object cloned = null; - try - { - cloned = super.clone(); - }catch (CloneNotSupportedException e){ ; } - return cloned; - } - - public java.util.UUID getUserid( ) - { - return gxTv_SdtUser_Userid ; - } - - public void setUserid( java.util.UUID value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Userid = value ; - } - - public String getUsername( ) - { - return gxTv_SdtUser_Username ; - } - - public void setUsername( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Username = value ; - } - - public java.util.Date getUserregistereddatetime( ) - { - return gxTv_SdtUser_Userregistereddatetime ; - } - - public void setUserregistereddatetime( java.util.Date value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Userregistereddatetime = value ; - } - - public String getUsereventmessagedata( ) - { - return gxTv_SdtUser_Usereventmessagedata ; - } - - public void setUsereventmessagedata( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Usereventmessagedata = value ; - } - - public String getMode( ) - { - return gxTv_SdtUser_Mode ; - } - - public void setMode( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Mode = value ; - } - - public short getInitialized( ) - { - return gxTv_SdtUser_Initialized ; - } - - public void setInitialized( short value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Initialized = value ; - } - - public java.util.UUID getUserid_Z( ) - { - return gxTv_SdtUser_Userid_Z ; - } - - public void setUserid_Z( java.util.UUID value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Userid_Z = value ; - } - - public String getUsername_Z( ) - { - return gxTv_SdtUser_Username_Z ; - } - - public void setUsername_Z( String value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Username_Z = value ; - } - - public java.util.Date getUserregistereddatetime_Z( ) - { - return gxTv_SdtUser_Userregistereddatetime_Z ; - } - - public void setUserregistereddatetime_Z( java.util.Date value ) - { - gxTv_SdtUser_N = (byte)(0) ; - gxTv_SdtUser_Userregistereddatetime_Z = value ; - } - - private byte gxTv_SdtUser_N ; - protected short gxTv_SdtUser_Initialized ; - protected String gxTv_SdtUser_Username ; - protected String gxTv_SdtUser_Mode ; - protected String gxTv_SdtUser_Username_Z ; - protected String gxTv_SdtUser_Usereventmessagedata ; - protected java.util.UUID gxTv_SdtUser_Userid ; - protected java.util.UUID gxTv_SdtUser_Userid_Z ; - protected java.util.Date gxTv_SdtUser_Userregistereddatetime ; - protected java.util.Date gxTv_SdtUser_Userregistereddatetime_Z ; +public final class StructSdtUser implements Cloneable, java.io.Serializable { + public StructSdtUser() { + this(-1, new ModelContext(StructSdtUser.class)); + } + + public StructSdtUser(int remoteHandle, + ModelContext context) { + java.util.Calendar cal = java.util.Calendar.getInstance(); + cal.set(1, 0, 1, 0, 0, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + gxTv_SdtUser_Userid = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000"); + gxTv_SdtUser_Username = ""; + gxTv_SdtUser_Userregistereddatetime = cal.getTime(); + gxTv_SdtUser_Usereventmessagedata = ""; + gxTv_SdtUser_Mode = ""; + gxTv_SdtUser_Userid_Z = java.util.UUID.fromString("00000000-0000-0000-0000-000000000000"); + gxTv_SdtUser_Username_Z = ""; + gxTv_SdtUser_Userregistereddatetime_Z = cal.getTime(); + } + + public Object clone() { + Object cloned = null; + try { + cloned = super.clone(); + } catch (CloneNotSupportedException e) { + ; + } + return cloned; + } + + public java.util.UUID getUserid() { + return gxTv_SdtUser_Userid; + } + + public void setUserid(java.util.UUID value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Userid = value; + } + + public String getUsername() { + return gxTv_SdtUser_Username; + } + + public void setUsername(String value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Username = value; + } + + public java.util.Date getUserregistereddatetime() { + return gxTv_SdtUser_Userregistereddatetime; + } + + public void setUserregistereddatetime(java.util.Date value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Userregistereddatetime = value; + } + + public String getUsereventmessagedata() { + return gxTv_SdtUser_Usereventmessagedata; + } + + public void setUsereventmessagedata(String value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Usereventmessagedata = value; + } + + public String getMode() { + return gxTv_SdtUser_Mode; + } + + public void setMode(String value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Mode = value; + } + + public short getInitialized() { + return gxTv_SdtUser_Initialized; + } + + public void setInitialized(short value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Initialized = value; + } + + public java.util.UUID getUserid_Z() { + return gxTv_SdtUser_Userid_Z; + } + + public void setUserid_Z(java.util.UUID value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Userid_Z = value; + } + + public String getUsername_Z() { + return gxTv_SdtUser_Username_Z; + } + + public void setUsername_Z(String value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Username_Z = value; + } + + public java.util.Date getUserregistereddatetime_Z() { + return gxTv_SdtUser_Userregistereddatetime_Z; + } + + public void setUserregistereddatetime_Z(java.util.Date value) { + gxTv_SdtUser_N = (byte) (0); + gxTv_SdtUser_Userregistereddatetime_Z = value; + } + + private byte gxTv_SdtUser_N; + protected short gxTv_SdtUser_Initialized; + protected String gxTv_SdtUser_Username; + protected String gxTv_SdtUser_Mode; + protected String gxTv_SdtUser_Username_Z; + protected String gxTv_SdtUser_Usereventmessagedata; + protected java.util.UUID gxTv_SdtUser_Userid; + protected java.util.UUID gxTv_SdtUser_Userid_Z; + protected java.util.Date gxTv_SdtUser_Userregistereddatetime; + protected java.util.Date gxTv_SdtUser_Userregistereddatetime_Z; } diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java index 1ace6049d..3db3e563f 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java @@ -7,19 +7,16 @@ public handlesimplerawsqsevent(int remoteHandle) { super(remoteHandle, new ModelContext(handlesimplerawsqsevent.class), ""); } - public handlesimplerawsqsevent(int remoteHandle, - ModelContext context) { + public handlesimplerawsqsevent(int remoteHandle, ModelContext context) { super(remoteHandle, context, ""); } - public void execute(String aP0, - com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + public void execute(String aP0, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { execute_int(aP0, aP1); } - private void execute_int(String aP0, - com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + private void execute_int(String aP0, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { handlesimplerawsqsevent.this.AV13RAWMessage = aP0; handlesimplerawsqsevent.this.aP1 = aP1; initialize(); @@ -30,11 +27,10 @@ private void execute_int(String aP0, private void privateExecute() { System.out.println("START Queue Event received"); - ; System.out.println(AV13RAWMessage); System.out.println("END Queue Event received"); System.out.println((boolean) ((GXutil.len(AV13RAWMessage) > 0))); - AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled( AV13RAWMessage.startsWith("{\"records\":[{\"messageId\":\"1\",\"receiptHandle\":\"123123\",\"body\":\"") ); + AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled(AV13RAWMessage.startsWith("{\"records\":[{\"messageId\":\"1\",\"receiptHandle\":\"123123\",\"body\":\"")); cleanup(); } diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java index 71a6db1b2..2e0652122 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java @@ -1,40 +1,31 @@ -package com.unittest.eventdriven.queue ; -import com.unittest.*; -import java.sql.*; -import com.genexus.db.*; +package com.unittest.eventdriven.queue; + import com.genexus.*; -import com.genexus.search.*; -public final class handlesimpleuserqueueevent extends GXProcedure -{ - public handlesimpleuserqueueevent( int remoteHandle ) - { - super( remoteHandle , new ModelContext( handlesimpleuserqueueevent.class ), "" ); +public final class handlesimpleuserqueueevent extends GXProcedure { + public handlesimpleuserqueueevent(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimpleuserqueueevent.class), ""); } - public handlesimpleuserqueueevent( int remoteHandle , - ModelContext context ) - { - super( remoteHandle , context, "" ); + public handlesimpleuserqueueevent(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, ""); } @SuppressWarnings("unchecked") - public com.genexus.genexusserverlessapi.SdtEventMessageResponse executeUdp( com.genexus.genexusserverlessapi.SdtEventMessages aP0 ) - { - handlesimpleuserqueueevent.this.aP1 = new com.genexus.genexusserverlessapi.SdtEventMessageResponse[] {new com.genexus.genexusserverlessapi.SdtEventMessageResponse()}; + public com.genexus.genexusserverlessapi.SdtEventMessageResponse executeUdp(com.genexus.genexusserverlessapi.SdtEventMessages aP0) { + handlesimpleuserqueueevent.this.aP1 = new com.genexus.genexusserverlessapi.SdtEventMessageResponse[]{new com.genexus.genexusserverlessapi.SdtEventMessageResponse()}; execute_int(aP0, aP1); return aP1[0]; } - public void execute( com.genexus.genexusserverlessapi.SdtEventMessages aP0 , - com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1 ) - { + public void execute(com.genexus.genexusserverlessapi.SdtEventMessages aP0, + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { execute_int(aP0, aP1); } - private void execute_int( com.genexus.genexusserverlessapi.SdtEventMessages aP0 , - com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1 ) - { + private void execute_int(com.genexus.genexusserverlessapi.SdtEventMessages aP0, + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { handlesimpleuserqueueevent.this.AV8EventMessages = aP0; handlesimpleuserqueueevent.this.aP1 = aP1; initialize(); @@ -43,67 +34,62 @@ private void execute_int( com.genexus.genexusserverlessapi.SdtEventMessages aP0 privateExecute(); } - private void privateExecute( ) - { - System.out.println("START Queue Event received") ; - System.out.println(AV8EventMessages.toJSonString(false, true)) ; + private void privateExecute() { + System.out.println("START Queue Event received"); + System.out.println(AV8EventMessages.toJSonString(false, true)); - AV16GXV1 = 1 ; - while ( AV16GXV1 <= AV8EventMessages.getgxTv_SdtEventMessages_Eventmessage().size() ) - { - AV10EventMessage = (com.genexus.genexusserverlessapi.SdtEventMessage)((com.genexus.genexusserverlessapi.SdtEventMessage)AV8EventMessages.getgxTv_SdtEventMessages_Eventmessage().elementAt(-1+AV16GXV1)); - System.out.println("Processing: "+AV10EventMessage.toJSonString(false, true)) ; - AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled( AV11UserSDT.fromJSonString(AV10EventMessage.getgxTv_SdtEventMessage_Eventmessagedata(), AV12OutMessages) ); - if ( ! AV9EventMessageResponse.getgxTv_SdtEventMessageResponse_Handled() ) - { - System.out.println("EventMessageData could not be parsed: "+AV10EventMessage.getgxTv_SdtEventMessage_Eventmessagedata()) ; - System.out.println(AV12OutMessages.toJSonString(false)) ; - AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Errormessage( AV12OutMessages.toJSonString(false) ); + AV16GXV1 = 1; + while (AV16GXV1 <= AV8EventMessages.getgxTv_SdtEventMessages_Eventmessage().size()) { + AV10EventMessage = (com.genexus.genexusserverlessapi.SdtEventMessage) ((com.genexus.genexusserverlessapi.SdtEventMessage) AV8EventMessages.getgxTv_SdtEventMessages_Eventmessage().elementAt(-1 + AV16GXV1)); + System.out.println("Processing: " + AV10EventMessage.toJSonString(false, true)); + AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled(AV11UserSDT.fromJSonString(AV10EventMessage.getgxTv_SdtEventMessage_Eventmessagedata(), AV12OutMessages)); + if (!AV9EventMessageResponse.getgxTv_SdtEventMessageResponse_Handled()) { + System.out.println("EventMessageData could not be parsed: " + AV10EventMessage.getgxTv_SdtEventMessage_Eventmessagedata()); + System.out.println(AV12OutMessages.toJSonString(false)); + AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Errormessage(AV12OutMessages.toJSonString(false)); returnInSub = true; cleanup(); if (true) return; } - System.out.println("UserSDT Processed OK: "+AV11UserSDT.toJSonString(false, true)); ; - AV16GXV1 = (int)(AV16GXV1+1) ; + System.out.println("UserSDT Processed OK: " + AV11UserSDT.toJSonString(false, true)); + ; + AV16GXV1 = (int) (AV16GXV1 + 1); } - System.out.println("END Queue Event received") ; + System.out.println("END Queue Event received"); cleanup(); } - protected void cleanup( ) - { + protected void cleanup() { this.aP1[0] = handlesimpleuserqueueevent.this.AV9EventMessageResponse; CloseOpenCursors(); exitApp(); } - protected void CloseOpenCursors( ) - { + protected void CloseOpenCursors() { } /* Aggregate/select formulas */ - public void initialize( ) - { + public void initialize() { AV9EventMessageResponse = new com.genexus.genexusserverlessapi.SdtEventMessageResponse(remoteHandle, context); - AV15Pgmname = "" ; + AV15Pgmname = ""; AV10EventMessage = new com.genexus.genexusserverlessapi.SdtEventMessage(remoteHandle, context); AV12OutMessages = new GXBaseCollection(com.genexus.SdtMessages_Message.class, "Message", "GeneXus", remoteHandle); AV11UserSDT = new com.unittest.eventdriven.SdtUser(remoteHandle); - AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent" ; + AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent"; /* GeneXus formulas. */ - AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent" ; - Gx_err = (short)(0) ; + AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent"; + Gx_err = (short) (0); } - private short Gx_err ; - private int AV16GXV1 ; - private String AV15Pgmname ; - private boolean returnInSub ; - private com.unittest.eventdriven.SdtUser AV11UserSDT ; - private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1 ; - private GXBaseCollection AV12OutMessages ; - private com.genexus.genexusserverlessapi.SdtEventMessages AV8EventMessages ; - private com.genexus.genexusserverlessapi.SdtEventMessage AV10EventMessage ; - private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse ; + private short Gx_err; + private int AV16GXV1; + private String AV15Pgmname; + private boolean returnInSub; + private com.unittest.eventdriven.SdtUser AV11UserSDT; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1; + private GXBaseCollection AV12OutMessages; + private com.genexus.genexusserverlessapi.SdtEventMessages AV8EventMessages; + private com.genexus.genexusserverlessapi.SdtEventMessage AV10EventMessage; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse; } diff --git a/gxawsserverless/src/test/java/log4j2.xml b/gxawsserverless/src/test/java/log4j2.xml index 39b9120e8..412bab990 100644 --- a/gxawsserverless/src/test/java/log4j2.xml +++ b/gxawsserverless/src/test/java/log4j2.xml @@ -1,21 +1,21 @@ - - logs - - - - - - - - - - - - - - - - + + logs + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java b/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java index 1b40e07d4..27cd6d751 100644 --- a/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java +++ b/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java @@ -1476,6 +1476,7 @@ public void setStream() { public void flushStream() { proxyCookieValues(); + try { if (buffered) { // Esto en realidad cierra el ZipOutputStream, o el ByteOutputStream, no cierra @@ -1485,6 +1486,7 @@ public void flushStream() { // que se grabaron al bytearray closeOutputStream(); IHttpServletResponse response = getResponse(); + if (buffer != null && !response.isCommitted()) { IServletOutputStream stream = response.getOutputStream(); response.setContentLength(buffer.size()); From e609f6f7c3a0b546850fe2f056e4328f5b815f24 Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Thu, 19 May 2022 21:25:21 -0300 Subject: [PATCH 08/12] Code qualtiy improvements --- .../cloud/aws/events/TestLambdaSQSHandler.java | 13 ++++--------- ...sqsevent.java => handlesimplesqsevent.java} | 14 +++++++------- ...ueevent.java => handlesimplesqsevent2.java} | 18 +++++++++--------- 3 files changed, 20 insertions(+), 25 deletions(-) rename gxawsserverless/src/test/java/com/unittest/eventdriven/queue/{handlesimplerawsqsevent.java => handlesimplesqsevent.java} (78%) rename gxawsserverless/src/test/java/com/unittest/eventdriven/queue/{handlesimpleuserqueueevent.java => handlesimplesqsevent2.java} (84%) diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java index f4b5cce4e..7f7392bb0 100644 --- a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaSQSHandler.java @@ -1,23 +1,18 @@ package com.genexus.cloud.aws.events; -import com.amazonaws.services.lambda.runtime.ClientContext; -import com.amazonaws.services.lambda.runtime.CognitoIdentity; -import com.amazonaws.services.lambda.runtime.Context; -import com.amazonaws.services.lambda.runtime.LambdaLogger; import com.amazonaws.services.lambda.runtime.events.SQSBatchResponse; import com.amazonaws.services.lambda.runtime.events.SQSEvent; -import com.genexus.cloud.serverless.aws.handler.LambdaBaseHandler; import com.genexus.cloud.serverless.aws.handler.LambdaSQSHandler; +import com.unittest.eventdriven.queue.handlesimplesqsevent; +import com.unittest.eventdriven.queue.handlesimplesqsevent2; import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; import org.junit.Test; import java.util.*; public class TestLambdaSQSHandler { - private static String SIMPLE_HANDLER = "com.unittest.eventdriven.queue.handlesimpleuserqueueevent"; - private static String SIMPLE_RAW_HANDLER = "com.unittest.eventdriven.queue.handlesimplerawsqsevent"; + private static String SIMPLE_HANDLER = handlesimplesqsevent2.class.getName(); + private static String SIMPLE_RAW_HANDLER = handlesimplesqsevent.class.getName(); @Test public void TestSQSSimpleEvent() throws Exception { diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplesqsevent.java similarity index 78% rename from gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java rename to gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplesqsevent.java index 3db3e563f..e5ae43f17 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplerawsqsevent.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplesqsevent.java @@ -2,12 +2,12 @@ import com.genexus.*; -public final class handlesimplerawsqsevent extends GXProcedure { - public handlesimplerawsqsevent(int remoteHandle) { - super(remoteHandle, new ModelContext(handlesimplerawsqsevent.class), ""); +public final class handlesimplesqsevent extends GXProcedure { + public handlesimplesqsevent(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimplesqsevent.class), ""); } - public handlesimplerawsqsevent(int remoteHandle, ModelContext context) { + public handlesimplesqsevent(int remoteHandle, ModelContext context) { super(remoteHandle, context, ""); } @@ -17,8 +17,8 @@ public void execute(String aP0, com.genexus.genexusserverlessapi.SdtEventMessage } private void execute_int(String aP0, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { - handlesimplerawsqsevent.this.AV13RAWMessage = aP0; - handlesimplerawsqsevent.this.aP1 = aP1; + handlesimplesqsevent.this.AV13RAWMessage = aP0; + handlesimplesqsevent.this.aP1 = aP1; initialize(); /* GeneXus formulas */ /* Output device settings */ @@ -35,7 +35,7 @@ private void privateExecute() { } protected void cleanup() { - this.aP1[0] = handlesimplerawsqsevent.this.AV9EventMessageResponse; + this.aP1[0] = handlesimplesqsevent.this.AV9EventMessageResponse; CloseOpenCursors(); exitApp(); } diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplesqsevent2.java similarity index 84% rename from gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java rename to gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplesqsevent2.java index 2e0652122..df68e999c 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimpleuserqueueevent.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/queue/handlesimplesqsevent2.java @@ -2,19 +2,19 @@ import com.genexus.*; -public final class handlesimpleuserqueueevent extends GXProcedure { - public handlesimpleuserqueueevent(int remoteHandle) { - super(remoteHandle, new ModelContext(handlesimpleuserqueueevent.class), ""); +public final class handlesimplesqsevent2 extends GXProcedure { + public handlesimplesqsevent2(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimplesqsevent2.class), ""); } - public handlesimpleuserqueueevent(int remoteHandle, - ModelContext context) { + public handlesimplesqsevent2(int remoteHandle, + ModelContext context) { super(remoteHandle, context, ""); } @SuppressWarnings("unchecked") public com.genexus.genexusserverlessapi.SdtEventMessageResponse executeUdp(com.genexus.genexusserverlessapi.SdtEventMessages aP0) { - handlesimpleuserqueueevent.this.aP1 = new com.genexus.genexusserverlessapi.SdtEventMessageResponse[]{new com.genexus.genexusserverlessapi.SdtEventMessageResponse()}; + handlesimplesqsevent2.this.aP1 = new com.genexus.genexusserverlessapi.SdtEventMessageResponse[]{new com.genexus.genexusserverlessapi.SdtEventMessageResponse()}; execute_int(aP0, aP1); return aP1[0]; } @@ -26,8 +26,8 @@ public void execute(com.genexus.genexusserverlessapi.SdtEventMessages aP0, private void execute_int(com.genexus.genexusserverlessapi.SdtEventMessages aP0, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { - handlesimpleuserqueueevent.this.AV8EventMessages = aP0; - handlesimpleuserqueueevent.this.aP1 = aP1; + handlesimplesqsevent2.this.AV8EventMessages = aP0; + handlesimplesqsevent2.this.aP1 = aP1; initialize(); /* GeneXus formulas */ /* Output device settings */ @@ -60,7 +60,7 @@ private void privateExecute() { } protected void cleanup() { - this.aP1[0] = handlesimpleuserqueueevent.this.AV9EventMessageResponse; + this.aP1[0] = handlesimplesqsevent2.this.AV9EventMessageResponse; CloseOpenCursors(); exitApp(); } From 983fe3a02078838b408303e4b1c563c057ec0ece Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Tue, 24 May 2022 18:20:06 -0300 Subject: [PATCH 09/12] Add EventBridge Support --- .../cloud/serverless/GXProcedureExecutor.java | 114 +++++++++++++++ .../com/genexus/cloud/serverless/Helper.java | 16 ++- .../GXProcedureDynamicExecuteStrategy.java | 96 ------------- .../aws/handler/LambdaBaseEventHandler.java | 94 +++++++++++++ .../aws/handler/LambdaBaseHandler.java | 130 ------------------ .../aws/handler/LambdaEventBridgeHandler.java | 66 +++++++++ .../aws/handler/LambdaSQSHandler.java | 4 +- .../exception/FunctionRuntimeException.java | 9 ++ .../model/EventMessageResponse.java | 5 +- .../events/TestLambdaEventBridgeHandler.java | 62 +++++++++ .../dummy/handlerruntimeexception.java | 58 ++++++++ .../dummy/handlesimplenoparmsevent.java | 47 +++++++ .../dummy/handlesimplesqsevent.java | 61 ++++++++ .../dummy/handlesimplesqsevent2.java | 80 +++++++++++ 14 files changed, 609 insertions(+), 233 deletions(-) create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java delete mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java delete mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java create mode 100644 gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionRuntimeException.java create mode 100644 gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlerruntimeexception.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplenoparmsevent.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent.java create mode 100644 gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent2.java diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java new file mode 100644 index 000000000..fa9e42121 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java @@ -0,0 +1,114 @@ +package com.genexus.cloud.serverless; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.genexus.GXProcedure; +import com.genexus.GxUserType; +import com.genexus.ModelContext; +import com.genexus.cloud.serverless.model.EventMessageResponse; +import com.genexus.cloud.serverless.model.EventMessages; +import com.genexus.db.DynamicExecute; +import org.apache.commons.lang.NotImplementedException; + +import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Optional; + +public class GXProcedureExecutor { + protected Class entryPointClass; + + private ModelContext modelContext; + private Class[][] supportedMethodSignatures = new Class[5][]; + private int methodSignatureIdx = -1; + + protected static final String MESSAGE_COLLECTION_INPUT_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessages"; + protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessageResponse"; + + public GXProcedureExecutor(String procedureClassName) throws ClassNotFoundException, NotImplementedException { + entryPointClass = (Class) Class.forName(procedureClassName); + + supportedMethodSignatures[0] = new Class[]{Class.forName(MESSAGE_COLLECTION_INPUT_CLASS_NAME), Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME)}; + supportedMethodSignatures[1] = new Class[]{String.class, Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME)}; + supportedMethodSignatures[2] = new Class[]{String.class}; + supportedMethodSignatures[3] = new Class[]{Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME)}; + supportedMethodSignatures[4] = new Class[]{}; //No inputs, no outputs + + Optional executeMethodOpt = Arrays.stream(this.entryPointClass.getDeclaredMethods()).filter(m -> m.getName() == DynamicExecute.METHOD_EXECUTE).findFirst(); + + if (!executeMethodOpt.isPresent()) { + throw new NotImplementedException(String.format("EXECUTE Method not implemented on Class '%s'", procedureClassName)); + } + + Method executeMethod = executeMethodOpt.get(); + Class[] parametersTypes = executeMethod.getParameterTypes(); + + for (int i = 0; i < supportedMethodSignatures.length && methodSignatureIdx < 0; i++) { + if (supportedMethodSignatures[i].length != parametersTypes.length) { + continue; + } + Class[] listParameters = (Class[]) supportedMethodSignatures[i]; + boolean isMatch = true; + for (int j = 0; j < listParameters.length && isMatch; j++) { + isMatch = listParameters[j] == parametersTypes[j] || listParameters[j] == parametersTypes[j].getComponentType(); + } + if (isMatch) { + methodSignatureIdx = i; + } + } + if (methodSignatureIdx < 0) { + throw new NotImplementedException("Expected signature method did not match"); + } + + } + + public EventMessageResponse execute(ModelContext modelContext, EventMessages msgs, String rawJsonEvent) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, JsonProcessingException { + EventMessageResponse response = new EventMessageResponse(); + + Object[] parameters; + boolean returnsValue = true; + switch (methodSignatureIdx) { + case 0: + Class inputClass = Class.forName(MESSAGE_COLLECTION_INPUT_CLASS_NAME); + Object msgsInput = inputClass.getConstructor().newInstance(); + if (GxUserType.class.isAssignableFrom(inputClass)) { + ((GxUserType) msgsInput).fromJSonString(Helper.toJSONString(msgs)); + } + parameters = new Object[]{msgsInput, new Object[]{}}; + break; + case 1: + parameters = new Object[]{rawJsonEvent, new Object[]{}}; + break; + case 2: + parameters = new Object[]{rawJsonEvent}; + response.setHandled(true); + returnsValue = false; + break; + case 3: + parameters = new Object[]{new Object[]{}}; + break; + default: + parameters = new Object[]{}; + returnsValue = false; + response.setHandled(true); + break; + } + + Object[] paramOutArray = null; + if (returnsValue) { + parameters[parameters.length - 1] = (Object[]) Array.newInstance(Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME), 1); + paramOutArray = (Object[]) parameters[parameters.length - 1]; + paramOutArray[0] = Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME).getConstructor(int.class, ModelContext.class).newInstance(-1, modelContext); + } + + com.genexus.db.DynamicExecute.dynamicExecute(modelContext, -1, entryPointClass, "", entryPointClass.getName(), parameters); + + if (paramOutArray != null) { + GxUserType handlerOutput = (GxUserType) paramOutArray[0]; + String jsonResponse = handlerOutput.toJSonString(false); + response = new ObjectMapper().readValue(jsonResponse, EventMessageResponse.class); + } + return response; + } +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java index 04bae7c1d..dc3338a9f 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java @@ -2,11 +2,21 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.genexus.cloud.serverless.model.EventMessage; +import com.genexus.cloud.serverless.model.EventMessageProperty; public class Helper { - public static String toJSONString(Object dtoObject) throws JsonProcessingException { - ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(dtoObject); + public static String toJSONString(Object dtoObject) { + try { + ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(dtoObject); + } + catch (Exception e) { } + return ""; + } + + public static void addEventMessageProperty(EventMessage msg, String key, String value) { + msg.getMessageProperties().add(new EventMessageProperty(key, value)); } } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java deleted file mode 100644 index 373551fe5..000000000 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/GXProcedureDynamicExecuteStrategy.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.genexus.cloud.serverless.aws.handler; - -import com.genexus.GXProcedure; -import com.genexus.GxUserType; -import com.genexus.ModelContext; -import com.genexus.db.DynamicExecute; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.List; - -public class GXProcedureDynamicExecuteStrategy { - private int id; - protected Class entryPointClass; - protected List> classParameters = new ArrayList<>(); - protected Class outputClassParameter; - private Boolean isValid = null; - - public GXProcedureDynamicExecuteStrategy(int id, String procedureClassName) throws ClassNotFoundException { - this.setId(id); - entryPointClass = (Class) Class.forName(procedureClassName); - } - - public void addInputParameter(String className) throws ClassNotFoundException { - classParameters.add((Class)Class.forName(className)); - } - - public void addOutputParameter(String className) throws ClassNotFoundException { - this.outputClassParameter = (Class)Class.forName(className); - } - - public boolean isValid() { - if (isValid != null) { - return isValid; - } - - List> classMethodParameters = new ArrayList<>(); - classMethodParameters.addAll(classParameters); - classMethodParameters.add(Array.newInstance(outputClassParameter, 0).getClass()); - - Class[] classMethodParametersArray = new Class[classMethodParameters.size()]; - for (int i = 0; i < classMethodParameters.size(); i++) { - classMethodParametersArray[i] = classMethodParameters.get(i); - } - - try { - this.entryPointClass.getMethod(DynamicExecute.METHOD_EXECUTE, classMethodParametersArray); - isValid = true; - } - catch (Exception e) { - isValid = false; - } - return isValid; - - } - - public Object[] execute(ModelContext m, String[] parmsStringSerializedValue) throws Exception { - int methodParameterSize = classParameters.size() + 1; - - if (parmsStringSerializedValue.length != classParameters.size()) { - throw new Exception("Signature method does not match"); - } - - Object[] parameters = new Object[methodParameterSize]; - int idx = 0; - for (String objString : parmsStringSerializedValue) { - Class classParameter = classParameters.get(idx); - parameters[idx] = classParameter.getConstructor().newInstance(); - - if (GxUserType.class.isAssignableFrom(classParameter)) { - GxUserType sdt = (GxUserType) parameters[idx]; - sdt.fromJSonString(objString); - } else if (classParameter == String.class) { - parameters[idx] = objString; - } else { - throw new Exception("Parameter cannot be handled"); - } - idx++; - } - - Object [] outputArray = (Object[]) Array.newInstance(outputClassParameter, 1); - outputArray[0] = outputClassParameter.getConstructor(int.class, ModelContext.class).newInstance(-1 , m);; - parameters[idx] = outputArray; - - com.genexus.db.DynamicExecute.dynamicExecute(m, -1, entryPointClass, "", entryPointClass.getName(), parameters); - return outputArray; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java new file mode 100644 index 000000000..5cb19e337 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java @@ -0,0 +1,94 @@ +package com.genexus.cloud.serverless.aws.handler; + +import com.genexus.ModelContext; +import com.genexus.cloud.serverless.*; +import com.genexus.cloud.serverless.model.EventMessageResponse; +import com.genexus.cloud.serverless.model.EventMessages; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.specific.java.Connect; +import com.genexus.specific.java.LogManager; +import com.genexus.util.IniFile; + + +public class LambdaBaseEventHandler { + protected static ILogger logger = null; + protected static Class entryPointClass = null; + private static LambdaFunctionConfiguration functionConfiguration; + private static final String GX_APPLICATION_CLASS = "GXcfg"; + private static String packageName = null; + private static GXProcedureExecutor executor; + + public LambdaBaseEventHandler() throws Exception { + initialize(); + + } + + public LambdaBaseEventHandler(String className) throws Exception { + functionConfiguration = new LambdaFunctionConfiguration(className); + initialize(); + + } + + + private void initialize() throws Exception { + logger = LogManager.initialize(".", LambdaBaseEventHandler.class); + Connect.init(); + + IniFile config = com.genexus.ConfigFileFinder.getConfigFile(null, "client.cfg", null); + packageName = config.getProperty("Client", "PACKAGE", null); + Class cfgClass; + + String cfgClassName = packageName.isEmpty() ? GX_APPLICATION_CLASS : String.format("%s.%s", packageName, GX_APPLICATION_CLASS); + try { + cfgClass = Class.forName(cfgClassName); + com.genexus.Application.init(cfgClass); + } catch (ClassNotFoundException e) { + logger.error(String.format("Failed to initialize GX AppConfig Class: %s", cfgClassName), e); + throw e; + } + + logger.debug("Initializing Function configuration"); + try { + if (functionConfiguration == null) { + functionConfiguration = LambdaFunctionConfigurationHelper.getFunctionConfiguration(); + } + entryPointClass = Class.forName(functionConfiguration.getEntryPointClassName()); + } catch (Exception e) { + logger.error(String.format("Failed to initialize Application for className: %s", functionConfiguration.getEntryPointClassName()), e); + throw e; + } + + if (entryPointClass == null) { + throw new ClassNotFoundException(String.format("GeneXus Procedure '%s' was not found. Check deployment package ", functionConfiguration.getEntryPointClassName())); + } + + executor = new GXProcedureExecutor(functionConfiguration.getEntryPointClassName()); + } + + protected EventMessageResponse dispatchEvent(EventMessages eventMessages, String lambdaRawMessageBody) throws Exception { + String jsonStringMessages = Helper.toJSONString(eventMessages); + + if (logger.isDebugEnabled()) { + logger.debug(String.format("dispatchEventMessages (%s) - serialized messages: %s", functionConfiguration.getEntryPointClassName(), jsonStringMessages)); + } + + ModelContext modelContext = new ModelContext(entryPointClass); + EventMessageResponse response = null; + + try { + response = executor.execute(modelContext, eventMessages, lambdaRawMessageBody); + } catch (Exception e) { + logger.error(String.format("dispatchEventmessages - program '%s' execution error", entryPointClass.getName()), e); + throw e; + } + + if (!response.isHandled()) { + logger.info("dispatchEventmessages - messages not handled with success: " + response.getErrorMessage()); + } else { + logger.debug("dispatchEventmessages - message handled with success"); + } + return response; + + } +} + diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java deleted file mode 100644 index de8183447..000000000 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseHandler.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.genexus.cloud.serverless.aws.handler; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.genexus.GxUserType; -import com.genexus.ModelContext; -import com.genexus.cloud.serverless.*; -import com.genexus.cloud.serverless.model.EventMessageResponse; -import com.genexus.cloud.serverless.model.EventMessages; -import com.genexus.diagnostics.core.ILogger; -import com.genexus.specific.java.Connect; -import com.genexus.specific.java.LogManager; -import com.genexus.util.IniFile; - -import java.util.ArrayList; -import java.util.List; - - -public class LambdaBaseHandler { - protected static ILogger logger = null; - protected static Class entryPointClass = null; - private static LambdaFunctionConfiguration functionConfiguration; - private static final String GX_APPLICATION_CLASS = "GXcfg"; - private static String packageName = null; - protected static final String MESSAGE_COLLECTION_INPUT_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessages"; - protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessageResponse"; - private static List strategies = new ArrayList<>(); - - public LambdaBaseHandler() throws Exception { - initialize(); - } - - public LambdaBaseHandler(String className) throws Exception { - functionConfiguration = new LambdaFunctionConfiguration(className); - initialize(); - } - - private void initialize() throws Exception { - logger = LogManager.initialize(".", LambdaBaseHandler.class); - Connect.init(); - - IniFile config = com.genexus.ConfigFileFinder.getConfigFile(null, "client.cfg", null); - packageName = config.getProperty("Client", "PACKAGE", null); - Class cfgClass; - - String cfgClassName = packageName.isEmpty() ? GX_APPLICATION_CLASS : String.format("%s.%s", packageName, GX_APPLICATION_CLASS); - try { - cfgClass = Class.forName(cfgClassName); - com.genexus.Application.init(cfgClass); - } catch (ClassNotFoundException e) { - logger.error(String.format("Failed to initialize GX AppConfig Class: %s", cfgClassName), e); - throw e; - } - - logger.debug("Initializing Function configuration"); - try { - if (functionConfiguration == null) { - functionConfiguration = LambdaFunctionConfigurationHelper.getFunctionConfiguration(); - } - entryPointClass = Class.forName(functionConfiguration.getEntryPointClassName()); - } catch (Exception e) { - logger.error(String.format("Failed to initialize Application for className: %s", functionConfiguration.getEntryPointClassName()), e); - throw e; - } - - if (entryPointClass == null) { - throw new ClassNotFoundException(String.format("GeneXus Procedure '%s' was not found. Check deployment package ", functionConfiguration.getEntryPointClassName())); - } - loadStrategies(); - } - - protected EventMessageResponse dispatchEventMessages(EventMessages eventMessages, String lambdaRawMessageBody) throws Exception { - try { - Object[] outResponse = null; - boolean handled = false; - - String jsonStringMessages = Helper.toJSONString(eventMessages); - ModelContext modelContext = new ModelContext(entryPointClass); - - if (logger.isDebugEnabled()) { - logger.debug(String.format("dispatchEventMessages (%s) - serialized messages: %s", functionConfiguration.getEntryPointClassName(), jsonStringMessages)); - } - for (GXProcedureDynamicExecuteStrategy stg : strategies) { - if (outResponse == null && stg.isValid()) { - handled = true; - switch (stg.getId()) { - case 1: - outResponse = stg.execute(modelContext, new String[]{jsonStringMessages}); - break; - case 2: - outResponse = stg.execute(modelContext, new String[]{lambdaRawMessageBody}); - break; - } - } - } - - if (!handled) { - throw new Exception(String.format("GeneXus Procedure '%s' does not comply with the required method signature required by Event Handlers. ", functionConfiguration.getEntryPointClassName())); - } - - GxUserType handlerOutput = (GxUserType) outResponse[0]; - String jsonResponse = handlerOutput.toJSonString(false); - EventMessageResponse response = new ObjectMapper().readValue(jsonResponse, EventMessageResponse.class); - - if (!response.isHandled()) { - logger.info("dispatchEventmessages - messages not handled with success: " + response.getErrorMessage()); - } else { - logger.debug("dispatchEventmessages - message handled with success"); - } - return response; - - } catch (Exception e) { - logger.error("HandleRequest failed: " + entryPointClass.getName(), e); - throw e; - } - } - - - private void loadStrategies() throws ClassNotFoundException { - GXProcedureDynamicExecuteStrategy strategy = new GXProcedureDynamicExecuteStrategy(1, functionConfiguration.getEntryPointClassName()); - strategy.addInputParameter(MESSAGE_COLLECTION_INPUT_CLASS_NAME); - strategy.addOutputParameter(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME); - strategies.add(strategy); - - strategy = new GXProcedureDynamicExecuteStrategy(2, functionConfiguration.getEntryPointClassName()); - strategy.addInputParameter(String.class.getName()); - strategy.addOutputParameter(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME); - strategies.add(strategy); - } -} - diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java new file mode 100644 index 000000000..9d84dae68 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java @@ -0,0 +1,66 @@ +package com.genexus.cloud.serverless.aws.handler; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.genexus.cloud.serverless.Helper; +import com.genexus.cloud.serverless.exception.FunctionRuntimeException; +import com.genexus.cloud.serverless.model.EventMessage; +import com.genexus.cloud.serverless.model.EventMessageResponse; +import com.genexus.cloud.serverless.model.EventMessageSourceType; +import com.genexus.cloud.serverless.model.EventMessages; +import com.genexus.webpanels.WebUtils; + +import java.util.Map; + +public class LambdaEventBridgeHandler extends LambdaBaseEventHandler implements RequestHandler, String> { + + public LambdaEventBridgeHandler() throws Exception { + super(); + } + + public LambdaEventBridgeHandler(String entryPointClassName) throws Exception { + super(entryPointClassName); + } + + @Override + public String handleRequest(Map stringObjectMap, Context context) { + String jsonEventRaw = Helper.toJSONString(stringObjectMap); + if (logger.isDebugEnabled()) { + logger.debug("handleRequest started with event: " + jsonEventRaw); + } + + String errorMessage; + EventMessageResponse response; + + try { + EventMessages msgs = new EventMessages(); + EventMessage msgItem = new EventMessage(); + msgItem.setMessageSourceType(EventMessageSourceType.ServiceBusMessage); + if (stringObjectMap.containsKey("time")) { + msgItem.setMessageDate(WebUtils.parseDTimeParm(stringObjectMap.get("time").toString())); + } + msgItem.setMessageId(stringObjectMap.getOrDefault("id", "").toString()); + msgItem.setMessageData(stringObjectMap.getOrDefault("detail", "").toString()); + for (Map.Entry entry : stringObjectMap.entrySet()) { + Helper.addEventMessageProperty(msgItem, entry.getKey(), entry.getValue().toString()); + } + msgs.add(msgItem); + response = dispatchEvent(msgs, jsonEventRaw); + } catch (Exception e) { + errorMessage = "HandleRequest execution error"; + logger.error(errorMessage, e); + throw new FunctionRuntimeException(errorMessage, e); + } + + if (response == null) { + return ""; + } + + if (!response.isHandled()) { + //Throw exception in order to mark the message as not processed. + logger.error(String.format("Messages were not handled. Error: %s", response.getErrorMessage())); + throw new RuntimeException(response.getErrorMessage()); + } + return Helper.toJSONString(response); + } +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java index 568348f4f..c4beb28ef 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java @@ -18,7 +18,7 @@ import java.util.Map; -public class LambdaSQSHandler extends LambdaBaseHandler implements RequestHandler { +public class LambdaSQSHandler extends LambdaBaseEventHandler implements RequestHandler { public LambdaSQSHandler() throws Exception { super(); @@ -64,7 +64,7 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) { String errorMessage; try { - EventMessageResponse response = dispatchEventMessages(msgs, Helper.toJSONString(sqsEvent)); + EventMessageResponse response = dispatchEvent(msgs, Helper.toJSONString(sqsEvent)); wasHandled = response.isHandled(); errorMessage = response.getErrorMessage(); } catch (Exception e) { diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionRuntimeException.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionRuntimeException.java new file mode 100644 index 000000000..83849cc79 --- /dev/null +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/exception/FunctionRuntimeException.java @@ -0,0 +1,9 @@ +package com.genexus.cloud.serverless.exception; + +public class FunctionRuntimeException extends RuntimeException { + + public FunctionRuntimeException(String errorMessage, Throwable e) { + super(errorMessage, e); + } + +} diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java index 776bb716b..2211b0528 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageResponse.java @@ -4,10 +4,10 @@ public class EventMessageResponse { @JsonProperty("Handled") - private boolean handled; + private boolean handled = false; @JsonProperty("ErrorMessage") - private String errorMessage; + private String errorMessage = ""; public boolean isHandled() { return handled; @@ -24,4 +24,5 @@ public String getErrorMessage() { public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } + } diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java new file mode 100644 index 000000000..8a9f002af --- /dev/null +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java @@ -0,0 +1,62 @@ +package com.genexus.cloud.aws.events; + +import com.genexus.cloud.serverless.aws.handler.LambdaEventBridgeHandler; +import com.unittest.eventdriven.dummy.handlerruntimeexception; +import com.unittest.eventdriven.dummy.handlesimplenoparmsevent; +import com.unittest.eventdriven.dummy.handlesimplesqsevent; +import com.unittest.eventdriven.dummy.handlesimplesqsevent2; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +public class TestLambdaEventBridgeHandler { + private static String SIMPLE_HANDLER = handlesimplesqsevent2.class.getName(); + private static String SIMPLE_RAW_HANDLER = handlesimplesqsevent.class.getName(); + private static String SIMPLE_NO_OUTPUT_HANDLER_EXCEPTION = handlerruntimeexception.class.getName(); + + private Map createEvent() { + Map evt = new HashMap(); + evt.put("id", "d043a3b9-7e7f-41d3-9656-6fe970b62888"); + evt.put("time", "2022-05-24T00:43:16Z"); + return evt; + } + + @Test + public void simpleEvent() throws Exception { + LambdaEventBridgeHandler handler = new LambdaEventBridgeHandler(SIMPLE_HANDLER); + String result = handler.handleRequest(createEvent(), new MockContext()); + Assert.assertEquals("{\"Handled\":true,\"ErrorMessage\":\"\"}", result); + } + + @Test + public void simpleEventRaw() throws Exception { + LambdaEventBridgeHandler handler = new LambdaEventBridgeHandler(SIMPLE_RAW_HANDLER); + String result = handler.handleRequest(createEvent(), new MockContext()); + Assert.assertEquals("{\"Handled\":true,\"ErrorMessage\":\"\"}", result); + } + + @Test + public void simpleEventNoParms() throws Exception { + LambdaEventBridgeHandler handler = new LambdaEventBridgeHandler(handlesimplenoparmsevent.class.getName()); + String result = handler.handleRequest(createEvent(), new MockContext()); + Assert.assertEquals("{\"Handled\":true,\"ErrorMessage\":\"\"}", result); + } + + + @Test + public void handlerExceptionError() throws Exception { + LambdaEventBridgeHandler handler = new LambdaEventBridgeHandler(SIMPLE_NO_OUTPUT_HANDLER_EXCEPTION); + + Exception thrown = null; + try { + String result = handler.handleRequest(createEvent(), new MockContext()); + } + catch (Exception e) { + thrown = e; + } + Assert.assertNotNull(thrown); + } + +} diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlerruntimeexception.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlerruntimeexception.java new file mode 100644 index 000000000..7e7190d16 --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlerruntimeexception.java @@ -0,0 +1,58 @@ +package com.unittest.eventdriven.dummy; + +import com.genexus.GXProcedure; +import com.genexus.ModelContext; + +public final class handlerruntimeexception extends GXProcedure { + public handlerruntimeexception(int remoteHandle) { + super(remoteHandle, new ModelContext(handlerruntimeexception.class), ""); + } + + public handlerruntimeexception(int remoteHandle, ModelContext context) { + super(remoteHandle, context, ""); + } + + + public void execute(String s, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + execute_int(s, aP1); + } + + private void execute_int(String s, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + handlerruntimeexception.this.aP1 = aP1; + initialize(); + /* GeneXus formulas */ + /* Output device settings */ + privateExecute(); + } + + private void privateExecute() { + System.out.println("START Schedule Event received"); + throw new RuntimeException("Handler error"); + } + + protected void cleanup() { + this.aP1[0] = handlerruntimeexception.this.AV9EventMessageResponse; + CloseOpenCursors(); + exitApp(); + } + + protected void CloseOpenCursors() { + } + + /* Aggregate/select formulas */ + public void initialize() { + AV9EventMessageResponse = new com.genexus.genexusserverlessapi.SdtEventMessageResponse(remoteHandle, context); + AV16Pgmname = ""; + AV16Pgmname = "EventDriven.Queue.HandleSimpleRAWSQSEvent"; + /* GeneXus formulas. */ + AV16Pgmname = "EventDriven.Queue.HandleSimpleRAWSQSEvent"; + Gx_err = (short) (0); + } + + private short Gx_err; + private String AV13RAWMessage; + private String AV16Pgmname; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse; +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplenoparmsevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplenoparmsevent.java new file mode 100644 index 000000000..66ca40440 --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplenoparmsevent.java @@ -0,0 +1,47 @@ +package com.unittest.eventdriven.dummy; + +import com.genexus.GXProcedure; +import com.genexus.ModelContext; + +public final class handlesimplenoparmsevent extends GXProcedure { + public handlesimplenoparmsevent(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimplenoparmsevent.class), ""); + } + + public handlesimplenoparmsevent(int remoteHandle, ModelContext context) { + super(remoteHandle, context, ""); + } + + + public void execute() { + execute_int(); + } + + private void execute_int() { + initialize(); + /* GeneXus formulas */ + /* Output device settings */ + privateExecute(); + } + + private void privateExecute() { + System.out.println("START EventBridge Event received with no parms"); + System.out.println("END EventBridge Event"); + cleanup(); + } + + protected void cleanup() { + CloseOpenCursors(); + exitApp(); + } + + protected void CloseOpenCursors() { + } + + /* Aggregate/select formulas */ + public void initialize() { + + } + +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent.java new file mode 100644 index 000000000..6bc8f2d21 --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent.java @@ -0,0 +1,61 @@ +package com.unittest.eventdriven.dummy; + +import com.genexus.GXProcedure; +import com.genexus.ModelContext; + +public final class handlesimplesqsevent extends GXProcedure { + public handlesimplesqsevent(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimplesqsevent.class), ""); + } + + public handlesimplesqsevent(int remoteHandle, ModelContext context) { + super(remoteHandle, context, ""); + } + + + public void execute(String aP0, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + execute_int(aP0, aP1); + } + + private void execute_int(String aP0, com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + handlesimplesqsevent.this.AV13RAWMessage = aP0; + handlesimplesqsevent.this.aP1 = aP1; + initialize(); + /* GeneXus formulas */ + /* Output device settings */ + privateExecute(); + } + + private void privateExecute() { + System.out.println("START EventBridge Event received"); + System.out.println("END EventBridge Event received"); + handlesimplesqsevent.this.AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled(true); + cleanup(); + } + + protected void cleanup() { + this.aP1[0] = handlesimplesqsevent.this.AV9EventMessageResponse; + CloseOpenCursors(); + exitApp(); + } + + protected void CloseOpenCursors() { + } + + /* Aggregate/select formulas */ + public void initialize() { + AV9EventMessageResponse = new com.genexus.genexusserverlessapi.SdtEventMessageResponse(remoteHandle, context); + AV16Pgmname = ""; + AV16Pgmname = "EventDriven.Queue.HandleSimpleRAWSQSEvent"; + /* GeneXus formulas. */ + AV16Pgmname = "EventDriven.Queue.HandleSimpleRAWSQSEvent"; + Gx_err = (short) (0); + } + + private short Gx_err; + private String AV13RAWMessage; + private String AV16Pgmname; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse; +} + diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent2.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent2.java new file mode 100644 index 000000000..d12c39f98 --- /dev/null +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/dummy/handlesimplesqsevent2.java @@ -0,0 +1,80 @@ +package com.unittest.eventdriven.dummy; + +import com.genexus.GXBaseCollection; +import com.genexus.GXProcedure; +import com.genexus.ModelContext; +import com.genexus.SdtMessages_Message; + +public final class handlesimplesqsevent2 extends GXProcedure { + public handlesimplesqsevent2(int remoteHandle) { + super(remoteHandle, new ModelContext(handlesimplesqsevent2.class), ""); + } + + public handlesimplesqsevent2(int remoteHandle, + ModelContext context) { + super(remoteHandle, context, ""); + } + + @SuppressWarnings("unchecked") + public com.genexus.genexusserverlessapi.SdtEventMessageResponse executeUdp(com.genexus.genexusserverlessapi.SdtEventMessages aP0) { + handlesimplesqsevent2.this.aP1 = new com.genexus.genexusserverlessapi.SdtEventMessageResponse[]{new com.genexus.genexusserverlessapi.SdtEventMessageResponse()}; + execute_int(aP0, aP1); + return aP1[0]; + } + + public void execute(com.genexus.genexusserverlessapi.SdtEventMessages aP0, + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + execute_int(aP0, aP1); + } + + private void execute_int(com.genexus.genexusserverlessapi.SdtEventMessages aP0, + com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1) { + handlesimplesqsevent2.this.AV8EventMessages = aP0; + handlesimplesqsevent2.this.aP1 = aP1; + initialize(); + /* GeneXus formulas */ + /* Output device settings */ + privateExecute(); + } + + private void privateExecute() { + System.out.println("START EventBridge Event received"); + System.out.println("END EventBridge Event received"); + handlesimplesqsevent2.this.AV9EventMessageResponse.setgxTv_SdtEventMessageResponse_Handled(true); + cleanup(); + } + + protected void cleanup() { + this.aP1[0] = handlesimplesqsevent2.this.AV9EventMessageResponse; + CloseOpenCursors(); + exitApp(); + } + + protected void CloseOpenCursors() { + } + + /* Aggregate/select formulas */ + public void initialize() { + AV9EventMessageResponse = new com.genexus.genexusserverlessapi.SdtEventMessageResponse(remoteHandle, context); + AV15Pgmname = ""; + AV10EventMessage = new com.genexus.genexusserverlessapi.SdtEventMessage(remoteHandle, context); + AV12OutMessages = new GXBaseCollection(SdtMessages_Message.class, "Message", "GeneXus", remoteHandle); + AV11UserSDT = new com.unittest.eventdriven.SdtUser(remoteHandle); + AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent"; + /* GeneXus formulas. */ + AV15Pgmname = "EventDriven.Queue.HandleSimpleUserQueueEvent"; + Gx_err = (short) (0); + } + + private short Gx_err; + private int AV16GXV1; + private String AV15Pgmname; + private boolean returnInSub; + private com.unittest.eventdriven.SdtUser AV11UserSDT; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse[] aP1; + private GXBaseCollection AV12OutMessages; + private com.genexus.genexusserverlessapi.SdtEventMessages AV8EventMessages; + private com.genexus.genexusserverlessapi.SdtEventMessage AV10EventMessage; + private com.genexus.genexusserverlessapi.SdtEventMessageResponse AV9EventMessageResponse; +} + From 0c5b9ba28fcbb181e4bc578452404c68afa054ec Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Mon, 6 Jun 2022 12:31:31 -0300 Subject: [PATCH 10/12] Member detail failed to serialized. Added unit tests --- .../serverless/aws/handler/LambdaEventBridgeHandler.java | 6 +++++- .../cloud/aws/events/TestLambdaEventBridgeHandler.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java index 9d84dae68..1073a46cd 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java @@ -2,6 +2,7 @@ import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.fasterxml.jackson.databind.ObjectMapper; import com.genexus.cloud.serverless.Helper; import com.genexus.cloud.serverless.exception.FunctionRuntimeException; import com.genexus.cloud.serverless.model.EventMessage; @@ -9,6 +10,7 @@ import com.genexus.cloud.serverless.model.EventMessageSourceType; import com.genexus.cloud.serverless.model.EventMessages; import com.genexus.webpanels.WebUtils; +import json.org.json.JSONObject; import java.util.Map; @@ -40,7 +42,9 @@ public String handleRequest(Map stringObjectMap, Context context msgItem.setMessageDate(WebUtils.parseDTimeParm(stringObjectMap.get("time").toString())); } msgItem.setMessageId(stringObjectMap.getOrDefault("id", "").toString()); - msgItem.setMessageData(stringObjectMap.getOrDefault("detail", "").toString()); + if (stringObjectMap.containsKey("detail")) { + msgItem.setMessageData(new JSONObject(jsonEventRaw).getString("detail")); + } for (Map.Entry entry : stringObjectMap.entrySet()) { Helper.addEventMessageProperty(msgItem, entry.getKey(), entry.getValue().toString()); } diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java index 8a9f002af..b83e4dad8 100644 --- a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java @@ -20,6 +20,9 @@ private Map createEvent() { Map evt = new HashMap(); evt.put("id", "d043a3b9-7e7f-41d3-9656-6fe970b62888"); evt.put("time", "2022-05-24T00:43:16Z"); + Map detail = new HashMap<>(); + detail.put("name", "test"); + evt.put("detail", detail); return evt; } From 6920bf1fe52059e276abd65d4f7b26ab3e86146f Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Tue, 21 Jun 2022 14:58:55 -0300 Subject: [PATCH 11/12] Formatting fixes --- .../events/TestLambdaEventBridgeHandler.java | 3 +- .../test/jersey/GeneXusAppAwsProxyTest.java | 28 +- .../proxy/test/jersey/JerseyAwsProxyTest.java | 282 +++++++++--------- 3 files changed, 156 insertions(+), 157 deletions(-) diff --git a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java index b83e4dad8..0d4d37098 100644 --- a/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java +++ b/gxawsserverless/src/test/java/com/genexus/cloud/aws/events/TestLambdaEventBridgeHandler.java @@ -55,8 +55,7 @@ public void handlerExceptionError() throws Exception { Exception thrown = null; try { String result = handler.handleRequest(createEvent(), new MockContext()); - } - catch (Exception e) { + } catch (Exception e) { thrown = e; } Assert.assertNotNull(thrown); diff --git a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java index d606bff20..797992e31 100644 --- a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java +++ b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/GeneXusAppAwsProxyTest.java @@ -39,24 +39,24 @@ */ public class GeneXusAppAwsProxyTest { - private static final String CUSTOM_HEADER_KEY = "x-custom-header"; - private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; + private static final String CUSTOM_HEADER_KEY = "x-custom-header"; + private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; - private ResourceConfig app; - private LambdaHandler l; + private ResourceConfig app; + private LambdaHandler l; - @Before - public void setUpStreams() { + @Before + public void setUpStreams() { Connect.init(); - try { - System.setProperty("LAMBDA_TASK_ROOT", "."); - l = new LambdaHandler(); - handler = LambdaHandler.handler; - } catch (Exception e) { - e.printStackTrace(); - } - } + try { + System.setProperty("LAMBDA_TASK_ROOT", "."); + l = new LambdaHandler(); + handler = LambdaHandler.handler; + } catch (Exception e) { + e.printStackTrace(); + } + } public GeneXusAppAwsProxyTest() { diff --git a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java index 545ce00b3..ce572407f 100644 --- a/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java +++ b/gxawsserverless/src/test/java/com/genexus/serverless/proxy/test/jersey/JerseyAwsProxyTest.java @@ -52,149 +52,149 @@ */ public class JerseyAwsProxyTest { - private static final String CUSTOM_HEADER_KEY = "x-custom-header"; - private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; + private static final String CUSTOM_HEADER_KEY = "x-custom-header"; + private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; - private ResourceConfig app; - private LambdaHandler l; + private ResourceConfig app; + private LambdaHandler l; - @Before - public void setUpStreams() { + @Before + public void setUpStreams() { Connect.init(); - try { - System.setProperty("LAMBDA_TASK_ROOT", "."); - l = new LambdaHandler(); - handler = LambdaHandler.handler; - } catch (Exception e) { - e.printStackTrace(); - } - } - - public JerseyAwsProxyTest() { - - } - - private JerseyLambdaContainerHandler handler = null; - - private static ObjectMapper objectMapper = new ObjectMapper(); - - private static Context lambdaContext = new MockLambdaContext(); - - - @Test - public void headers_getHeaders_echo() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/headers", "GET") - .json() - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - } - - @Test - public void headers_servletRequest_echo() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/servlet-headers", "GET") - .json() - .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - validateMapResponseModel(output); - } - - @Test - public void queryString_uriInfo_echo() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/query-string", "GET") - .json() - .queryString(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - validateMapResponseModel(output); - } - - - @Test - public void errors_unknownRoute_expect404() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/test33", "GET").build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(404, output.getStatusCode()); - } - - @Test - public void error_contentType_invalidContentType() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") - .header("Content-Type", "application/octet-stream") - .body("asdasdasd") - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(415, output.getStatusCode()); - } - - @Test - public void error_statusCode_methodNotAllowed() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "POST") - .json() - .queryString("status", "201") - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(405, output.getStatusCode()); - } - - @Test - public void responseBody_responseWriter_validBody() throws JsonProcessingException { - SingleValueModel singleValueModel = new SingleValueModel(); - singleValueModel.setValue(CUSTOM_HEADER_VALUE); - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") - .json() - .body(objectMapper.writeValueAsString(singleValueModel)) - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(200, output.getStatusCode()); - assertNotNull(output.getBody()); - - validateSingleValueModel(output, CUSTOM_HEADER_VALUE); - } - - @Test - public void statusCode_responseStatusCode_customStatusCode() { - AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "GET") - .json() - .queryString("status", "201") - .build(); - - AwsProxyResponse output = handler.proxy(request, lambdaContext); - assertEquals(201, output.getStatusCode()); - } - - - private void validateMapResponseModel(AwsProxyResponse output) { - try { - MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class); - assertNotNull(response.getValues().get(CUSTOM_HEADER_KEY)); - assertEquals(CUSTOM_HEADER_VALUE, response.getValues().get(CUSTOM_HEADER_KEY)); - } catch (IOException e) { - fail("Exception while parsing response body: " + e.getMessage()); - e.printStackTrace(); - } - } - - private void validateSingleValueModel(AwsProxyResponse output, String value) { - try { - SingleValueModel response = objectMapper.readValue(output.getBody(), SingleValueModel.class); - assertNotNull(response.getValue()); - assertEquals(value, response.getValue()); - } catch (IOException e) { - fail("Exception while parsing response body: " + e.getMessage()); - e.printStackTrace(); - } - } + try { + System.setProperty("LAMBDA_TASK_ROOT", "."); + l = new LambdaHandler(); + handler = LambdaHandler.handler; + } catch (Exception e) { + e.printStackTrace(); + } + } + + public JerseyAwsProxyTest() { + + } + + private JerseyLambdaContainerHandler handler = null; + + private static ObjectMapper objectMapper = new ObjectMapper(); + + private static Context lambdaContext = new MockLambdaContext(); + + + @Test + public void headers_getHeaders_echo() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/headers", "GET") + .json() + .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + } + + @Test + public void headers_servletRequest_echo() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/servlet-headers", "GET") + .json() + .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + validateMapResponseModel(output); + } + + @Test + public void queryString_uriInfo_echo() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/query-string", "GET") + .json() + .queryString(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + validateMapResponseModel(output); + } + + + @Test + public void errors_unknownRoute_expect404() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/test33", "GET").build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(404, output.getStatusCode()); + } + + @Test + public void error_contentType_invalidContentType() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") + .header("Content-Type", "application/octet-stream") + .body("asdasdasd") + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(415, output.getStatusCode()); + } + + @Test + public void error_statusCode_methodNotAllowed() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "POST") + .json() + .queryString("status", "201") + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(405, output.getStatusCode()); + } + + @Test + public void responseBody_responseWriter_validBody() throws JsonProcessingException { + SingleValueModel singleValueModel = new SingleValueModel(); + singleValueModel.setValue(CUSTOM_HEADER_VALUE); + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/json-body", "POST") + .json() + .body(objectMapper.writeValueAsString(singleValueModel)) + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(200, output.getStatusCode()); + assertNotNull(output.getBody()); + + validateSingleValueModel(output, CUSTOM_HEADER_VALUE); + } + + @Test + public void statusCode_responseStatusCode_customStatusCode() { + AwsProxyRequest request = new AwsProxyRequestBuilder("/echo/status-code", "GET") + .json() + .queryString("status", "201") + .build(); + + AwsProxyResponse output = handler.proxy(request, lambdaContext); + assertEquals(201, output.getStatusCode()); + } + + + private void validateMapResponseModel(AwsProxyResponse output) { + try { + MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class); + assertNotNull(response.getValues().get(CUSTOM_HEADER_KEY)); + assertEquals(CUSTOM_HEADER_VALUE, response.getValues().get(CUSTOM_HEADER_KEY)); + } catch (IOException e) { + fail("Exception while parsing response body: " + e.getMessage()); + e.printStackTrace(); + } + } + + private void validateSingleValueModel(AwsProxyResponse output, String value) { + try { + SingleValueModel response = objectMapper.readValue(output.getBody(), SingleValueModel.class); + assertNotNull(response.getValue()); + assertEquals(value, response.getValue()); + } catch (IOException e) { + fail("Exception while parsing response body: " + e.getMessage()); + e.printStackTrace(); + } + } } From 7020b95c2507112ea94bcb81462bc16739b607db Mon Sep 17 00:00:00 2001 From: Gonzalo Gallotti Date: Thu, 23 Jun 2022 09:35:22 -0300 Subject: [PATCH 12/12] Address @iroqueta review comments --- .../cloud/serverless/GXProcedureExecutor.java | 8 +- .../com/genexus/cloud/serverless/Helper.java | 9 +- .../aws/handler/LambdaBaseEventHandler.java | 6 +- .../aws/handler/LambdaEventBridgeHandler.java | 12 +- .../LambdaFunctionConfigurationHelper.java | 2 +- .../aws/handler/LambdaSQSHandler.java | 2 +- .../model/EventMessageSourceType.java | 8 +- ...tEventCustomPayload_CustomPayloadItem.java | 14 - .../genexusserverlessapi/SdtEventMessage.java | 42 --- .../SdtEventMessages.java | 15 - .../com/unittest/eventdriven/SdtUser.java | 325 ------------------ 11 files changed, 22 insertions(+), 421 deletions(-) diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java index fa9e42121..3809181b1 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/GXProcedureExecutor.java @@ -19,16 +19,14 @@ public class GXProcedureExecutor { protected Class entryPointClass; - private ModelContext modelContext; private Class[][] supportedMethodSignatures = new Class[5][]; private int methodSignatureIdx = -1; protected static final String MESSAGE_COLLECTION_INPUT_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessages"; protected static final String MESSAGE_OUTPUT_COLLECTION_CLASS_NAME = "com.genexus.genexusserverlessapi.SdtEventMessageResponse"; - public GXProcedureExecutor(String procedureClassName) throws ClassNotFoundException, NotImplementedException { - entryPointClass = (Class) Class.forName(procedureClassName); - + public GXProcedureExecutor(Class entryPointClassParms) throws ClassNotFoundException, NotImplementedException { + entryPointClass = entryPointClassParms; supportedMethodSignatures[0] = new Class[]{Class.forName(MESSAGE_COLLECTION_INPUT_CLASS_NAME), Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME)}; supportedMethodSignatures[1] = new Class[]{String.class, Class.forName(MESSAGE_OUTPUT_COLLECTION_CLASS_NAME)}; supportedMethodSignatures[2] = new Class[]{String.class}; @@ -38,7 +36,7 @@ public GXProcedureExecutor(String procedureClassName) throws ClassNotFoundExcept Optional executeMethodOpt = Arrays.stream(this.entryPointClass.getDeclaredMethods()).filter(m -> m.getName() == DynamicExecute.METHOD_EXECUTE).findFirst(); if (!executeMethodOpt.isPresent()) { - throw new NotImplementedException(String.format("EXECUTE Method not implemented on Class '%s'", procedureClassName)); + throw new NotImplementedException(String.format("EXECUTE Method not implemented on Class '%s'", entryPointClass.getName())); } Method executeMethod = executeMethodOpt.get(); diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java index dc3338a9f..1f86e4c0b 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/Helper.java @@ -1,18 +1,23 @@ package com.genexus.cloud.serverless; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.genexus.cloud.serverless.model.EventMessage; import com.genexus.cloud.serverless.model.EventMessageProperty; +import com.genexus.diagnostics.core.ILogger; +import com.genexus.diagnostics.core.LogManager; public class Helper { + private static final ILogger logger = LogManager.getLogger(Helper.class); + public static String toJSONString(Object dtoObject) { try { ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(dtoObject); } - catch (Exception e) { } + catch (Exception e) { + logger.error("Failed to serialize object to jsonString", e); + } return ""; } diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java index 5cb19e337..02ec3b03f 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaBaseEventHandler.java @@ -58,11 +58,7 @@ private void initialize() throws Exception { throw e; } - if (entryPointClass == null) { - throw new ClassNotFoundException(String.format("GeneXus Procedure '%s' was not found. Check deployment package ", functionConfiguration.getEntryPointClassName())); - } - - executor = new GXProcedureExecutor(functionConfiguration.getEntryPointClassName()); + executor = new GXProcedureExecutor(entryPointClass); } protected EventMessageResponse dispatchEvent(EventMessages eventMessages, String lambdaRawMessageBody) throws Exception { diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java index 1073a46cd..c3ae7c7bb 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaEventBridgeHandler.java @@ -2,15 +2,14 @@ import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.RequestHandler; -import com.fasterxml.jackson.databind.ObjectMapper; import com.genexus.cloud.serverless.Helper; import com.genexus.cloud.serverless.exception.FunctionRuntimeException; import com.genexus.cloud.serverless.model.EventMessage; import com.genexus.cloud.serverless.model.EventMessageResponse; import com.genexus.cloud.serverless.model.EventMessageSourceType; import com.genexus.cloud.serverless.model.EventMessages; -import com.genexus.webpanels.WebUtils; import json.org.json.JSONObject; +import org.apache.http.client.utils.DateUtils; import java.util.Map; @@ -27,9 +26,8 @@ public LambdaEventBridgeHandler(String entryPointClassName) throws Exception { @Override public String handleRequest(Map stringObjectMap, Context context) { String jsonEventRaw = Helper.toJSONString(stringObjectMap); - if (logger.isDebugEnabled()) { - logger.debug("handleRequest started with event: " + jsonEventRaw); - } + + logger.debug("handleRequest started with event: " + jsonEventRaw); String errorMessage; EventMessageResponse response; @@ -37,9 +35,9 @@ public String handleRequest(Map stringObjectMap, Context context try { EventMessages msgs = new EventMessages(); EventMessage msgItem = new EventMessage(); - msgItem.setMessageSourceType(EventMessageSourceType.ServiceBusMessage); + msgItem.setMessageSourceType(EventMessageSourceType.SERVICE_BUS_MESSAGE); if (stringObjectMap.containsKey("time")) { - msgItem.setMessageDate(WebUtils.parseDTimeParm(stringObjectMap.get("time").toString())); + msgItem.setMessageDate(DateUtils.parseDate(stringObjectMap.get("time").toString())); } msgItem.setMessageId(stringObjectMap.getOrDefault("id", "").toString()); if (stringObjectMap.containsKey("detail")) { diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java index b8626d0ff..b66e79d3b 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaFunctionConfigurationHelper.java @@ -35,7 +35,7 @@ public static LambdaFunctionConfiguration getFunctionConfiguration() throws Func config.setEntryPointClassName(System.getenv(ENTRY_POINT_CLASS_NAME_VAR)); } - if (config == null || !config.isValidConfiguration()) { + if (!config.isValidConfiguration()) { throw new FunctionConfigurationException(String.format("Please check function configuration. Either file '%s' should be present, or '%s' Environment Variable must be defined", FUNCTION_CONFIG_PATH, ENTRY_POINT_CLASS_NAME_VAR)); } return config; diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java index c4beb28ef..24034679a 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/aws/handler/LambdaSQSHandler.java @@ -40,7 +40,7 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) { logger.debug(String.format("Processing sqsEvent Message: %s", sqsItem.getMessageId())); EventMessage msg = new EventMessage(); msg.setMessageId(sqsItem.getMessageId()); - msg.setMessageSourceType(EventMessageSourceType.QueueMessage); + msg.setMessageSourceType(EventMessageSourceType.QUEUE_MESSAGE); msg.setMessageDate(new Date()); msg.setMessageData(sqsItem.getBody()); List msgAtts = msg.getMessageProperties(); diff --git a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java index cb8aa9e78..8421202d2 100644 --- a/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java +++ b/gxawsserverless/src/main/java/com/genexus/cloud/serverless/model/EventMessageSourceType.java @@ -1,8 +1,8 @@ package com.genexus.cloud.serverless.model; public class EventMessageSourceType { - public static String QueueMessage = "QueueMessage"; - public static String ServiceBusMessage = "ServiceBusMessage"; - public static String Timer = "Timer"; - public static String StreamMessage = "StreamMessage"; + public static String QUEUE_MESSAGE = "QueueMessage"; + public static String SERVICE_BUS_MESSAGE = "ServiceBusMessage"; + public static String TIMER = "Timer"; + public static String STREAM_MESSAGE = "StreamMessage"; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java index 55b44e80f..7510b3ed8 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventCustomPayload_CustomPayloadItem.java @@ -36,20 +36,6 @@ public String getJsonMap(String value) { return (String) mapper.get(value); } - public void tojson() { - tojson(true); - } - - public void tojson(boolean includeState) { - tojson(includeState, true); - } - - public void tojson(boolean includeState, - boolean includeNonInitialized) { - AddObjectProperty("PropertyId", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid, false, false); - AddObjectProperty("PropertyValue", gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyvalue, false, false); - } - public String getgxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid() { return gxTv_SdtEventCustomPayload_CustomPayloadItem_Propertyid; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java index 515468902..d3502078e 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessage.java @@ -24,52 +24,10 @@ public SdtEventMessage(StructSdtEventMessage struct) { private static java.util.HashMap mapper = new java.util.HashMap(); - static { - } - public String getJsonMap(String value) { return (String) mapper.get(value); } - public void tojson() { - tojson(true); - } - - public void tojson(boolean includeState) { - tojson(includeState, true); - } - - public void tojson(boolean includeState, - boolean includeNonInitialized) { - AddObjectProperty("EventMessageId", gxTv_SdtEventMessage_Eventmessageid, false, false); - datetime_STZ = gxTv_SdtEventMessage_Eventmessagedate; - sDateCnv = ""; - sNumToPad = GXutil.trim(GXutil.str(GXutil.year(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.month(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.day(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "T"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.second(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - AddObjectProperty("EventMessageDate", sDateCnv, false, false); - AddObjectProperty("EventMessageSourceType", gxTv_SdtEventMessage_Eventmessagesourcetype, false, false); - AddObjectProperty("EventMessageData", gxTv_SdtEventMessage_Eventmessagedata, false, false); - AddObjectProperty("EventMessageVersion", gxTv_SdtEventMessage_Eventmessageversion, false, false); - if (gxTv_SdtEventMessage_Eventmessagecustompayload != null) { - AddObjectProperty("EventMessageCustomPayload", gxTv_SdtEventMessage_Eventmessagecustompayload, false, false); - } - } - public String getgxTv_SdtEventMessage_Eventmessageid() { return gxTv_SdtEventMessage_Eventmessageid; } diff --git a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java index 2f95b6ef0..af0c5fb35 100644 --- a/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java +++ b/gxawsserverless/src/test/java/com/genexus/genexusserverlessapi/SdtEventMessages.java @@ -36,21 +36,6 @@ public String getJsonMap(String value) { return (String) mapper.get(value); } - public void tojson() { - tojson(true); - } - - public void tojson(boolean includeState) { - tojson(includeState, true); - } - - public void tojson(boolean includeState, - boolean includeNonInitialized) { - if (gxTv_SdtEventMessages_Eventmessage != null) { - AddObjectProperty("EventMessage", gxTv_SdtEventMessages_Eventmessage, false, false); - } - } - public GXBaseCollection getgxTv_SdtEventMessages_Eventmessage() { if (gxTv_SdtEventMessages_Eventmessage == null) { gxTv_SdtEventMessages_Eventmessage = new GXBaseCollection(com.genexus.genexusserverlessapi.SdtEventMessage.class, "EventMessage", "ServerlessAPI", remoteHandle); diff --git a/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java b/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java index a30d1e4cd..73f489a6b 100644 --- a/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java +++ b/gxawsserverless/src/test/java/com/unittest/eventdriven/SdtUser.java @@ -34,326 +34,6 @@ public String getJsonMap(String value) { return (String) mapper.get(value); } - public void Load(UUID AV4UserId) { - IGxSilentTrn obj; - obj = getTransaction(); - obj.LoadKey(new Object[]{AV4UserId}); - } - - public void LoadStrParms(String sAV4UserId) { - UUID AV4UserId; - AV4UserId = GXutil.strToGuid(sAV4UserId); - Load(AV4UserId); - } - - public Object[][] GetBCKey() { - return (Object[][]) (new Object[][]{new Object[]{"UserId", UUID.class}}); - } - - public com.genexus.util.GXProperties getMetadata() { - com.genexus.util.GXProperties metadata = new com.genexus.util.GXProperties(); - metadata.set("Name", "EventDriven\\User"); - metadata.set("BT", "User"); - metadata.set("PK", "[ \"UserId\" ]"); - metadata.set("PKAssigned", "[ \"UserId\" ]"); - metadata.set("AllowInsert", "True"); - metadata.set("AllowUpdate", "True"); - metadata.set("AllowDelete", "True"); - return metadata; - } - - public short readxml(XMLReader oReader, - String sName) { - short GXSoapError = 1; - formatError = false; - sTagName = oReader.getName(); - if (oReader.getIsSimple() == 0) { - GXSoapError = oReader.read(); - nOutParmCount = (short) (0); - while (((GXutil.strcmp(oReader.getName(), sTagName) != 0) || (oReader.getNodeType() == 1)) && (GXSoapError > 0)) { - readOk = (short) (0); - readElement = false; - if (GXutil.strcmp2(oReader.getLocalName(), "UserId")) { - gxTv_SdtUser_Userid = GXutil.strToGuid(oReader.getValue()); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "UserName")) { - gxTv_SdtUser_Username = oReader.getValue(); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "UserRegisteredDateTime")) { - if ((GXutil.strcmp(oReader.getValue(), "") == 0) || (oReader.existsAttribute("xsi:nil") == 1)) { - gxTv_SdtUser_Userregistereddatetime = GXutil.resetTime(GXutil.nullDate()); - } else { - gxTv_SdtUser_Userregistereddatetime = localUtil.ymdhmsToT((short) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 1, 4), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 6, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 9, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 12, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 15, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 18, 2), ".")))); - } - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "UserEventMessageData")) { - gxTv_SdtUser_Usereventmessagedata = oReader.getValue(); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "Mode")) { - gxTv_SdtUser_Mode = oReader.getValue(); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "Initialized")) { - gxTv_SdtUser_Initialized = (short) (getnumericvalue(oReader.getValue())); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "UserId_Z")) { - gxTv_SdtUser_Userid_Z = GXutil.strToGuid(oReader.getValue()); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "UserName_Z")) { - gxTv_SdtUser_Username_Z = oReader.getValue(); - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (GXutil.strcmp2(oReader.getLocalName(), "UserRegisteredDateTime_Z")) { - if ((GXutil.strcmp(oReader.getValue(), "") == 0) || (oReader.existsAttribute("xsi:nil") == 1)) { - gxTv_SdtUser_Userregistereddatetime_Z = GXutil.resetTime(GXutil.nullDate()); - } else { - gxTv_SdtUser_Userregistereddatetime_Z = localUtil.ymdhmsToT((short) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 1, 4), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 6, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 9, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 12, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 15, 2), "."))), (byte) (DecimalUtil.decToDouble(CommonUtil.decimalVal(GXutil.substring(oReader.getValue(), 18, 2), ".")))); - } - readElement = true; - if (GXSoapError > 0) { - readOk = (short) (1); - } - GXSoapError = oReader.read(); - } - if (!readElement) { - readOk = (short) (1); - GXSoapError = oReader.read(); - } - nOutParmCount = (short) (nOutParmCount + 1); - if ((readOk == 0) || formatError) { - context.globals.sSOAPErrMsg += "Error reading " + sTagName + GXutil.newLine(); - context.globals.sSOAPErrMsg += "Message: " + oReader.readRawXML(); - GXSoapError = (short) (nOutParmCount * -1); - } - } - } - return GXSoapError; - } - - public void writexml(XMLWriter oWriter, - String sName, - String sNameSpace) { - writexml(oWriter, sName, sNameSpace, true); - } - - public void writexml(XMLWriter oWriter, - String sName, - String sNameSpace, - boolean sIncludeState) { - if ((GXutil.strcmp("", sName) == 0)) { - sName = "User"; - } - if ((GXutil.strcmp("", sNameSpace) == 0)) { - sNameSpace = "Issue95858"; - } - oWriter.writeStartElement(sName); - if (GXutil.strcmp(GXutil.left(sNameSpace, 10), "[*:nosend]") != 0) { - oWriter.writeAttribute("xmlns", sNameSpace); - } else { - sNameSpace = GXutil.right(sNameSpace, GXutil.len(sNameSpace) - 10); - } - oWriter.writeElement("UserId", gxTv_SdtUser_Userid.toString()); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserName", gxTv_SdtUser_Username); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - sDateCnv = ""; - sNumToPad = GXutil.trim(GXutil.str(GXutil.year(gxTv_SdtUser_Userregistereddatetime), 10, 0)); - sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.month(gxTv_SdtUser_Userregistereddatetime), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.day(gxTv_SdtUser_Userregistereddatetime), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "T"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(gxTv_SdtUser_Userregistereddatetime), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(gxTv_SdtUser_Userregistereddatetime), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.second(gxTv_SdtUser_Userregistereddatetime), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - oWriter.writeElement("UserRegisteredDateTime", sDateCnv); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - if (sIncludeState) { - oWriter.writeElement("Mode", gxTv_SdtUser_Mode); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("Initialized", GXutil.trim(GXutil.str(gxTv_SdtUser_Initialized, 4, 0))); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserId_Z", gxTv_SdtUser_Userid_Z.toString()); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - oWriter.writeElement("UserName_Z", gxTv_SdtUser_Username_Z); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - sDateCnv = ""; - sNumToPad = GXutil.trim(GXutil.str(GXutil.year(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); - sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.month(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.day(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "T"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.second(gxTv_SdtUser_Userregistereddatetime_Z), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - oWriter.writeElement("UserRegisteredDateTime_Z", sDateCnv); - if (GXutil.strcmp(sNameSpace, "Issue95858") != 0) { - oWriter.writeAttribute("xmlns", "Issue95858"); - } - } - oWriter.writeEndElement(); - } - - public long getnumericvalue(String value) { - if (GXutil.notNumeric(value)) { - formatError = true; - } - return GXutil.lval(value); - } - - public void tojson() { - tojson(true); - } - - public void tojson(boolean includeState) { - tojson(includeState, true); - } - - public void tojson(boolean includeState, - boolean includeNonInitialized) { - AddObjectProperty("UserId", gxTv_SdtUser_Userid, false, includeNonInitialized); - AddObjectProperty("UserName", gxTv_SdtUser_Username, false, includeNonInitialized); - datetime_STZ = gxTv_SdtUser_Userregistereddatetime; - sDateCnv = ""; - sNumToPad = GXutil.trim(GXutil.str(GXutil.year(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.month(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.day(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "T"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.second(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - AddObjectProperty("UserRegisteredDateTime", sDateCnv, false, includeNonInitialized); - AddObjectProperty("UserEventMessageData", gxTv_SdtUser_Usereventmessagedata, false, includeNonInitialized); - if (includeState) { - AddObjectProperty("Mode", gxTv_SdtUser_Mode, false, includeNonInitialized); - AddObjectProperty("Initialized", gxTv_SdtUser_Initialized, false, includeNonInitialized); - AddObjectProperty("UserId_Z", gxTv_SdtUser_Userid_Z, false, includeNonInitialized); - AddObjectProperty("UserName_Z", gxTv_SdtUser_Username_Z, false, includeNonInitialized); - datetime_STZ = gxTv_SdtUser_Userregistereddatetime_Z; - sDateCnv = ""; - sNumToPad = GXutil.trim(GXutil.str(GXutil.year(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("0000", 1, 4 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.month(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "-"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.day(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += "T"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.hour(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.minute(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - sDateCnv += ":"; - sNumToPad = GXutil.trim(GXutil.str(GXutil.second(datetime_STZ), 10, 0)); - sDateCnv += GXutil.substring("00", 1, 2 - GXutil.len(sNumToPad)) + sNumToPad; - AddObjectProperty("UserRegisteredDateTime_Z", sDateCnv, false, includeNonInitialized); - } - } - - public void updateDirties(SdtUser sdt) { - if (sdt.IsDirty("UserId")) { - gxTv_SdtUser_N = (byte) (0); - gxTv_SdtUser_Userid = sdt.getgxTv_SdtUser_Userid(); - } - if (sdt.IsDirty("UserName")) { - gxTv_SdtUser_N = (byte) (0); - gxTv_SdtUser_Username = sdt.getgxTv_SdtUser_Username(); - } - if (sdt.IsDirty("UserRegisteredDateTime")) { - gxTv_SdtUser_N = (byte) (0); - gxTv_SdtUser_Userregistereddatetime = sdt.getgxTv_SdtUser_Userregistereddatetime(); - } - if (sdt.IsDirty("UserEventMessageData")) { - gxTv_SdtUser_N = (byte) (0); - gxTv_SdtUser_Usereventmessagedata = sdt.getgxTv_SdtUser_Usereventmessagedata(); - } - } - public UUID getgxTv_SdtUser_Userid() { return gxTv_SdtUser_Userid; } @@ -546,8 +226,6 @@ public com.unittest.eventdriven.StructSdtUser getStruct() { private byte gxTv_SdtUser_N; private short gxTv_SdtUser_Initialized; - private short readOk; - private short nOutParmCount; private String gxTv_SdtUser_Username; private String gxTv_SdtUser_Mode; private String gxTv_SdtUser_Username_Z; @@ -557,10 +235,7 @@ public com.unittest.eventdriven.StructSdtUser getStruct() { private Date gxTv_SdtUser_Userregistereddatetime; private Date gxTv_SdtUser_Userregistereddatetime_Z; private Date datetime_STZ; - private boolean readElement; - private boolean formatError; private String gxTv_SdtUser_Usereventmessagedata; - private UUID AV4UserId; private UUID gxTv_SdtUser_Userid; private UUID gxTv_SdtUser_Userid_Z; }