Major changes : - Rename all packages to org.apache.*
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/dc1d1520 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/dc1d1520 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/dc1d1520 Branch: refs/heads/master Commit: dc1d152032c76fa3d5828d1ec416febc7baded2e Parents: c5e32d1 Author: Serge Huber <[email protected]> Authored: Wed Nov 18 11:48:16 2015 +0100 Committer: Serge Huber <[email protected]> Committed: Wed Nov 18 11:48:18 2015 +0100 ---------------------------------------------------------------------- README.md | 10 +- .../java/org/apache/unomi/api/BatchUpdate.java | 104 ++ .../java/org/apache/unomi/api/ClusterNode.java | 225 +++ .../org/apache/unomi/api/ContextRequest.java | 369 +++++ .../org/apache/unomi/api/ContextResponse.java | 188 +++ .../java/org/apache/unomi/api/CustomItem.java | 69 + .../main/java/org/apache/unomi/api/Event.java | 323 +++++ .../java/org/apache/unomi/api/EventInfo.java | 49 + .../org/apache/unomi/api/EventProperty.java | 100 ++ .../java/org/apache/unomi/api/EventSource.java | 63 + .../java/org/apache/unomi/api/EventTarget.java | 72 + .../unomi/api/EventsCollectorRequest.java | 40 + .../main/java/org/apache/unomi/api/Item.java | 113 ++ .../java/org/apache/unomi/api/Metadata.java | 261 ++++ .../java/org/apache/unomi/api/MetadataItem.java | 58 + .../java/org/apache/unomi/api/Parameter.java | 61 + .../java/org/apache/unomi/api/PartialList.java | 144 ++ .../main/java/org/apache/unomi/api/Persona.java | 37 + .../org/apache/unomi/api/PersonaSession.java | 35 + .../apache/unomi/api/PersonaWithSessions.java | 59 + .../java/org/apache/unomi/api/PluginType.java | 39 + .../main/java/org/apache/unomi/api/Profile.java | 203 +++ .../api/PropertyMergeStrategyExecutor.java | 37 + .../unomi/api/PropertyMergeStrategyType.java | 69 + .../java/org/apache/unomi/api/PropertyType.java | 336 +++++ .../java/org/apache/unomi/api/ServerInfo.java | 70 + .../main/java/org/apache/unomi/api/Session.java | 227 +++ api/src/main/java/org/apache/unomi/api/Tag.java | 190 +++ .../org/apache/unomi/api/TimestampedItem.java | 32 + .../java/org/apache/unomi/api/ValueType.java | 177 +++ .../org/apache/unomi/api/actions/Action.java | 121 ++ .../unomi/api/actions/ActionExecutor.java | 37 + .../unomi/api/actions/ActionPostExecutor.java | 32 + .../apache/unomi/api/actions/ActionType.java | 211 +++ .../apache/unomi/api/campaigns/Campaign.java | 193 +++ .../unomi/api/campaigns/CampaignDetail.java | 149 ++ .../api/campaigns/events/CampaignEvent.java | 150 ++ .../apache/unomi/api/conditions/Condition.java | 157 +++ .../unomi/api/conditions/ConditionType.java | 273 ++++ .../initializers/ChoiceListInitializer.java | 34 + .../initializers/ChoiceListValue.java | 60 + .../conditions/initializers/I18nSupport.java | 27 + .../java/org/apache/unomi/api/goals/Goal.java | 90 ++ .../org/apache/unomi/api/goals/GoalReport.java | 105 ++ .../org/apache/unomi/api/query/Aggregate.java | 83 ++ .../apache/unomi/api/query/AggregateQuery.java | 100 ++ .../org/apache/unomi/api/query/DateRange.java | 54 + .../org/apache/unomi/api/query/IpRange.java | 54 + .../apache/unomi/api/query/NumericRange.java | 54 + .../java/org/apache/unomi/api/query/Query.java | 151 ++ .../java/org/apache/unomi/api/rules/Rule.java | 179 +++ .../org/apache/unomi/api/segments/Scoring.java | 76 + .../unomi/api/segments/ScoringElement.java | 73 + .../org/apache/unomi/api/segments/Segment.java | 78 + .../unomi/api/segments/SegmentsAndScores.java | 61 + .../unomi/api/services/ClusterService.java | 53 + .../unomi/api/services/DefinitionsService.java | 178 +++ .../api/services/EventListenerService.java | 46 + .../apache/unomi/api/services/EventService.java | 109 ++ .../apache/unomi/api/services/GoalsService.java | 171 +++ .../unomi/api/services/PrivacyService.java | 57 + .../unomi/api/services/ProfileService.java | 296 ++++ .../apache/unomi/api/services/QueryService.java | 80 ++ .../apache/unomi/api/services/RulesService.java | 79 ++ .../unomi/api/services/SegmentService.java | 206 +++ .../contextserver/api/BatchUpdate.java | 104 -- .../contextserver/api/ClusterNode.java | 225 --- .../contextserver/api/ContextRequest.java | 364 ----- .../contextserver/api/ContextResponse.java | 187 --- .../contextserver/api/CustomItem.java | 71 - .../org/oasis_open/contextserver/api/Event.java | 324 ----- .../oasis_open/contextserver/api/EventInfo.java | 49 - .../contextserver/api/EventProperty.java | 100 -- .../contextserver/api/EventSource.java | 63 - .../contextserver/api/EventTarget.java | 72 - .../api/EventsCollectorRequest.java | 40 - .../org/oasis_open/contextserver/api/Item.java | 114 -- .../oasis_open/contextserver/api/Metadata.java | 262 ---- .../contextserver/api/MetadataItem.java | 58 - .../oasis_open/contextserver/api/Parameter.java | 61 - .../contextserver/api/PartialList.java | 144 -- .../oasis_open/contextserver/api/Persona.java | 37 - .../contextserver/api/PersonaSession.java | 35 - .../contextserver/api/PersonaWithSessions.java | 59 - .../contextserver/api/PluginType.java | 39 - .../oasis_open/contextserver/api/Profile.java | 202 --- .../api/PropertyMergeStrategyExecutor.java | 37 - .../api/PropertyMergeStrategyType.java | 69 - .../contextserver/api/PropertyType.java | 336 ----- .../contextserver/api/ServerInfo.java | 70 - .../oasis_open/contextserver/api/Session.java | 229 --- .../org/oasis_open/contextserver/api/Tag.java | 191 --- .../contextserver/api/TimestampedItem.java | 32 - .../oasis_open/contextserver/api/ValueType.java | 178 --- .../contextserver/api/actions/Action.java | 119 -- .../api/actions/ActionExecutor.java | 36 - .../api/actions/ActionPostExecutor.java | 32 - .../contextserver/api/actions/ActionType.java | 212 --- .../contextserver/api/campaigns/Campaign.java | 194 --- .../api/campaigns/CampaignDetail.java | 149 -- .../api/campaigns/events/CampaignEvent.java | 149 -- .../contextserver/api/conditions/Condition.java | 158 --- .../api/conditions/ConditionType.java | 274 ---- .../initializers/ChoiceListInitializer.java | 34 - .../initializers/ChoiceListValue.java | 60 - .../conditions/initializers/I18nSupport.java | 27 - .../contextserver/api/goals/Goal.java | 92 -- .../contextserver/api/goals/GoalReport.java | 105 -- .../contextserver/api/query/Aggregate.java | 83 -- .../contextserver/api/query/AggregateQuery.java | 100 -- .../contextserver/api/query/DateRange.java | 54 - .../contextserver/api/query/IpRange.java | 54 - .../contextserver/api/query/NumericRange.java | 54 - .../contextserver/api/query/Query.java | 151 -- .../contextserver/api/rules/Rule.java | 183 --- .../contextserver/api/segments/Scoring.java | 77 - .../api/segments/ScoringElement.java | 73 - .../contextserver/api/segments/Segment.java | 79 -- .../api/segments/SegmentsAndScores.java | 59 - .../api/services/ClusterService.java | 53 - .../api/services/DefinitionsService.java | 178 --- .../api/services/EventListenerService.java | 46 - .../api/services/EventService.java | 107 -- .../api/services/GoalsService.java | 170 --- .../api/services/PrivacyService.java | 57 - .../api/services/ProfileService.java | 296 ---- .../api/services/QueryService.java | 80 -- .../api/services/RulesService.java | 79 -- .../api/services/SegmentService.java | 207 --- .../unomi/geonames/rest/GeonamesEndPoint.java | 113 ++ .../unomi/geonames/rest/GeonamesEndPoint.java | 113 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- .../unomi/geonames/services/GeonameEntry.java | 213 +++ .../geonames/services/GeonamesService.java | 44 + .../geonames/services/GeonamesServiceImpl.java | 302 ++++ .../unomi/geonames/services/GeonameEntry.java | 213 --- .../geonames/services/GeonamesService.java | 44 - .../geonames/services/GeonamesServiceImpl.java | 302 ---- .../resources/OSGI-INF/blueprint/blueprint.xml | 7 +- .../lists/rest/UserListServiceEndPoint.java | 83 ++ .../unomi/rest/UserListServiceEndPoint.java | 83 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- .../java/org/apache/unomi/lists/UserList.java | 38 + .../apache/unomi/services/UserListService.java | 39 + .../unomi/services/UserListServiceImpl.java | 102 ++ .../java/org/jahia/unomi/lists/UserList.java | 38 - .../jahia/unomi/services/UserListService.java | 39 - .../unomi/services/UserListServiceImpl.java | 102 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- .../privacy/rest/PrivacyServiceEndPoint.java | 121 ++ .../privacy/rest/PrivacyServiceEndPoint.java | 121 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- .../privacy/internal/PrivacyServiceImpl.java | 207 +++ .../privacy/internal/PrivacyServiceImpl.java | 207 --- .../resources/OSGI-INF/blueprint/blueprint.xml | 10 +- .../java/org/apache/unomi/itests/AllTests.java | 37 + .../java/org/apache/unomi/itests/BaseTest.java | 100 ++ .../java/org/apache/unomi/itests/BasicTest.java | 99 ++ .../apache/unomi/itests/ConditionBuilder.java | 290 ++++ .../itests/ConditionESQueryBuilderTest.java | 59 + .../unomi/itests/ConditionEvaluatorTest.java | 178 +++ .../org/apache/unomi/itests/SegmentTest.java | 48 + .../java/org/apache/unomi/itests/TestUtils.java | 35 + .../contextserver/itests/AllTests.java | 37 - .../contextserver/itests/BaseTest.java | 100 -- .../contextserver/itests/BasicTest.java | 99 -- .../contextserver/itests/ConditionBuilder.java | 290 ---- .../itests/ConditionESQueryBuilderTest.java | 59 - .../itests/ConditionEvaluatorTest.java | 184 --- .../contextserver/itests/SegmentTest.java | 48 - .../contextserver/itests/TestUtils.java | 35 - package/pom.xml | 9 +- .../unomi/performancetests/BasicTest.java | 187 +++ .../performancetests/BasicTest.java | 188 --- persistence-elasticsearch/core/pom.xml | 5 +- .../ElasticSearchPersistenceServiceImpl.java | 1328 ++++++++++++++++++ .../conditions/ConditionContextHelper.java | 150 ++ .../conditions/ConditionESQueryBuilder.java | 29 + .../ConditionESQueryBuilderDispatcher.java | 106 ++ .../conditions/ConditionEvaluator.java | 32 + .../ConditionEvaluatorDispatcher.java | 91 ++ .../ElasticSearchPersistenceServiceImpl.java | 1328 ------------------ .../conditions/ConditionContextHelper.java | 150 -- .../conditions/ConditionESQueryBuilder.java | 30 - .../ConditionESQueryBuilderDispatcher.java | 104 -- .../conditions/ConditionEvaluator.java | 32 - .../ConditionEvaluatorDispatcher.java | 90 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 12 +- .../plugin/security/IPRangeMatcher.java | 158 +++ .../plugin/security/SecurityPlugin.java | 61 + .../plugin/security/SecurityPluginModule.java | 33 + .../plugin/security/SecurityPluginService.java | 157 +++ .../contextserver/IPRangeMatcher.java | 158 --- .../contextserver/SecurityPlugin.java | 61 - .../contextserver/SecurityPluginModule.java | 33 - .../contextserver/SecurityPluginService.java | 157 --- .../src/main/resources/es-plugin.properties | 2 +- .../persistence/spi/CustomObjectMapper.java | 92 ++ .../unomi/persistence/spi/ItemDeserializer.java | 60 + .../persistence/spi/PersistenceService.java | 399 ++++++ .../unomi/persistence/spi/PropertyHelper.java | 91 ++ .../spi/PropertyTypedObjectDeserializer.java | 114 ++ .../spi/aggregate/BaseAggregate.java | 30 + .../spi/aggregate/DateAggregate.java | 77 + .../spi/aggregate/DateRangeAggregate.java | 50 + .../spi/aggregate/IpRangeAggregate.java | 39 + .../spi/aggregate/NumericRangeAggregate.java | 39 + .../spi/aggregate/TermsAggregate.java | 24 + .../persistence/spi/CustomObjectMapper.java | 93 -- .../persistence/spi/ItemDeserializer.java | 61 - .../persistence/spi/PersistenceService.java | 399 ------ .../persistence/spi/PropertyHelper.java | 91 -- .../spi/PropertyTypedObjectDeserializer.java | 111 -- .../spi/aggregate/BaseAggregate.java | 30 - .../spi/aggregate/DateAggregate.java | 77 - .../spi/aggregate/DateRangeAggregate.java | 51 - .../spi/aggregate/IpRangeAggregate.java | 39 - .../spi/aggregate/NumericRangeAggregate.java | 39 - .../spi/aggregate/TermsAggregate.java | 24 - .../AllEventToProfilePropertiesAction.java | 68 + .../actions/EvaluateProfileAgeAction.java | 44 + .../actions/EvaluateProfileSegmentsAction.java | 58 + .../actions/EventToProfilePropertyAction.java | 39 + .../actions/IncrementInterestsValuesAction.java | 63 + .../actions/MergeProfilesOnPropertyAction.java | 200 +++ .../baseplugin/actions/SendEventAction.java | 53 + .../actions/SetEventOccurenceCountAction.java | 87 ++ .../baseplugin/actions/SetPropertyAction.java | 63 + .../BooleanConditionESQueryBuilder.java | 54 + .../conditions/BooleanConditionEvaluator.java | 51 + ...onByPointSessionConditionESQueryBuilder.java | 60 + ...ocationByPointSessionConditionEvaluator.java | 70 + .../MatchAllConditionESQueryBuilder.java | 34 + .../conditions/MatchAllConditionEvaluator.java | 33 + .../conditions/NotConditionESQueryBuilder.java | 37 + .../conditions/NotConditionEvaluator.java | 37 + .../PastEventConditionESQueryBuilder.java | 88 ++ .../conditions/PastEventConditionEvaluator.java | 104 ++ .../PropertyConditionESQueryBuilder.java | 135 ++ .../conditions/PropertyConditionEvaluator.java | 299 ++++ ...rceEventPropertyConditionESQueryBuilder.java | 54 + .../SourceEventPropertyConditionEvaluator.java | 80 ++ .../AllEventToProfilePropertiesAction.java | 68 - .../actions/EvaluateProfileAgeAction.java | 44 - .../actions/EvaluateProfileSegmentsAction.java | 58 - .../actions/EventToProfilePropertyAction.java | 39 - .../actions/IncrementInterestsValuesAction.java | 63 - .../actions/MergeProfilesOnPropertyAction.java | 200 --- .../baseplugin/actions/SendEventAction.java | 51 - .../actions/SetEventOccurenceCountAction.java | 87 -- .../baseplugin/actions/SetPropertyAction.java | 63 - .../BooleanConditionESQueryBuilder.java | 54 - .../conditions/BooleanConditionEvaluator.java | 51 - ...onByPointSessionConditionESQueryBuilder.java | 60 - ...ocationByPointSessionConditionEvaluator.java | 70 - .../MatchAllConditionESQueryBuilder.java | 34 - .../conditions/MatchAllConditionEvaluator.java | 33 - .../conditions/NotConditionESQueryBuilder.java | 37 - .../conditions/NotConditionEvaluator.java | 37 - .../PastEventConditionESQueryBuilder.java | 88 -- .../conditions/PastEventConditionEvaluator.java | 104 -- .../PropertyConditionESQueryBuilder.java | 137 -- .../conditions/PropertyConditionEvaluator.java | 299 ---- ...rceEventPropertyConditionESQueryBuilder.java | 55 - .../SourceEventPropertyConditionEvaluator.java | 81 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 86 +- .../HoverEventConditionESQueryBuilder.java | 53 + .../HoverEventConditionESQueryBuilder.java | 55 - .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- .../plugins/mail/actions/SendMailAction.java | 117 ++ .../plugins/mail/actions/SendMailAction.java | 117 -- .../resources/OSGI-INF/blueprint/blueprint.xml | 4 +- .../resources/OSGI-INF/metatype/metatype.xml | 6 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- plugins/pom.xml | 6 +- .../RequestHeaderToProfilePropertyAction.java | 58 + ...RequestParameterToProfilePropertyAction.java | 58 + .../actions/SetRemoteHostInfoAction.java | 181 +++ .../RequestHeaderToProfilePropertyAction.java | 58 - ...RequestParameterToProfilePropertyAction.java | 58 - .../actions/SetRemoteHostInfoAction.java | 183 --- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 6 +- rest/pom.xml | 5 +- .../unomi/rest/CampaignsServiceEndPoint.java | 172 +++ .../unomi/rest/ClusterServiceEndPoint.java | 103 ++ .../unomi/rest/DefinitionsServiceEndPoint.java | 252 ++++ .../apache/unomi/rest/GoalsServiceEndPoint.java | 135 ++ .../apache/unomi/rest/LocalizationHelper.java | 279 ++++ .../unomi/rest/ProfileServiceEndPoint.java | 507 +++++++ .../apache/unomi/rest/QueryServiceEndPoint.java | 143 ++ .../org/apache/unomi/rest/RESTActionType.java | 74 + .../apache/unomi/rest/RESTConditionType.java | 79 ++ .../org/apache/unomi/rest/RESTParameter.java | 76 + .../java/org/apache/unomi/rest/RESTTag.java | 84 ++ .../org/apache/unomi/rest/RESTValueType.java | 68 + .../apache/unomi/rest/ResourceBundleHelper.java | 109 ++ .../apache/unomi/rest/RulesServiceEndPoint.java | 126 ++ .../unomi/rest/ScoringServiceEndPoint.java | 143 ++ .../unomi/rest/SegmentServiceEndPoint.java | 191 +++ .../rest/CampaignsServiceEndPoint.java | 171 --- .../rest/ClusterServiceEndPoint.java | 103 -- .../rest/DefinitionsServiceEndPoint.java | 252 ---- .../rest/GoalsServiceEndPoint.java | 134 -- .../contextserver/rest/LocalizationHelper.java | 279 ---- .../rest/ProfileServiceEndPoint.java | 507 ------- .../rest/QueryServiceEndPoint.java | 143 -- .../contextserver/rest/RESTActionType.java | 72 - .../contextserver/rest/RESTConditionType.java | 77 - .../contextserver/rest/RESTParameter.java | 75 - .../oasis_open/contextserver/rest/RESTTag.java | 82 -- .../contextserver/rest/RESTValueType.java | 66 - .../rest/ResourceBundleHelper.java | 109 -- .../rest/RulesServiceEndPoint.java | 126 -- .../rest/ScoringServiceEndPoint.java | 143 -- .../rest/SegmentServiceEndPoint.java | 191 --- .../resources/OSGI-INF/blueprint/blueprint.xml | 42 +- .../actions/ActionExecutorDispatcher.java | 201 +++ ...ComparisonOperatorChoiceListInitializer.java | 76 + .../ComparisonOperatorChoiceListValue.java | 89 ++ .../CountryChoiceListInitializer.java | 68 + .../EventPropertyChoiceListInitializer.java | 47 + .../EventTypeIdChoiceListInitializer.java | 46 + .../GoalsChoiceListInitializer.java | 44 + .../PropertyTypeChoiceListValue.java | 135 ++ .../SegmentsChoiceListInitializer.java | 47 + .../AddPropertyMergeStrategyExecutor.java | 78 + .../DefaultPropertyMergeStrategyExecutor.java | 38 + ...MostRecentPropertyMergeStrategyExecutor.java | 40 + .../NonEmptyPropertyMergeStrategyExecutor.java | 30 + .../OldestPropertyMergeStrategyExecutor.java | 30 + .../services/DefinitionsServiceImpl.java | 456 ++++++ .../services/services/EventServiceImpl.java | 223 +++ .../services/services/GoalsServiceImpl.java | 613 ++++++++ .../unomi/services/services/ParserHelper.java | 126 ++ .../services/services/ProfileServiceImpl.java | 701 +++++++++ .../services/services/QueryServiceImpl.java | 109 ++ .../services/services/RulesServiceImpl.java | 387 +++++ .../services/services/SegmentServiceImpl.java | 816 +++++++++++ .../impl/actions/ActionExecutorDispatcher.java | 205 --- ...ComparisonOperatorChoiceListInitializer.java | 76 - .../ComparisonOperatorChoiceListValue.java | 89 -- .../CountryChoiceListInitializer.java | 74 - .../EventPropertyChoiceListInitializer.java | 47 - .../EventTypeIdChoiceListInitializer.java | 46 - .../GoalsChoiceListInitializer.java | 44 - .../PropertyTypeChoiceListValue.java | 135 -- .../SegmentsChoiceListInitializer.java | 48 - .../AddPropertyMergeStrategyExecutor.java | 78 - .../DefaultPropertyMergeStrategyExecutor.java | 38 - ...MostRecentPropertyMergeStrategyExecutor.java | 40 - .../NonEmptyPropertyMergeStrategyExecutor.java | 30 - .../OldestPropertyMergeStrategyExecutor.java | 30 - .../impl/services/DefinitionsServiceImpl.java | 456 ------ .../impl/services/EventServiceImpl.java | 223 --- .../impl/services/GoalsServiceImpl.java | 613 -------- .../impl/services/ParserHelper.java | 126 -- .../impl/services/ProfileServiceImpl.java | 704 ---------- .../impl/services/QueryServiceImpl.java | 109 -- .../impl/services/RulesServiceImpl.java | 385 ----- .../impl/services/SegmentServiceImpl.java | 818 ----------- .../resources/OSGI-INF/blueprint/blueprint.xml | 45 +- src/site/markdown/clustering.md | 4 +- src/site/markdown/configuration.md | 91 +- wab/pom.xml | 13 +- .../org/apache/unomi/web/ContextServlet.java | 368 +++++ .../unomi/web/EventsCollectorServlet.java | 185 +++ .../java/org/apache/unomi/web/HttpUtils.java | 159 +++ .../contextserver/web/ContextServlet.java | 371 ----- .../web/EventsCollectorServlet.java | 185 --- .../oasis_open/contextserver/web/HttpUtils.java | 159 --- .../resources/OSGI-INF/blueprint/blueprint.xml | 15 +- 372 files changed, 23271 insertions(+), 23198 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index 0a66628..9a796a9 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ In order to use it, you need to install the Geonames database into . Get the "al http://download.geonames.org/export/dump/ Download it and put it in the "etc" directory, without unzipping it. -Edit $MY_KARAF_HOME/etc/org.oasis_open.contextserver.geonames.cfg and set request.geonamesDatabase.forceImport to true, import should start right away. +Edit $MY_KARAF_HOME/etc/org.apache.unomi.geonames.cfg and set request.geonamesDatabase.forceImport to true, import should start right away. Otherwise, import should start at the next startup. Import runs in background, but can take about 15 minutes. At the end, you should have about 4 million entries in the geonames index. @@ -139,7 +139,7 @@ Changing the default configuration If you want to change the default configuration, you can perform any modification you want in the $MY_KARAF_HOME/etc directory. -The context server configuration is kept in the $MY_KARAF_HOME/etc/org.oasis_open.contextserver.web.cfg . It defines the +The context server configuration is kept in the $MY_KARAF_HOME/etc/org.apache.unomi.web.cfg . It defines the addresses and port where it can be found : contextserver.address=localhost @@ -152,7 +152,7 @@ BEFORE you start the server for the first time, or you will loose all the data y To change the cluster name, first create a file called - $MY_KARAF_HOME/etc/org.oasis_open.contextserver.persistence.elasticsearch.cfg + $MY_KARAF_HOME/etc/org.apache.unomi.persistence.elasticsearch.cfg with the following contents: @@ -256,7 +256,7 @@ Cluster setup ------------- Context server relies on Elasticsearch to discover and configure its cluster. You just need to install multiple context -servers on the same network, and enable the discovery protocol in $MY_KARAF_HOME/etc/org.oasis_open.contextserver.persistence.elasticsearch.cfg file : +servers on the same network, and enable the discovery protocol in $MY_KARAF_HOME/etc/org.apache.unomi.persistence.elasticsearch.cfg file : discovery.zen.ping.multicast.enabled=true @@ -305,7 +305,7 @@ Node C : ### Specific configuration If multicast is not allowed on your network, you'll need to switch to unicast protocol and manually configure the server IPs. This can be -done by disabling the elasticsearch automatic discovery in $MY_KARAF_HOME/etc/org.oasis_open.contextserver.persistence.elasticsearch.cfg : +done by disabling the elasticsearch automatic discovery in $MY_KARAF_HOME/etc/org.apache.unomi.persistence.elasticsearch.cfg : discovery.zen.ping.multicast.enabled=false http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/BatchUpdate.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/BatchUpdate.java b/api/src/main/java/org/apache/unomi/api/BatchUpdate.java new file mode 100644 index 0000000..45bf9e8 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/BatchUpdate.java @@ -0,0 +1,104 @@ +/* + * 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; + +import org.apache.unomi.api.conditions.Condition; + +/** + * A representation of an operation to update the value of a property on items matching a specific condition. + */ +public class BatchUpdate { + private String propertyName; + private Object propertyValue; + private Condition condition; + private String strategy; + + /** + * Retrieves the property name which value needs to be updated. Note that the property name follows the + * <a href='https://commons.apache.org/proper/commons-beanutils/apidocs/org/apache/commons/beanutils/expression/DefaultResolver.html'>Apache Commons BeanUtils expression + * format</a> + * + * @return an Apache Commons BeanUtils expression identifying which property we want to update + */ + public String getPropertyName() { + return propertyName; + } + + /** + * Specifies (as an Apache Commons BeanUtils expression) which property needs to be updated. + * + * @param propertyName an Apache Commons BeanUtils expression identifying which property we want to update + */ + public void setPropertyName(String propertyName) { + this.propertyName = propertyName; + } + + /** + * Retrieves the new property value. + * + * @return the new property value + */ + public Object getPropertyValue() { + return propertyValue; + } + + /** + * Sets the new property value to use for the update. + * + * @param propertyValue the new property value to use for the update + */ + public void setPropertyValue(Object propertyValue) { + this.propertyValue = propertyValue; + } + + /** + * Retrieves the condition which items we want to update must satisfy. + * + * @return the condition which items we want to update must satisfy + */ + public Condition getCondition() { + return condition; + } + + /** + * Specifies the condition which items to update. + * + * @param condition the condition specifying which items to update + */ + public void setCondition(Condition condition) { + this.condition = condition; + } + + /** + * Retrieves the identifier for the {@link PropertyMergeStrategyType} to use during the update if needed. + * + * @return the identifier for the {@link PropertyMergeStrategyType} to use during the update if needed + */ + public String getStrategy() { + return strategy; + } + + /** + * Sets the identifier for the {@link PropertyMergeStrategyType} to use during the update if needed. + * + * @param strategy the identifier for the {@link PropertyMergeStrategyType} to use during the update if needed + */ + public void setStrategy(String strategy) { + this.strategy = strategy; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/ClusterNode.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/ClusterNode.java b/api/src/main/java/org/apache/unomi/api/ClusterNode.java new file mode 100644 index 0000000..0917008 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/ClusterNode.java @@ -0,0 +1,225 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * Information about a cluster node. + */ +public class ClusterNode implements Serializable { + + private static final long serialVersionUID = 1281422346318230514L; + + private double cpuLoad; + private double[] loadAverage; + private String hostName; + private String hostAddress; + private int publicPort; + private String secureHostAddress; + private int securePort; + private long uptime; + private boolean master; + private boolean data; + + /** + * Instantiates a new Cluster node. + */ + public ClusterNode() { + } + + /** + * Retrieves the cpu load. + * + * @return the cpu load + */ + public double getCpuLoad() { + return cpuLoad; + } + + /** + * Sets the cpu load. + * + * @param cpuLoad the cpu load + */ + public void setCpuLoad(double cpuLoad) { + this.cpuLoad = cpuLoad; + } + + /** + * Retrieves the host name. + * + * @return the host name + */ + public String getHostName() { + return hostName; + } + + /** + * Sets the host name. + * + * @param hostName the host name + */ + public void setHostName(String hostName) { + this.hostName = hostName; + } + + /** + * Retrieves the host address. + * + * @return the host address + */ + public String getHostAddress() { + return hostAddress; + } + + /** + * Sets the host address. + * + * @param hostAddress the host address + */ + public void setHostAddress(String hostAddress) { + this.hostAddress = hostAddress; + } + + /** + * Retrieves the public port. + * + * @return the public port + */ + public int getPublicPort() { + return publicPort; + } + + /** + * Sets the public port. + * + * @param publicPort the public port + */ + public void setPublicPort(int publicPort) { + this.publicPort = publicPort; + } + + /** + * Retrieves the secure host address which uses the HTTPS protocol for communications between clients and the context server. + * + * @return the secure host address + */ + public String getSecureHostAddress() { + return secureHostAddress; + } + + /** + * Sets the secure host address which uses the HTTPS protocol for communications between clients and the context server. + * + * @param secureHostAddress the secure host address + */ + public void setSecureHostAddress(String secureHostAddress) { + this.secureHostAddress = secureHostAddress; + } + + /** + * Retrieves the secure port. + * + * @return the secure port + */ + public int getSecurePort() { + return securePort; + } + + /** + * Sets the secure port. + * + * @param securePort the secure port + */ + public void setSecurePort(int securePort) { + this.securePort = securePort; + } + + /** + * Retrieves the load average for the last minute, five minutes and fifteen minutes. + * + * @return an array of {@code double} containing, in order and starting from index {@code 0}, the load average for the last minute, last five minutes and last fifteen minutes + */ + public double[] getLoadAverage() { + return loadAverage; + } + + /** + * Sets the load average for the last minute, five minutes and fifteen minutes. + * + * @param loadAverage an array of {@code double} containing, in order and starting from index {@code 0}, the load average for the last minute, last five minutes and last fifteen minutes + */ + public void setLoadAverage(double[] loadAverage) { + this.loadAverage = loadAverage; + } + + /** + * Retrieves the uptime. + * + * @return the uptime + */ + public long getUptime() { + return uptime; + } + + /** + * Sets the uptime. + * + * @param uptime the uptime + */ + public void setUptime(long uptime) { + this.uptime = uptime; + } + + /** + * Determines whether this ClusterNode is a master node, i.e. this node doesn't store any data but is only focused on cluster management operations. + * + * @return {@code true} if this node is a master node, {@code false} otherwise + */ + public boolean isMaster() { + return master; + } + + /** + * Specifies whether this ClusterNode is a master node, i.e. this node doesn't store any data but is only focused on cluster management operations.. + * + * @param master {@code true} if this node is a master node, {@code false} otherwise + */ + public void setMaster(boolean master) { + this.master = master; + } + + /** + * Determines whether this ClusterNode locally stores data. + * + * @return {@code true} if this node locally stores data, {@code false} otherwise + */ + public boolean isData() { + return data; + } + + /** + * Specifies whether this ClusterNode locally stores data. + * + * @param data {@code true} if this node locally stores data, {@code false} otherwise + */ + public void setData(boolean data) { + this.data = data; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/ContextRequest.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/ContextRequest.java b/api/src/main/java/org/apache/unomi/api/ContextRequest.java new file mode 100644 index 0000000..f1e642a --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/ContextRequest.java @@ -0,0 +1,369 @@ +/* + * 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; + +import org.apache.unomi.api.actions.Action; +import org.apache.unomi.api.conditions.Condition; +import org.apache.unomi.api.rules.Rule; +import org.apache.unomi.api.services.EventListenerService; +import org.apache.unomi.api.services.ProfileService; +import org.apache.unomi.api.services.RulesService; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * An incoming request for context information from clients of the context server. This allows clients to specify which type of information they are interested in getting from + * the context server as well as specify incoming events or content filtering or property/segment overrides for personalization or impersonation. This conditions what the + * context server will return with its response. + * <p/> + * Events that are generated on the client as part of its functioning can be specified in the client as part of its request for contextual data. The context server will deliver + * these events to {@link EventListenerService}s to be processed. In particular, the {@link + * RulesService} will trigger any applicable {@link Rule} which in turn might trigger {@link + * Action}s. An appropriate Event is also triggered when a Rule matches so that other rules can react to it. Finally, an event will also + * be emitted if the user {@link Profile} has been updated as part of the event processing. + * <p/> + * A client wishing to perform content personalization might also specify filtering condition to be evaluated by the context server so that it can tell the client + * whether the content associated with the filter should be activated for this profile/session. + * <p/> + * It is also possible to clients wishing to perform user impersonation to specify properties or segment to override the proper ones so as to emulate a specific profile, in + * which case the overridden value will temporarily replace the proper values so that all rules will be evaluated with these values instead of the proper ones. + * + * @see ContextResponse + * @see Event + */ +public class ContextRequest { + + private Item source; + private boolean requireSegments; + private List<String> requiredProfileProperties; + private List<String> requiredSessionProperties; + private List<Event> events; + private List<FilteredContent> filters; + + // the following overrides make it possible to override temporarily the current profile segments, properties or + // even session properties. This is useful for building UIs to temporarily override one of these parameters to + // test different filter results. + + private Set<String> segmentOverrides; + private Map<String, Object> profilePropertiesOverrides; + private Map<String, Object> sessionPropertiesOverrides; + + /** + * Retrieves the source of the context request. + * + * @return the source + */ + public Item getSource() { + return source; + } + + /** + * Sets the source. + * + * @param source the source + */ + public void setSource(Item source) { + this.source = source; + } + + /** + * Determines whether or not the context server should return the segments associated with the profile from which the request was issued. + * + * @return {@code true} if the context server should return the profile segments, {@code false otherwise} + * @see ContextResponse#getProfileSegments() + */ + public boolean isRequireSegments() { + return requireSegments; + } + + /** + * Specifies whether to return the profile segments with the response. + * + * @param requireSegments {@code true} if the context server should return the profile segments, {@code false otherwise} + */ + public void setRequireSegments(boolean requireSegments) { + this.requireSegments = requireSegments; + } + + /** + * Retrieves the list of profile properties the context server should return with its context response. + * + * @return the required profile properties the client requested to be returned with the response + * @see ContextResponse#getProfileProperties() + */ + public List<String> getRequiredProfileProperties() { + return requiredProfileProperties; + } + + /** + * Specifies which profile properties should be returned with the response. + * + * @param requiredProfileProperties the profile properties that should be returned with the response + */ + public void setRequiredProfileProperties(List<String> requiredProfileProperties) { + this.requiredProfileProperties = requiredProfileProperties; + } + + /** + * Retrieves the list of session properties the context server should return with its context response. + * + * @return the required session properties the client requested to be returned with the response + * @see ContextResponse#getSessionProperties() + */ + public List<String> getRequiredSessionProperties() { + return requiredSessionProperties; + } + + /** + * Specifies which session properties should be returned with the response. + * + * @param requiredSessionProperties the session properties that should be returned with the response + */ + public void setRequiredSessionProperties(List<String> requiredSessionProperties) { + this.requiredSessionProperties = requiredSessionProperties; + } + + /** + * Retrieves the filters aimed at content personalization that should be evaluated for the given session and/or profile so that the context server can tell the client + * whether the content associated with the filter should be activated for this profile/session. The filter identifier is used in the {@link ContextResponse} with the + * associated evaluation result. + * + * @return the filters aimed at content personalization that should be evaluated for the given session and/or profile + * @see ProfileService#matchCondition(Condition, Profile, Session) Details on how the filter conditions are evaluated + * @see ContextResponse#getFilteringResults() Details on how the evaluation results are returned to the client + */ + public List<FilteredContent> getFilters() { + return filters; + } + + /** + * Specifies the content filters to be evaluated. + * + * @param filters the content filters to be evaluated + */ + public void setFilters(List<FilteredContent> filters) { + this.filters = filters; + } + + /** + * Retrieves the events that the client has generated as part of its processes and wishes the context server to process. + * + * @return the client events to be processed by the context server + * @see Event + */ + public List<Event> getEvents() { + return events; + } + + /** + * Specifies the events to be processed by the context server. + * + * @param events the events to be processed by the context server + */ + public void setEvents(List<Event> events) { + this.events = events; + } + + /** + * Retrieves the segment overrides. + * + * @return the segment overrides + */ + public Set<String> getSegmentOverrides() { + return segmentOverrides; + } + + /** + * Sets the segment overrides. + * + * @param segmentOverrides the segment overrides + */ + public void setSegmentOverrides(Set<String> segmentOverrides) { + this.segmentOverrides = segmentOverrides; + } + + /** + * Retrieves the profile properties overrides. + * + * @return the profile properties overrides + */ + public Map<String, Object> getProfilePropertiesOverrides() { + return profilePropertiesOverrides; + } + + /** + * Sets the profile properties overrides. + * + * @param profilePropertiesOverrides the profile properties overrides + */ + public void setProfilePropertiesOverrides(Map<String, Object> profilePropertiesOverrides) { + this.profilePropertiesOverrides = profilePropertiesOverrides; + } + + /** + * Retrieves the session properties overrides. + * + * @return the session properties overrides + */ + public Map<String, Object> getSessionPropertiesOverrides() { + return sessionPropertiesOverrides; + } + + /** + * Sets the session properties overrides. + * + * @param sessionPropertiesOverrides the session properties overrides + */ + public void setSessionPropertiesOverrides(Map<String, Object> sessionPropertiesOverrides) { + this.sessionPropertiesOverrides = sessionPropertiesOverrides; + } + + /** + * A content filtering definition. + */ + public static class FilteredContent { + private String filterid; + private List<Filter> filters; + + /** + * Retrieves the filter identifier associated with this content filtering definition. + * + * @return the filter identifier associated with this content filtering definition + */ + public String getFilterid() { + return filterid; + } + + /** + * Sets the filter identifier associated with this content filtering definition. + * + * @param filterid the filter identifier associated with this content filtering definition + */ + public void setFilterid(String filterid) { + this.filterid = filterid; + } + + /** + * Retrieves the filters. + * + * @return the filters + */ + public List<Filter> getFilters() { + return filters; + } + + /** + * Sets the filters. + * + * @param filters the filters + */ + public void setFilters(List<Filter> filters) { + this.filters = filters; + } + } + + /** + * A filter definition for content filtering + */ + public static class Filter { + private List<Target> appliesOn; + private Condition condition; + + /** + * Retrieves the list of targets this filter applies on. + * + * @return the applies on + */ + public List<Target> getAppliesOn() { + return appliesOn; + } + + /** + * Specifies which targets this filter applies on. + * + * @param appliesOn the list of {@link ContextRequest.Target} this filter should be applied on + */ + public void setAppliesOn(List<Target> appliesOn) { + this.appliesOn = appliesOn; + } + + /** + * Retrieves the condition associated with this filter. + * + * @return the condition associated with this filter + */ + public Condition getCondition() { + return condition; + } + + /** + * Sets the condition associated with this filter. + * + * @param condition the condition associated with this filter + */ + public void setCondition(Condition condition) { + this.condition = condition; + } + } + + /** + * A target for content filtering. + */ + public static class Target { + private String target; + private List<String> values; + + /** + * Retrieves the target. + * + * @return the target + */ + public String getTarget() { + return target; + } + + /** + * Sets the target. + * + * @param target the target + */ + public void setTarget(String target) { + this.target = target; + } + + /** + * Retrieves the values. + * + * @return the values + */ + public List<String> getValues() { + return values; + } + + /** + * Sets the values. + * + * @param values the values + */ + public void setValues(List<String> values) { + this.values = values; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/ContextResponse.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/ContextResponse.java b/api/src/main/java/org/apache/unomi/api/ContextResponse.java new file mode 100644 index 0000000..823cb25 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/ContextResponse.java @@ -0,0 +1,188 @@ +/* + * 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; + +import org.apache.unomi.api.conditions.Condition; +import org.apache.unomi.api.services.RulesService; + +import java.io.Serializable; +import java.util.Map; +import java.util.Set; + +/** + * A context server response resulting from the evaluation of a client's context request. Note that all returned values result of the evaluation of the data provided in the + * associated ContextRequest and might therefore reflect results due to user impersonation via properties / segment overrides. + * + * @see ContextRequest + */ +public class ContextResponse implements Serializable { + + private static final long serialVersionUID = -5638595408986826332L; + + private String profileId; + + private String sessionId; + + private Map<String, Object> profileProperties; + + private Map<String, Object> sessionProperties; + + private Set<String> profileSegments; + + private Map<String, Boolean> filteringResults; + + private Set<Condition> trackedConditions; + + /** + * Retrieves the profile identifier associated with the profile of the user on behalf of which the client performed the context request. + * + * @return the profile identifier associated with the profile of the active user + */ + public String getProfileId() { + return profileId; + } + + /** + * Sets the profile id. + * + * @param profileId the profile id + */ + public void setProfileId(String profileId) { + this.profileId = profileId; + } + + /** + * Retrieves the session identifier associated with the processed request. + * + * @return the session identifier associated with the processed request + * @see Session + */ + public String getSessionId() { + return sessionId; + } + + /** + * Sets the session id. + * + * @param sessionId the session id + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** + * Retrieves the profile properties that were requested by the client. + * + * @return the profile properties that were requested by the client + * @see ContextRequest#getRequiredProfileProperties() + */ + public Map<String, Object> getProfileProperties() { + return profileProperties; + } + + /** + * Sets the profile properties. + * + * @param profileProperties the profile properties + */ + public void setProfileProperties(Map<String, Object> profileProperties) { + this.profileProperties = profileProperties; + } + + /** + * Retrieves the session properties that were requested by the client. + * + * @return the session properties that were requested by the client + * @see ContextRequest#getRequiredSessionProperties() + */ + public Map<String, Object> getSessionProperties() { + return sessionProperties; + } + + /** + * Sets the session properties. + * + * @param sessionProperties the session properties + */ + public void setSessionProperties(Map<String, Object> sessionProperties) { + this.sessionProperties = sessionProperties; + } + + /** + * Retrieves the identifiers of the profile segments associated with the user if they were requested by the client. Note that these segments are evaluated taking potential + * overrides as requested by the client or as a result of evaluating overridden properties. + * + * @return the profile segments associated with the user accounting for potential overrides + */ + public Set<String> getProfileSegments() { + return profileSegments; + } + + /** + * Sets the profile segments. + * + * @param profileSegments the profile segments + */ + public void setProfileSegments(Set<String> profileSegments) { + this.profileSegments = profileSegments; + } + + /** + * Retrieves the results of the evaluation content filtering definitions and whether individual definitions match with the associated profile (potentially modified by + * overridden values). + * + * @return a Map associating the filter identifier as key to its evaluation result by the context server + */ + public Map<String, Boolean> getFilteringResults() { + return filteringResults; + } + + /** + * Sets the filtering results. + * + * @param filteringResults the filtering results + */ + public void setFilteringResults(Map<String, Boolean> filteringResults) { + this.filteringResults = filteringResults; + } + + /** + * Retrieves the tracked conditions, if any, associated with the source of the context request that resulted in this ContextResponse. Upon evaluating the incoming request, + * the context server will determine if there are any rules marked with the "trackedCondition" tag and which source condition matches the source of the incoming request and + * return these tracked conditions to the client that can use them to know that the context server can react to events matching the tracked condition and coming from that + * source. This is, in particular, used to implement form mapping (a solution that allows clients to update user profiles based on values provided when a form is submitted). + * + * TODO: trackedCondition should be a constant, possibly on the Tag class? + * + * @return the tracked conditions + * @see ContextRequest#getSource() + * @see RulesService#getTrackedConditions(Item) + */ + public Set<Condition> getTrackedConditions() { + return trackedConditions; + } + + /** + * Sets the tracked conditions. + * + * @param trackedConditions the tracked conditions + */ + public void setTrackedConditions(Set<Condition> trackedConditions) { + this.trackedConditions = trackedConditions; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/CustomItem.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/CustomItem.java b/api/src/main/java/org/apache/unomi/api/CustomItem.java new file mode 100644 index 0000000..df012dd --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/CustomItem.java @@ -0,0 +1,69 @@ +/* + * 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; + +import java.util.HashMap; +import java.util.Map; + +/** + * A generic extension of Item for context server extensions, properties are stored in a Map. + */ +public class CustomItem extends Item { + /** + * The CustomItem ITEM_TYPE. + * @see Item for a discussion of ITEM_TYPE + */ + public static final String ITEM_TYPE = "custom"; + private static final long serialVersionUID = -7178914125308851922L; + private Map<String,Object> properties = new HashMap<String,Object>(); + + /** + * Instantiates a new Custom item. + */ + public CustomItem() { + } + + /** + * Instantiates a new Custom item. + * + * @param itemId the item id + * @param itemType the item type + */ + public CustomItem(String itemId, String itemType) { + super(itemId); + this.itemType = itemType; + } + + /** + * Retrieves this CustomItem's properties. + * + * @return a Map of the item's properties associating the property name as key to its value. + */ + public Map<String, Object> getProperties() { + return properties; + } + + /** + * Sets the properties. + * + * @param properties the properties + */ + public void setProperties(Map<String, Object> properties) { + this.properties = properties; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/Event.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/Event.java b/api/src/main/java/org/apache/unomi/api/Event.java new file mode 100644 index 0000000..b20662b --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/Event.java @@ -0,0 +1,323 @@ +/* + * 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; + +import org.apache.unomi.api.actions.ActionPostExecutor; + +import javax.xml.bind.annotation.XmlTransient; +import java.util.*; + +/** + * An event that can be processed and evaluated by the context server. Events can be triggered by clients following user actions or can also be issued internally in the context + * server in response to another event. Conceptually, an event can be seen as a sentence, the event's type being the verb, the source the subject and the target the object. + * + * Source and target can be any unomi item but are not limited to them. In particular, as long as they can be described using properties and unomiâs type mechanism and can be + * processed either natively or via extension plugins, source and target can represent just about anything. + */ +public class Event extends Item implements TimestampedItem { + + /** + * The Event ITEM_TYPE. + * + * @see Item for a discussion of ITEM_TYPE + */ + public static final String ITEM_TYPE = "event"; + /** + * A constant for the name of the attribute that can be used to retrieve the current HTTP request. + */ + public static final String HTTP_REQUEST_ATTRIBUTE = "http_request"; + /** + * A constant for the name of the attribute that can be used to retrieve the current HTTP response. + */ + public static final String HTTP_RESPONSE_ATTRIBUTE = "http_response"; + private static final long serialVersionUID = -1096874942838593575L; + private String eventType; + private String sessionId = null; + private String profileId = null; + private Date timeStamp; + private Map<String, Object> properties; + + private transient Profile profile; + private transient Session session; + private transient List<ActionPostExecutor> actionPostExecutors; + + private String scope; + + private Item source; + private Item target; + + private transient boolean persistent = true; + + private transient Map<String, Object> attributes = new LinkedHashMap<>(); + + /** + * Instantiates a new Event. + */ + public Event() { + } + + /** + * Instantiates a new Event. + * + * @param eventType the event type identifier + * @param session the session associated with the event + * @param profile the profile associated with the event + * @param scope the scope from which the event is issued + * @param source the source of the event + * @param target the target of the event if any + * @param timestamp the timestamp associated with the event if provided + */ + public Event(String eventType, Session session, Profile profile, String scope, Item source, Item target, Date timestamp) { + super(UUID.randomUUID().toString()); + this.eventType = eventType; + this.profile = profile; + this.session = session; + this.profileId = profile.getItemId(); + this.scope = scope; + this.source = source; + this.target = target; + + if (session != null) { + this.sessionId = session.getItemId(); + } + this.timeStamp = timestamp; + + this.properties = new HashMap<String, Object>(); + + actionPostExecutors = new ArrayList<>(); + } + + /** + * Instantiates a new Event. + * + * @param eventType the event type identifier + * @param session the session associated with the event + * @param profile the profile associated with the event + * @param scope the scope from which the event is issued + * @param source the source of the event + * @param target the target of the event if any + * @param timestamp the timestamp associated with the event if provided + * @param properties the properties for this event if any + */ + public Event(String eventType, Session session, Profile profile, String scope, Item source, Item target, Map<String, Object> properties, Date timestamp) { + this(eventType, session, profile, scope, source, target, timestamp); + if (properties != null) { + this.properties = properties; + } + } + + /** + * Retrieves the session identifier if available. + * + * @return the session identifier or {@code null} if unavailable + */ + public String getSessionId() { + return sessionId; + } + + /** + * Retrieves the profile identifier of the Profile associated with this event + * + * @return the profile id + */ + public String getProfileId() { + return profileId; + } + + /** + * Sets the profile id. + * + * @param profileId the profile id + */ + public void setProfileId(String profileId) { + this.profileId = profileId; + } + + /** + * Retrieves the event type. + * + * @return the event type + */ + public String getEventType() { + return eventType; + } + + public Date getTimeStamp() { + return timeStamp; + } + + /** + * Retrieves the profile. + * + * @return the profile + */ + @XmlTransient + public Profile getProfile() { + return profile; + } + + /** + * Sets the profile. + * + * @param profile the profile + */ + public void setProfile(Profile profile) { + this.profile = profile; + } + + /** + * Retrieves the session. + * + * @return the session + */ + @XmlTransient + public Session getSession() { + return session; + } + + /** + * Sets the session. + * + * @param session the session + */ + public void setSession(Session session) { + this.session = session; + } + + /** + * Determines whether this Event needs to be persisted to the context server or not. Events that don't participate in building the user profile don't usually need to be + * persisted. + * + * @return {@code true} if this Event needs to be persisted, {@code false} otherwise + */ + @XmlTransient + public boolean isPersistent() { + return persistent; + } + + /** + * Specifies if this Event needs to be persisted. + * + * @param persistent {@code true} if this Event needs to be persisted, {@code false} otherwise + */ + public void setPersistent(boolean persistent) { + this.persistent = persistent; + } + + /** + * Retrieves the attributes. Attributes are not serializable, and can be used to provide additional contextual objects such as HTTP request or response objects, etc... + * + * @return the attributes + */ + @XmlTransient + public Map<String, Object> getAttributes() { + return attributes; + } + + /** + * Sets the property identified by the provided name to the specified value. + * + * @param name the name of the property to be set + * @param value the value of the property + */ + public void setProperty(String name, Object value) { + properties.put(name, value); + } + + /** + * Retrieves the value of the property identified by the specified name. + * + * @param name the name of the property to be retrieved + * @return the value of the property identified by the specified name + */ + public Object getProperty(String name) { + return properties.get(name); + } + + /** + * Retrieves the properties. + * + * @return the properties + */ + public Map<String, Object> getProperties() { + return properties; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + /** + * Retrieves the source. + * + * @return the source + */ + public Item getSource() { + return source; + } + + /** + * Sets the source. + * + * @param source the source + */ + public void setSource(Item source) { + this.source = source; + } + + /** + * Retrieves the target. + * + * @return the target + */ + public Item getTarget() { + return target; + } + + /** + * Sets the target. + * + * @param target the target + */ + public void setTarget(Item target) { + this.target = target; + } + + /** + * Retrieves the action post executors for this event, if extra actions need to be executed after all Rule-triggered actions have been processed + * + * @return the action post executors + */ + @XmlTransient + public List<ActionPostExecutor> getActionPostExecutors() { + return actionPostExecutors; + } + + /** + * Sets the action post executors. + * + * @param actionPostExecutors the action post executors + */ + public void setActionPostExecutors(List<ActionPostExecutor> actionPostExecutors) { + this.actionPostExecutors = actionPostExecutors; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/EventInfo.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/EventInfo.java b/api/src/main/java/org/apache/unomi/api/EventInfo.java new file mode 100644 index 0000000..b78e727 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/EventInfo.java @@ -0,0 +1,49 @@ +/* + * 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; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Basic event information + */ +@XmlRootElement +public class EventInfo { + + private String name; + private Long occurences; + + public EventInfo() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getOccurences() { + return occurences; + } + + public void setOccurences(Long occurences) { + this.occurences = occurences; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/EventProperty.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/EventProperty.java b/api/src/main/java/org/apache/unomi/api/EventProperty.java new file mode 100644 index 0000000..d727e14 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/EventProperty.java @@ -0,0 +1,100 @@ +/* + * 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; + +import java.io.Serializable; + +/** + * An event property. + * + * @author Sergiy Shyrkov + */ +public class EventProperty implements Serializable { + + private static final long serialVersionUID = -6727761503135013816L; + + private String id; + + private String valueType = "string"; + + /** + * Initializes an instance of this class. + */ + public EventProperty() { + super(); + } + + /** + * Initializes an instance of an event property with the string value type. + * + * @param id the event property id + */ + public EventProperty(String id) { + this(id, null); + } + + /** + * Initializes an instance of this class. + * + * @param id the event property id + * @param type the type of the value for this property + */ + public EventProperty(String id, String type) { + this(); + this.id = id; + if (type != null) { + this.valueType = type; + } + } + + /** + * Retrieves the identifier for this EventProperty. + * + * @return the identifier for this EventProperty + */ + public String getId() { + return id; + } + + /** + * Sets the identifier. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Retrieves the type. + * + * @return the value type + */ + public String getValueType() { + return valueType; + } + + /** + * Sets the value type. + * + * @param type the type + */ + public void setValueType(String type) { + this.valueType = type; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/EventSource.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/EventSource.java b/api/src/main/java/org/apache/unomi/api/EventSource.java new file mode 100644 index 0000000..90128cf --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/EventSource.java @@ -0,0 +1,63 @@ +/* + * 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; + +/** + * TODO: REMOVE + */ +public class EventSource { + private String scope; + private String id; + private String path; + private String type; + + public EventSource() { + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/EventTarget.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/EventTarget.java b/api/src/main/java/org/apache/unomi/api/EventTarget.java new file mode 100644 index 0000000..f1bc1ad --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/EventTarget.java @@ -0,0 +1,72 @@ +/* + * 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; + +import java.io.Serializable; +import java.util.Map; + +/** + * TODO: REMOVE + */ +public class EventTarget implements Serializable { + private static final long serialVersionUID = 6370790894348364803L; + private String id; + private String type; + private Map<String, Object> properties; + + public EventTarget() { + } + + public EventTarget(String id, String type) { + this.id = id; + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Map<String, Object> getProperties() { + return properties; + } + + public void setProperties(Map<String, Object> properties) { + this.properties = properties; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("EventTarget{"); + sb.append("id='").append(id).append('\''); + sb.append(", type='").append(type).append('\''); + sb.append('}'); + return sb.toString(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/EventsCollectorRequest.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/EventsCollectorRequest.java b/api/src/main/java/org/apache/unomi/api/EventsCollectorRequest.java new file mode 100644 index 0000000..2880240 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/EventsCollectorRequest.java @@ -0,0 +1,40 @@ +/* + * 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; + +import java.util.List; + +/** + * A request for events to be processed. + */ +public class EventsCollectorRequest { + private List<Event> events; + + /** + * Retrieves the events to be processed. + * + * @return the events to be processed + */ + public List<Event> getEvents() { + return events; + } + + public void setEvents(List<Event> events) { + this.events = events; + } +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dc1d1520/api/src/main/java/org/apache/unomi/api/Item.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/Item.java b/api/src/main/java/org/apache/unomi/api/Item.java new file mode 100644 index 0000000..18e5910 --- /dev/null +++ b/api/src/main/java/org/apache/unomi/api/Item.java @@ -0,0 +1,113 @@ +/* + * 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; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serializable; + +/** + * A context server tracked entity. All tracked entities need to extend this class so as to provide the minimal information the context server needs to be able to track such + * entities and operate on them. Items are persisted according to their type (structure) and identifier (identity). Of note, all Item subclasses <strong>must</strong> define a + * public String constant named {@code ITEM_TYPE} that is used to identify the type of a specific Item via {@link #getItemType}. It is therefore important that + * {@code ITEM_TYPE} be unique across all persisted type of Items. Similarly, since Items are persisted according to their type, an Item's identifier must be unique among + * Items of the same type. + * <p/> + * Additionally, Items are also gathered by scope allowing the context server to group together related Items (usually pertaining to a given site being analyzed, + * though scopes could span across sites depending on the desired analysis granularity). Scopes allow clients accessing the context server to filter data. The context server + * defines a built-in scope ({@link Metadata#SYSTEM_SCOPE}) that clients can use to share data across scopes. + */ +public abstract class Item implements Serializable { + private static final Logger logger = LoggerFactory.getLogger(Item.class.getName()); + + private static final long serialVersionUID = 7446061538573517071L; + protected String itemId; + protected String itemType; + protected String scope; + + public Item() { + try { + this.itemType = (String) this.getClass().getField("ITEM_TYPE").get(null); + } catch (IllegalAccessException | NoSuchFieldException e) { + logger.error("Item implementations must provide a public String constant named ITEM_TYPE to uniquely identify this Item for the persistence service.", e); + } + } + + public Item(String itemId) { + this(); + this.itemId = itemId; + } + + + /** + * Retrieves the Item's identifier used to uniquely identify this Item when persisted or when referred to. An Item's identifier must be unique among Items with the same type. + * + * @return a String representation of the identifier, no particular format is prescribed as long as it is guaranteed unique for this particular Item. + */ + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + /** + * Retrieves the Item's type used to assert metadata and structure common to Items of this type, notably for persistence purposes. The Item's type <strong>must</strong> + * match the value defined by the implementation's {@code ITEM_TYPE} public constant. + * + * @return a String representation of this Item's type, must equal the {@code ITEM_TYPE} value + */ + public String getItemType() { + return itemType; + } + + public void setItemType(String itemType) { + this.itemType = itemType; + } + + /** + * Retrieves the Item's scope. + * + * @return the Item's scope name + */ + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Item item = (Item) o; + + return !(itemId != null ? !itemId.equals(item.itemId) : item.itemId != null); + + } + + @Override + public int hashCode() { + return itemId != null ? itemId.hashCode() : 0; + } +}
