diff --git a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/ScriptMetadata.java b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/ScriptMetadata.java index 57b44e3ae..4756d97cd 100644 --- a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/ScriptMetadata.java +++ b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/ScriptMetadata.java @@ -28,13 +28,10 @@ * This class encapsulates all metadata associated with a compiled Groovy script, * including content hash for efficient change detection and the compiled class * for direct execution without recompilation. - *
- * ** Thread Safety: This class is immutable and thread-safe. All fields are final * and the class provides no methods to modify its state after construction. - *
- * + * * @since 2.7.0 */ public final class ScriptMetadata { @@ -43,10 +40,10 @@ public final class ScriptMetadata { private final String contentHash; private final long creationTime; private final Class extends Script> compiledClass; - + /** * Constructs a new ScriptMetadata instance. - * + * * @param actionName the unique name/identifier of the action * @param scriptContent the raw Groovy script content * @param compiledClass the compiled Groovy script class @@ -62,17 +59,17 @@ public ScriptMetadata(String actionName, String scriptContent, Class extends S if (compiledClass == null) { throw new IllegalArgumentException("Compiled class cannot be null"); } - + this.actionName = actionName; this.scriptContent = scriptContent; this.contentHash = calculateHash(scriptContent); this.creationTime = System.currentTimeMillis(); this.compiledClass = compiledClass; } - + /** * Calculates SHA-256 hash of the given content. - * + * * @param content the content to hash * @return Base64 encoded SHA-256 hash * @throws RuntimeException if SHA-256 algorithm is not available @@ -86,14 +83,13 @@ private String calculateHash(String content) { throw new RuntimeException("SHA-256 algorithm not available", e); } } - + /** * Determines if the script content has changed compared to new content. ** This method uses SHA-256 hash comparison for efficient change detection * without storing or comparing the full script content. - *
- * + * * @param newContent the new script content to compare against * @return {@code true} if content has changed, {@code false} if unchanged * @throws IllegalArgumentException if newContent is null @@ -104,53 +100,53 @@ public boolean hasChanged(String newContent) { } return !contentHash.equals(calculateHash(newContent)); } - + /** * Returns the action name/identifier. - * + * * @return the action name, never null */ - public String getActionName() { - return actionName; + public String getActionName() { + return actionName; } - + /** * Returns the original script content. - * + * * @return the script content, never null */ - public String getScriptContent() { - return scriptContent; + public String getScriptContent() { + return scriptContent; } - + /** * Returns the SHA-256 hash of the script content. - * + * * @return Base64 encoded content hash, never null */ - public String getContentHash() { - return contentHash; + public String getContentHash() { + return contentHash; } - + /** * Returns the timestamp when this metadata was created. - * + * * @return creation timestamp in milliseconds since epoch */ - public long getCreationTime() { - return creationTime; + public long getCreationTime() { + return creationTime; } - + /** * Returns the compiled Groovy script class. ** This class can be used to create new script instances for execution * without requiring recompilation. - *
- * + * + * * @return the compiled script class, never null */ - public Class extends Script> getCompiledClass() { - return compiledClass; + public Class extends Script> getCompiledClass() { + return compiledClass; } -} \ No newline at end of file +} diff --git a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/GroovyActionsService.java b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/GroovyActionsService.java index 1b4bf14be..ed2c2f213 100644 --- a/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/GroovyActionsService.java +++ b/extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/GroovyActionsService.java @@ -27,8 +27,6 @@ * This service provides functionality to load, compile, cache, and execute * Groovy scripts as actions within the Apache Unomi framework. It implements * optimized compilation and caching strategies to achieve high performance. - * - * ** Key features: *
* Thread Safety: Implementations must be thread-safe as this service * is accessed concurrently during script execution. - *
* * @see GroovyAction * @see ScriptMetadata @@ -56,7 +51,6 @@ public interface GroovyActionsService { * This method compiles the script, validates it has the required * annotations, persists it, and updates the internal cache. * If the script content hasn't changed, recompilation is skipped. - * * * @param actionName the unique identifier for the action * @param groovyScript the Groovy script source code @@ -70,7 +64,6 @@ public interface GroovyActionsService { ** This method removes the action from both the cache and persistent storage, * and cleans up any registered action types in the definitions service. - *
* * @param actionName the unique identifier of the action to remove * @throws IllegalArgumentException if id is null @@ -83,7 +76,6 @@ public interface GroovyActionsService { * This is the preferred method for script execution as it returns * pre-compiled classes without any compilation overhead. Returns * {@code null} if the script is not found in the cache. - * * * @param actionName the unique identifier of the action * @return the compiled script class, or {@code null} if not found in cache @@ -97,7 +89,6 @@ public interface GroovyActionsService { * The returned metadata includes content hash, compilation timestamp, * and the compiled class reference. This is useful for monitoring * tools and debugging. - * * * @param actionName the unique identifier of the action * @return the script metadata, or {@code null} if not found diff --git a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/MigrationUtils.java b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/MigrationUtils.java index 53cc90a94..4f2fc21c8 100644 --- a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/MigrationUtils.java +++ b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/MigrationUtils.java @@ -313,9 +313,9 @@ public static void waitForYellowStatus(CloseableHttpClient httpClient, String es /** * Updates documents in an index based on a specified query. - * - *This method sends a request to update documents that match the provided query in the specified index. The update operation is - * performed asynchronously, and the method waits for the task to complete before returning.
+ *+ * This method sends a request to update documents that match the provided query in the specified index. The update operation is + * performed asynchronously, and the method waits for the task to complete before returning. * * @param httpClient the CloseableHttpClient used to send the request to the Elasticsearch server * @param esAddress the address of the Elasticsearch server @@ -332,10 +332,10 @@ public static void updateByQuery(CloseableHttpClient httpClient, String esAddres /** * Deletes documents from an index based on a specified query. - * - *
This method sends a request to the Elasticsearch cluster to delete documents + *
+ * This method sends a request to the Elasticsearch cluster to delete documents * that match the provided query in the specified index. The deletion operation is - * performed asynchronously, and the method waits for the task to complete before returning.
+ * performed asynchronously, and the method waits for the task to complete before returning. * * @param httpClient the CloseableHttpClient used to send the request to the Elasticsearch server * @param esAddress the address of the Elasticsearch server