From 8735fed4fbf1f3708c08afe74c3d09a2f563c2fa Mon Sep 17 00:00:00 2001 From: Mathieu Delrocq Date: Mon, 10 Feb 2020 15:34:38 +0100 Subject: [PATCH 1/3] update .gitignore for eclipse --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7e5d5dd2..b9ba0c79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ +.settings/* .idea/* *.iml /target/ /work/ +/.classpath +/.project From 2f92dad84605a35ee6c9da727f1463f657e0a505 Mon Sep 17 00:00:00 2001 From: Mathieu Delrocq Date: Mon, 10 Feb 2020 15:40:30 +0100 Subject: [PATCH 2/3] Use net.sf.json parser and remove Boon --- pom.xml | 5 ----- .../ExtendedChoiceParameterDefinition.java | 4 ++-- .../jsonContent.jelly | 12 ++++-------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 28ed0321..8dee1226 100644 --- a/pom.xml +++ b/pom.xml @@ -43,11 +43,6 @@ script-security 1.19 - - io.fastjson - boon - 0.34 - diff --git a/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java b/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java index dead9743..8a0675fd 100644 --- a/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java +++ b/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java @@ -1458,7 +1458,7 @@ else if(!StringUtils.isBlank(javascriptFile)) { return result; } - public Object getJSONEditorOptions() { + public JSONObject getJSONEditorOptions() { Object result = null; try { String script = null; @@ -1474,7 +1474,7 @@ public Object getJSONEditorOptions() { catch(IOException | URISyntaxException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } - return result; + return (JSONObject) result; } private String expandVariables(String input) { diff --git a/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly b/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly index 2459c5d2..9ee176d0 100644 --- a/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly +++ b/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly @@ -13,17 +13,13 @@ - - - - - - + + From f16f3a846873ca690afd6438b8323187e0654fe1 Mon Sep 17 00:00:00 2001 From: Mathieu Delrocq Date: Wed, 12 Feb 2020 14:33:36 +0100 Subject: [PATCH 3/3] functional version on JDK11 --- .../ExtendedChoiceParameterDefinition.java | 8 +++----- .../jsonContent.jelly | 14 +++++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java b/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java index 8a0675fd..d3734974 100644 --- a/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java +++ b/src/main/java/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition.java @@ -718,7 +718,6 @@ private String executeGroovyScriptAndProcessGroovyValue(String groovyScript, Str private Object executeGroovyScript(String groovyScript, String bindings, String groovyClasspath) throws URISyntaxException, IOException { Object groovyValue = null; - if(checkScriptApproval(groovyScript, groovyClasspath, false)) { GroovyShell groovyShell = getGroovyShell(groovyClasspath); GroovyCodeSource codeSource = new GroovyCodeSource(groovyScript, computeMD5Hash(groovyScript), "/groovy/shell"); @@ -1458,8 +1457,8 @@ else if(!StringUtils.isBlank(javascriptFile)) { return result; } - public JSONObject getJSONEditorOptions() { - Object result = null; + public Object getJSONEditorOptions() { + Object result = null; try { String script = null; if(!StringUtils.isBlank(groovyScript)) { @@ -1468,13 +1467,12 @@ public JSONObject getJSONEditorOptions() { else { script = Util.loadFile(new File(expandVariables(groovyScriptFile))); } - result = executeGroovyScript(script, bindings, groovyClasspath); } catch(IOException | URISyntaxException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } - return (JSONObject) result; + return result; } private String expandVariables(String input) { diff --git a/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly b/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly index 9ee176d0..484d1ef3 100644 --- a/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly +++ b/src/main/resources/com/cwctravel/hudson/plugins/extended_choice_parameter/ExtendedChoiceParameterDefinition/jsonContent.jelly @@ -13,13 +13,17 @@ - - + + + + + +