Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Condition implements Serializable {

ConditionType conditionType;
String conditionTypeId;
Map<String, Object> parameterValues = new HashMap<String, Object>();
Map<String, Object> parameterValues = new HashMap<>();

/**
* Instantiates a new Condition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ public interface EventService {
*/
String authenticateThirdPartyServer(String key, String ip);

/**
* Retrieves the list of available event properties.
*
* @return a list of available event properties
* @deprecated use event types instead
*/
List<EventProperty> getEventProperties();

/**
* Retrieves the set of known event type identifiers.
*
Expand Down
23 changes: 6 additions & 17 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@
</dependency>

<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>

Expand Down Expand Up @@ -235,7 +235,6 @@
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
Expand Down Expand Up @@ -297,11 +296,6 @@
<artifactId>opencsv</artifactId>
<version>${opencsv.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-all</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>net.jodah</groupId>
<artifactId>failsafe</artifactId>
Expand Down Expand Up @@ -337,11 +331,6 @@
<artifactId>jackson-coreutils</artifactId>
<version>${jackson-coreutils.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.unomi.groovy.actions;

import groovy.lang.Script;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -44,7 +45,7 @@ public final class ScriptMetadata {
/**
* Constructs a new ScriptMetadata instance.
*
* @param actionName the unique name/identifier of the action
* @param actionName the unique name/identifier of the action
* @param scriptContent the raw Groovy script content
* @param compiledClass the compiled Groovy script class
* @throws IllegalArgumentException if any parameter is null
Expand Down Expand Up @@ -143,10 +144,9 @@ public long getCreationTime() {
* 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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* <p>
* Thread Safety: Implementations must be thread-safe as this service
* is accessed concurrently during script execution.
*
* @see GroovyAction
* @see ScriptMetadata
* @since 2.7.0
Expand All @@ -51,7 +50,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
* @throws IllegalArgumentException if actionName or groovyScript is null
Expand All @@ -64,7 +62,6 @@ public interface GroovyActionsService {
* <p>
* 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
*/
Expand All @@ -76,7 +73,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
* @throws IllegalArgumentException if id is null
Expand All @@ -89,7 +85,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
* @throws IllegalArgumentException if actionName is null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ protected void service(HttpServletRequest request, HttpServletResponse response)
response.getWriter().println(mapper.writeValueAsString(checks));
response.setContentType("application/json");
response.setHeader("Cache-Control", "no-cache");
if (checks.stream().allMatch(HealthCheckResponse::isLive)) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
}
if (checks.stream().allMatch(HealthCheckResponse::isLive)) {
response.setStatus(HttpServletResponse.SC_OK);
} else {
response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
}
}
}
20 changes: 10 additions & 10 deletions itests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ https://maven.apache.org/surefire/maven-failsafe-plugin/examples/single-test.htm

Here's an example:

mvn clean install -Dit.karaf.debug=hold:true -Dit.test=org.apache.unomi.itests.graphql.GraphQLEventIT
mvn clean install -Dit.karaf.debug=hold:true -Dit.test=org.apache.unomi.itests.BasicIT

## Migration tests

Expand Down Expand Up @@ -137,12 +137,12 @@ public class Migrate16xTo200IT extends BaseIT {
// Create snapshot repo
HttpUtils.executePutRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/", resourceAsString("migration/create_snapshots_repository.json"), null);
// Get snapshot, insure it exists
String snapshot = HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_1.6.x", null);
if (snapshot == null || !snapshot.contains("snapshot_1.6.x")) {
String snapshot = HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_2", null);
if (snapshot == null || !snapshot.contains("snapshot_2")) {
throw new RuntimeException("Unable to retrieve 1.6.x snapshot for ES restore");
}
// Restore the snapshot
HttpUtils.executePostRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_1.6.x/_restore?wait_for_completion=true", "{}", null);
HttpUtils.executePostRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_2/_restore?wait_for_completion=true", "{}", null);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -167,7 +167,7 @@ public class Migrate16xTo200IT extends BaseIT {

### How to update a migration test ElasticSearch Snapshot ?

In the following example we want to modify the snapshot: `snapshot_1.6.x`.
In the following example we want to modify the snapshot: `snapshot_2`.
This snapshot has been done on Unomi 1.6.x using ElasticSearch 7.11.0.
So we will set up locally those servers in the exact same versions.
(For now just download them and do not start them yet.)
Expand Down Expand Up @@ -217,13 +217,13 @@ Now we have to add the snapshot repository, do the following request on your Ela
}

Now we need to restore the snapshot we want to modify,
but first let's try to see if the snapshot with the id `snapshot_1.6.x` correctly exists:
but first let's try to see if the snapshot with the id `snapshot_2` correctly exists:

GET /_snapshot/snapshots_repository/snapshot_1.6.x
GET /_snapshot/snapshots_repository/snapshot_2

If the snapshot exists we can restore it:

POST /_snapshot/snapshots_repository/snapshot_1.6.x/_restore?wait_for_completion=true
POST /_snapshot/snapshots_repository/snapshot_2/_restore?wait_for_completion=true
{}

At the end of the previous request ElasticSearch should be ready and our Unomi snapshot is restored to version `1.6.x`.
Expand All @@ -241,11 +241,11 @@ they are probably used by the actual migration tests already.)

Once you data updated we need to recreate the snapshot, first we delete the old snapshot:

DELETE /_snapshot/snapshots_repository/snapshot_1.6.x
DELETE /_snapshot/snapshots_repository/snapshot_2

Then we recreate it:

PUT /_snapshot/snapshots_repository/snapshot_1.6.x
PUT /_snapshot/snapshots_repository/snapshot_2

Once the process finished (check the ElasticSearch logs to see that the snapshot is correctly created),
we need to remove the snapshot repository from our local ElasticSearch
Expand Down
5 changes: 3 additions & 2 deletions itests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@
<groupId>com.github.alexcojocaru</groupId>
<artifactId>elasticsearch-maven-plugin</artifactId>
<!-- REPLACE THE FOLLOWING WITH THE PLUGIN VERSION YOU NEED -->
<version>6.23</version>
<version>6.29</version>
<configuration>
<!-- <downloadUrl>https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.1.3-darwin-aarch64.tar
.gz</downloadUrl> -->
<clusterName>contextElasticSearchITests</clusterName>
<transportPort>9500</transportPort>
<httpPort>9400</httpPort>
Expand All @@ -223,7 +225,6 @@
<xpack.ml.enabled>false</xpack.ml.enabled>
<path.repo>${project.build.directory}/snapshots_repository</path.repo>
<cluster.routing.allocation.disk.threshold_enabled>false</cluster.routing.allocation.disk.threshold_enabled>
<http.cors.allow-origin>*</http.cors.allow-origin>
<http.cors.allow-methods>OPTIONS,HEAD,GET,POST,PUT,DELETE</http.cors.allow-methods>
<http.cors.allow-headers>Authorization,X-Requested-With,X-Auth-Token,Content-Type,Content-Length</http.cors.allow-headers>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,13 @@ public void testConcealedProperties() throws Exception {
HttpPost request = new HttpPost(getFullUrl(CONTEXT_URL));
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
assertEquals(TestUtils.executeContextJSONRequest(request, sessionId).getContextResponse().getProfileProperties().get("customProperty"), ("concealedValue"));
// set the property as concealed
// set the property as concealed
customPropertyType.getMetadata().getSystemTags().add("concealed");
profileService.deletePropertyType(customPropertyType.getItemId());
persistenceService.refreshIndex(PropertyType.class);
Thread.sleep(2000);
profileService.setPropertyType(customPropertyType);

// Not in all properties
request.setEntity(new StringEntity(objectMapper.writeValueAsString(contextRequest), ContentType.APPLICATION_JSON));
assertNull(TestUtils.executeContextJSONRequest(request, sessionId).getContextResponse().getProfileProperties().get("customProperty"));
Expand Down
6 changes: 3 additions & 3 deletions itests/src/test/java/org/apache/unomi/itests/SegmentIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public void testScoringPastEventRecalculationMaximumEventCount() throws Exceptio
Condition pastEventCondition = new Condition(definitionsService.getConditionType("pastEventCondition"));
pastEventCondition.setParameter("numberOfDays", 10);
Condition pastEventEventCondition = new Condition(definitionsService.getConditionType("eventTypeCondition"));
pastEventEventCondition.setParameter("eventTypeId", "test-event-type-max");
pastEventEventCondition.setParameter("eventTypeId", "testeventtypemax");
pastEventCondition.setParameter("eventCondition", pastEventEventCondition);
pastEventCondition.setParameter("maximumEventCount", 1);

Expand All @@ -481,7 +481,7 @@ public void testScoringPastEventRecalculationMaximumEventCount() throws Exceptio
// Persist the event (do not send it into the system so that it will not be processed by the rules)
ZoneId defaultZoneId = ZoneId.systemDefault();
LocalDate localDate = LocalDate.now().minusDays(3);
Event testEvent = new Event("test-event-type-max", null, profile, null, null, profile,
Event testEvent = new Event("testeventtypemax", null, profile, null, null, profile,
Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
testEvent.setPersistent(true);
persistenceService.save(testEvent, null, true);
Expand All @@ -503,7 +503,7 @@ public void testScoringPastEventRecalculationMaximumEventCount() throws Exceptio
// Persist the 2 event (do not send it into the system so that it will not be processed by the rules)
defaultZoneId = ZoneId.systemDefault();
localDate = LocalDate.now().minusDays(3);
testEvent = new Event("test-event-type-max", null, profile, null, null, profile,
testEvent = new Event("testeventtypemax", null, profile, null, null, profile,
Date.from(localDate.atStartOfDay(defaultZoneId).toInstant()));
testEvent.setPersistent(true);
persistenceService.save(testEvent, null, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public void waitForStartup() throws InterruptedException {
// Create snapshot repo
HttpUtils.executePutRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/", resourceAsString("migration/create_snapshots_repository.json"), null);
// Get snapshot, insure it exists
String snapshot = HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_1.6.x", null);
if (snapshot == null || !snapshot.contains("snapshot_1.6.x")) {
String snapshot = HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_2", null);
if (snapshot == null || !snapshot.contains("snapshot_2")) {
throw new RuntimeException("Unable to retrieve 1.6.x snapshot for ES restore");
}
// Restore the snapshot
HttpUtils.executePostRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_1.6.x/_restore?wait_for_completion=true", "{}", null);
HttpUtils.executePostRequest(httpClient, "http://localhost:9400/_snapshot/snapshots_repository/snapshot_2/_restore?wait_for_completion=true", "{}", null);

// Get initial counts of items to compare after migration
initCounts(httpClient);
Expand Down
Binary file modified itests/src/test/resources/migration/snapshots_repository.zip
Binary file not shown.
1 change: 0 additions & 1 deletion kar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
<artifactId>httpclient-osgi</artifactId>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
Expand Down
2 changes: 2 additions & 0 deletions kar/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
<bundle start-level="75" start="false">mvn:org.apache.unomi/unomi-scripting/${project.version}</bundle>
<bundle start-level="75" start="false">mvn:org.apache.unomi/unomi-metrics/${project.version}</bundle>
<bundle start-level="75" start="false">mvn:org.apache.unomi/unomi-persistence-spi/${project.version}</bundle>

<bundle start-level="76" start="false">mvn:org.apache.unomi/unomi-persistence-elasticsearch-core/${project.version}</bundle>
<bundle start-level="77" start="false">mvn:org.apache.unomi/unomi-persistence-elasticsearch-conditions/${project.version}</bundle>
<bundle start-level="77" start="false">mvn:org.apache.unomi/unomi-services/${project.version}</bundle>
<bundle start-level="77" start="false">mvn:org.apache.unomi/unomi-json-schema-services/${project.version}</bundle>
<bundle start-level="77" start="false">mvn:org.apache.unomi/unomi-json-schema-rest/${project.version}</bundle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<entry key="org.apache.unomi.metrics" value="false"/>
<entry key="org.apache.unomi.persistence-spi" value="false"/>
<entry key="org.apache.unomi.persistence-elasticsearch-core" value="false"/>
<entry key="org.apache.unomi.persistence-elasticsearch-conditions" value="false"/>
<entry key="org.apache.unomi.services" value="false"/>
<entry key="org.apache.unomi.cxs-lists-extension-services" value="false"/>
<entry key="org.apache.unomi.cxs-lists-extension-rest" value="false"/>
Expand Down
Loading
Loading