UNOMI-631 Map sources to scopes (#463)
* UNOMI-631 Map sources to scopes
- Remove SourceItem and SourceService and replace with Scope and ScopeService
- Map all GraphQL CDPSource operations to Scope and ScopeService
* UNOMI-631 Map sources to scopes
- Remove remaining configuration in custom.system.properties
- Remove Event scope accessors since they exist in parent object (item)
diff --git a/api/src/main/java/org/apache/unomi/api/Event.java b/api/src/main/java/org/apache/unomi/api/Event.java
index 0397b8a..b8ce833 100644
--- a/api/src/main/java/org/apache/unomi/api/Event.java
+++ b/api/src/main/java/org/apache/unomi/api/Event.java
@@ -64,11 +64,6 @@
private transient Session session;
private transient List<ActionPostExecutor> actionPostExecutors;
- @Deprecated
- private String scope;
-
- private String sourceId;
-
private Item source;
private Item target;
@@ -396,19 +391,6 @@
}
/**
- * @return the scope
- */
- @Deprecated
- public String getScope() {
- return scope;
- }
-
- @Deprecated
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- /**
* Retrieves the source.
*
* @return the source
@@ -463,16 +445,4 @@
this.actionPostExecutors = actionPostExecutors;
}
- public String getSourceId() {
- if ( sourceId == null && scope != null ) {
- return scope;
- } else {
- return sourceId;
- }
- }
-
- public void setSourceId( final String sourceId )
- {
- this.sourceId = sourceId;
- }
}
diff --git a/api/src/main/java/org/apache/unomi/api/SourceItem.java b/api/src/main/java/org/apache/unomi/api/SourceItem.java
deleted file mode 100644
index 2e68269..0000000
--- a/api/src/main/java/org/apache/unomi/api/SourceItem.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.unomi.api;
-
-public class SourceItem extends Item {
-
- public static final String ITEM_TYPE = "source";
-
- private String sourceId;
-
- private Boolean thirdParty;
-
- public String getSourceId() {
- return sourceId;
- }
-
- public void setSourceId(final String sourceId) {
- this.sourceId = sourceId;
- }
-
- public Boolean getThirdParty() {
- return thirdParty;
- }
-
- public void setThirdParty(final Boolean thirdParty) {
- this.thirdParty = thirdParty;
- }
-
- @Override
- public String toString() {
- return "SourceItem{" +
- "sourceId='" + sourceId + '\'' +
- ", thirdParty='" + thirdParty + '\'' +
- '}';
- }
-
-}
diff --git a/api/src/main/java/org/apache/unomi/api/services/SourceService.java b/api/src/main/java/org/apache/unomi/api/services/SourceService.java
deleted file mode 100644
index 6c794e7..0000000
--- a/api/src/main/java/org/apache/unomi/api/services/SourceService.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.unomi.api.services;
-
-import org.apache.unomi.api.SourceItem;
-
-import java.util.List;
-
-public interface SourceService {
-
- /**
- * Retrieves the source identified by the specified identifier.
- *
- * @param sourceId the identifier of the source to retrieve
- * @return the topic identified by the specified identifier or {@code null} if no such source exists
- */
- SourceItem load(final String sourceId);
-
- /**
- * Saves the specified source in the context server.
- *
- * @param source the source to be saved
- * @return the newly saved topic if the creation or update was successful, {@code null} otherwise
- */
- SourceItem save(final SourceItem source);
-
- /**
- * Retrieves all sources.
- *
- * @return a {@link List} of {@link SourceItem} metadata
- */
- List<SourceItem> getAll();
-
- /**
- * Removes the source identified by the specified identifier.
- *
- * @param sourceId the identifier of the profile or persona to delete
- * @return {@code true} if the deletion was successful, {@code false} otherwise
- */
- boolean delete(final String sourceId);
-
-}
diff --git a/extensions/lists-extension/actions/src/main/java/org/apache/unomi/lists/actions/AddToListsAction.java b/extensions/lists-extension/actions/src/main/java/org/apache/unomi/lists/actions/AddToListsAction.java
index c209e48..7f60f08 100644
--- a/extensions/lists-extension/actions/src/main/java/org/apache/unomi/lists/actions/AddToListsAction.java
+++ b/extensions/lists-extension/actions/src/main/java/org/apache/unomi/lists/actions/AddToListsAction.java
@@ -65,7 +65,7 @@
if (listsChanged) {
profile.getSystemProperties().put("lists", existingListIdentifiers);
- eventService.send(new Event("profileUpdated", null, profile, event.getSourceId(), null, profile, null,new Date(), false));
+ eventService.send(new Event("profileUpdated", null, profile, event.getScope(), null, profile, null,new Date(), false));
return EventService.PROFILE_UPDATED;
} else {
return EventService.NO_CHANGE;
diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/CreateOrUpdateSourceCommand.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/CreateOrUpdateSourceCommand.java
index ee2a275..5a02796 100644
--- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/CreateOrUpdateSourceCommand.java
+++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/CreateOrUpdateSourceCommand.java
@@ -16,8 +16,8 @@
*/
package org.apache.unomi.graphql.commands;
-import org.apache.unomi.api.SourceItem;
-import org.apache.unomi.api.services.SourceService;
+import org.apache.unomi.api.Scope;
+import org.apache.unomi.api.services.ScopeService;
import org.apache.unomi.graphql.types.input.CDPSourceInput;
import org.apache.unomi.graphql.types.output.CDPSource;
@@ -35,22 +35,19 @@
@Override
public CDPSource execute() {
- SourceService sourceService = serviceManager.getService(SourceService.class);
+ ScopeService scopeService = serviceManager.getService(ScopeService.class);
- SourceItem source = sourceService.load(sourceInput.getId());
+ Scope scope = scopeService.getScope(sourceInput.getId());
- if (source == null) {
- source = new SourceItem();
+ if (scope == null) {
+ scope = new Scope();
- source.setItemId(sourceInput.getId());
- source.setSourceId(sourceInput.getId());
+ scope.setItemId(sourceInput.getId());
}
- source.setThirdParty(sourceInput.getThirdParty());
+ scopeService.save(scope);
- SourceItem persistedSource = sourceService.save(source);
-
- return new CDPSource(persistedSource.getSourceId(), persistedSource.getThirdParty());
+ return new CDPSource(scope.getItemId(), false);
}
public static Builder create(final CDPSourceInput topicInput) {
diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/DeleteSourceCommand.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/DeleteSourceCommand.java
index d9146fe..4fa013e 100644
--- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/DeleteSourceCommand.java
+++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/commands/DeleteSourceCommand.java
@@ -16,7 +16,7 @@
*/
package org.apache.unomi.graphql.commands;
-import org.apache.unomi.api.services.SourceService;
+import org.apache.unomi.api.services.ScopeService;
import java.util.Objects;
@@ -32,7 +32,7 @@
@Override
public Boolean execute() {
- return serviceManager.getService(SourceService.class).delete(sourceId);
+ return serviceManager.getService(ScopeService.class).delete(sourceId);
}
public static Builder create(final String sourceId) {
diff --git a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/fetchers/SourceDataFetcher.java b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/fetchers/SourceDataFetcher.java
index bed77cf..248e638 100644
--- a/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/fetchers/SourceDataFetcher.java
+++ b/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql/fetchers/SourceDataFetcher.java
@@ -18,8 +18,8 @@
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
-import org.apache.unomi.api.SourceItem;
-import org.apache.unomi.api.services.SourceService;
+import org.apache.unomi.api.Scope;
+import org.apache.unomi.api.services.ScopeService;
import org.apache.unomi.graphql.services.ServiceManager;
import org.apache.unomi.graphql.types.output.CDPSource;
@@ -32,12 +32,12 @@
public List<CDPSource> get(final DataFetchingEnvironment environment) throws Exception {
ServiceManager serviceManager = environment.getContext();
- SourceService sourceService = serviceManager.getService(SourceService.class);
+ ScopeService scopeService = serviceManager.getService(ScopeService.class);
- List<SourceItem> sources = sourceService.getAll();
+ List<Scope> sources = scopeService.getScopes();
return sources.stream().
- map(sourceItem -> new CDPSource(sourceItem.getSourceId(), sourceItem.getThirdParty())).
+ map(scope -> new CDPSource(scope.getItemId(), false)).
collect(Collectors.toList());
}
diff --git a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java
index bb03585..a5a828f 100644
--- a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLSourceIT.java
@@ -17,7 +17,7 @@
package org.apache.unomi.itests.graphql;
import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.unomi.api.services.SourceService;
+import org.apache.unomi.api.services.ScopeService;
import org.junit.Test;
import org.ops4j.pax.exam.util.Filter;
@@ -30,7 +30,7 @@
@Inject
@Filter(timeout = 600000)
- SourceService sourceService;
+ ScopeService scopeService;
@Test
public void testCRUD() throws IOException, InterruptedException {
diff --git a/package/src/main/resources/etc/custom.system.properties b/package/src/main/resources/etc/custom.system.properties
index b073136..fe09b36 100644
--- a/package/src/main/resources/etc/custom.system.properties
+++ b/package/src/main/resources/etc/custom.system.properties
@@ -416,11 +416,6 @@
org.apache.unomi.weatherUpdate.url.attributes=${env:UNOMI_WEATHERUPDATE_URL_ATTRIBUTES:-data/2.5/weather}
#######################################################################################################################
-## Settings for EventService ##
-#######################################################################################################################
-org.apache.unomi.events.shouldBeCheckedEventSourceId=${env:UNOMI_SHOULD_BE_CHECKED_EVENT_SOURCE_ID:-false}
-
-#######################################################################################################################
## Settings for GraphQL ##
#######################################################################################################################
org.apache.unomi.graphql.feature.activated=${env:UNOMI_GRAPHQL_FEATURE_ACTIVATED:-false}
diff --git a/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/CustomObjectMapper.java b/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/CustomObjectMapper.java
index 1d14d55..65d09b0 100644
--- a/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/CustomObjectMapper.java
+++ b/persistence-spi/src/main/java/org/apache/unomi/persistence/spi/CustomObjectMapper.java
@@ -92,7 +92,6 @@
builtinItemTypeClasses.put(ConditionType.ITEM_TYPE, ConditionType.class);
builtinItemTypeClasses.put(ActionType.ITEM_TYPE, ActionType.class);
builtinItemTypeClasses.put(Topic.ITEM_TYPE, Topic.class);
- builtinItemTypeClasses.put(SourceItem.ITEM_TYPE, SourceItem.class);
builtinItemTypeClasses.put(ProfileAlias.ITEM_TYPE, ProfileAlias.class);
for (Map.Entry<String, Class<? extends Item>> entry : builtinItemTypeClasses.entrySet()) {
propertyTypedObjectDeserializer.registerMapping("itemType=" + entry.getKey(), entry.getValue());
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
index 6a94ca7..2e21d8b 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java
@@ -125,7 +125,7 @@
if (currentSession != null) {
currentSession.setProfile(profile);
- eventService.send(new Event("sessionReassigned", currentSession, profile, event.getSourceId(), event, currentSession,
+ eventService.send(new Event("sessionReassigned", currentSession, profile, event.getScope(), event, currentSession,
null, event.getTimeStamp(), false));
}
@@ -175,7 +175,7 @@
if (currentSession != null) {
currentSession.setProfile(masterProfile);
if (privacyService.isRequireAnonymousBrowsing(profile)) {
- privacyService.setRequireAnonymousBrowsing(masterProfileId, true, event.getSourceId());
+ privacyService.setRequireAnonymousBrowsing(masterProfileId, true, event.getScope());
}
if (anonymousBrowsing) {
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SendEventAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SendEventAction.java
index 70af7f1..909fb59 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SendEventAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SendEventAction.java
@@ -43,7 +43,7 @@
Map<String, Object> eventProperties = (Map<String, Object>) action.getParameterValues().get("eventProperties");
Item target = (Item) action.getParameterValues().get("eventTarget");
- Event subEvent = new Event(eventType, event.getSession(), event.getProfile(), event.getSourceId(), event, target, event.getTimeStamp());
+ Event subEvent = new Event(eventType, event.getSession(), event.getProfile(), event.getScope(), event, target, event.getTimeStamp());
subEvent.setProfileId(event.getProfileId());
subEvent.getAttributes().putAll(event.getAttributes());
subEvent.getProperties().putAll(eventProperties);
diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
index 870159e..fd833a5 100644
--- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
+++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/SetPropertyAction.java
@@ -62,7 +62,7 @@
Map<String, Object> propertyToUpdate = new HashMap<>();
propertyToUpdate.put(propertyName, propertyValue);
- Event updateProperties = new Event("updateProperties", event.getSession(), event.getProfile(), event.getSourceId(), null, null, new Date());
+ Event updateProperties = new Event("updateProperties", event.getSession(), event.getProfile(), event.getScope(), null, null, new Date());
updateProperties.setPersistent(false);
updateProperties.setProperty(UpdatePropertiesAction.PROPS_TO_UPDATE, propertyToUpdate);
diff --git a/rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java
index 11b4d8c..8911402 100644
--- a/rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/endpoints/EventsCollectorEndpoint.java
@@ -124,8 +124,8 @@
// Get the first available scope that is not equal to systemscope to create the session otherwise systemscope will be used
for (Event event : eventsCollectorRequest.getEvents()) {
if (StringUtils.isNotBlank(event.getEventType())) {
- if (StringUtils.isNotBlank(event.getSourceId()) && !event.getSourceId().equals("systemscope")) {
- scope = event.getSourceId();
+ if (StringUtils.isNotBlank(event.getScope()) && !event.getScope().equals("systemscope")) {
+ scope = event.getScope();
break;
} else if (event.getSource() != null && StringUtils.isNotBlank(event.getSource().getScope()) && !event.getSource()
.getScope().equals("systemscope")) {
diff --git a/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java b/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
index ec1170c..fae86da 100644
--- a/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
+++ b/rest/src/main/java/org/apache/unomi/rest/service/impl/RestServiceUtilsImpl.java
@@ -92,7 +92,7 @@
for (Event event : events) {
processedEventsCnt++;
if (event.getEventType() != null) {
- Event eventToSend = new Event(event.getEventType(), session, profile, event.getSourceId(), event.getSource(),
+ Event eventToSend = new Event(event.getEventType(), session, profile, event.getScope(), event.getSource(),
event.getTarget(), event.getProperties(), timestamp, event.isPersistent());
eventToSend.setFlattenedProperties(event.getFlattenedProperties());
if (!eventService.isEventAllowed(event, thirdPartyId)) {
@@ -100,7 +100,7 @@
continue;
}
if (thirdPartyId != null && event.getItemId() != null) {
- eventToSend = new Event(event.getItemId(), event.getEventType(), session, profile, event.getSourceId(),
+ eventToSend = new Event(event.getItemId(), event.getEventType(), session, profile, event.getScope(),
event.getSource(), event.getTarget(), event.getProperties(), timestamp, event.isPersistent());
eventToSend.setFlattenedProperties(event.getFlattenedProperties());
}
diff --git a/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java b/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java
index 75c388f..74c2242 100644
--- a/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java
+++ b/samples/trainingplugin/src/main/java/org/apache/unomi/training/TrainedNotificationAction.java
@@ -48,7 +48,7 @@
if (trained == null) {
// create trained flag property type
- Metadata propertyTypeMetadata = new Metadata(event.getSourceId(), TRAINED_NB_PROPERTY, TRAINED_NB_PROPERTY, "Am I trained");
+ Metadata propertyTypeMetadata = new Metadata(event.getScope(), TRAINED_NB_PROPERTY, TRAINED_NB_PROPERTY, "Am I trained");
propertyTypeMetadata.setSystemTags(Collections.singleton("training"));
PropertyType propertyType = new PropertyType();
propertyType.setValueTypeId("boolean");
diff --git a/samples/tweet-button-plugin/src/main/java/org/apache/unomi/samples/tweet_button_plugin/actions/IncrementTweetNumberAction.java b/samples/tweet-button-plugin/src/main/java/org/apache/unomi/samples/tweet_button_plugin/actions/IncrementTweetNumberAction.java
index b062425..c6fa4e5 100644
--- a/samples/tweet-button-plugin/src/main/java/org/apache/unomi/samples/tweet_button_plugin/actions/IncrementTweetNumberAction.java
+++ b/samples/tweet-button-plugin/src/main/java/org/apache/unomi/samples/tweet_button_plugin/actions/IncrementTweetNumberAction.java
@@ -43,14 +43,14 @@
if (tweetNb == null || tweetedFrom == null) {
// create tweet number property type
- PropertyType propertyType = new PropertyType(new Metadata(event.getSourceId(), TWEET_NB_PROPERTY, TWEET_NB_PROPERTY, "Number of times a user tweeted"));
+ PropertyType propertyType = new PropertyType(new Metadata(event.getScope(), TWEET_NB_PROPERTY, TWEET_NB_PROPERTY, "Number of times a user tweeted"));
propertyType.setValueTypeId("integer");
propertyType.getMetadata().setTags(Collections.singleton("social"));
propertyType.setTarget(TARGET);
service.setPropertyType(propertyType);
// create tweeted from property type
- propertyType = new PropertyType(new Metadata(event.getSourceId(), TWEETED_FROM_PROPERTY, TWEETED_FROM_PROPERTY, "The list of pages a user tweeted from"));
+ propertyType = new PropertyType(new Metadata(event.getScope(), TWEETED_FROM_PROPERTY, TWEETED_FROM_PROPERTY, "The list of pages a user tweeted from"));
propertyType.setValueTypeId("string");
propertyType.getMetadata().setTags(Collections.singleton("social"));
propertyType.setTarget(TARGET);
diff --git a/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
index 5b81819..97944ef 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
@@ -61,8 +61,6 @@
private DefinitionsService definitionsService;
- private SourceService sourceService;
-
private BundleContext bundleContext;
private Set<String> predefinedEventTypeIds = new LinkedHashSet<String>();
@@ -71,8 +69,6 @@
private Map<String, ThirdPartyServer> thirdPartyServers = new HashMap<>();
- private Boolean shouldBeCheckedEventSourceId;
-
public void setThirdPartyConfiguration(Map<String, String> thirdPartyConfiguration) {
this.thirdPartyServers = new HashMap<>();
for (Map.Entry<String, String> entry : thirdPartyConfiguration.entrySet()) {
@@ -108,10 +104,6 @@
this.restrictedEventTypeIds = restrictedEventTypeIds;
}
- public void setShouldBeCheckedEventSourceId(boolean shouldBeCheckedEventSourceId) {
- this.shouldBeCheckedEventSourceId = shouldBeCheckedEventSourceId;
- }
-
public void setPersistenceService(PersistenceService persistenceService) {
this.persistenceService = persistenceService;
}
@@ -120,10 +112,6 @@
this.definitionsService = definitionsService;
}
- public void setSourceService(SourceService sourceService) {
- this.sourceService = sourceService;
- }
-
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
@@ -159,11 +147,6 @@
}
private int send(Event event, int depth) {
- if (shouldBeCheckedEventSourceId == Boolean.TRUE && sourceService.load(event.getSourceId()) == null) {
- logger.warn("Event sending was rejected, because source with sourceId=\"{}\" does not registered in the system.", event.getSourceId());
- return NO_CHANGE;
- }
-
if (depth > MAX_RECURSION_DEPTH) {
logger.warn("Max recursion depth reached");
return NO_CHANGE;
@@ -195,7 +178,7 @@
}
if ((changes & PROFILE_UPDATED) == PROFILE_UPDATED) {
- Event profileUpdated = new Event("profileUpdated", session, event.getProfile(), event.getSourceId(), event.getSource(), event.getProfile(), event.getTimeStamp());
+ Event profileUpdated = new Event("profileUpdated", session, event.getProfile(), event.getScope(), event.getSource(), event.getProfile(), event.getTimeStamp());
profileUpdated.setPersistent(false);
profileUpdated.getAttributes().putAll(event.getAttributes());
changes |= send(profileUpdated, depth + 1);
diff --git a/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
index 60b0795..56e2e8f 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/rules/RulesServiceImpl.java
@@ -190,7 +190,7 @@
RuleStatistics ruleStatistics = getLocalRuleStatistics(rule);
long ruleConditionStartTime = System.currentTimeMillis();
String scope = rule.getMetadata().getScope();
- if (scope.equals(Metadata.SYSTEM_SCOPE) || scope.equals(event.getSourceId())) {
+ if (scope.equals(Metadata.SYSTEM_SCOPE) || scope.equals(event.getScope())) {
Condition eventCondition = definitionsService.extractConditionBySystemTag(rule.getCondition(), "eventCondition");
if (eventCondition == null) {
@@ -318,7 +318,7 @@
changes |= actionExecutorDispatcher.execute(action, event);
}
long totalActionsTime = System.currentTimeMillis() - actionsStartTime;
- Event ruleFired = new Event("ruleFired", event.getSession(), event.getProfile(), event.getSourceId(), event, rule, event.getTimeStamp());
+ Event ruleFired = new Event("ruleFired", event.getSession(), event.getProfile(), event.getScope(), event, rule, event.getTimeStamp());
ruleFired.getAttributes().putAll(event.getAttributes());
ruleFired.setPersistent(false);
changes |= eventService.send(ruleFired);
diff --git a/services/src/main/java/org/apache/unomi/services/impl/source/SourceServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/source/SourceServiceImpl.java
deleted file mode 100644
index 47c4bed..0000000
--- a/services/src/main/java/org/apache/unomi/services/impl/source/SourceServiceImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.unomi.services.impl.source;
-
-import org.apache.unomi.api.SourceItem;
-import org.apache.unomi.api.services.SourceService;
-import org.apache.unomi.persistence.spi.PersistenceService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.SynchronousBundleListener;
-
-import java.util.List;
-
-public class SourceServiceImpl implements SourceService, SynchronousBundleListener {
-
- private PersistenceService persistenceService;
-
- private BundleContext bundleContext;
-
- @Override
- public SourceItem load(String sourceId) {
- return persistenceService.load(sourceId, SourceItem.class);
- }
-
- @Override
- public SourceItem save(SourceItem source) {
- if (persistenceService.save(source)) {
- persistenceService.refreshIndex(SourceItem.class, null);
-
- return source;
- }
-
- return null;
- }
-
- @Override
- public List<SourceItem> getAll() {
- return persistenceService.getAllItems(SourceItem.class);
- }
-
- @Override
- public boolean delete(String sourceId) {
- return persistenceService.remove(sourceId, SourceItem.class);
- }
-
- @Override
- public void bundleChanged(BundleEvent bundleEvent) {
- // do nothing
- }
-
- public void setPersistenceService(PersistenceService persistenceService) {
- this.persistenceService = persistenceService;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public void postConstruct() {
- bundleContext.addBundleListener(this);
- }
-
- public void preDestroy() {
- bundleContext.removeBundleListener(this);
- }
-
-}
diff --git a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index df30cf7..3347588 100644
--- a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -42,7 +42,6 @@
<cm:property name="segment.daily.dateexpr.evaluation.hourutc" value="5"/>
<cm:property name="rules.refresh.interval" value="1000"/>
<cm:property name="rules.statistics.refresh.interval" value="10000"/>
- <cm:property name="events.shouldBeCheckedEventSourceId" value="false"/>
<cm:property name="rules.optimizationActivated" value="true"/>
<cm:property name="schedules.thread.poolSize" value="5"/>
<cm:property name="scopes.refresh.interval" value="1000"/>
@@ -105,7 +104,6 @@
<bean id="eventServiceImpl" class="org.apache.unomi.services.impl.events.EventServiceImpl">
<property name="persistenceService" ref="persistenceService"/>
<property name="definitionsService" ref="definitionsServiceImpl"/>
- <property name="sourceService" ref="sourceServiceImpl"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="predefinedEventTypeIds">
<set>
@@ -128,7 +126,6 @@
<property name="thirdPartyConfiguration">
<cm:cm-properties persistent-id="org.apache.unomi.thirdparty" update="true"/>
</property>
- <property name="shouldBeCheckedEventSourceId" value="${services.events.shouldBeCheckedEventSourceId}"/>
</bean>
<service id="eventService" ref="eventServiceImpl" interface="org.apache.unomi.api.services.EventService"/>
@@ -303,18 +300,6 @@
</interfaces>
</service>
- <bean id="sourceServiceImpl" class="org.apache.unomi.services.impl.source.SourceServiceImpl"
- init-method="postConstruct" destroy-method="preDestroy">
- <property name="persistenceService" ref="persistenceService"/>
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </bean>
- <service id="sourceService" ref="sourceServiceImpl">
- <interfaces>
- <value>org.apache.unomi.api.services.SourceService</value>
- <value>org.osgi.framework.SynchronousBundleListener</value>
- </interfaces>
- </service>
-
<!-- We use a listener here because using the list directly for listening to proxies coming from the same bundle didn't seem to work -->
<reference-list id="eventListenerServices"
interface="org.apache.unomi.api.services.EventListenerService"
diff --git a/services/src/main/resources/org.apache.unomi.services.cfg b/services/src/main/resources/org.apache.unomi.services.cfg
index 536a9aa..2393055 100644
--- a/services/src/main/resources/org.apache.unomi.services.cfg
+++ b/services/src/main/resources/org.apache.unomi.services.cfg
@@ -70,9 +70,6 @@
# The interval in milliseconds to use to reload the rules statistics
rules.statistics.refresh.interval=${org.apache.unomi.rules.statistics.refresh.interval:-10000}
-# The indicator should be checked is there a sourceId in the system or not
-events.shouldBeCheckedEventSourceId=${org.apache.unomi.events.shouldBeCheckedEventSourceId:-false}
-
# If this setting is active, the rules engine will try to classify the events by event type internally which makes
# rules execution a lot faster. If there are any problems detected with rules execution, you might want to try to turn
# off the optimization and file a bug report if this fixed the problem.
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
index 985aa1c..b996a70 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
@@ -81,7 +81,7 @@
rowData.add(event.getSessionId());
rowData.add(event.getProfileId());
rowData.add(event.getTimeStamp().toString());
- rowData.add(event.getSourceId());
+ rowData.add(event.getScope());
rowData.add(Boolean.toString(event.isPersistent()));
dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
}
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventSearch.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventSearch.java
index 290f60c..082f1d3 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventSearch.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventSearch.java
@@ -90,7 +90,7 @@
rowData.add(event.getSessionId());
rowData.add(event.getProfileId());
rowData.add(event.getTimeStamp().toString());
- rowData.add(event.getSourceId());
+ rowData.add(event.getScope());
rowData.add(Boolean.toString(event.isPersistent()));
dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
}
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java
index 75f76c0..36ecdec 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java
@@ -84,7 +84,7 @@
eventInfo.add(event.getSessionId());
eventInfo.add(event.getProfileId());
eventInfo.add(event.getTimeStamp().toString());
- eventInfo.add(event.getSourceId());
+ eventInfo.add(event.getScope());
eventInfo.add(Boolean.toString(event.isPersistent()));
outputLine(out, eventInfo);
return EventService.NO_CHANGE;
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java
index f381539..6cf66b2 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java
@@ -86,7 +86,7 @@
ruleExecutionInfo.add(event.getSessionId());
ruleExecutionInfo.add(event.getProfileId());
ruleExecutionInfo.add(event.getTimeStamp().toString());
- ruleExecutionInfo.add(event.getSourceId());
+ ruleExecutionInfo.add(event.getScope());
outputLine(out, ruleExecutionInfo);
}
}
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java
index c922445..c943944 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java
@@ -101,7 +101,7 @@
ruleExecutionInfo.add(event.getSessionId());
ruleExecutionInfo.add(event.getProfileId());
ruleExecutionInfo.add(event.getTimeStamp().toString());
- ruleExecutionInfo.add(event.getSourceId());
+ ruleExecutionInfo.add(event.getScope());
outputLine(out, ruleExecutionInfo);
}