You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2022/07/22 07:33:15 UTC

[unomi] branch UNOMI-631-map-sources-to-scopes created (now af109debd)

This is an automated email from the ASF dual-hosted git repository.

shuber pushed a change to branch UNOMI-631-map-sources-to-scopes
in repository https://gitbox.apache.org/repos/asf/unomi.git


      at af109debd 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

This branch includes the following new commits:

     new af109debd 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

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[unomi] 01/01: 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

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

shuber pushed a commit to branch UNOMI-631-map-sources-to-scopes
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit af109debdd0170b7c48551161c291a7743099e5d
Author: Serge Huber <sh...@jahia.com>
AuthorDate: Fri Jul 22 09:33:08 2022 +0200

    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
---
 api/src/main/java/org/apache/unomi/api/Event.java  | 19 -----
 .../main/java/org/apache/unomi/api/SourceItem.java | 51 --------------
 .../apache/unomi/api/services/SourceService.java   | 56 ---------------
 .../unomi/lists/actions/AddToListsAction.java      |  2 +-
 .../commands/CreateOrUpdateSourceCommand.java      | 21 +++---
 .../graphql/commands/DeleteSourceCommand.java      |  4 +-
 .../unomi/graphql/fetchers/SourceDataFetcher.java  | 10 +--
 .../unomi/itests/graphql/GraphQLSourceIT.java      |  4 +-
 .../unomi/persistence/spi/CustomObjectMapper.java  |  1 -
 .../actions/MergeProfilesOnPropertyAction.java     |  4 +-
 .../baseplugin/actions/SendEventAction.java        |  2 +-
 .../baseplugin/actions/SetPropertyAction.java      |  2 +-
 .../rest/endpoints/EventsCollectorEndpoint.java    |  4 +-
 .../rest/service/impl/RestServiceUtilsImpl.java    |  4 +-
 .../unomi/training/TrainedNotificationAction.java  |  2 +-
 .../actions/IncrementTweetNumberAction.java        |  4 +-
 .../services/impl/events/EventServiceImpl.java     | 19 +----
 .../services/impl/rules/RulesServiceImpl.java      |  4 +-
 .../services/impl/source/SourceServiceImpl.java    | 81 ----------------------
 .../resources/OSGI-INF/blueprint/blueprint.xml     | 15 ----
 .../main/resources/org.apache.unomi.services.cfg   |  3 -
 .../org/apache/unomi/shell/commands/EventList.java |  2 +-
 .../apache/unomi/shell/commands/EventSearch.java   |  2 +-
 .../org/apache/unomi/shell/commands/EventTail.java |  2 +-
 .../org/apache/unomi/shell/commands/RuleTail.java  |  2 +-
 .../org/apache/unomi/shell/commands/RuleWatch.java |  2 +-
 26 files changed, 38 insertions(+), 284 deletions(-)

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 0397b8acd..4ac9717cb 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 @@ public class Event extends Item implements TimestampedItem {
     private transient Session session;
     private transient List<ActionPostExecutor> actionPostExecutors;
 
-    @Deprecated
-    private String scope;
-
-    private String sourceId;
-
     private Item source;
     private Item target;
 
@@ -398,12 +393,10 @@ public class Event extends Item implements TimestampedItem {
     /**
      * @return the scope
      */
-    @Deprecated
     public String getScope() {
         return scope;
     }
 
-    @Deprecated
     public void setScope(String scope) {
         this.scope = scope;
     }
@@ -463,16 +456,4 @@ public class Event extends Item implements TimestampedItem {
         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 2e682691a..000000000
--- 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 6c794e713..000000000
--- 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 c209e48e6..7f60f0881 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 @@ public class AddToListsAction implements ActionExecutor {
 
         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 ee2a275ed..5a02796c2 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 @@ public class CreateOrUpdateSourceCommand extends BaseCommand<CDPSource> {
 
     @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 d9146fecd..4fa013ecb 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 @@ public class DeleteSourceCommand extends BaseCommand<Boolean> {
 
     @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 bed77cf77..248e638c7 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 @@ package org.apache.unomi.graphql.fetchers;
 
 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 class SourceDataFetcher implements DataFetcher<List<CDPSource>> {
     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 bb0358556..a5a828fb3 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 @@ public class GraphQLSourceIT extends BaseGraphQLIT {
 
     @Inject
     @Filter(timeout = 600000)
-    SourceService sourceService;
+    ScopeService scopeService;
 
     @Test
     public void testCRUD() throws IOException, InterruptedException {
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 1d14d5503..65d09b0c7 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 @@ public class CustomObjectMapper extends ObjectMapper {
         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 6a94ca787..2e21d8b1c 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 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor {
 
             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 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor {
                 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 70af7f195..909fb59a5 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 @@ public class SendEventAction implements ActionExecutor {
         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 870159ed4..fd833a5e8 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 @@ public class SetPropertyAction implements ActionExecutor {
                 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 11b4d8c62..8911402a2 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 @@ public class EventsCollectorEndpoint {
             // 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 ec1170c14..fae86daa2 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 @@ public class RestServiceUtilsImpl implements RestServiceUtils {
             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 @@ public class RestServiceUtilsImpl implements RestServiceUtils {
                         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 75c388ff5..74c2242e2 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 @@ public class TrainedNotificationAction implements ActionExecutor {
 
         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 b0624259b..c6fa4e565 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 @@ public class IncrementTweetNumberAction implements ActionExecutor {
 
         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 5b81819b9..97944efe4 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 @@ public class EventServiceImpl implements EventService {
 
     private DefinitionsService definitionsService;
 
-    private SourceService sourceService;
-
     private BundleContext bundleContext;
 
     private Set<String> predefinedEventTypeIds = new LinkedHashSet<String>();
@@ -71,8 +69,6 @@ public class EventServiceImpl implements EventService {
 
     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 @@ public class EventServiceImpl implements EventService {
         this.restrictedEventTypeIds = restrictedEventTypeIds;
     }
 
-    public void setShouldBeCheckedEventSourceId(boolean shouldBeCheckedEventSourceId) {
-        this.shouldBeCheckedEventSourceId = shouldBeCheckedEventSourceId;
-    }
-
     public void setPersistenceService(PersistenceService persistenceService) {
         this.persistenceService = persistenceService;
     }
@@ -120,10 +112,6 @@ public class EventServiceImpl implements EventService {
         this.definitionsService = definitionsService;
     }
 
-    public void setSourceService(SourceService sourceService) {
-        this.sourceService = sourceService;
-    }
-
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
@@ -159,11 +147,6 @@ public class EventServiceImpl implements EventService {
     }
 
     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 @@ public class EventServiceImpl implements EventService {
                 }
 
                 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 60b079501..56e2e8fb0 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 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
             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 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
                 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 47c4bedf8..000000000
--- 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 df30cf716..3347588ab 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 536a9aac4..239305529 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 @@ scopes.refresh.interval=${org.apache.unomi.scopes.refresh.interval:-1000}
 # 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 985aa1c06..b996a7085 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 @@ public class EventList extends ListCommandSupport {
             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 290f60cd7..082f1d3d3 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 @@ public class EventSearch extends ListCommandSupport  {
             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 75f76c022..36ecdeceb 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 @@ public class EventTail extends TailCommandSupport  {
             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 f3815393b..6cf66b219 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 @@ public class RuleTail extends TailCommandSupport {
             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 c9224451c..c94394455 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 @@ public class RuleWatch extends TailCommandSupport {
             ruleExecutionInfo.add(event.getSessionId());
             ruleExecutionInfo.add(event.getProfileId());
             ruleExecutionInfo.add(event.getTimeStamp().toString());
-            ruleExecutionInfo.add(event.getSourceId());
+            ruleExecutionInfo.add(event.getScope());
             outputLine(out, ruleExecutionInfo);
         }