Commit Graph

87 Commits

Author SHA1 Message Date
Kai Kreuzer
61fd47c853
Apply spotless and resolver (#3018)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2022-06-27 13:41:28 +02:00
openhab-bot
8944bdbbe4 [unleash-maven-plugin] Preparation for next development cycle. 2022-06-26 16:37:00 +00:00
J-N-K
293de9d6db
Allow DSL scripts for script transformation (#2990)
* Allow DSL scripts for script transformation

Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-06-14 21:15:28 +02:00
Wouter Born
86ee4dc2b5
Fix null type mismatch errors (#2976)
This fixes the null type errors in Eclipse which were introduced by #2906.

Signed-off-by: Wouter Born <github@maindrain.net>
2022-05-23 16:30:08 +02:00
Wouter Born
8f7db68d1a
Fix a few SAT findings (#2936)
Signed-off-by: Wouter Born <github@maindrain.net>
2022-04-27 23:09:37 +02:00
J-N-K
3135017895
Properly close script engines in script transformation (#2932)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-04-24 19:40:43 +02:00
J-N-K
a192a1dfc6
Add a generic script transformation (#2883)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-04-24 19:00:03 +02:00
J-N-K
eec80f0e20
Fix ScriptEngine not removed if created by ScriptAction (#2886)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-04-01 22:56:27 +02:00
Wouter Born
738149d44b
Remove unused local variable (#2807)
Signed-off-by: Wouter Born <github@maindrain.net>
2022-02-27 11:10:41 +01:00
J-N-K
0ba4de3594
Fix deadlock when removing ScriptEngine (#2785)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-02-26 10:29:38 +01:00
Wouter Born
9ff7ad43b9
Add more null annotations to automation bundles (#2763)
* Add more null annotations to automation bundles. This adds null annotations to many classes in the automation bundles and a few dimension classes.
* Further cleanup AutomationCommandExport
* Remove null from RuleStatusInfo JavaDocs. This should be clear from how the class is now annotated.
* Validate deserialized RuleStatusInfo
* Allow TriggerHandlerCallback to be triggered without providing a context

Signed-off-by: Wouter Born <github@maindrain.net>
2022-02-25 16:40:02 +01:00
Wouter Born
2e0b242099
Fix rules stay uninitialized when using Java 17 (#2787)
On Java 17 there is no Nashorn scripting engine so it takes a bit longer before ScriptEngines are available.
Rules would stay uninitialized forever because the ScriptModuleTypeProvider did not notify its listeners whenever script.ScriptAction, script.ScriptCondition became available.

Signed-off-by: Wouter Born <github@maindrain.net>
2022-02-20 20:42:32 +01:00
J-N-K
69069270a9
Fix context being re-used for next execution (#2760)
Trigger information is inserted in the execution context. This information is changed to the new information each time the context is updated with the same keys. If the context of the next execution does not contain values for each key, the old key is re-used, leading e.g. to wrong event information in the context.

The solution is to re-set the individual context after each execution.

Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-02-17 20:32:58 +01:00
J-N-K
9a9217eab8
Expose three classes used as bindings in JSR-223 rules as interfaces (#2723)
Signed-off-by: Jan N. Klug <github@klug.nrw>
2022-02-13 09:57:22 +01:00
Jonathan Gilbert
59bc10a2af
Script Engines now removed from manager when closed (#2706)
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
2022-01-25 09:12:02 +01:00
Jonathan Gilbert
22c28595ab
Script engines now unloaded if replaced, and closed if AutoCloseable (#2681)
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
2022-01-15 13:15:46 +01:00
Christoph Weitkamp
cabb3f7315
Update license headers to 2022 (#2671)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2022-01-07 13:16:42 +01:00
Kai Kreuzer
e3b07782b4
pom reference update from http to https (#2644)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2021-12-23 22:55:20 +01:00
Kai Kreuzer
1ebf7395d9 Apply spotless
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2021-12-20 06:59:22 +01:00
openhab-bot
5ac05c4968 [unleash-maven-plugin] Preparation for next development cycle. 2021-12-19 21:49:34 +00:00
Yannick Schaus
fa682c551e
Improve logic to choose a script engine preferred MIME type (#2629)
As discussed in https://github.com/openhab/openhab-addons/issues/11818.
This should select `application/x-python` for Jython (instead of `application/python` currently)
and allow other script engines to advertise their MIME type:
- JRuby: `application/x-ruby`
- Groovy: `application/x-groovy`

Signed-off-by: Yannick Schaus <github@schaus.net>
2021-12-19 20:01:48 +01:00
Dan Cunningham
eb3f1e92cc
Use the mime types provided by the ScriptEngineFactory (#2595)
* Use the mime types provided by the ScriptEngineFactory and not the underlying script engines they provide. This allows mutliple versions of script engines to co-exist, like Nashorn and GraalVM .

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
2021-12-13 07:13:04 +01:00
Christoph Weitkamp
793ced6286
Added basic time-related classes for usage in script and ruled (#2587)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2021-12-10 23:41:08 +01:00
Wouter Born
044aad891e
Remove unnecessary executable permissions (#2591)
These files are marked as executable for no good reason at all.

Signed-off-by: Wouter Born <github@maindrain.net>
2021-12-05 19:58:23 +01:00
jimtng
5d5b7665b4
[automation] Make LifecycleScriptExtensionProvider and its Disposable interface public (#2565)
Signed-off-by: Jimmy Tanagra <jimmy@tanagra.id.au>
2021-11-12 21:02:27 +01:00
J-N-K
1d17166c79
add item name to ScriptBusEvent log messages (#2503)
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
2021-10-03 22:15:18 +02:00
J-N-K
b02dfdc067
[automation] implement a listener for ScriptEngineFactory changes (#2459)
* implement a listener for ScriptEngineFactory changes

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
2021-08-22 12:15:23 +02:00
Kai Kreuzer
5a667cc868 applied spotless
Signed-off-by: Kai Kreuzer <kai@openhab.org>
2021-06-27 23:22:02 +02:00
jenkins
b8d2077805 [unleash-maven-plugin] Preparation for next development cycle. 2021-06-27 15:50:02 +00:00
Christoph Weitkamp
8acaa8994f
Added nullness annotations to Item events (#2384)
* Added nullness annotations to Item events
* Added nullness annotations to tests

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2021-05-30 18:27:15 +02:00
Yannick Schaus
66149659ca
[automation] Remove readOnly flag on script type parameter (#2373)
Not sure if there's a good rationale behind it being read-only (maybe because it's not supposed to change after having been set) but removing it will fix https://github.com/openhab/openhab-webui/issues/1061.

Signed-off-by: Yannick Schaus <github@schaus.net>
2021-05-20 20:39:32 +02:00
Wouter Born
07b95ca668
Fix SAT findings (#2256)
Fixes 65 SAT findings.

Signed-off-by: Wouter Born <github@maindrain.net>
2021-03-25 20:18:08 +01:00
Wouter Born
49e148ad7d
Fix headers (#2161)
Signed-off-by: Wouter Born <github@maindrain.net>
2021-01-27 23:43:44 +01:00
Jonathan Gilbert
f0c9a8434d
Added ability for ScriptEngines to allow script dependencies to be tracked and changes to trigger script reloading (#1884)
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
2021-01-26 22:23:31 +01:00
Wouter Born
774b9d607b
Update license headers to 2021 (#2041)
Signed-off-by: Wouter Born <github@maindrain.net>
2021-01-01 16:43:46 +01:00
Wouter Born
bf14e1077f
Apply Spotless, resolve itest runbundles for 3.1.0 (#1982)
Signed-off-by: Wouter Born <github@maindrain.net>
2020-12-22 10:01:42 +01:00
jenkins
965531696b [unleash-maven-plugin] Preparation for next development cycle. 2020-12-20 22:24:39 +00:00
Christoph Weitkamp
397ebaab64
Fixed NPE by not calling 'toString()' (#1948)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2020-12-16 18:59:28 +01:00
Wouter Born
13c2d7bf2b
Rename classes with "SmartHome" in their name (#1896)
* Rename SmartHomeUnits to Units
* Rename SmartHome Servlets and HTTP Context

Signed-off-by: Wouter Born <github@maindrain.net>
2020-12-06 23:35:37 +01:00
Jonathan Gilbert
e8d017da77
Extracted accessor into interface and added to script engine context to allow access to script extensions from script engine factories (#1843)
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
2020-11-28 23:24:19 +01:00
Jonathan Gilbert
60edebc111
Pass script context to script engines (#1837)
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
2020-11-22 10:52:22 +01:00
Wouter Born
d5e7fe3ab3
Update LastNPE EEAs to 2.2.1 (#1821)
Signed-off-by: Wouter Born <github@maindrain.net>
2020-11-17 16:29:09 +01:00
Yannick Schaus
4e045204ac
[automation] Create Nashorn script engines with the proper class loader (#1799)
This should fix the issue reported here:
https://community.openhab.org/t/openhab-3-0-milestone-2-discussion/107564/8

where the Nashorn script engine would be created with the
current thread's class loader, causing JS code like this:
```
var Log = Java.type("org.openhab.core.model.script.actions.Log");
Log.logError("Experiments", "This is an OH error log");
Log.logWarn("Experiments", "This is an OH warn log");
Log.logInfo("Experiments", "This is an OH info log");
Log.logDebug("Experiments", "This is an OH debug log");
```
to run fine when the rule was triggered but fail to find the Log
class when run from the REST API's `/rest/rules/{ruleUID}/runnow`,
because in that case the generic createScriptEngine implementation
would return script engines using the JAX-RS class loader as the
"app" class loader.

Note:
We also have an opportunity to restrict which classes are exposed
to the script with a ClassFilter to a specific set:
https://docs.oracle.com/javase/8/docs/jdk/api/nashorn/jdk/nashorn/api/scripting/NashornScriptEngineFactory.html#getScriptEngine-java.lang.String:A-java.lang.ClassLoader-jdk.nashorn.api.scripting.ClassFilter-
This could prove useful to mitigate code execution vulnerabilities,
as the script code is modifiable remotely.

Signed-off-by: Yannick Schaus <github@schaus.net>
2020-11-14 15:17:33 +01:00
Wouter Born
2f2bfde500
Remove Map null annotation workarounds (#1780)
These workarounds to prevent false positives can be removed now the EEAs allow for proper null analysis.

Signed-off-by: Wouter Born <github@maindrain.net>
2020-11-03 22:12:22 +01:00
Wouter Born
0281c10036
[infrastructure] add external null-annotations (#1775)
Add EEAs and fix null analysis errors.

Related to:

* #888
* openhab/openhab-addons#8848

Signed-off-by: Wouter Born <github@maindrain.net>
2020-11-03 21:33:48 +01:00
Wouter Born
584c85a07f
[automation] Improve rule debugging (#1742)
* Add rule UID to error message
* Add exception with stacktrace when debug level is enabled

Related to #1734

Signed-off-by: Wouter Born <github@maindrain.net>
2020-10-20 15:50:25 +02:00
Christoph Weitkamp
7d70a97b77
Fixed IndexOutOfBoundsException in ScriptModuleTypeProvider (#1730)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
2020-10-19 13:41:58 +02:00
Wouter Born
7d8126e89f
Fix ScriptEngine parameter option removal (#1716)
When one of the engines is unset the ScriptModuleTypeProvider clears all parameter options instead of only those that apply to that engine.
This fixes the Nashorn engine missing from the parameter options on the first openHAB startup.

Signed-off-by: Wouter Born <github@maindrain.net>
2020-10-13 23:13:30 +02:00
Wouter Born
057604cc2d
Use new Collection API methods (#1598)
Using the new methods there will be less and more readable code.

Signed-off-by: Wouter Born <github@maindrain.net>
2020-08-22 23:04:11 +02:00
Kai Kreuzer
840335bbd5
[automation] Moved constants to top and made them public for reference (#1513)
* Moved constants to top and made them public for reference

Signed-off-by: Kai Kreuzer <kai@openhab.org>
2020-06-07 23:03:53 +02:00