From 232fbf12d69f3b68b26e6f407bd0e45f9b234385 Mon Sep 17 00:00:00 2001 From: Oscar Tisnado <68830577+otisnado@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:03:25 -0600 Subject: [PATCH 1/3] add boxlang to matrix --- .cfconfig.json | 1 + .github/workflows/tests.yml | 8 ++++++++ server-boxlang@1.json | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 .cfconfig.json create mode 100644 server-boxlang@1.json diff --git a/.cfconfig.json b/.cfconfig.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.cfconfig.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45ee0cc..bd2f272 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,6 +38,14 @@ jobs: javaVersion: "21" ELASTICSEARCH_VERSION: "8.14.1" experimental: true + - cfengine: "boxlang@1" + coldboxVersion: "be" + ELASTICSEARCH_VERSION: "8.14.1" + experimental: true + - cfengine: "boxlang@1" + coldboxVersion: "be" + ELASTICSEARCH_VERSION: "7.17.10" + experimental: true steps: - name: Checkout Repository uses: actions/checkout@v4 diff --git a/server-boxlang@1.json b/server-boxlang@1.json new file mode 100644 index 0000000..1175974 --- /dev/null +++ b/server-boxlang@1.json @@ -0,0 +1,36 @@ +{ + "app":{ + "cfengine":"boxlang@be", + "serverHomeDirectory":".engine/boxlang" + }, + "name":"cbelasticsearch-boxlang@1", + "force":true, + "openBrowser":false, + "web":{ + "directoryBrowsing":true, + "http":{ + "port":"60299" + }, + "rewrites":{ + "enable":"true" + }, + "webroot":"test-harness", + "aliases":{ + "/moduleroot/cbelasticsearch":"./" + } + }, + "JVM":{ + "heapSize":"1024", + "javaVersion":"openjdk21_jdk", + "args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999" + }, + "cfconfig":{ + "file":".cfconfig.json" + }, + "env":{ + "BOXLANG_DEBUG":true + }, + "scripts":{ + "onServerInitialInstall":"install bx-mail,bx-mysql,bx-derby,bx-compat-cfml@be,bx-unsafe-evaluate,bx-esapi --noSave" + } +} \ No newline at end of file From ba2ccd97d2037bcc82bf73072e679541089311b9 Mon Sep 17 00:00:00 2001 From: Oscar Tisnado <68830577+otisnado@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:09:07 -0600 Subject: [PATCH 2/3] add missing javaVersion param --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bd2f272..85eb38e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,10 +40,12 @@ jobs: experimental: true - cfengine: "boxlang@1" coldboxVersion: "be" + javaVersion: "21" ELASTICSEARCH_VERSION: "8.14.1" experimental: true - cfengine: "boxlang@1" coldboxVersion: "be" + javaVersion: "21" ELASTICSEARCH_VERSION: "7.17.10" experimental: true steps: From 7a3e8291b07f63f983100908f7808d48df8ee73f Mon Sep 17 00:00:00 2001 From: otisnado Date: Mon, 16 Dec 2024 16:17:07 +0000 Subject: [PATCH 3/3] Apply cfformat changes --- models/io/HyperClient.cfc | 42 ++++++++++++---------------- models/logging/LogstashAppender.cfc | 43 ++++++++++++++--------------- models/util/Util.cfc | 18 ++++++++---- 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/models/io/HyperClient.cfc b/models/io/HyperClient.cfc index 8950e1a..ce49f65 100644 --- a/models/io/HyperClient.cfc +++ b/models/io/HyperClient.cfc @@ -276,9 +276,9 @@ component accessors="true" threadSafe singleton { */ struct function getMappings( required string indexName, string field ){ var path = arguments.indexName & "/_mapping"; - if( !isNull( arguments.field ) ){ + if ( !isNull( arguments.field ) ) { path &= "/field/" & arguments.field; - } else if( findNoCase( "*", arguments.indexName ) ){ + } else if ( findNoCase( "*", arguments.indexName ) ) { // if a wild card is present we are only interested in the fields arguments.field = "*"; path &= "/field/" & arguments.field; @@ -290,18 +290,20 @@ component accessors="true" threadSafe singleton { } else { var mappings = response.json(); return isNull( arguments.field ) - ? mappings[ indexName ].mappings - : mappings.reduce( ( acc, indexKey, value ) => { - value.mappings.keyArray().each( ( mappingKey ) => { - if( !acc.keyExists( mappingKey ) ){ - acc[ mappingKey ] = value.mappings[ mappingKey ]; - acc[ mappingKey ]["indices"] = [ indexKey ]; + ? mappings[ indexName ].mappings + : mappings.reduce( ( acc, indexKey, value ) => { + value.mappings + .keyArray() + .each( ( mappingKey ) => { + if ( !acc.keyExists( mappingKey ) ) { + acc[ mappingKey ] = value.mappings[ mappingKey ]; + acc[ mappingKey ][ "indices" ] = [ indexKey ]; } else { - acc[ mappingKey ]["indices"].append( indexKey ); + acc[ mappingKey ][ "indices" ].append( indexKey ); } } ); - return acc; - }, {} ); + return acc; + }, {} ); } } @@ -1236,7 +1238,7 @@ component accessors="true" threadSafe singleton { required array documents, boolean throwOnError = false, struct params = {}, - string mode = "update" + string mode = "update" ){ var requests = []; @@ -1267,23 +1269,17 @@ component accessors="true" threadSafe singleton { var opAction = { "#mode#" : { "_index" : doc.getIndex() } }; - if( !isNull( doc.getId() ) ){ + if ( !isNull( doc.getId() ) ) { opAction[ mode ][ "_id" ] = doc.getId(); } var docAction = { "doc" : memento }; - if( mode == "update" ){ + if ( mode == "update" ) { docAction[ "doc_as_upsert" ] = true; } - requests.append( - [ - opAction, - docAction - ], - true - ); + requests.append( [ opAction, docAction ], true ); } ); var saveResult = processBulkOperation( @@ -1694,9 +1690,7 @@ component accessors="true" threadSafe singleton { * @name */ boolean function dataStreamExists( required string name ){ - var check = variables.nodePool - .newRequest( "_data_stream/#arguments.name#" ) - .send(); + var check = variables.nodePool.newRequest( "_data_stream/#arguments.name#" ).send(); return check.getStatusCode() == "200" && check.json().data_streams.len(); } diff --git a/models/logging/LogstashAppender.cfc b/models/logging/LogstashAppender.cfc index 90487d1..e1260eb 100644 --- a/models/logging/LogstashAppender.cfc +++ b/models/logging/LogstashAppender.cfc @@ -659,22 +659,22 @@ component "number_of_replicas" : getProperty( "indexReplicas" ), "index.lifecycle.name" : getProperty( "ILMPolicyName" ), "index.default_pipeline" : getProperty( "pipelineName" ), - "analysis": { - "analyzer": { - "component_path_analyzer": { - "tokenizer": "standard", - "filter": [ "component_path_filter" ] - } + "analysis" : { + "analyzer" : { + "component_path_analyzer" : { + "tokenizer" : "standard", + "filter" : [ "component_path_filter" ] + } }, - "filter": { - "component_path_filter": { - "type": "word_delimiter", - "type_table": [ ". => SUBWORD_DELIM" ], - "split_on_case_change": false, - "split_on_numerics": false, - "stem_english_possessive": true, - "preserve_original": true - } + "filter" : { + "component_path_filter" : { + "type" : "word_delimiter", + "type_table" : [ ". => SUBWORD_DELIM" ], + "split_on_case_change" : false, + "split_on_numerics" : false, + "stem_english_possessive" : true, + "preserve_original" : true + } } } }, @@ -719,17 +719,14 @@ component }, "error" : { "type" : "object", - "properties" : { - "extrainfo" : { - "type" : "text", - "analyzer": "component_path_analyzer" - } + "properties" : { + "extrainfo" : { "type" : "text", "analyzer" : "component_path_analyzer" } } }, "message" : { - "type" : "text", - "analyzer": "component_path_analyzer", - "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 512 } } + "type" : "text", + "analyzer" : "component_path_analyzer", + "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 512 } } }, "event" : { "type" : "object", diff --git a/models/util/Util.cfc b/models/util/Util.cfc index 9d30370..fb66ec4 100644 --- a/models/util/Util.cfc +++ b/models/util/Util.cfc @@ -1,6 +1,6 @@ component accessors="true" singleton { - property name="appEnvironment" inject="box:setting:environment"; + property name="appEnvironment" inject="box:setting:environment"; property name="interceptorService" inject="coldbox:InterceptorService"; /** @@ -131,13 +131,19 @@ component accessors="true" singleton { } // We pre-test this because ACF2018 will not recognize an already formatted ISO8601 datetime with offset - if( isDate( arguments.logObj[ "@timestamp" ] ) ){ - arguments.logObj[ "@timestamp" ] = dateTimeFormat( arguments.logObj[ "@timestamp" ], "yyyy-mm-dd'T'HH:nn:ssZZ" ); + if ( isDate( arguments.logObj[ "@timestamp" ] ) ) { + arguments.logObj[ "@timestamp" ] = dateTimeFormat( + arguments.logObj[ "@timestamp" ], + "yyyy-mm-dd'T'HH:nn:ssZZ" + ); } - if( arguments.logObj.keyExists( "event" ) && arguments.logObj.event.keyExists( "created" ) ){ - if( isDate( arguments.logObj.event.created ) ){ - arguments.logObj.event.created = dateTimeFormat( arguments.logObj.event.created, "yyyy-mm-dd'T'HH:nn:ssZZ" ); + if ( arguments.logObj.keyExists( "event" ) && arguments.logObj.event.keyExists( "created" ) ) { + if ( isDate( arguments.logObj.event.created ) ) { + arguments.logObj.event.created = dateTimeFormat( + arguments.logObj.event.created, + "yyyy-mm-dd'T'HH:nn:ssZZ" + ); } }