This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch reduceIndicesItems2
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/reduceIndicesItems2 by this
push:
new 454578b42 UNOMI-736: More fixes regarding groovy actions
454578b42 is described below
commit 454578b4238c37c899efe46787c28734d1751e66
Author: Kevan <[email protected]>
AuthorDate: Fri Feb 24 11:52:01 2023 +0100
UNOMI-736: More fixes regarding groovy actions
---
.../groovy/actions/services/impl/GroovyActionsServiceImpl.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git
a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
index 67547a9df..14816f46a 100644
---
a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
+++
b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java
@@ -184,15 +184,10 @@ public class GroovyActionsServiceImpl implements
GroovyActionsService {
@Override
public void save(String actionName, String groovyScript) {
- handleFile(actionName, groovyScript);
- }
-
- private void handleFile(String actionName, String groovyScript) {
GroovyCodeSource groovyCodeSource = buildClassScript(groovyScript,
actionName);
try {
saveActionType(groovyShell.parse(groovyCodeSource).getClass().getMethod("execute").getAnnotation(Action.class));
saveScript(actionName, groovyScript);
- groovyCodeSourceMap.put(actionName, groovyCodeSource);
logger.info("The script {} has been loaded.", actionName);
} catch (NoSuchMethodException e) {
logger.error("Failed to save the script {}", actionName, e);
@@ -220,13 +215,13 @@ public class GroovyActionsServiceImpl implements
GroovyActionsService {
@Override
public void remove(String id) {
+ String groovySourceCodeId = getGroovyCodeSourceIdForActionId(id);
try {
definitionsService.removeActionType(
-
groovyShell.parse(groovyCodeSourceMap.get(id)).getClass().getMethod("execute").getAnnotation(Action.class).id());
+
groovyShell.parse(groovyCodeSourceMap.get(groovySourceCodeId)).getClass().getMethod("execute").getAnnotation(Action.class).id());
} catch (NoSuchMethodException e) {
logger.error("Failed to delete the action type for the id {}", id,
e);
}
- String groovySourceCodeId = getGroovyCodeSourceIdForActionId(id);
persistenceService.remove(groovySourceCodeId, GroovyAction.class);
groovyCodeSourceMap.remove(groovySourceCodeId);
}